Add in illegal stat buff checks and asserts when adding to an unsupported stat buff for both monsters and players. 77/77 tests passing.

This commit is contained in:
2024-07-07 10:07:13 -05:00
parent fab21ab693
commit 9dbc5b46f8
5 changed files with 142 additions and 2 deletions
@@ -283,5 +283,89 @@ namespace MonsterTests
Assert::AreEqual(1,testMonster.GetHealth());
Assert::IsTrue(testMonster.IsAlive());
}
TEST_METHOD(IllegalDefenseStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Defense"});
Assert::Fail(L"Adding a Defense buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalMoveSpdStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Move Spd %"});
Assert::Fail(L"Adding a Move Spd % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalDefensePctStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Defense %"});
Assert::Fail(L"Adding a Defense % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalCDRStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"CDR"});
Assert::Fail(L"Adding a CDR buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalCritRateStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Crit Rate"});
Assert::Fail(L"Adding a Crit Rate buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalCritDmgStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Crit Damage"});
Assert::Fail(L"Adding a Crit Damage buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalHPRecoveryPctStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"HP Recovery %"});
Assert::Fail(L"Adding a HP Recovery % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalHP6RecoveryPctStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"HP6 Recovery %"});
Assert::Fail(L"Adding a HP6 Recovery % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalHP4RecoveryPctStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"HP4 Recovery %"});
Assert::Fail(L"Adding a HP4 Recovery % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalDamageReductionStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Damage Reduction"});
Assert::Fail(L"Adding a Damage Reduction buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalAttackSpdStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Attack Spd"});
Assert::Fail(L"Adding a Attack Spd buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){};
}
TEST_METHOD(IllegalManaStatUpBuffCheck){
try{
Monster testMonster{{},MONSTER_DATA["TestName"]};
testMonster.AddBuff(BuffType::STAT_UP,5.f,5.f,{"Mana"});
Assert::Fail(L"Adding a Mana buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
};
}
@@ -314,6 +314,60 @@ namespace PlayerTests
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Health %"});
Assert::AreEqual(1000+player->GetBaseStat("Health"),float(player->GetMaxHealth()),L"Max Health stat should be increased from 100 to 1100.");
}
TEST_METHOD(IllegalMoveSpdStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Move Spd %"});
Assert::Fail(L"Adding a Move Spd % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalCritRateStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Crit Rate"});
Assert::Fail(L"Adding a Crit Rate buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalCritDmgStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Crit Damage"});
Assert::Fail(L"Adding a Crit Damage buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalHPRecoveryPctStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"HP Recovery %"});
Assert::Fail(L"Adding a HP Recovery % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalHP6RecoveryPctStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"HP6 Recovery %"});
Assert::Fail(L"Adding a HP6 Recovery % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalHP4RecoveryPctStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"HP4 Recovery %"});
Assert::Fail(L"Adding a HP4 Recovery % buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalDamageReductionStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Damage Reduction"});
Assert::Fail(L"Adding a Damage Reduction buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(IllegalAttackSpdStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Attack Spd"});
Assert::Fail(L"Adding a Attack Spd buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){};
}
TEST_METHOD(IllegalManaStatUpBuffCheck){
try{
player->AddBuff(BuffType::STAT_UP,5.f,1000.0_Pct,{"Mana"});
Assert::Fail(L"Adding a Mana buff succeeded! This should NOT be allowed!");
}catch(std::exception&e){}
}
TEST_METHOD(AttackStatEquipCheck){
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor"s)};
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);