diff --git a/Adventures in Lestoria Tests/MonsterTests.cpp b/Adventures in Lestoria Tests/MonsterTests.cpp index 8c4bcb66..d8a250f9 100644 --- a/Adventures in Lestoria Tests/MonsterTests.cpp +++ b/Adventures in Lestoria Tests/MonsterTests.cpp @@ -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){} + } }; } \ No newline at end of file diff --git a/Adventures in Lestoria Tests/PlayerTests.cpp b/Adventures in Lestoria Tests/PlayerTests.cpp index 889b8614..52fa5529 100644 --- a/Adventures in Lestoria Tests/PlayerTests.cpp +++ b/Adventures in Lestoria Tests/PlayerTests.cpp @@ -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_ptrsetArmor{Inventory::AddItem("Test Armor"s)}; Inventory::EquipItem(setArmor,EquipSlot::ARMOR); diff --git a/Adventures in Lestoria/Error.h b/Adventures in Lestoria/Error.h index c3047633..52bb9187 100644 --- a/Adventures in Lestoria/Error.h +++ b/Adventures in Lestoria/Error.h @@ -81,7 +81,7 @@ inline std::ofstream debugLogger; inline static void log(std::stringstream&str,std::source_location loc){ debugLogger<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::setattr){ + 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::functionrepeatAction){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index c86b03d4..48b86885 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 9923 +#define VERSION_BUILD 9928 #define stringify(a) stringify_(a) #define stringify_(a) #a