diff --git a/src/game_logic/zombies/infected.cpp b/src/game_logic/zombies/infected.cpp index 96b1b59..d24bf14 100644 --- a/src/game_logic/zombies/infected.cpp +++ b/src/game_logic/zombies/infected.cpp @@ -176,4 +176,9 @@ void Infected::change_chase_state_to_running() { ChaseState* Infected::get_chasing_state() { return chase_state; +} + +void Infected::set_walking() { + delete chase_state; + chase_state = new ChaseWalking; } \ No newline at end of file diff --git a/src/game_logic/zombies/infected.h b/src/game_logic/zombies/infected.h index d178201..3aa9388 100644 --- a/src/game_logic/zombies/infected.h +++ b/src/game_logic/zombies/infected.h @@ -66,6 +66,7 @@ std::int16_t get_health(); ZombieState* get_state() override; void change_chase_state_to_running(); ChaseState* get_chasing_state(); +void set_walking(); }; #endif // WALKER_H_ diff --git a/test/game_logic_testing/test_zombie_states.cpp b/test/game_logic_testing/test_zombie_states.cpp index 74d3e4c..333c037 100644 --- a/test/game_logic_testing/test_zombie_states.cpp +++ b/test/game_logic_testing/test_zombie_states.cpp @@ -41,6 +41,7 @@ void testInfectedChaseAndStateChangesToWalking(void) { Infected walker(5, 5, 0, map); map.add_zombie(&walker, 5, 5); + walker.set_walking(); map.chase_soldiers(1); @@ -191,6 +192,7 @@ void testInfectedWalkingAndGetsAttacked(void) { soldier.set_direction(LEFT); Infected walker(5, 5, 0, map); + walker.set_walking(); map.add_zombie(&walker, 5, 5); map.chase_soldiers(1); @@ -215,6 +217,7 @@ void testInfectedgetsShotAndDie(void) { soldier.set_direction(LEFT); Infected walker(5, 5, 0, map); + walker.set_walking(); map.add_zombie(&walker, 5, 5); map.chase_soldiers(1); @@ -226,8 +229,8 @@ void testInfectedgetsShotAndDie(void) { ZombieDead* walker_state = dynamic_cast(walker.get_state()); - TEST_ASSERT(walker_state != nullptr); - TEST_ASSERT(old_state != nullptr); + TEST_CHECK(walker_state != nullptr); + TEST_CHECK(old_state != nullptr); TEST_CHECK(walker.get_health() < 100); map.empty_vectors(); }