From 6cb67ccaa6209faf3e855508c8c9d0cd208681ef Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 25 Jun 2024 15:27:52 -0500 Subject: [PATCH] Fix unit test crashing when loading from GFX. --- Adventures in Lestoria Tests/PlayerTests.cpp | 13 +++++++++++++ Adventures in Lestoria/Effect.cpp | 4 ++-- Adventures in Lestoria/Version.h | 2 +- x64/Release/Adventures in Lestoria.exe | Bin 3768320 -> 3768320 bytes 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Adventures in Lestoria Tests/PlayerTests.cpp b/Adventures in Lestoria Tests/PlayerTests.cpp index 70e6a7f9..d6c1bacb 100644 --- a/Adventures in Lestoria Tests/PlayerTests.cpp +++ b/Adventures in Lestoria Tests/PlayerTests.cpp @@ -42,6 +42,8 @@ All rights reserved. using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace olc::utils; +INCLUDE_GFX + namespace PlayerTests { TEST_CLASS(PlayerTest) @@ -61,6 +63,7 @@ namespace PlayerTests sig::Animation::InitializeAnimations(); testGame->InitializeDefaultKeybinds(); testGame->InitializePlayer(); + sig::Animation::SetupPlayerAnimations(); Menu::InitializeMenus(); Tutorial::Initialize(); Stats::InitializeDamageReductionTable(); @@ -69,6 +72,8 @@ namespace PlayerTests testKeyboardInput.AddKeybind(Input{InputType::KEY,0}); testKey=&testGame->pKeyboardState[0]; testGame->olc_UpdateKeyFocus(true); //Force the game to be "focused" for tests. Required if we want keyboard inputs to work. + Menu::themes.SetInitialized(); + GFX.SetInitialized(); } TEST_METHOD(PlayerAlive){ @@ -130,5 +135,13 @@ namespace PlayerTests player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput); Assert::AreEqual(player->GetMaxMana(),player->GetMana()); } + TEST_METHOD(RangerCastDoesNotConsumeManaImmediately){ + testGame->ChangePlayerClass(RANGER); + player=testGame->GetPlayer(); //The player pointer has been reassigned... + //Ability 2 is Charged Shot, which is a cast. Mana should not be consumed for a spell that begins as a cast. + testKey->bHeld=true; //Force the key to be held down for testing purposes. + player->CheckAndPerformAbility(player->GetAbility2(),testKeyboardInput); + Assert::AreEqual(player->GetMaxMana(),player->GetMana()); + } }; } diff --git a/Adventures in Lestoria/Effect.cpp b/Adventures in Lestoria/Effect.cpp index 0a6c567d..daeca148 100644 --- a/Adventures in Lestoria/Effect.cpp +++ b/Adventures in Lestoria/Effect.cpp @@ -45,12 +45,12 @@ INCLUDE_game Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,float size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending) :Effect::Effect(pos,lifetime,imgFile,upperLevel,vf2d{size,size},fadeout,spd,col,rotation,rotationSpd,additiveBlending){ - this->animation.AddState(imgFile,ANIMATION_DATA[imgFile]); + this->animation.AddState(imgFile,ANIMATION_DATA.at(imgFile)); } Effect::Effect(vf2d pos,float lifetime,std::string imgFile,bool upperLevel,vf2d size,float fadeout,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending) :pos(pos),lifetime(lifetime),upperLevel(upperLevel),size(size),fadeout(fadeout),original_fadeoutTime(fadeout),spd(spd),col(col),rotation(rotation),rotationSpd(rotationSpd),additiveBlending(additiveBlending){ - this->animation.AddState(imgFile,ANIMATION_DATA[imgFile]); + this->animation.AddState(imgFile,ANIMATION_DATA.at(imgFile)); } bool Effect::Update(float fElapsedTime){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index c5c82e63..5016c2f6 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 -#define VERSION_BUILD 9837 +#define VERSION_BUILD 9840 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 4b4be76f00ac4b1566f64231236a71d81bede164..4d4b600245a3b6926c2b1d9c17b5e5396202b984 100644 GIT binary patch delta 347 zcmYMvyG{a86ouhApu#XC7exg@xyxmA2DxcMLG6oJ5(1&3ISC|FQkiM&r=>ejK|#k8 z_yn{h{8JEj@+CWK?Pg2)CnPov5iTVbOG~(x2!s&E1uk)g2%^xHC1PJwF?Q#(7z~)W zMjQzwk-`mbk;WbF@qi4nctj3)JmDDy6j4GM6;x5f3+iZ~i54ups`>0~?G1V2TVq0) zV5J;w4rac`&F1y>rjl7^G{6{dImY4zN#@1Tu$bkIeR N_c6eS+WMc}{Rxzla(Ms% delta 347 zcmYMvyG{a86ouhATpbP~=z!n_Q5*vJ0kw$d0)2hZ4rqfjs%iOA&mo=+7_AjvH0|-lME!X zI7ALd$fJN`oWMd6C7hy+3eIqj3tXa#8m>@B15LEh#x-ux!7aM5ai^z~-aL5ai4TK` zVT74>jaleMk+JKt>=rh3n|&9&NvC4&j&i};bZWkmj#knwFN6%X-`yvF6}q^`10K;w Ols{vDp