@ -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 ( ) ) ;
}
} ;
}