The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
609 lines
37 KiB
609 lines
37 KiB
#pragma region License
|
|
/*
|
|
License (OLC-3)
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
are permitted provided that the following conditions are met:
|
|
|
|
1. Redistributions or derivations of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions or derivative works in binary form must reproduce the above
|
|
copyright notice. This list of conditions and the following disclaimer must be
|
|
reproduced in the documentation and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the copyright holder nor the names of its contributors may
|
|
be used to endorse or promote products derived from this software without specific
|
|
prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
SUCH DAMAGE.
|
|
|
|
Portions of this software are copyright © 2024 The FreeType
|
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
|
All rights reserved.
|
|
*/
|
|
#pragma endregion
|
|
#include "CppUnitTest.h"
|
|
#include "AdventuresInLestoria.h"
|
|
#include "Tutorial.h"
|
|
#include <random>
|
|
#include <format>
|
|
#include "ItemDrop.h"
|
|
#include "DamageNumber.h"
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
using namespace olc::utils;
|
|
|
|
INCLUDE_GFX
|
|
INCLUDE_ITEM_DATA
|
|
INCLUDE_DAMAGENUMBER_LIST
|
|
|
|
extern std::mt19937 rng;
|
|
|
|
namespace PlayerTests
|
|
{
|
|
TEST_CLASS(PlayerTest)
|
|
{
|
|
public:
|
|
std::unique_ptr<AiL>testGame;
|
|
InputGroup testKeyboardInput;
|
|
Player*player;
|
|
HWButton*testKey;
|
|
TEST_METHOD_INITIALIZE(PlayerInitialize){
|
|
rng=std::mt19937{57189U};//Establish a fixed random seed on setup so the exact same results are generated every test run.
|
|
testGame.reset(new AiL(true));
|
|
ItemAttribute::Initialize();
|
|
ItemInfo::InitializeItems();
|
|
testGame->InitializeGraphics();
|
|
testGame->InitializeClasses();
|
|
sig::Animation::InitializeAnimations();
|
|
testGame->InitializeDefaultKeybinds();
|
|
testGame->InitializePlayer();
|
|
sig::Animation::SetupPlayerAnimations();
|
|
Menu::InitializeMenus();
|
|
Tutorial::Initialize();
|
|
Stats::InitializeDamageReductionTable();
|
|
|
|
GameState::Initialize();
|
|
GameState::STATE=GameState::states.at(States::State::GAME_RUN);
|
|
|
|
#pragma region Setup a fake test map and test monster
|
|
game->MAP_DATA["CAMPAIGN_1_1"];
|
|
ItemDrop::drops.clear();
|
|
MonsterData testMonsterData{"TestName","Test Monster",1000,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f};
|
|
MONSTER_DATA["TestName"]=testMonsterData;
|
|
#pragma endregion
|
|
|
|
player=testGame->GetPlayer();
|
|
//Setup key "0" as a test input
|
|
testKeyboardInput.AddKeybind(Input{InputType::KEY,0});
|
|
testKey=&testGame->pKeyboardState[0];
|
|
testGame->olc_UpdateKeyFocus(true); //Force the game to be "focused" for tests. Required if we want keyboard inputs to work.
|
|
Menu::themes.SetInitialized();
|
|
GFX.SetInitialized();
|
|
|
|
DAMAGENUMBER_LIST.clear();
|
|
}
|
|
TEST_METHOD_CLEANUP(CleanupTests){
|
|
testGame->EndGame();
|
|
}
|
|
TEST_METHOD(PlayerAlive){
|
|
Assert::IsTrue(player->IsAlive());
|
|
}
|
|
TEST_METHOD(PlayerTakesDamage){
|
|
player->Hurt(30,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(70,player->GetHealth());
|
|
}
|
|
TEST_METHOD(PlayerBlockingTakesNoDamage){
|
|
player->SetState(State::BLOCK);
|
|
player->Hurt(30,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(100,player->GetHealth());
|
|
}
|
|
TEST_METHOD(PlayerIframesPreventsDamage){
|
|
player->ApplyIframes(0.5f);
|
|
player->Hurt(30,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(100,player->GetHealth());
|
|
}
|
|
TEST_METHOD(PlayerConsumesManaOnRightClickAbilityUse){
|
|
int abilityManaCost{player->GetRightClickAbility().manaCost};
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetRightClickAbility(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana()-abilityManaCost,player->GetMana());
|
|
}
|
|
TEST_METHOD(PlayerConsumesManaOnAbility1Use){
|
|
int abilityManaCost{player->GetAbility1().manaCost};
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility1(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana()-abilityManaCost,player->GetMana());
|
|
}
|
|
TEST_METHOD(PlayerConsumesManaOnAbility2Use){
|
|
int abilityManaCost{player->GetAbility2().manaCost};
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility2(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana()-abilityManaCost,player->GetMana());
|
|
}
|
|
TEST_METHOD(PlayerConsumesManaOnAbility3Use){
|
|
int abilityManaCost{player->GetAbility3().manaCost};
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana()-abilityManaCost,player->GetMana());
|
|
}
|
|
TEST_METHOD(PlayerConsumesManaOnAbility4Use){
|
|
int abilityManaCost{player->GetAbility4().manaCost};
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility4(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana()-abilityManaCost,player->GetMana());
|
|
}
|
|
TEST_METHOD(WarriorBlockActivatesBlock){
|
|
player->GetRightClickAbility().action(player,player->GetPos());
|
|
Assert::AreEqual(int(State::BLOCK),int(player->GetState()));
|
|
}
|
|
TEST_METHOD(WizardCastDoesNotConsumeManaImmediately){
|
|
testGame->ChangePlayerClass(WIZARD);
|
|
player=testGame->GetPlayer(); //The player pointer has been reassigned...
|
|
//Ability 3 is Meteor, which is a cast. Mana should not be consumed for a spell that begins as a cast.
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana(),player->GetMana());
|
|
}
|
|
TEST_METHOD(RangerCastDoesNotConsumeManaImmediately){
|
|
testGame->ChangePlayerClass(RANGER);
|
|
player=testGame->GetPlayer(); //The player pointer has been reassigned...
|
|
//Ability 2 is Charged Shot, which is a cast. Mana should not be consumed for a spell that begins as a cast.
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility2(),testKeyboardInput);
|
|
Assert::AreEqual(player->GetMaxMana(),player->GetMana());
|
|
}
|
|
TEST_METHOD(PlayerTakesDamageWithDamageReductionApplied){
|
|
std::weak_ptr<Item>testArmor{Inventory::AddItem("Bone Armor"s)};
|
|
testArmor.lock()->enhancementLevel="Item.Item Max Enhancement Level"_I; //Force enhance the item to the max enhancement level.
|
|
Inventory::EquipItem(testArmor,EquipSlot::ARMOR);
|
|
|
|
//If any of these values change, the armor piece may return a different value and these need to be updated for
|
|
//BONE ARMOR +10!
|
|
Assert::AreEqual(72.f,testArmor.lock()->GetStats().A_Read("Defense"),L"Defense increase is not 72");
|
|
Assert::AreEqual(14.f,testArmor.lock()->GetStats().A_Read("Health"),L"Health increase is not 14");
|
|
Assert::AreEqual(7.f,testArmor.lock()->GetStats().A_Read("Attack"),L"Attack increase is not 7");
|
|
|
|
player->Hurt(30,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(74,player->GetHealth()); //Even though we are supposed to take 30 damage, damage reduction reduces it to 26 instead. (Random variance is controlled during testing. If this number changes at some point, either the damage formula or the item's stats have changed!)
|
|
}
|
|
TEST_METHOD(PlayerSetEffectsAcknowledged){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor"s)};
|
|
setArmor.lock()->enhancementLevel="Item.Item Max Enhancement Level"_I; //Force enhance the item to the max enhancement level.
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
|
|
//This gear is supposed to be provide an additional 100 defense, 1000 health, and 100 attack.
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Defense"),player->GetEquipStat("Defense"),L"Defense stat was not increased by 100.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Attack"),player->GetEquipStat("Attack"),L"Attack stat was not increased by 100.");
|
|
Assert::AreEqual(1000.f+player->GetBaseStat("Health"),player->GetEquipStat("Health"),L"Health Points was not increased by 1000.");
|
|
}
|
|
TEST_METHOD(PlayerSetEffectsAcknowledged2){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
setArmor.lock()->enhancementLevel="Item.Item Max Enhancement Level"_I; //Force enhance the item to the max enhancement level.
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
|
|
//This gear is supposed to be provide an additional 100% defense, 100% Attack, 100% Move Spd, 100% CDR, 100% Crit Rate, 100% Crit Dmg, 100% Health %, 100% HP/6 Recovery
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Defense %"),player->GetEquipStat("Defense %"),L"Defense % stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Attack %"),player->GetEquipStat("Attack %"),L"Attack % stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Move Spd %"),player->GetEquipStat("Move Spd %"),L"Move Spd % stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("CDR"),player->GetEquipStat("CDR"),L"CDR stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Crit Rate % stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Crit Dmg"),player->GetEquipStat("Crit Dmg"),L"Critical Damage stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Health %"),player->GetEquipStat("Health %"),L"Health Points was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("HP6 Recovery %"),player->GetEquipStat("HP6 Recovery %"),L"HP/6s Recovery stat was not increased by 100%.");
|
|
}
|
|
TEST_METHOD(PlayerSetEffectsAcknowledged3){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor3"s)};
|
|
setArmor.lock()->enhancementLevel="Item.Item Max Enhancement Level"_I; //Force enhance the item to the max enhancement level.
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
|
|
//This gear is supposed to be provide an additional 100% HP/4 Recovery, 100% Damage Reduction
|
|
Assert::AreEqual(100.f+player->GetBaseStat("HP4 Recovery %"),player->GetEquipStat("HP4 Recovery %"),L"HP/4s Recovery stat was not increased by 100%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Damage Reduction"),player->GetEquipStat("Damage Reduction"),L"Damage Reduction stat was not increased by 100%.");
|
|
}
|
|
TEST_METHOD(PlayerSetEffectsAcknowledged4){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor4"s)};
|
|
setArmor.lock()->enhancementLevel="Item.Item Max Enhancement Level"_I; //Force enhance the item to the max enhancement level.
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
|
|
//This gear is supposed to be provide an additional 100% HP/s Recovery, 50% Attack Spd, and 100 More Base Mana.
|
|
Assert::AreEqual(100.f+player->GetBaseStat("HP Recovery %"),player->GetEquipStat("HP Recovery %"),L"HP Recovery % stat was not increased by 100%.");
|
|
Assert::AreEqual(50.f+player->GetBaseStat("Attack Spd"),player->GetEquipStat("Attack Spd"),L"Attack Speed stat was not increased by 50%.");
|
|
Assert::AreEqual(100.f+player->GetBaseStat("Mana"),player->GetEquipStat("Mana"),L"Mana stat was not increased by 100.");
|
|
}
|
|
TEST_METHOD(MultiPieceSetEffectsWork){
|
|
std::weak_ptr<Item>testArmor{Inventory::AddItem("Bone Armor"s)};
|
|
std::weak_ptr<Item>testHeadpiece{Inventory::AddItem("Bone Helmet"s)};
|
|
std::weak_ptr<Item>testLeggings{Inventory::AddItem("Bone Pants"s)};
|
|
std::weak_ptr<Item>testGloves{Inventory::AddItem("Bone Gloves"s)};
|
|
|
|
Assert::AreEqual(player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Base Crit Rate does not match initial Crit Rate");
|
|
Assert::AreEqual(player->GetBaseStat("Crit Dmg"),player->GetEquipStat("Crit Dmg"),L"Base Crit Dmg does not match initial Crit Dmg");
|
|
|
|
Inventory::EquipItem(testArmor,EquipSlot::ARMOR);
|
|
Inventory::EquipItem(testHeadpiece,EquipSlot::HELMET);
|
|
|
|
Assert::AreEqual(5+player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Crit Rate does not increase by 5% with 2 Bone Equips (Set Bonus)");
|
|
Assert::AreEqual(player->GetBaseStat("Crit Dmg"),player->GetEquipStat("Crit Dmg"),L"Crit Dmg does not remain the same with 2 Bone Equips (Set Bonus)");
|
|
|
|
Inventory::UnequipItem(EquipSlot::ARMOR);
|
|
Assert::AreEqual(player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Removing an armor piece does not remove the crit rate set effect");
|
|
Assert::AreEqual(player->GetBaseStat("Crit Dmg"),player->GetEquipStat("Crit Dmg"),L"Removing an armor piece affects crit dmg incorrectly");
|
|
|
|
Inventory::EquipItem(testArmor,EquipSlot::ARMOR);
|
|
Inventory::EquipItem(testLeggings,EquipSlot::PANTS);
|
|
Inventory::EquipItem(testGloves,EquipSlot::GLOVES);
|
|
Assert::AreEqual(5+player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Crit Rate does not increase by 5% with 4 Bone Equips (Set Bonus)");
|
|
Assert::AreEqual(7+player->GetBaseStat("Crit Dmg"),player->GetEquipStat("Crit Dmg"),L"Crit Dmg does not increase by 5% with 4 Bone Equips (Set Bonus)");
|
|
}
|
|
TEST_METHOD(AccessoriesWork){
|
|
std::weak_ptr<Item>testRing{Inventory::AddItem("Bird's Treasure"s)};
|
|
std::weak_ptr<Item>testRing2{Inventory::AddItem("Bird's Treasure"s)};
|
|
|
|
Assert::AreEqual(3.f,testRing.lock()->RandomStats().A_Read("Move Spd %"),L"Generated Ring 1 Move Spd % is incorrect.");
|
|
Assert::AreEqual(2.f,testRing.lock()->RandomStats().A_Read("Crit Rate"),L"Generated Ring 1 Crit Rate is incorrect.");
|
|
Assert::AreEqual(5.f,testRing.lock()->RandomStats().A_Read("Mana"),L"Generated Ring 1 Mana is incorrect.");
|
|
|
|
Assert::AreEqual(2.f,testRing2.lock()->RandomStats().A_Read("Move Spd %"),L"Generated Ring 2 Move Spd % is incorrect.");
|
|
Assert::AreEqual(2.f,testRing2.lock()->RandomStats().A_Read("Crit Rate"),L"Generated Ring 2 Crit Rate is incorrect.");
|
|
Assert::AreEqual(2.f,testRing2.lock()->RandomStats().A_Read("Mana"),L"Generated Ring 2 Mana is incorrect.");
|
|
|
|
Assert::IsTrue(testRing.lock()->RandomStats().A_Read("Move Spd %")>=ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Move Spd %")&&
|
|
testRing.lock()->RandomStats().A_Read("Move Spd %")<=ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Move Spd %"),std::format(L"Generated Move Spd % {} is out of bounds: Min:{} Max:{}",testRing.lock()->RandomStats().A_Read("Move Spd %"),ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Move Spd %"),ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Move Spd %")).c_str());
|
|
Assert::IsTrue(testRing.lock()->RandomStats().A_Read("Crit Rate")>=ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Crit Rate")&&
|
|
testRing.lock()->RandomStats().A_Read("Crit Rate")<=ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Crit Rate"),std::format(L"Generated Crit Rate {} is out of bounds: Min:{} Max:{}",testRing.lock()->RandomStats().A_Read("Crit Rate"),ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Move Spd %"),ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Crit Rate")).c_str());
|
|
Assert::IsTrue(testRing.lock()->RandomStats().A_Read("Mana")>=ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Mana")&&
|
|
testRing.lock()->RandomStats().A_Read("Mana")<=ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Mana"),std::format(L"Generated Mana {} is out of bounds: Min:{} Max:{}",testRing.lock()->RandomStats().A_Read("Mana"),ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Mana"),ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Mana")).c_str());
|
|
|
|
Assert::IsTrue(testRing2.lock()->RandomStats().A_Read("Move Spd %")>=ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Move Spd %")&&
|
|
testRing2.lock()->RandomStats().A_Read("Move Spd %")<=ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Move Spd %"),std::format(L"Generated Move Spd % {} is out of bounds: Min:{} Max:{}",testRing2.lock()->RandomStats().A_Read("Move Spd %"),ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Move Spd %"),ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Move Spd %")).c_str());
|
|
Assert::IsTrue(testRing2.lock()->RandomStats().A_Read("Crit Rate")>=ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Crit Rate")&&
|
|
testRing2.lock()->RandomStats().A_Read("Crit Rate")<=ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Crit Rate"),std::format(L"Generated Crit Rate {} is out of bounds: Min:{} Max:{}",testRing2.lock()->RandomStats().A_Read("Crit Rate"),ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Move Spd %"),ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Crit Rate")).c_str());
|
|
Assert::IsTrue(testRing2.lock()->RandomStats().A_Read("Mana")>=ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Mana")&&
|
|
testRing2.lock()->RandomStats().A_Read("Mana")<=ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Mana"),std::format(L"Generated Mana {} is out of bounds: Min:{} Max:{}",testRing2.lock()->RandomStats().A_Read("Mana"),ITEM_DATA.at("Bird's Treasure"s).GetMinStats().A_Read("Mana"),ITEM_DATA.at("Bird's Treasure"s).GetMaxStats().A_Read("Mana")).c_str());
|
|
|
|
//Ensure stats are default.
|
|
Assert::AreEqual(player->GetBaseStat("Move Spd %"),player->GetEquipStat("Move Spd %"),L"Base Move Spd %does not match initial Move Spd %");
|
|
Assert::AreEqual(player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Base Crit Rate does not match initial Crit Rate");
|
|
Assert::AreEqual(player->GetBaseStat("Mana"),player->GetEquipStat("Mana"),L"Base Mana does not match initial Mana");
|
|
|
|
Inventory::EquipItem(testRing,EquipSlot::RING1);
|
|
Assert::AreEqual(3+player->GetBaseStat("Move Spd %"),player->GetEquipStat("Move Spd %"),L"Move Spd % increased incorrectly when ring 1 equipped!");
|
|
Assert::AreEqual(2+player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Crit Rate increased incorrectly when ring 1 equipped!");
|
|
Assert::AreEqual(5+player->GetBaseStat("Mana"),player->GetEquipStat("Mana"),L"Mana increased incorrectly when ring 1 equipped!");
|
|
|
|
//Equipping to same slot should undo the previous stats and apply the new ring's stats.
|
|
Inventory::EquipItem(testRing2,EquipSlot::RING1);
|
|
Assert::AreEqual(2+player->GetBaseStat("Move Spd %"),player->GetEquipStat("Move Spd %"),L"Move Spd % increased incorrectly when ring 1 equipped!");
|
|
Assert::AreEqual(2+player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Crit Rate increased incorrectly when ring 1 equipped!");
|
|
Assert::AreEqual(2+player->GetBaseStat("Mana"),player->GetEquipStat("Mana"),L"Mana increased incorrectly when ring 1 equipped!");
|
|
|
|
Inventory::UnequipItem(EquipSlot::RING1);
|
|
//Ensure stats are default again.
|
|
Assert::AreEqual(player->GetBaseStat("Move Spd %"),player->GetEquipStat("Move Spd %"),L"Base Move Spd %does not match initial Move Spd % after unequipping the ring.");
|
|
Assert::AreEqual(player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Base Crit Rate does not match initial Crit Rate after unequipping the ring.");
|
|
Assert::AreEqual(player->GetBaseStat("Mana"),player->GetEquipStat("Mana"),L"Base Mana does not match initial Mana after unequipping the ring.");
|
|
|
|
Inventory::EquipItem(testRing,EquipSlot::RING1);
|
|
Inventory::EquipItem(testRing2,EquipSlot::RING2);
|
|
Assert::AreEqual(5+player->GetBaseStat("Move Spd %"),player->GetEquipStat("Move Spd %"),L"Move Spd % increased incorrectly when both rings equipped!");
|
|
Assert::AreEqual(4+player->GetBaseStat("Crit Rate"),player->GetEquipStat("Crit Rate"),L"Crit Rate increased incorrectly when both rings equipped!");
|
|
Assert::AreEqual(7+player->GetBaseStat("Mana"),player->GetEquipStat("Mana"),L"Mana increased incorrectly when both rings equipped!");
|
|
}
|
|
TEST_METHOD(FlatDefenseStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor"s)};
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
player->Hurt(100,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(17,player->GetHealth(),L"100 Defense prevents 17 damage, resulting in 83 damage points dealt.");
|
|
}
|
|
TEST_METHOD(HealthStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor"s)};
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(1000+player->GetBaseStat("Health"),float(player->GetMaxHealth()),L"Max Health stat should be increased from 100 to 1100.");
|
|
}
|
|
TEST_METHOD(HealthStatUpBuffCheck){
|
|
player->AddBuff(BuffType::STAT_UP,5.f,1000.f,{"Health"});
|
|
Assert::AreEqual(1000+player->GetBaseStat("Health"),float(player->GetMaxHealth()),L"Max Health stat should be increased from 100 to 1100.");
|
|
}
|
|
TEST_METHOD(HealthPctStatUpBuffCheck){
|
|
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(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);
|
|
Assert::AreEqual(100+player->GetBaseStat("Attack"),float(player->GetAttack()),L"Attack stat should be increased from 10 to 110.");
|
|
}
|
|
TEST_METHOD(DefensePctStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(player->GetBaseStat("Defense"),float(player->GetDefense()),L"100% Defense % causes a 0 increase in Defense when it's default zero.");
|
|
|
|
std::weak_ptr<Item>bonePants{Inventory::AddItem("Bone Pants"s)};
|
|
bonePants.lock()->enhancementLevel="Item.Item Max Enhancement Level"_I; //Force enhance the item to the max enhancement level.
|
|
Inventory::EquipItem(bonePants,EquipSlot::PANTS);
|
|
Assert::AreEqual(122.f+player->GetBaseStat("Defense"),float(player->GetDefense()),L"100% Defense % causes double increase in Defense. 61 -> 122");
|
|
|
|
Inventory::UnequipItem(EquipSlot::ARMOR);
|
|
player->Hurt(100,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(13,player->GetHealth(),L"Took 87 damage with 61 defense.");
|
|
player->Heal(87); //Back to 100 Health.
|
|
LOG(std::format("Player Health is now {}",player->GetHealth()));
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
player->Hurt(100,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(36,player->GetHealth(),L"Took 54 damage with 122 defense.");
|
|
}
|
|
TEST_METHOD(AttackPctStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
|
|
testMonster.Hurt(player->GetAttack(),player->OnUpperLevel(),player->GetZ());
|
|
const int damageDealt{testMonster.GetMaxHealth()-testMonster.GetHealth()};
|
|
|
|
testMonster.Heal(testMonster.GetMaxHealth());
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(player->GetBaseStat("Attack")*2,float(player->GetAttack()),L"100% Attack should double the attack of the player.");
|
|
|
|
testMonster.Hurt(player->GetAttack(),player->OnUpperLevel(),player->GetZ());
|
|
const int enhancedDamageDealt{testMonster.GetMaxHealth()-testMonster.GetHealth()};
|
|
Assert::AreEqual(enhancedDamageDealt,damageDealt*5,L"Original damage dealt should be half of the new attack. Factor in 100% crit rate and a bonus 100% crit dmg (making it 250%) 200%*2.5=500% damage.");
|
|
}
|
|
TEST_METHOD(MoveSpdPctStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
|
|
Assert::AreEqual(1.f,player->GetMoveSpdMult(),L"Move Spd is 100%");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(2.f,player->GetMoveSpdMult(),L"100% Move Spd should double the move speed from 100% to 200%");
|
|
}
|
|
TEST_METHOD(CDRStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
|
|
Assert::AreEqual(0.f,player->GetCooldownReductionPct(),L"CDR is 0%");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(1.f,player->GetCooldownReductionPct(),L"Player should have 100% CDR");
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetRightClickAbility(),testKeyboardInput);
|
|
player->CheckAndPerformAbility(player->GetAbility1(),testKeyboardInput);
|
|
player->CheckAndPerformAbility(player->GetAbility2(),testKeyboardInput);
|
|
player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput);
|
|
player->CheckAndPerformAbility(player->GetAbility4(),testKeyboardInput);
|
|
game->SetElapsedTime(0.01f); //Force elapsed time value.
|
|
game->OnUserUpdate(0.01f); //Let 0.01 seconds go by. All abilities should be off cooldown.
|
|
Assert::AreEqual(0.f,player->GetRightClickAbility().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
|
|
Assert::AreEqual(0.f,player->GetAbility1().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
|
|
Assert::AreEqual(0.f,player->GetAbility2().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
|
|
Assert::AreEqual(0.f,player->GetAbility3().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
|
|
Assert::AreEqual(0.f,player->GetAbility4().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
|
|
}
|
|
TEST_METHOD(CritRateStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
|
|
Assert::AreEqual(0.f,player->GetCritRatePct(),L"Crit Rate is 0%");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(1.f,player->GetCritRatePct(),L"Player should have 100% Crit Rate");
|
|
}
|
|
TEST_METHOD(CritDmgStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
|
|
Assert::AreEqual(0.5f,player->GetCritDmgPct(),L"Crit Damage is 50%");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(1.5f,player->GetCritDmgPct(),L"Player should have 150% Crit Damage");
|
|
}
|
|
TEST_METHOD(HealthPctStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
|
|
Assert::AreEqual(100,player->GetHealth(),L"Current Health is 100");
|
|
Assert::AreEqual(100,player->GetMaxHealth(),L"Max Health is 100");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100,player->GetHealth(),L"Current Health is still 100");
|
|
Assert::AreEqual(200,player->GetMaxHealth(),L"Max Health is now 200");
|
|
}
|
|
TEST_METHOD(HP6RecoveryStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
|
|
Assert::AreEqual(0.0_Pct,player->GetHP6RecoveryPct(),L"HP6 Recovery % is 0");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetHP6RecoveryPct(),L"HP6 Recovery % is 100%");
|
|
}
|
|
TEST_METHOD(HP4RecoveryStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor3"s)};
|
|
|
|
Assert::AreEqual(0.0_Pct,player->GetHP4RecoveryPct(),L"HP4 Recovery % is 0");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetHP4RecoveryPct(),L"HP4 Recovery % is 100%");
|
|
}
|
|
TEST_METHOD(DamageReductionStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor3"s)};
|
|
Assert::AreEqual(0.0_Pct,player->GetDamageReductionPct(),L"Damage Reduction is 0%");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetDamageReductionPct(),L"Damage Reduction is 100%");
|
|
}
|
|
TEST_METHOD(HPRecoveryStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor4"s)};
|
|
|
|
Assert::AreEqual(0.0_Pct,player->GetHPRecoveryPct(),L"HP Recovery % is 0");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetHPRecoveryPct(),L"HP Recovery % is 100%");
|
|
}
|
|
TEST_METHOD(AttackSpeedStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor4"s)};
|
|
|
|
Assert::AreEqual(0.f,player->GetAttackRecoveryRateReduction(),L"Attack Speed Reduction is 0 seconds");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(50.f,player->GetAttackRecoveryRateReduction(),L"Attack Speed Reduction is 50 seconds");
|
|
}
|
|
TEST_METHOD(ManaStatEquipCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor4"s)};
|
|
|
|
Assert::AreEqual(100,player->GetMana(),L"Mana is 100");
|
|
Assert::AreEqual(100,player->GetMaxMana(),L"Max Mana is 100");
|
|
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100,player->GetMana(),L"Mana is still 100");
|
|
Assert::AreEqual(200,player->GetMaxMana(),L"Max Mana is now 200");
|
|
}
|
|
TEST_METHOD(HP6RecoveryTest){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
|
|
game->SetElapsedTime(0.1f);
|
|
game->OnUserUpdate(0.1f); //Advance the game by 0.1s so that all healing ticks occur at least once.
|
|
//Hurt the player for most of their health.
|
|
player->Hurt(player->GetMaxHealth()-1,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(1,player->GetHealth(),L"Player is at 1 Health.");
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetHP6RecoveryPct(),L"HP6 Recovery % is 100%");
|
|
|
|
game->SetElapsedTime(3.f);
|
|
game->OnUserUpdate(3.f); //Wait 3 seconds. The player shouldn't be healed yet.
|
|
Assert::AreEqual(1,player->GetHealth(),L"After waiting for 3 seconds, the player should still be at 1 health.");
|
|
game->SetElapsedTime(3.f);
|
|
game->OnUserUpdate(3.f); //Wait 3 more seconds. The player should be healed now.
|
|
Assert::AreEqual(player->GetMaxHealth(),player->GetHealth(),L"After waiting for 6 seconds, the player should be at full health.");
|
|
}
|
|
TEST_METHOD(HP4RecoveryTest){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor3"s)};
|
|
game->SetElapsedTime(0.1f);
|
|
game->OnUserUpdate(0.1f); //Advance the game by 0.1s so that all healing ticks occur at least once.
|
|
//Hurt the player for most of their health.
|
|
player->Hurt(player->GetMaxHealth()-1,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(1,player->GetHealth(),L"Player is at 1 Health.");
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetHP4RecoveryPct(),L"HP4 Recovery % is 100%");
|
|
|
|
game->SetElapsedTime(2.f);
|
|
game->OnUserUpdate(2.f); //Wait 2 seconds. The player shouldn't be healed yet.
|
|
Assert::AreEqual(1,player->GetHealth(),L"After waiting for 2 seconds, the player should still be at 1 health.");
|
|
game->SetElapsedTime(2.f);
|
|
game->OnUserUpdate(2.f); //Wait 2 more seconds. The player should be healed now.
|
|
Assert::AreEqual(player->GetMaxHealth(),player->GetHealth(),L"After waiting for 4 seconds, the player should be at full health.");
|
|
}
|
|
TEST_METHOD(HPRecoveryTest){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor4"s)};
|
|
game->SetElapsedTime(0.1f);
|
|
game->OnUserUpdate(0.1f); //Advance the game by 0.1s so that all healing ticks occur at least once.
|
|
//Hurt the player for most of their health.
|
|
player->Hurt(player->GetMaxHealth()-1,player->OnUpperLevel(),player->GetZ());
|
|
Assert::AreEqual(1,player->GetHealth(),L"Player is at 1 Health.");
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
|
|
Assert::AreEqual(100.0_Pct,player->GetHPRecoveryPct(),L"HP Recovery % is 100%");
|
|
|
|
game->SetElapsedTime(0.5f);
|
|
game->OnUserUpdate(0.5f); //Wait 0.5 seconds. The player shouldn't be healed yet.
|
|
Assert::AreEqual(1,player->GetHealth(),L"After waiting for 0.5 seconds, the player should still be at 1 health.");
|
|
game->SetElapsedTime(0.5f);
|
|
game->OnUserUpdate(0.5f); //Wait 0.5 more seconds. The player should be healed now.
|
|
Assert::AreEqual(player->GetMaxHealth(),player->GetHealth(),L"After waiting for 1 second, the player should be at full health.");
|
|
}
|
|
TEST_METHOD(AdrenalineRushSkillBuffTest){
|
|
testGame->ChangePlayerClass(THIEF);
|
|
player=testGame->GetPlayer(); //The player pointer has been reassigned...
|
|
Assert::AreEqual(1.f,player->GetMoveSpdMult(),L"Move Speed Multiplier is set to x1.0 by default.");
|
|
Assert::AreEqual(0.f,player->GetAttackRecoveryRateReduction(),L"Attack rate cooldown starts with being reduced by 0 seconds.");
|
|
testKey->bHeld=true; //Force the key to be held down for testing purposes.
|
|
player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput);
|
|
Assert::IsTrue(player->GetBuffs(BuffType::ADRENALINE_RUSH).size()>0,L"After using Adrenaline Rush, player has the Adrenaline Rush buff.");
|
|
Assert::AreEqual(1.1f,player->GetMoveSpdMult(),L"Move Speed Multiplier increased by 10% to x1.1");
|
|
Assert::AreEqual(0.105f,player->GetAttackRecoveryRateReduction(),L"Attack Recovery Rate reduced by 30%, or 0.105s");
|
|
}
|
|
TEST_METHOD(TrueDamageCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor3"s)};
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR); //Equip an item with 100% damage reduction.
|
|
player->Hurt(20,player->OnUpperLevel(),player->GetZ(),TrueDamageFlag::IGNORE_DAMAGE_RULES);
|
|
Assert::AreEqual(80,player->GetHealth(),L"Player should take 20 damage through true damage.");
|
|
player->ApplyIframes(0.5f);
|
|
player->Hurt(20,player->OnUpperLevel(),player->GetZ(),TrueDamageFlag::IGNORE_DAMAGE_RULES);
|
|
Assert::AreEqual(60,player->GetHealth(),L"Player should take 20 damage through true damage even when iframes are on.");
|
|
}
|
|
TEST_METHOD(DOTDamageCheck){
|
|
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor3"s)};
|
|
Inventory::EquipItem(setArmor,EquipSlot::ARMOR); //Equip an item with 100% damage reduction.
|
|
player->Hurt(20,player->OnUpperLevel(),player->GetZ(),HurtFlag::DOT);
|
|
Assert::AreEqual(80,player->GetHealth(),L"Player should take 20 damage through a DOT.");
|
|
Assert::AreEqual(1,std::accumulate(DAMAGENUMBER_LIST.begin(),DAMAGENUMBER_LIST.end(),0,[](int count,const std::shared_ptr<DamageNumber>&damageNumber){
|
|
if(damageNumber->type==DamageNumberType::DOT)return count+1;
|
|
else return count;
|
|
})
|
|
,L"There should be a damage number of type DOT.");
|
|
player->Update(1.0f);//Let some time pass so two DOT numbers don't stack up.
|
|
player->ApplyIframes(0.5f);
|
|
player->Hurt(20,player->OnUpperLevel(),player->GetZ(),HurtFlag::DOT);
|
|
Assert::AreEqual(80,player->GetHealth(),L"Player should take 20 damage through a DOT even when iframes are on."); //HP Recovery/4s set effect has restored the health of the player to 100. So it should go back down to 80.
|
|
Assert::AreEqual(2,std::accumulate(DAMAGENUMBER_LIST.begin(),DAMAGENUMBER_LIST.end(),0,[](int count,const std::shared_ptr<DamageNumber>&damageNumber){
|
|
if(damageNumber->type==DamageNumberType::DOT)return count+1;
|
|
else return count;
|
|
})
|
|
,L"There should be 2 damage numbers of type DOT.");
|
|
}
|
|
};
|
|
}
|
|
|