Skip to content

Commit

Permalink
More actor tapes
Browse files Browse the repository at this point in the history
  • Loading branch information
captainurist committed Oct 13, 2023
1 parent 2c71a9d commit abb6164
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/Bin/GameTest/GameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ GAME_TEST(Prs, Pr469) {

GAME_TEST(Issues, Issue488) {
// Test that Mass Distortion spell works.
auto actorHpTape = tapes.custom([] { return pActors[24].currentHP; });
auto actorHpTape = actorTapes.hp(24);
test.playTraceFromTestData("issue_488.mm7", "issue_488.json");
EXPECT_EQ(actorHpTape, tape(3, 2));
}
Expand Down Expand Up @@ -1171,8 +1171,8 @@ GAME_TEST(Issues, Issue742) {

GAME_TEST(Issues, Issue755) {
// Resurrection doesn't crash. Crashes were actually quite random because the code was reading pointer parts as ints.
auto actor2Tape = tapes.custom([] { return pActors[2].aiState; });
auto actor37Tape = tapes.custom([] { return pActors[37].aiState; });
auto actor2Tape = actorTapes.aiState(2);
auto actor37Tape = actorTapes.aiState(37);
test.playTraceFromTestData("issue_755.mm7", "issue_755.json");
EXPECT_TRUE(actor2Tape.contains(Dead));
EXPECT_TRUE(actor2Tape.contains(Resurrected));
Expand Down Expand Up @@ -1437,8 +1437,8 @@ GAME_TEST(Issues, Issue895) {
GAME_TEST(Issues, Issue906_773) {
// Issue with some use of Spellbuff Expired() - check actors cast buffs.
// #773: AI_SpellAttack using wrong actor buff for bless.
auto blessTape = tapes.custom([] { return pActors[2].buffs[ACTOR_BUFF_BLESS].Active(); });
auto heroismTape = tapes.custom([] { return pActors[2].buffs[ACTOR_BUFF_HEROISM].Active(); });
auto blessTape = actorTapes.hasBuff(2, ACTOR_BUFF_BLESS);
auto heroismTape = actorTapes.hasBuff(2, ACTOR_BUFF_HEROISM);
test.playTraceFromTestData("issue_906.mm7", "issue_906.json");
EXPECT_EQ(blessTape, tape(true, false, true));
EXPECT_EQ(heroismTape, tape(true, false, true));
Expand Down
11 changes: 11 additions & 0 deletions test/Testing/Game/ActorTapeRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ TestTape<int> ActorTapeRecorder::countByBuff(ACTOR_BUFF_INDEX buff) {
TestTape<int> ActorTapeRecorder::hp(int actorIndex) {
return custom(actorIndex, std::bind<int>(&Actor::currentHP, _1));
}

TestTape<AIState> ActorTapeRecorder::aiState(int actorIndex) {
return custom(actorIndex, std::bind(&Actor::aiState, _1));
}

TestTape<bool> ActorTapeRecorder::hasBuff(int actorIndex, ACTOR_BUFF_INDEX buff) {
return custom(actorIndex, [buff] (const Actor &actor) {
return actor.buffs[buff].Active();
});
}

4 changes: 4 additions & 0 deletions test/Testing/Game/ActorTapeRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class ActorTapeRecorder {

TestTape<int> hp(int actorIndex);

TestTape<AIState> aiState(int actorIndex);

TestTape<bool> hasBuff(int actorIndex, ACTOR_BUFF_INDEX buff);

private:
static std::span<Actor> actors();

Expand Down

0 comments on commit abb6164

Please sign in to comment.