* Let disasters happen. * @todo Decide what to do with the 'nothing happens' disaster (since the * chance that a disaster happens is expressed in the \c DisChance * table). */
| 80 | * table). |
| 81 | */ |
| 82 | void Micropolis::doDisasters() |
| 83 | { |
| 84 | /* Chance of disasters at lev 0 1 2 */ |
| 85 | static const short DisChance[3] = { |
| 86 | 10 * 48, // Game level 0 |
| 87 | 5 * 48, // Game level 1 |
| 88 | 60 // Game level 2 |
| 89 | }; |
| 90 | assert(LEVEL_COUNT == LENGTH_OF(DisChance)); |
| 91 | |
| 92 | if (floodCount) { |
| 93 | floodCount--; |
| 94 | } |
| 95 | |
| 96 | if (disasterEvent != SC_NONE) { |
| 97 | scenarioDisaster(); |
| 98 | } |
| 99 | |
| 100 | if (!enableDisasters) { // Disasters have been disabled |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | int x = gameLevel; |
| 105 | if (x > LEVEL_LAST) { |
| 106 | x = LEVEL_EASY; |
| 107 | } |
| 108 | |
| 109 | if (!getRandom(DisChance[x])) { |
| 110 | switch (getRandom(8)) { |
| 111 | case 0: |
| 112 | case 1: |
| 113 | setFire(); // 2/9 chance a fire breaks out |
| 114 | break; |
| 115 | |
| 116 | case 2: |
| 117 | case 3: |
| 118 | makeFlood(); // 2/9 chance for a flood |
| 119 | break; |
| 120 | |
| 121 | case 4: |
| 122 | // 1/9 chance nothing happens (was airplane crash, |
| 123 | // which EA removed after 9/11, and requested it be |
| 124 | // removed from this code) |
| 125 | break; |
| 126 | |
| 127 | case 5: |
| 128 | makeTornado(); // 1/9 chance tornado |
| 129 | break; |
| 130 | |
| 131 | case 6: |
| 132 | makeEarthquake(); // 1/9 chance earthquake |
| 133 | break; |
| 134 | |
| 135 | case 7: |
| 136 | case 8: |
| 137 | // 2/9 chance a scary monster arrives in a dirty town |
| 138 | if (pollutionAverage > /* 80 */ 60) { |
| 139 | makeMonster(); |
nothing calls this directly
no outgoing calls
no test coverage detected