Added Monster unit tests relating to the damage formula, crit rates, and special survival cases.
This commit is contained in:
parent
f1fa126d1e
commit
2c7d69d1b5
@ -144,6 +144,83 @@ namespace MonsterTests
|
|||||||
testMonster.AddBuff(BuffType::SPEEDBOOST,5.f,0.75f);
|
testMonster.AddBuff(BuffType::SPEEDBOOST,5.f,0.75f);
|
||||||
Assert::AreEqual(2.5f,testMonster.GetMoveSpdMult());
|
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());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
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{
|
class DeathSpawnInfo{
|
||||||
std::string monsterSpawnName;
|
std::string monsterSpawnName;
|
||||||
uint8_t spawnAmt;
|
uint8_t spawnAmt;
|
||||||
@ -72,12 +76,12 @@ public:
|
|||||||
DeathSpawnInfo(const std::string_view monsterName,const uint8_t spawnAmt,const vf2d spawnOffset={});
|
DeathSpawnInfo(const std::string_view monsterName,const uint8_t spawnAmt,const vf2d spawnOffset={});
|
||||||
void Spawn(const vf2d monsterDeathPos,const bool onUpperLevel);
|
void Spawn(const vf2d monsterDeathPos,const bool onUpperLevel);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Monster:IAttributable{
|
class Monster:IAttributable{
|
||||||
friend struct STRATEGY;
|
friend struct STRATEGY;
|
||||||
friend class AiL;
|
friend class AiL;
|
||||||
friend class InventoryCreator;
|
friend class InventoryCreator;
|
||||||
friend class DeathSpawnInfo;
|
friend class DeathSpawnInfo;
|
||||||
|
friend class MonsterTests::MonsterTest;
|
||||||
public:
|
public:
|
||||||
Monster()=delete;
|
Monster()=delete;
|
||||||
Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false);
|
Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false);
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 3
|
#define VERSION_PATCH 3
|
||||||
#define VERSION_BUILD 9790
|
#define VERSION_BUILD 9792
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user