Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Fanusaez/Left4Dead
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho-1 committed Jun 15, 2023
2 parents 20eb733 + a0791a9 commit 9090eac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/game_logic/zombies/infected.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/game_logic/zombies/infected.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
7 changes: 5 additions & 2 deletions test/game_logic_testing/test_zombie_states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -226,8 +229,8 @@ void testInfectedgetsShotAndDie(void) {

ZombieDead* walker_state = dynamic_cast<ZombieDead*>(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();
}
Expand Down

0 comments on commit 9090eac

Please sign in to comment.