Skip to content

Commit

Permalink
Fix & test OpenEnroth#1340
Browse files Browse the repository at this point in the history
  • Loading branch information
captainurist committed Oct 15, 2023
1 parent 2e7197c commit ea1851a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Engine/Objects/Chest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ void GenerateItemsInChest() {
break;
}
currItem->SetIdentified();
currItem->special_enchantment = (ItemEnchantment)goldAmount;
currItem->goldAmount = goldAmount;
} else {
pItemTable->generateItem(resultTreasureLevel, RANDOM_ITEM_ANY, currItem);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Bin/GameTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if(OE_BUILD_TESTS)
ExternalProject_Add(OpenEnroth_TestData
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/test_data_tmp
GIT_REPOSITORY https://github.com/OpenEnroth/OpenEnroth_TestData.git
GIT_TAG 00fd069134db2f7a85643a6c46de4733b0bfbd21
GIT_TAG b11f684625eb68dde884b53525212073ae96d2dd
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/test_data
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
16 changes: 16 additions & 0 deletions test/Bin/GameTest/GameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,7 @@ GAME_TEST(Issues, Issue1331) {
}

GAME_TEST(Issues, Issue1338) {
// Casting telepathy on an actor and then killing it results in the actor not dropping any gold.
auto deadTape = actorTapes.indicesByState(AIState::Dead);
auto statusTape = tapes.statusBar();
auto goldTape = tapes.gold();
Expand All @@ -1718,3 +1719,18 @@ GAME_TEST(Issues, Issue1338) {
EXPECT_TRUE(statusTape.contains(fmt::format("{} gold", peasantGoldTape.max()))); // Telepathy status message.
EXPECT_TRUE(statusTape.contains(fmt::format("You found {} gold!", peasantGoldTape.max()))); // Corpse pickup message.
}

GAME_TEST(Issues, Issue1340) {
// Gold piles in chests are generated with 0 gold.
auto goldTape = tapes.gold();
auto mapTape = tapes.map();
auto statusTape = tapes.statusBar();
auto screenTape = tapes.screen();
test.playTraceFromTestData("issue_1340.mm7", "issue_1340.json");
EXPECT_EQ(mapTape, tape("out01.odm", "d29.blv")); // Emerald Isle -> Castle Harmondale.
EXPECT_TRUE(screenTape.contains(SCREEN_CHEST));
EXPECT_GT(goldTape.delta(), 0); // Party should have picked some gold from the chest.
EXPECT_FALSE(statusTape.contains("You found 0 gold!")); // No piles of 0 size.
for (int gold : goldTape.adjacentDeltas())
EXPECT_TRUE(statusTape.contains(fmt::format("You found {} gold!", gold)));
}

0 comments on commit ea1851a

Please sign in to comment.