diff --git a/Adventures in Lestoria Tests/Adventures in Lestoria Tests.cpp b/Adventures in Lestoria Tests/Adventures in Lestoria Tests.cpp index 88d76329..62eaa94f 100644 --- a/Adventures in Lestoria Tests/Adventures in Lestoria Tests.cpp +++ b/Adventures in Lestoria Tests/Adventures in Lestoria Tests.cpp @@ -144,6 +144,83 @@ namespace MonsterTests testMonster.AddBuff(BuffType::SPEEDBOOST,5.f,0.75f); Assert::AreEqual(2.5f,testMonster.GetMoveSpdMult()); } + TEST_METHOD(DamageReductionBuffTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + testMonster.AddBuff(BuffType::DAMAGE_REDUCTION,5.f,0.25f); + + testMonster.Hurt(testMonster.GetAttack(),testMonster.OnUpperLevel(),testMonster.GetZ()); + //25% damage reduction should result in 7.5 health taken, When ceiling'd results in 8 health taken. + Assert::AreEqual(22,testMonster.GetHealth()); + } + TEST_METHOD(BarrierBuffTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + testMonster.AddBuff(BuffType::BARRIER_DAMAGE_REDUCTION,5.f,0.5f); + + testMonster.Hurt(testMonster.GetAttack(),testMonster.OnUpperLevel(),testMonster.GetZ()); + //50% damage reduction should result in 5 health taken + Assert::AreEqual(25,testMonster.GetHealth()); + } + TEST_METHOD(AdditiveDamageReductionTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + testMonster.AddBuff(BuffType::DAMAGE_REDUCTION,5.f,0.25f); + testMonster.AddBuff(BuffType::BARRIER_DAMAGE_REDUCTION,5.f,0.5f); + + testMonster.Hurt(testMonster.GetAttack(),testMonster.OnUpperLevel(),testMonster.GetZ()); + //25+50% damage reduction should result in 2.5 health taken. When ceiling'd, results in 3 health taken. + Assert::AreEqual(27,testMonster.GetHealth()); + } + TEST_METHOD(MaximumDamageReductionTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + testMonster.AddBuff(BuffType::DAMAGE_REDUCTION,5.f,INFINITY); + + testMonster.Hurt(testMonster.GetAttack(),testMonster.OnUpperLevel(),testMonster.GetZ()); + //At 100% or more damage reduction, the monster should take 0 damage. + Assert::AreEqual(30,testMonster.GetHealth()); + } + TEST_METHOD(TrueDamageTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + + testMonster._DealTrueDamage(testMonster.GetAttack()*3); + Assert::AreEqual(0,testMonster.GetHealth()); + } + TEST_METHOD(TrueDamageTestWith100PctDamageReduction){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + testMonster.AddBuff(BuffType::DAMAGE_REDUCTION,5.f,INFINITY); + + testMonster._DealTrueDamage(testMonster.GetAttack()*3); + //Damage reduction should not affect true damage at all. + Assert::AreEqual(0,testMonster.GetHealth()); + } + TEST_METHOD(CriticalRateTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + + game->GetPlayer()->SetBaseStat(ItemAttribute::Get("Crit Rate"),100.f); + + testMonster.Hurt(5,testMonster.OnUpperLevel(),testMonster.GetZ()); + //If crit rate works 100% of the time, getting hurt should deal crit dmg % more damage (which defaults to 50%). Ceiling 7.5 damage to 8. + Assert::AreEqual(22,testMonster.GetHealth()); + } + TEST_METHOD(CriticalDamageTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + + game->GetPlayer()->SetBaseStat(ItemAttribute::Get("Crit Rate"),100.f); + game->GetPlayer()->SetBaseStat(ItemAttribute::Get("Crit Dmg"),150.f); + + testMonster.Hurt(5,testMonster.OnUpperLevel(),testMonster.GetZ()); + //If crit rate works 100% of the time, getting hurt will deal 150% more damage. Ceiling 12.5 damage to 13. + Assert::AreEqual(17,testMonster.GetHealth()); + } + TEST_METHOD(ShouldNotDieNormallyTest){ + Monster testMonster{{},MONSTER_DATA["TestName"]}; + testMonster.diesNormally=false; + + testMonster.Hurt(1000,testMonster.OnUpperLevel(),testMonster.GetZ()); + testMonster.Hurt(1000,testMonster.OnUpperLevel(),testMonster.GetZ()); + testMonster.Hurt(1000,testMonster.OnUpperLevel(),testMonster.GetZ()); + //Health should continue to remain at 1 and the monster should remain alive if the dies normally flag is false. + Assert::AreEqual(1,testMonster.GetHealth()); + Assert::IsTrue(testMonster.IsAlive()); + } }; } diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index c49e99ed..4a06c50c 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -64,6 +64,10 @@ enum class TrueDamageFlag{ IGNORE_DAMAGE_RULES, //Deals true damage, ignoring established invulnerability/iframe rules. Will never miss and will not have its damage modified by any buffs/stats. }; +namespace MonsterTests{ + class MonsterTest; +}; + class DeathSpawnInfo{ std::string monsterSpawnName; uint8_t spawnAmt; @@ -72,12 +76,12 @@ public: DeathSpawnInfo(const std::string_view monsterName,const uint8_t spawnAmt,const vf2d spawnOffset={}); void Spawn(const vf2d monsterDeathPos,const bool onUpperLevel); }; - class Monster:IAttributable{ friend struct STRATEGY; friend class AiL; friend class InventoryCreator; friend class DeathSpawnInfo; + friend class MonsterTests::MonsterTest; public: Monster()=delete; Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index cb67ecc0..17d91468 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 9790 +#define VERSION_BUILD 9792 #define stringify(a) stringify_(a) #define stringify_(a) #a