From 47319a99f87e72c19e0cbc7ecee2de3b8f889c1d Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 23 Jul 2024 04:41:24 -0500 Subject: [PATCH] Fix unit tests, item script tests weren't properly updated. Mark Tests were properly killing targets, removing their marks. 105/105 Tests passing. Release Build 10302. --- Adventures in Lestoria Tests/ItemTests.cpp | 10 +++++-- Adventures in Lestoria Tests/MonsterTests.cpp | 26 ++++++++++--------- Adventures in Lestoria/Buff.cpp | 14 +++++++++- Adventures in Lestoria/Version.h | 2 +- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Adventures in Lestoria Tests/ItemTests.cpp b/Adventures in Lestoria Tests/ItemTests.cpp index ce0c7534..111ae579 100644 --- a/Adventures in Lestoria Tests/ItemTests.cpp +++ b/Adventures in Lestoria Tests/ItemTests.cpp @@ -145,21 +145,25 @@ namespace ItemTests } TEST_METHOD(FlatRestoreScriptTest){ player->Hurt(75,player->OnUpperLevel(),player->GetZ()); - player->mana=25; + player->mana=24; Inventory::AddItem("Flat Recovery Potion"s,5U); game->SetLoadoutItem(0,"Flat Recovery Potion"); testKey->bHeld=true; //Simulate key being pressed. player->CheckAndPerformAbility(player->useItem1,testKeyboardInput); + game->SetElapsedTime(0.05f); + game->OnUserUpdate(0.05f);//Wait some time as the item applies a buff that heals us. We're also going to gain one mana during this tick. Assert::AreEqual(75,player->GetHealth(),L"Player Health is 75 after using Flat Recovery Potion."); Assert::AreEqual(75,player->GetMana(),L"Player Mana is 75 after using Flat Recovery Potion."); } TEST_METHOD(PctRestoreScriptTest){ player->Hurt(75,player->OnUpperLevel(),player->GetZ()); - player->mana=25; + player->mana=24; Inventory::AddItem("Pct Recovery Potion"s,5U); game->SetLoadoutItem(1,"Pct Recovery Potion"); testKey->bHeld=true; //Simulate key being pressed. player->CheckAndPerformAbility(player->useItem2,testKeyboardInput); + game->SetElapsedTime(0.05f); + game->OnUserUpdate(0.05f);//Wait some time as the item applies a buff that heals us. Assert::AreEqual(75,player->GetHealth(),L"Player Health is 75 after using Pct Recovery Potion."); Assert::AreEqual(75,player->GetMana(),L"Player Mana is 75 after using Pct Recovery Potion."); } @@ -169,6 +173,8 @@ namespace ItemTests game->SetLoadoutItem(2,"Bandages"); testKey->bHeld=true; //Simulate key being pressed. player->CheckAndPerformAbility(player->useItem3,testKeyboardInput); + game->SetElapsedTime(0.05f); + game->OnUserUpdate(0.05f);//Wait some time as the item applies a buff that heals us. Assert::AreEqual(30,player->GetHealth(),L"Player is immediately healed for 5 health points on Bandages use."); game->SetElapsedTime(1.f); game->OnUserUpdate(1.f); diff --git a/Adventures in Lestoria Tests/MonsterTests.cpp b/Adventures in Lestoria Tests/MonsterTests.cpp index 5334e42d..2df8b7ce 100644 --- a/Adventures in Lestoria Tests/MonsterTests.cpp +++ b/Adventures in Lestoria Tests/MonsterTests.cpp @@ -401,48 +401,50 @@ namespace MonsterTests TEST_METHOD(TrapperMarkTest){ Monster testMonster{{},MONSTER_DATA["TestName"]}; - Assert::AreEqual(0,testMonster.GetMarkStacks(),L"Monster has 0 marks initially."); + Assert::AreEqual(uint8_t(0),testMonster.GetMarkStacks(),L"Monster has 0 marks initially."); testMonster.ApplyMark(7.f,5U); - Assert::AreEqual(5,testMonster.GetMarkStacks(),L"Monster has 5 marks after receiving a buff."); + Assert::AreEqual(uint8_t(5),testMonster.GetMarkStacks(),L"Monster has 5 marks after receiving a buff."); testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ()); - Assert::AreEqual(5,testMonster.GetMarkStacks(),L"Monster should still have 5 marks after taking damage from a normal attack."); + Assert::AreEqual(uint8_t(5),testMonster.GetMarkStacks(),L"Monster should still have 5 marks after taking damage from a normal attack."); testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::PLAYER_ABILITY); - Assert::AreEqual(4,testMonster.GetMarkStacks(),L"Monster should have 4 marks remaining."); + Assert::AreEqual(uint8_t(4),testMonster.GetMarkStacks(),L"Monster should have 4 marks remaining."); Assert::AreEqual(22,testMonster.GetHealth(),L"Mark deals 60% of the player's attack. And 2 damage already taken from earlier."); testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::DOT); - Assert::AreEqual(4,testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining (DOTs don't remove a mark)."); + Assert::AreEqual(uint8_t(4),testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining (DOTs don't remove a mark)."); - testMonster._DealTrueDamage(10); + testMonster._DealTrueDamage(1); - Assert::AreEqual(4,testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining after taking true damage from something not marked as a player ability."); + Assert::AreEqual(uint8_t(4),testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining after taking true damage from something not marked as a player ability."); - testMonster._DealTrueDamage(10,HurtFlag::PLAYER_ABILITY); + testMonster.Heal(testMonster.GetMaxHealth()); //Heal the monster so it doesn't die. - Assert::AreEqual(3,testMonster.GetMarkStacks(),L"Monster should have 3 marks remaining after taking true damage."); + testMonster._DealTrueDamage(1,HurtFlag::PLAYER_ABILITY); + + Assert::AreEqual(uint8_t(3),testMonster.GetMarkStacks(),L"Monster should have 3 marks remaining after taking true damage."); testMonster._DealTrueDamage(10,HurtFlag::DOT|HurtFlag::PLAYER_ABILITY); - Assert::AreEqual(2,testMonster.GetMarkStacks(),L"Monster should have 2 marks remaining after taking true damage, even though it's classified as a DOT. This is an edge case, but it's really meaningless here..."); + Assert::AreEqual(uint8_t(2),testMonster.GetMarkStacks(),L"Monster should have 2 marks remaining after taking true damage, even though it's classified as a DOT. This is an edge case, but it's really meaningless here..."); testMonster.Heal(testMonster.GetMaxHealth()); testMonster.TriggerMark(); - Assert::AreEqual(1,testMonster.GetMarkStacks(),L"Monster should have 1 mark remaining after using TriggerMark function"); + Assert::AreEqual(uint8_t(1),testMonster.GetMarkStacks(),L"Monster should have 1 mark remaining after using TriggerMark function"); Assert::AreEqual(24,testMonster.GetHealth(),L"Monster should not take damage from the TriggerMark function (Mark deals 6 damage though)."); game->SetElapsedTime(10.f); testMonster.Update(10.f); - Assert::AreEqual(0,testMonster.GetMarkStacks(),L"The marks should have expired after 10 seconds."); + Assert::AreEqual(uint8_t(0),testMonster.GetMarkStacks(),L"The marks should have expired after 10 seconds."); } }; } \ No newline at end of file diff --git a/Adventures in Lestoria/Buff.cpp b/Adventures in Lestoria/Buff.cpp index 3d0f9980..96ffb343 100644 --- a/Adventures in Lestoria/Buff.cpp +++ b/Adventures in Lestoria/Buff.cpp @@ -52,7 +52,19 @@ Buff::Buff(std::variantattachedTarget,BuffType type,float dura } } Buff::Buff(std::variantattachedTarget,BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks) - :attachedTarget(attachedTarget),type(type==BuffRestorationType::OVER_TIME||type==BuffRestorationType::ONE_OFF?OVER_TIME:OVER_TIME_DURING_CAST),duration(duration),intensity(intensity),nextTick(duration-timeBetweenTicks),timeBetweenTicks(timeBetweenTicks),overTimeType(overTimeType){} + :attachedTarget(attachedTarget),duration(duration),intensity(intensity),nextTick(duration-timeBetweenTicks),timeBetweenTicks(timeBetweenTicks),overTimeType(overTimeType){ + switch(type){ + case BuffRestorationType::ONE_OFF:{ + this->type=ONE_OFF; + }break; + case BuffRestorationType::OVER_TIME:{ + this->type=OVER_TIME; + }break; + case BuffRestorationType::OVER_TIME_DURING_CAST:{ + this->type=OVER_TIME_DURING_CAST; + }break; + } +} void Buff::Update(AiL*game,float fElapsedTime){ duration-=fElapsedTime; diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index c3bbf217..bdff4aaa 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 10300 +#define VERSION_BUILD 10302 #define stringify(a) stringify_(a) #define stringify_(a) #a