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.
460 lines
20 KiB
460 lines
20 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 "config.h"
|
|
#include "ItemDrop.h"
|
|
#include "Tutorial.h"
|
|
#include "DamageNumber.h"
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
using namespace olc::utils;
|
|
|
|
INCLUDE_MONSTER_DATA
|
|
INCLUDE_game
|
|
INCLUDE_GFX
|
|
INCLUDE_DAMAGENUMBER_LIST
|
|
INCLUDE_MONSTER_LIST
|
|
INCLUDE_INITIALIZEGAMECONFIGURATIONS
|
|
|
|
TEST_MODULE_INITIALIZE(AiLTestSuite)
|
|
{
|
|
debugLogger.open("debug.log");
|
|
}
|
|
|
|
namespace MonsterTests
|
|
{
|
|
TEST_CLASS(MonsterTest)
|
|
{
|
|
public:
|
|
std::unique_ptr<AiL>testGame;
|
|
#pragma region Setup Functions
|
|
//Makes MONSTER_DATA["TestName"] available.
|
|
void SetupTestMonster(){
|
|
InitializeGameConfigurations();
|
|
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
|
|
game->MAP_DATA["CAMPAIGN_1_1"];
|
|
game->_SetCurrentLevel("CAMPAIGN_1_1");
|
|
ItemDrop::ClearDrops();
|
|
#pragma endregion
|
|
|
|
MonsterData testMonsterData{"TestName","Test Monster",30,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f};
|
|
MONSTER_DATA["TestName"]=testMonsterData;
|
|
|
|
Menu::themes.SetInitialized();
|
|
GFX.SetInitialized();
|
|
DAMAGENUMBER_LIST.clear();
|
|
}
|
|
void SetupMockMap(){
|
|
game->MAP_DATA["CAMPAIGN_1_1"];
|
|
ItemDrop::ClearDrops();
|
|
}
|
|
#pragma endregion
|
|
|
|
TEST_METHOD_INITIALIZE(MonsterInitialize){
|
|
SetupTestMonster();
|
|
SetupMockMap();
|
|
}
|
|
~MonsterTest(){
|
|
testGame.release();
|
|
}
|
|
TEST_METHOD(DisplayNameCheck){
|
|
Assert::AreEqual("Test Monster",MONSTER_DATA["TestName"].GetDisplayName().c_str());
|
|
}
|
|
TEST_METHOD(InternalNameCheck){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
Assert::AreEqual("TestName",testMonster.GetName().c_str());
|
|
}
|
|
TEST_METHOD(HealthCheck){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
Assert::AreEqual(testMonster.GetHealth(),testMonster.GetMaxHealth());
|
|
Assert::AreEqual(testMonster.GetHealth(),30);
|
|
}
|
|
TEST_METHOD(Deal5Damage)
|
|
{
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.Hurt(5,testMonster.OnUpperLevel(),testMonster.GetZ());
|
|
Assert::AreEqual(testMonster.GetHealth(),testMonster.GetMaxHealth()-5);
|
|
}
|
|
TEST_METHOD(IFrameShouldResultInNoDamage){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.ApplyIframes(0.5f);
|
|
testMonster.Hurt(5,testMonster.OnUpperLevel(),testMonster.GetZ());
|
|
Assert::AreEqual(testMonster.GetHealth(),testMonster.GetMaxHealth());
|
|
}
|
|
TEST_METHOD(BeingInTheAirShouldAvoidAttacksFromTheGround){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.SetZ(2.f);
|
|
testMonster.Hurt(5,testMonster.OnUpperLevel(),0.f);
|
|
Assert::AreEqual(testMonster.GetHealth(),testMonster.GetMaxHealth());
|
|
}
|
|
TEST_METHOD(MonstersDeal10Damage_NoDamageReduction)
|
|
{
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
Monster testMonster2{{},MONSTER_DATA["TestName"]};
|
|
game->GetPlayer()->Hurt(testMonster.GetAttack(),testMonster.OnUpperLevel(),testMonster.GetZ());
|
|
testMonster2.Hurt(testMonster.GetAttack(),testMonster.OnUpperLevel(),testMonster.GetZ());
|
|
Assert::AreEqual(game->GetPlayer()->GetMaxHealth()-10,game->GetPlayer()->GetHealth());
|
|
Assert::AreEqual(testMonster2.GetMaxHealth()-10,testMonster2.GetHealth());
|
|
}
|
|
TEST_METHOD(DoubleAttackPctModifierWorks){
|
|
Monster buffMonster{{},MONSTER_DATA["TestName"]};
|
|
buffMonster.AddBuff(BuffType::STAT_UP,5,100._Pct,{ItemAttribute::Get("Attack %")});
|
|
|
|
Monster testMonster2{{},MONSTER_DATA["TestName"]};
|
|
game->GetPlayer()->Hurt(buffMonster.GetAttack(),buffMonster.OnUpperLevel(),buffMonster.GetZ());
|
|
testMonster2.Hurt(buffMonster.GetAttack(),buffMonster.OnUpperLevel(),buffMonster.GetZ());
|
|
Assert::AreEqual(game->GetPlayer()->GetMaxHealth()-20,game->GetPlayer()->GetHealth());
|
|
Assert::AreEqual(testMonster2.GetMaxHealth()-20,testMonster2.GetHealth());
|
|
}
|
|
TEST_METHOD(AttackUpModifierWorks){
|
|
Monster buffMonster{{},MONSTER_DATA["TestName"]};
|
|
buffMonster.AddBuff(BuffType::STAT_UP,5,5.f,{"Attack"});
|
|
|
|
Monster testMonster2{{},MONSTER_DATA["TestName"]};
|
|
game->GetPlayer()->Hurt(buffMonster.GetAttack(),buffMonster.OnUpperLevel(),buffMonster.GetZ());
|
|
testMonster2.Hurt(buffMonster.GetAttack(),buffMonster.OnUpperLevel(),buffMonster.GetZ());
|
|
Assert::AreEqual(game->GetPlayer()->GetMaxHealth()-15,game->GetPlayer()->GetHealth(),L"Player Health is now 85.");
|
|
Assert::AreEqual(testMonster2.GetMaxHealth()-15,testMonster2.GetHealth(),L"Monster Health is now 15.");
|
|
}
|
|
TEST_METHOD(HealthUpModifierWorks){
|
|
Monster buffMonster{{},MONSTER_DATA["TestName"]};
|
|
buffMonster.AddBuff(BuffType::STAT_UP,5,5.f,{"Health"});
|
|
|
|
Assert::AreEqual(35,buffMonster.GetMaxHealth(),L"Monster Max Health is now 35.");
|
|
Assert::AreEqual(30,buffMonster.GetHealth(),L"Monster Current Health is still 30.");
|
|
}
|
|
TEST_METHOD(AttackUpPctModifierWorks){
|
|
Monster buffMonster{{},MONSTER_DATA["TestName"]};
|
|
buffMonster.AddBuff(BuffType::STAT_UP,5,100.0_Pct,{"Attack %"});
|
|
|
|
Monster testMonster2{{},MONSTER_DATA["TestName"]};
|
|
game->GetPlayer()->Hurt(buffMonster.GetAttack(),buffMonster.OnUpperLevel(),buffMonster.GetZ());
|
|
testMonster2.Hurt(buffMonster.GetAttack(),buffMonster.OnUpperLevel(),buffMonster.GetZ());
|
|
Assert::AreEqual(game->GetPlayer()->GetMaxHealth()-20,game->GetPlayer()->GetHealth(),L"Player Health is now 80.");
|
|
Assert::AreEqual(testMonster2.GetMaxHealth()-20,testMonster2.GetHealth(),L"Monster Health is now 10.");
|
|
}
|
|
TEST_METHOD(MonsterIsConsideredDeadAt0Health){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.Hurt(testMonster.GetMaxHealth(),testMonster.OnUpperLevel(),testMonster.GetZ());
|
|
Assert::AreEqual(true,testMonster.IsDead());
|
|
}
|
|
TEST_METHOD(ItemDropSpawnsWhenMonsterIsKilled){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.Hurt(testMonster.GetMaxHealth(),testMonster.OnUpperLevel(),testMonster.GetZ());
|
|
Assert::AreEqual(size_t(1),ItemDrop::GetDrops().size());
|
|
}
|
|
TEST_METHOD(MoveSpdSetCorrectly){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
Assert::AreEqual(2.f,testMonster.GetMoveSpdMult());
|
|
}
|
|
TEST_METHOD(SlowdownBuffTest){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.AddBuff(BuffType::SLOWDOWN,5.f,0.5f);
|
|
Assert::AreEqual(1.f,testMonster.GetMoveSpdMult());
|
|
}
|
|
TEST_METHOD(SelfInflictedSlowdownTest){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.AddBuff(BuffType::SELF_INFLICTED_SLOWDOWN,5.f,0.5f);
|
|
Assert::AreEqual(1.f,testMonster.GetMoveSpdMult());
|
|
}
|
|
TEST_METHOD(SpeedBoostTest){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.AddBuff(BuffType::SPEEDBOOST,5.f,0.5f);
|
|
Assert::AreEqual(3.f,testMonster.GetMoveSpdMult());
|
|
}
|
|
TEST_METHOD(LockOnSpeedBoostTest){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.AddBuff(BuffType::LOCKON_SPEEDBOOST,5.f,0.5f);
|
|
Assert::AreEqual(3.f,testMonster.GetMoveSpdMult());
|
|
}
|
|
TEST_METHOD(AdditiveMoveSpdBuffsTest){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.AddBuff(BuffType::SLOWDOWN,5.f,0.5f);
|
|
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());
|
|
}
|
|
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){}
|
|
}
|
|
TEST_METHOD(DOTTest){
|
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
|
testMonster.AddBuff(BuffType::DAMAGE_REDUCTION,10.f,100._Pct);
|
|
testMonster.Hurt(10,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::DOT);
|
|
Assert::AreEqual(20,testMonster.GetHealth(),L"A DOT should go through all sources of damage reduction.");
|
|
testMonster.Update(1.f); //Let time pass so two DOT numbers don't stack up.
|
|
testMonster.ApplyIframes(0.5f);
|
|
testMonster.Hurt(10,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::DOT);
|
|
Assert::AreEqual(10,testMonster.GetHealth(),L"A DOT should go through all sources of iframes.");
|
|
Assert::AreEqual(2,std::accumulate(DAMAGENUMBER_LIST.begin(),DAMAGENUMBER_LIST.end(),0,[](int count,const std::shared_ptr<DamageNumber>&damageNumber){
|
|
if(damageNumber->GetType()==DamageNumberType::DOT)return count+1;
|
|
else return count;
|
|
})
|
|
,L"There should be 2 damage numbers of type DOT.");
|
|
}
|
|
TEST_METHOD(TrapperMarkTest){
|
|
MonsterData testMonsterData{"TestName","Test Monster",30,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f};
|
|
game->SpawnMonster({},testMonsterData);
|
|
game->SetElapsedTime(0.1f);
|
|
game->OnUserUpdate(0.1f); //A monster that is spawned needs to be added to the monster list in the next tick.
|
|
std::weak_ptr<Monster>testMonster{MONSTER_LIST.front()};
|
|
|
|
Assert::AreEqual(uint8_t(0),testMonster.lock()->GetMarkStacks(),L"Monster has 0 marks initially.");
|
|
|
|
testMonster.lock()->ApplyMark(7.f,5U);
|
|
|
|
game->SetElapsedTime(0.3f);
|
|
game->OnUserUpdate(0.3f); //A monster that had a mark applied needs to be added as a lock on target in the next tick.
|
|
|
|
Assert::AreEqual(uint8_t(5),testMonster.lock()->GetMarkStacks(),L"Monster has 5 marks after receiving a buff.");
|
|
|
|
testMonster.lock()->Hurt(1,testMonster.lock()->OnUpperLevel(),testMonster.lock()->GetZ());
|
|
|
|
Assert::AreEqual(uint8_t(5),testMonster.lock()->GetMarkStacks(),L"Monster should still have 5 marks after taking damage from a normal attack.");
|
|
|
|
testMonster.lock()->Hurt(1,testMonster.lock()->OnUpperLevel(),testMonster.lock()->GetZ(),HurtFlag::PLAYER_ABILITY);
|
|
|
|
Assert::AreEqual(uint8_t(4),testMonster.lock()->GetMarkStacks(),L"Monster should have 4 marks remaining.");
|
|
Assert::AreEqual(22,testMonster.lock()->GetHealth(),L"Mark deals 60% of the player's attack. And 2 damage already taken from earlier.");
|
|
|
|
testMonster.lock()->Hurt(1,testMonster.lock()->OnUpperLevel(),testMonster.lock()->GetZ(),HurtFlag::DOT);
|
|
|
|
Assert::AreEqual(uint8_t(4),testMonster.lock()->GetMarkStacks(),L"Monster should still have 4 marks remaining (DOTs don't remove a mark).");
|
|
|
|
testMonster.lock()->_DealTrueDamage(1);
|
|
|
|
Assert::AreEqual(uint8_t(4),testMonster.lock()->GetMarkStacks(),L"Monster should still have 4 marks remaining after taking true damage from something not marked as a player ability.");
|
|
|
|
testMonster.lock()->Heal(testMonster.lock()->GetMaxHealth()); //Heal the monster so it doesn't die.
|
|
|
|
testMonster.lock()->_DealTrueDamage(1,HurtFlag::PLAYER_ABILITY);
|
|
|
|
Assert::AreEqual(uint8_t(3),testMonster.lock()->GetMarkStacks(),L"Monster should have 3 marks remaining after taking true damage.");
|
|
|
|
testMonster.lock()->_DealTrueDamage(10,HurtFlag::DOT|HurtFlag::PLAYER_ABILITY);
|
|
|
|
Assert::AreEqual(uint8_t(2),testMonster.lock()->GetMarkStacks(),L"Monster should have 2 marks remaining after taking true damage, even though it's classified as a DOT. This is an edge case, but it's really meaningless here...");
|
|
|
|
testMonster.lock()->Heal(testMonster.lock()->GetMaxHealth());
|
|
|
|
testMonster.lock()->TriggerMark();
|
|
|
|
Assert::AreEqual(uint8_t(1),testMonster.lock()->GetMarkStacks(),L"Monster should have 1 mark remaining after using TriggerMark function");
|
|
Assert::AreEqual(24,testMonster.lock()->GetHealth(),L"Monster should not take damage from the TriggerMark function (Mark deals 6 damage though).");
|
|
|
|
game->SetElapsedTime(10.f);
|
|
testMonster.lock()->Update(10.f);
|
|
|
|
Assert::AreEqual(uint8_t(0),testMonster.lock()->GetMarkStacks(),L"The marks should have expired after 10 seconds.");
|
|
}
|
|
};
|
|
} |