Contains the code for performing a city evaluation.
| 14 | * Contains the code for performing a city evaluation. |
| 15 | */ |
| 16 | public class CityEval |
| 17 | { |
| 18 | private final Micropolis engine; |
| 19 | private final Random PRNG; |
| 20 | |
| 21 | public CityEval(Micropolis engine) |
| 22 | { |
| 23 | this.engine = engine; |
| 24 | this.PRNG = engine.PRNG; |
| 25 | |
| 26 | assert PRNG != null; |
| 27 | } |
| 28 | |
| 29 | /** Percentage of population "approving" the mayor. Derived from cityScore. */ |
| 30 | public int cityYes; |
| 31 | |
| 32 | /** Percentage of population "disapproving" the mayor. Derived from cityScore. */ |
| 33 | public int cityNo; |
| 34 | |
| 35 | /** City assessment value. */ |
| 36 | public int cityAssValue; |
| 37 | |
| 38 | /** Player's score, 0-1000. */ |
| 39 | public int cityScore; |
| 40 | |
| 41 | /** Change in cityScore since last evaluation. */ |
| 42 | public int deltaCityScore; |
| 43 | |
| 44 | /** City population as of current evaluation. */ |
| 45 | public int cityPop; |
| 46 | |
| 47 | /** Change in cityPopulation since last evaluation. */ |
| 48 | public int deltaCityPop; |
| 49 | |
| 50 | /** Classification of city size. 0==village, 1==town, etc. */ |
| 51 | public int cityClass; // 0..5 |
| 52 | |
| 53 | /** City's top 4 (or fewer) problems as reported by citizens. */ |
| 54 | public CityProblem [] problemOrder = new CityProblem[0]; |
| 55 | |
| 56 | /** Number of votes given for the various problems identified by problemOrder[]. */ |
| 57 | public EnumMap<CityProblem,Integer> problemVotes = new EnumMap<CityProblem,Integer>(CityProblem.class); |
| 58 | |
| 59 | /** Score for various problems. */ |
| 60 | public EnumMap<CityProblem,Integer> problemTable = new EnumMap<CityProblem,Integer>(CityProblem.class); |
| 61 | |
| 62 | /** |
| 63 | * Perform an evaluation. |
| 64 | */ |
| 65 | void cityEvaluation() |
| 66 | { |
| 67 | if (engine.totalPop != 0) { |
| 68 | calculateAssValue(); |
| 69 | doPopNum(); |
| 70 | doProblems(); |
| 71 | calculateScore(); |
| 72 | doVotes(); |
| 73 | } else { |
nothing calls this directly
no outgoing calls
no test coverage detected