The game engine now has two bonuses for long build streaks. +10% max hp or 1 free death. I'll be adding more but that's enough to work on the real UI.

This commit is contained in:
Zed A. Shaw 2024-09-15 04:19:52 -04:00
parent 07553400f5
commit 0a9fa59365
3 changed files with 81 additions and 9 deletions

View file

@ -36,7 +36,44 @@ TEST_CASE("game engine death cycle", "[game_engine]") {
}
TEST_CASE("game can do success build", "[game_engine]") {
GameEngine game{10};
// test fails on purpose right now
GameEngine game{100};
for(int i = 0; i < 10; i++) {
game.event(GameEvent::BUILD_START);
game.event(GameEvent::BUILD_SUCCESS);
REQUIRE(game.hits_taken == 0);
REQUIRE(game.hit_points == game.starting_hp);
// confirm streaks, hit_taken, rounds are maintained
REQUIRE(game.streak == i);
REQUIRE(game.rounds == i);
REQUIRE(game.is_dead() == false);
game.event(GameEvent::BUILD_DONE);
}
// if you hit a streak of 10 then you get one of two bonuses
// 1. 10% more hp
// 2. 1 free death
game.add_bonus(GameBonus::MORE_HP);
REQUIRE(game.max_hp() > game.starting_hp);
REQUIRE(game.hit_points == game.starting_hp * game.hp_bonus);
REQUIRE(game.hit_points == game.max_hp());
game.add_bonus(GameBonus::FREE_DEATH);
REQUIRE(game.free_death == true);
game.event(GameEvent::BUILD_START);
game.event(GameEvent::HIT, "error");
game.event(GameEvent::HIT, "error");
game.event(GameEvent::HIT, "error");
REQUIRE(game.is_dead() == false);
REQUIRE(game.streak == 10);
game.event(GameEvent::BUILD_FAILED);
game.event(GameEvent::BUILD_DONE);
REQUIRE(game.streak == 10);
REQUIRE(game.free_death == false);
REQUIRE(game.hit_points == int(game.max_hp() * 0.5f));
}