Devlog #30-35 - Major update ****BankingSystem, FinanceSystem, Snapshots for charts, MoneyEvent... UI bugs, dev

 **** Major update, Ui, bankingSystem, FinanceSystem,Snapshots etc. fun times!! **** 

This was something I worked on in parallel to other systems, and now it finally happened becuase the structure and Ui was ready for it. Before it was just a written code and idea.

basically , the FinanceSystem  is a system that counts all the MoneyEvents during the single turn. So for example, all the revenue goes to addMoney(amount, MoneyEventType..) and all the expenses go to the( from the) removeMoney(amount, MoneyEventType). The FinanceSystem basically calculates and adds each of those revenue or expenses into 2 float values, and in the end it shows basically in the accounting tab. Later the taxes will be aded, and system modified slightly, but for now this is how it works.





Which brings me to another very clever solution. Snapshots! Which after trial and error, this appeared to be the best solution. Instead of remembering single values, I applied the same principle as before, using struct in a list. So then the Snapshot would basically have bunch of values, like currentTurn, revenue, expense etc. Then later the Chart as seen above woudl basically go through the list of all Snapshots (for finance in this case) , and just simple put them in order. So each time we load Accounting tab, it goes through all snapshots history and shows the ones we need. 

For example : 

public struct TurnFinancialSnapshot
{
public int turnNumber;
public float revenue;
public float expenses;
public float netCash;
public float debt;

So now, we have small cards basically that contain the values for each day, wether that is the turn 30 or turn 50, it deosnt matter.

Anyhow, so now i applied this same system of snapshots into other values that we need to be memorised. ( not everything was implemented yet) , but for example, priceHistory per market per city, snapshot, city growth snapshot, THIS IS MAJOR litteraly a breakthrough... And it solved mostly everything regardless to charts and history.

So in essence, after each turn, the calculated value of all revenue and expenses is calculated and memorized in a snapshot and added to the list. amazing right? 



________________________________________________________________________


MoneyEvent
 not sure if it was mentioned before, but, now we have the actual use for it, accounting ledger for 1, and for second we are using it to categorize expenses vs income. So basically MoneyEvent is Enum with all the possible moneyincome/expense values, like, storeSale, or StoreUpkeep, or Truckupkee, fuel etc.. Then when we deduct the money or add we say,  addMOney(amount , MoneyType.Truckfuel, name:... description.. ) and then we have that in the account ledger, which basically registers each transaction and shows it on the list.


Simple sistem, yet it was somewhat frustarting, but good thing it applies to the existing strucutre. so adding new game mechanics comes easier. 




_________________________________________________________________________


Banking System!!! Maybe one of my favourite things to design

So basically we need loans, for players to get loans if the want to exapdn faster. now the bankingSystem is basic at the moment but it serves the purpose, and hopefully will be enough for now, for mvp. In essence , i did research about credits and loans, and some were fairly complex , while others were easier, but , i wanted something to do that i will clearly understand and it will be very easy to undersatnd how it works in game, and how it spossible to pay it off earlier if necessary.

So i made the system that works by simply calculating the amount of the loan with variable rate which would depend upon the time of paying back ( turns to payback(days)). In other words, you choose 50 days to pay off, it counts the interest, then breaks it down into equal parts including the interest, and then each day the daily amount is removed. Thats it! simple. 


            //
        float t = Mathf.InverseLerp(minTurns,maxTurns,turns);
        float interestRate = Mathf.Lerp(maxRate, minRate, t);


        return interestRate;
    }

Here is an example , so what we have here is a simple static float for realtime Ui calculation, which basically calculates based upon the values I set before, and gives that nice balance of everything.

what will be added later, is 
-How the maximum amount of loan is calculated
-How many loans can be actually taken?
-Variable rate depending if there are more loans? higher for more loans.
-Different type of lenders ( which was already added, only i never actually used it, draft) 


Just some of the questionsthat keep me awake,but it will be solved! Then it will also mean that the bank will give bigger loans, longer, but higher rate?, and other type of lenders will give vice versa.. not sure yet, i have to research more about loans in general.






Thank you!!











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