From 0b8efea5135a2ff5faf041bc4a5b99b5a83258ba Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sat, 23 Mar 2013 15:45:52 +0000 Subject: [PATCH] CityBudget: move in the four escrow-style account balances git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@601 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/CityBudget.java | 25 +++++++++++++++++++++++++ src/micropolisj/engine/Micropolis.java | 24 ++++++++++-------------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/micropolisj/engine/CityBudget.java b/src/micropolisj/engine/CityBudget.java index a2bb919..abf9426 100644 --- a/src/micropolisj/engine/CityBudget.java +++ b/src/micropolisj/engine/CityBudget.java @@ -11,8 +11,33 @@ package micropolisj.engine; public class CityBudget { private final Micropolis city; + + /** + * The amount of cash on hand. + */ public int totalFunds; + /** + * Amount of taxes collected so far in the current financial + * period (in 1/TAXFREQ's). + */ + int taxFund; + + /** + * Amount of prepaid road maintenance (in 1/TAXFREQ's). + */ + int roadFundEscrow; + + /** + * Amount of prepaid fire station maintenance (in 1/TAXFREQ's). + */ + int fireFundEscrow; + + /** + * Amount of prepaid police station maintenance (in 1/TAXFREQ's). + */ + int policeFundEscrow; + CityBudget(Micropolis city) { this.city = city; diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 6d2a0e7..ff38e1d 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -178,10 +178,6 @@ public class Micropolis int policeEffect = 1000; int fireEffect = 1000; - int taxFund; - int roadFundEscrow; - int fireFundEscrow; - int policeFundEscrow; int cashFlow; //net change in totalFunds in previous year boolean newPower; @@ -1686,10 +1682,10 @@ public class Micropolis BudgetNumbers b = generateBudget(); - taxFund += b.taxIncome; - roadFundEscrow -= b.roadFunded; - fireFundEscrow -= b.fireFunded; - policeFundEscrow -= b.policeFunded; + budget.taxFund += b.taxIncome; + budget.roadFundEscrow -= b.roadFunded; + budget.fireFundEscrow -= b.fireFunded; + budget.policeFundEscrow -= b.policeFunded; taxEffect = b.taxRate; roadEffect = b.roadRequest != 0 ? @@ -1714,8 +1710,8 @@ public class Micropolis void collectTax() { - int revenue = taxFund / TAXFREQ; - int expenses = -(roadFundEscrow + fireFundEscrow + policeFundEscrow) / TAXFREQ; + int revenue = budget.taxFund / TAXFREQ; + int expenses = -(budget.roadFundEscrow + budget.fireFundEscrow + budget.policeFundEscrow) / TAXFREQ; FinancialHistory hist = new FinancialHistory(); hist.cityTime = cityTime; @@ -1728,10 +1724,10 @@ public class Micropolis hist.totalFunds = budget.totalFunds; financialHistory.add(0,hist); - taxFund = 0; - roadFundEscrow = 0; - fireFundEscrow = 0; - policeFundEscrow = 0; + budget.taxFund = 0; + budget.roadFundEscrow = 0; + budget.fireFundEscrow = 0; + budget.policeFundEscrow = 0; } /** Annual maintenance cost of each police station. */