From 2f8662e1637ac408375848302bd66fa369b94e05 Mon Sep 17 00:00:00 2001 From: Peter Skelton Date: Sat, 16 Mar 2024 23:38:10 +0000 Subject: [PATCH] Add test for #1532 --- test/Bin/GameTest/GameTests_1500.cpp | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/Bin/GameTest/GameTests_1500.cpp b/test/Bin/GameTest/GameTests_1500.cpp index d0d77e32d49b..d3755d05bb1d 100644 --- a/test/Bin/GameTest/GameTests_1500.cpp +++ b/test/Bin/GameTest/GameTests_1500.cpp @@ -1,12 +1,17 @@ #include +#include #include "Testing/Game/GameTest.h" +#include "Engine/Spells/CastSpellInfo.h" #include "Engine/Engine.h" #include "Engine/mm7_data.h" #include "Engine/Party.h" +#include "Engine/Objects/SpriteObject.h" + #include "GUI/GUIWindow.h" #include "GUI/UI/UIPartyCreation.h" +#include "GUI/UI/UIStatusBar.h" // 1500 @@ -26,6 +31,30 @@ GAME_TEST(Issues, Issue1510) { EXPECT_LE(actorDistTape.max(), meleeRange); } +GAME_TEST(Issues, Issue1532) { + // Can cast too many firespikes + game.startNewGame(); + engine->config->debug.AllMagic.setValue(true); + engine->config->debug.NoActors.setValue(true); + auto statusTape = tapes.statusBar(); + + // keep casting till the spell fails + while (engine->_statusBar->get() != "Spell failed") { + if (pParty->pCharacters[0].CanAct()) + pushSpellOrRangedAttack(SPELL_FIRE_FIRE_SPIKE, 0, CombinedSkillValue(10, CHARACTER_SKILL_MASTERY_GRANDMASTER), 0, 0); + game.tick(1); + } + + // count should be 9 for gm + EXPECT_EQ(9, std::ranges::count_if(pSpriteObjects, [](const SpriteObject& object) { + return object.uType != SPRITE_NULL && + object.uObjectDescID != 0 && // exploded fire spikes have no DescID + object.uSpellID == SPELL_FIRE_FIRE_SPIKE && + object.spell_caster_pid == Pid(OBJECT_Character, 0); + }) + ); +} + GAME_TEST(Issues, Issue1535) { // Queued messages stay in the event queue and roll over between tests. game.startNewGame();