Devlog #48 - Bug Fixes, StoreUpgrade system, Store construction, store sell, StoreSystem refactoring code, optimisation. Testing and many bug-fixes. Store buy/upgrade/sell UI- same as other systems.

 ******StoreSystem applying same structure as before, upgrade, construct, sell, with product imports. Also code refactoring. UI introduction for upgrade/construct, same as for Hub, Truck etc..Many bug fixes**** - I was focusing so much on logic and optimisation/writing and thinking about logic and economy dependencies, that i spent so little time actually playing/testing the game.

anyhow

First what changed - code refactoring, last time it was going through all stores each method, now we do it at the Tick and then forward the ref store directly. For example: 


and now:

for (int s = 0; s < city.cityStores.Count; s++)
{
StoreState store = city.cityStores[s];
// UpdateStoreData(ref city, storeDatabase);

if (store.isUnderConstruction)
{
StoreConstructionTick(ref store);
city.cityStores[s] = store;
continue;
}

if (store.isUpgrading) StoreUpgradeTick(ref store);

// UpdateStoreData(ref store);
CalculateStoreOutputCapacity(ref store, city.officeEfficiency);


So we forward the reference. instead of whole CityStruct that contains the stores list and go through each city and all stores.


What was more complex then Hub or Office System was that the store actualyl needs to have list with products, or array in this case, because it is all using the same Product database that is sorted and ensured that they will be in the right order, same happens for each store. Store is a struct, with the array of the products, each array has data like amount, price etc, so it is crucial to import all the beforehand, and in the exact order. Why is it crucial? Whole system works based on the strict enum order of products. The TruckSystem would deliver the wrong product, at the wrong place ( at the wrong time kidding) , and it would be a disaster, if the bread product for example, is not on 1, but on 0 because the store has a different order of product. The truck would effectively deliver milk in the place of bread hah. Imagine fixing that bug hahah.

anyhow, example:

int productCount = Enum.GetValues(typeof(ProductType)).Length;
newStore.inventory = new StoreSlotState[productCount];
for (int p = 0; p < productCount; p++)
{
StoreSlotState slot = newStore.inventory[p];


So first we get the length of all products ( lenght of array of products), then we create a new array that we import all the products in right order in it. And if you wonder what is StoreSlotState that is exactly what i said before, info about each product in the given store. its another struct


________________________________________________________________________________


Ui for upgrade: Same as hub, nothing special for now. just basic information, amount of workers, cost to construct/ upgrade.



Ok and now i see that it needs to have also amount of ticks/days to be upgraded /constructed. ha.....

______________________________________________________________________________

Now the bugs..I will just list them (the ones I actually remember..) and examplain briefly. Why suddenly there were many bugs, is because I love writing and desigining the system, and spend very little time actually testing. Then i notice actual errors in the code.

anyhow,:
 
-Upgrade Truck that i wrote few devlogs before, was doing everything nicely, chargning except it never upgraded the truck...the reason was one like after paying , was that the truck.truckType = type( from the import) -  this line was never added. So money was charged, everything went smoothly except the truck never changed the type, and the new values were never added.

-Sell truck, Hub never refreshed the current number of trucks, so they appeared the next day,-tiny bug

-Truck charged the base price and not the current price for calculating, which resulted in industry price being changed but never counted in the expenses( this is improtant because its related to another placeholder method of price fluctuation for realism, more on that in future devlogs).

-Chart bug, wrong list was being taken from, that didn't actually extst. so instead of using IndustryHistory, it was trying to get snapshots from industryHisotryList ( that didnt exist hah, only in my mind perhaps) 

- BuildStore couldn't create another store because it was looking for tthe existing storeIndex. haha imagine that, creating a store and using the index as we used in the upgrade to actually LOCATE THE STORE , so yeah, the index didn't exist in the firs tplace.

- Store Upgrade system didnt remember the upgradeType , so it would be lost the nxt tick, and forget what actualy has to be upgraded.

- Money event wrong inputs 

-STore sale , money ( this still has to be fixed apparently), taxed the amount from selling a store hahahahah

-CalculateStore output, was caluclated form the last day's output, so it would drop to zero. Solution : Simply introduce another that holds value and counts from there.  BaseMaxOutputPerDay;

-Store was showing 0 output on the first day, because the officeSystem came later after thestore, so the store got the officeEfficiency of 0 ;

and others.. Ther weer also many Ui bugs, like buttons not showing, or doing wrong things. New truck was still a palceholder from before introducing the BuyNewTruck method, and was giving away free trucks hah. 

-CityMarkets chart was never loaded except for the first city that has the store because the loop was going within the cities but only with those who have stores. so all the other charts and growth were empty. 

-OfficeHq was showing in the Player office, also the industries that palyer didn't owned, or "state owned industries'.  


Thank you!! 

We are getting closer to the first MVp,with only few products,and working game. Many system to be implemented in the future, and PlayerOwnedIndustries..but first things first!! 

Soon the steam page will be opened and put to coming soon! Very exciting! (If I ever finish this game first hahah) 




Comments

Popular posts from this blog

Devlog #47 - TaxSystem/FinanceSystem ,Update-FIx -LoanFixes-- TruckSystem Update - Upgrade/BuyNEwTruck - Costs Prices introduced / OfficeSystem CreateNewOffice, upgrade office - other Fixes

Devlog #46 - HubSystem - CreatNewHub added, HubBuild Ui + INdustrySystem Update - -INdustryTierData to be combined with the IndustryData and IndustryState struct -

Devlog #49-50 - Asset System-NEW system, *Game Design* -construction costs update - LoanSystem- fix-redesign-upgrade,Bug fixes-storeSystem,AutoAdvance Day, Market system, Truck System cost redesign, refactored, Ui bug fixes