Fix unit tests, item script tests weren't properly updated. Mark Tests were properly killing targets, removing their marks. 105/105 Tests passing. Release Build 10302.
This commit is contained in:
parent
8025680617
commit
0cb52d1c0f
@ -145,21 +145,25 @@ namespace ItemTests
|
|||||||
}
|
}
|
||||||
TEST_METHOD(FlatRestoreScriptTest){
|
TEST_METHOD(FlatRestoreScriptTest){
|
||||||
player->Hurt(75,player->OnUpperLevel(),player->GetZ());
|
player->Hurt(75,player->OnUpperLevel(),player->GetZ());
|
||||||
player->mana=25;
|
player->mana=24;
|
||||||
Inventory::AddItem("Flat Recovery Potion"s,5U);
|
Inventory::AddItem("Flat Recovery Potion"s,5U);
|
||||||
game->SetLoadoutItem(0,"Flat Recovery Potion");
|
game->SetLoadoutItem(0,"Flat Recovery Potion");
|
||||||
testKey->bHeld=true; //Simulate key being pressed.
|
testKey->bHeld=true; //Simulate key being pressed.
|
||||||
player->CheckAndPerformAbility(player->useItem1,testKeyboardInput);
|
player->CheckAndPerformAbility(player->useItem1,testKeyboardInput);
|
||||||
|
game->SetElapsedTime(0.05f);
|
||||||
|
game->OnUserUpdate(0.05f);//Wait some time as the item applies a buff that heals us. We're also going to gain one mana during this tick.
|
||||||
Assert::AreEqual(75,player->GetHealth(),L"Player Health is 75 after using Flat Recovery Potion.");
|
Assert::AreEqual(75,player->GetHealth(),L"Player Health is 75 after using Flat Recovery Potion.");
|
||||||
Assert::AreEqual(75,player->GetMana(),L"Player Mana is 75 after using Flat Recovery Potion.");
|
Assert::AreEqual(75,player->GetMana(),L"Player Mana is 75 after using Flat Recovery Potion.");
|
||||||
}
|
}
|
||||||
TEST_METHOD(PctRestoreScriptTest){
|
TEST_METHOD(PctRestoreScriptTest){
|
||||||
player->Hurt(75,player->OnUpperLevel(),player->GetZ());
|
player->Hurt(75,player->OnUpperLevel(),player->GetZ());
|
||||||
player->mana=25;
|
player->mana=24;
|
||||||
Inventory::AddItem("Pct Recovery Potion"s,5U);
|
Inventory::AddItem("Pct Recovery Potion"s,5U);
|
||||||
game->SetLoadoutItem(1,"Pct Recovery Potion");
|
game->SetLoadoutItem(1,"Pct Recovery Potion");
|
||||||
testKey->bHeld=true; //Simulate key being pressed.
|
testKey->bHeld=true; //Simulate key being pressed.
|
||||||
player->CheckAndPerformAbility(player->useItem2,testKeyboardInput);
|
player->CheckAndPerformAbility(player->useItem2,testKeyboardInput);
|
||||||
|
game->SetElapsedTime(0.05f);
|
||||||
|
game->OnUserUpdate(0.05f);//Wait some time as the item applies a buff that heals us.
|
||||||
Assert::AreEqual(75,player->GetHealth(),L"Player Health is 75 after using Pct Recovery Potion.");
|
Assert::AreEqual(75,player->GetHealth(),L"Player Health is 75 after using Pct Recovery Potion.");
|
||||||
Assert::AreEqual(75,player->GetMana(),L"Player Mana is 75 after using Pct Recovery Potion.");
|
Assert::AreEqual(75,player->GetMana(),L"Player Mana is 75 after using Pct Recovery Potion.");
|
||||||
}
|
}
|
||||||
@ -169,6 +173,8 @@ namespace ItemTests
|
|||||||
game->SetLoadoutItem(2,"Bandages");
|
game->SetLoadoutItem(2,"Bandages");
|
||||||
testKey->bHeld=true; //Simulate key being pressed.
|
testKey->bHeld=true; //Simulate key being pressed.
|
||||||
player->CheckAndPerformAbility(player->useItem3,testKeyboardInput);
|
player->CheckAndPerformAbility(player->useItem3,testKeyboardInput);
|
||||||
|
game->SetElapsedTime(0.05f);
|
||||||
|
game->OnUserUpdate(0.05f);//Wait some time as the item applies a buff that heals us.
|
||||||
Assert::AreEqual(30,player->GetHealth(),L"Player is immediately healed for 5 health points on Bandages use.");
|
Assert::AreEqual(30,player->GetHealth(),L"Player is immediately healed for 5 health points on Bandages use.");
|
||||||
game->SetElapsedTime(1.f);
|
game->SetElapsedTime(1.f);
|
||||||
game->OnUserUpdate(1.f);
|
game->OnUserUpdate(1.f);
|
||||||
|
@ -401,48 +401,50 @@ namespace MonsterTests
|
|||||||
TEST_METHOD(TrapperMarkTest){
|
TEST_METHOD(TrapperMarkTest){
|
||||||
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
Monster testMonster{{},MONSTER_DATA["TestName"]};
|
||||||
|
|
||||||
Assert::AreEqual(0,testMonster.GetMarkStacks(),L"Monster has 0 marks initially.");
|
Assert::AreEqual(uint8_t(0),testMonster.GetMarkStacks(),L"Monster has 0 marks initially.");
|
||||||
|
|
||||||
testMonster.ApplyMark(7.f,5U);
|
testMonster.ApplyMark(7.f,5U);
|
||||||
|
|
||||||
Assert::AreEqual(5,testMonster.GetMarkStacks(),L"Monster has 5 marks after receiving a buff.");
|
Assert::AreEqual(uint8_t(5),testMonster.GetMarkStacks(),L"Monster has 5 marks after receiving a buff.");
|
||||||
|
|
||||||
testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ());
|
testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ());
|
||||||
|
|
||||||
Assert::AreEqual(5,testMonster.GetMarkStacks(),L"Monster should still have 5 marks after taking damage from a normal attack.");
|
Assert::AreEqual(uint8_t(5),testMonster.GetMarkStacks(),L"Monster should still have 5 marks after taking damage from a normal attack.");
|
||||||
|
|
||||||
testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::PLAYER_ABILITY);
|
testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::PLAYER_ABILITY);
|
||||||
|
|
||||||
Assert::AreEqual(4,testMonster.GetMarkStacks(),L"Monster should have 4 marks remaining.");
|
Assert::AreEqual(uint8_t(4),testMonster.GetMarkStacks(),L"Monster should have 4 marks remaining.");
|
||||||
Assert::AreEqual(22,testMonster.GetHealth(),L"Mark deals 60% of the player's attack. And 2 damage already taken from earlier.");
|
Assert::AreEqual(22,testMonster.GetHealth(),L"Mark deals 60% of the player's attack. And 2 damage already taken from earlier.");
|
||||||
|
|
||||||
testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::DOT);
|
testMonster.Hurt(1,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::DOT);
|
||||||
|
|
||||||
Assert::AreEqual(4,testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining (DOTs don't remove a mark).");
|
Assert::AreEqual(uint8_t(4),testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining (DOTs don't remove a mark).");
|
||||||
|
|
||||||
testMonster._DealTrueDamage(10);
|
testMonster._DealTrueDamage(1);
|
||||||
|
|
||||||
Assert::AreEqual(4,testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining after taking true damage from something not marked as a player ability.");
|
Assert::AreEqual(uint8_t(4),testMonster.GetMarkStacks(),L"Monster should still have 4 marks remaining after taking true damage from something not marked as a player ability.");
|
||||||
|
|
||||||
testMonster._DealTrueDamage(10,HurtFlag::PLAYER_ABILITY);
|
testMonster.Heal(testMonster.GetMaxHealth()); //Heal the monster so it doesn't die.
|
||||||
|
|
||||||
Assert::AreEqual(3,testMonster.GetMarkStacks(),L"Monster should have 3 marks remaining after taking true damage.");
|
testMonster._DealTrueDamage(1,HurtFlag::PLAYER_ABILITY);
|
||||||
|
|
||||||
|
Assert::AreEqual(uint8_t(3),testMonster.GetMarkStacks(),L"Monster should have 3 marks remaining after taking true damage.");
|
||||||
|
|
||||||
testMonster._DealTrueDamage(10,HurtFlag::DOT|HurtFlag::PLAYER_ABILITY);
|
testMonster._DealTrueDamage(10,HurtFlag::DOT|HurtFlag::PLAYER_ABILITY);
|
||||||
|
|
||||||
Assert::AreEqual(2,testMonster.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...");
|
Assert::AreEqual(uint8_t(2),testMonster.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.Heal(testMonster.GetMaxHealth());
|
testMonster.Heal(testMonster.GetMaxHealth());
|
||||||
|
|
||||||
testMonster.TriggerMark();
|
testMonster.TriggerMark();
|
||||||
|
|
||||||
Assert::AreEqual(1,testMonster.GetMarkStacks(),L"Monster should have 1 mark remaining after using TriggerMark function");
|
Assert::AreEqual(uint8_t(1),testMonster.GetMarkStacks(),L"Monster should have 1 mark remaining after using TriggerMark function");
|
||||||
Assert::AreEqual(24,testMonster.GetHealth(),L"Monster should not take damage from the TriggerMark function (Mark deals 6 damage though).");
|
Assert::AreEqual(24,testMonster.GetHealth(),L"Monster should not take damage from the TriggerMark function (Mark deals 6 damage though).");
|
||||||
|
|
||||||
game->SetElapsedTime(10.f);
|
game->SetElapsedTime(10.f);
|
||||||
testMonster.Update(10.f);
|
testMonster.Update(10.f);
|
||||||
|
|
||||||
Assert::AreEqual(0,testMonster.GetMarkStacks(),L"The marks should have expired after 10 seconds.");
|
Assert::AreEqual(uint8_t(0),testMonster.GetMarkStacks(),L"The marks should have expired after 10 seconds.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -52,7 +52,19 @@ Buff::Buff(std::variant<Player*,Monster*>attachedTarget,BuffType type,float dura
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Buff::Buff(std::variant<Player*,Monster*>attachedTarget,BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks)
|
Buff::Buff(std::variant<Player*,Monster*>attachedTarget,BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks)
|
||||||
:attachedTarget(attachedTarget),type(type==BuffRestorationType::OVER_TIME||type==BuffRestorationType::ONE_OFF?OVER_TIME:OVER_TIME_DURING_CAST),duration(duration),intensity(intensity),nextTick(duration-timeBetweenTicks),timeBetweenTicks(timeBetweenTicks),overTimeType(overTimeType){}
|
:attachedTarget(attachedTarget),duration(duration),intensity(intensity),nextTick(duration-timeBetweenTicks),timeBetweenTicks(timeBetweenTicks),overTimeType(overTimeType){
|
||||||
|
switch(type){
|
||||||
|
case BuffRestorationType::ONE_OFF:{
|
||||||
|
this->type=ONE_OFF;
|
||||||
|
}break;
|
||||||
|
case BuffRestorationType::OVER_TIME:{
|
||||||
|
this->type=OVER_TIME;
|
||||||
|
}break;
|
||||||
|
case BuffRestorationType::OVER_TIME_DURING_CAST:{
|
||||||
|
this->type=OVER_TIME_DURING_CAST;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Buff::Update(AiL*game,float fElapsedTime){
|
void Buff::Update(AiL*game,float fElapsedTime){
|
||||||
duration-=fElapsedTime;
|
duration-=fElapsedTime;
|
||||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 3
|
#define VERSION_PATCH 3
|
||||||
#define VERSION_BUILD 10300
|
#define VERSION_BUILD 10302
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user