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:
parent
fab21ab693
commit
9dbc5b46f8
@ -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);
|
||||
|
@ -81,7 +81,7 @@ inline std::ofstream debugLogger;
|
||||
inline static void log(std::stringstream&str,std::source_location loc){
|
||||
debugLogger<<loc.file_name()<<"("<<loc.line()<<":"<<loc.column()<<") "<<loc.function_name()<<": "<<str.str()<<std::endl;
|
||||
std::cout<<loc.file_name()<<"("<<loc.line()<<":"<<loc.column()<<") "<<loc.function_name()<<": "<<str.str()<<std::endl;
|
||||
throw;
|
||||
throw std::exception{std::format("{}({}:{}) {}: {}",loc.file_name(),loc.line(),loc.column(),loc.function_name(),str.str()).c_str()};
|
||||
}
|
||||
};
|
||||
#else
|
||||
|
@ -932,9 +932,11 @@ void Player::AddBuff(BuffType type,float duration,float intensity){
|
||||
buffList.push_back(Buff{type,duration,intensity});
|
||||
}
|
||||
void Player::AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr){
|
||||
if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const ItemAttribute&attr){if(attr.ActualName()!="Health"&&attr.ActualName()!="Health %"&&attr.ActualName()!="Attack"&&attr.ActualName()!="Attack %"&&attr.ActualName()!="Defense"&&attr.ActualName()!="Defense %"&&attr.ActualName()!="CDR")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr.ActualName()));});
|
||||
buffList.push_back(Buff{type,duration,intensity,attr});
|
||||
}
|
||||
void Player::AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr){
|
||||
if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const std::string&attr){if(attr!="Health"&&attr!="Health %"&&attr!="Attack"&&attr!="Attack %"&&attr!="Defense"&&attr!="Defense %"&&attr!="CDR")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr));});
|
||||
buffList.push_back(Buff{type,duration,intensity,attr});
|
||||
}
|
||||
void Player::AddBuff(BuffType type,float duration,float intensity,float timeBetweenTicks,std::function<void(AiL*,int)>repeatAction){
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 3
|
||||
#define VERSION_BUILD 9923
|
||||
#define VERSION_BUILD 9928
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
Loading…
x
Reference in New Issue
Block a user