| 19 | #include "game_consts.hpp" |
| 20 | |
| 21 | void ObstacleGenerator::Generate(Obstacle* result) { |
| 22 | static const int PROB_TABLE[] = { |
| 23 | // EASY MED INT HARD |
| 24 | 100, 0, 0, 0, // difficulty 0 |
| 25 | 75, 25, 0, 0, // difficulty 1 |
| 26 | 50, 50, 0, 0, // difficulty 2 |
| 27 | 25, 75, 0, 0, // difficulty 3 |
| 28 | 0, 100, 0, 0, // difficulty 4 |
| 29 | 0, 75, 25, 0, // difficulty 5 |
| 30 | 0, 50, 50, 0, // difficulty 6 |
| 31 | 0, 25, 75, 0, // difficulty 7 |
| 32 | 0, 0, 100, 0, // difficulty 8 |
| 33 | 0, 0, 75, 25, // difficulty 9 |
| 34 | 0, 0, 50, 50, // difficulty 10 |
| 35 | 0, 0, 25, 75, // difficulty 11 |
| 36 | 0, 0, 0, 100 // difficulty 12+ |
| 37 | }; |
| 38 | result->Reset(); |
| 39 | result->style = 1 + Random(7); |
| 40 | |
| 41 | int d = Clamp(mDifficulty, 0, 12); |
| 42 | int easyProb = PROB_TABLE[d * 4]; |
| 43 | int medProb = PROB_TABLE[d * 4 + 1]; |
| 44 | int intermediateProb = PROB_TABLE[d * 4 + 2]; |
| 45 | int roll = Random(100); |
| 46 | if (roll <= easyProb) { |
| 47 | GenEasy(result); |
| 48 | } else if (roll <= easyProb + medProb) { |
| 49 | GenMedium(result); |
| 50 | } else if (roll <= easyProb + medProb + intermediateProb) { |
| 51 | GenIntermediate(result); |
| 52 | } else { |
| 53 | GenHard(result); |
| 54 | } |
| 55 | result->PutRandomBonus(); |
| 56 | } |
| 57 | |
| 58 | void ObstacleGenerator::FillRow(Obstacle* result, int row) { |
| 59 | for (int i = 0; i < OBS_GRID_SIZE; ++i) { |
no test coverage detected