Added tests for equipment stats, equipment set effects, and accessory random stat checks.

mac-build
sigonasr2 7 months ago
parent 6410d837c7
commit 02523d5ebb
  1. 125
      Adventures in Lestoria Tests/PlayerTests.cpp
  2. 3
      Adventures in Lestoria/Item.cpp
  3. 2
      Adventures in Lestoria/Version.h

@ -39,11 +39,13 @@ All rights reserved.
#include "AdventuresInLestoria.h"
#include "Tutorial.h"
#include <random>
#include <format>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace olc::utils;
INCLUDE_GFX
INCLUDE_ITEM_DATA
extern std::mt19937 rng;
@ -154,9 +156,9 @@ namespace PlayerTests
//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"));
Assert::AreEqual(14.f,testArmor.lock()->GetStats().A_Read("Health"));
Assert::AreEqual(7.f,testArmor.lock()->GetStats().A_Read("Attack"));
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!)
@ -167,43 +169,122 @@ namespace PlayerTests
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->GetStat("Defense"));
Assert::AreEqual(100.f+player->GetBaseStat("Attack"),player->GetStat("Attack"));
Assert::AreEqual(1000.f+player->GetBaseStat("Health"),player->GetStat("Health"));
Assert::AreEqual(100.f+player->GetBaseStat("Defense"),player->GetStat("Defense"),L"Defense stat was not increased by 100.");
Assert::AreEqual(100.f+player->GetBaseStat("Attack"),player->GetStat("Attack"),L"Attack stat was not increased by 100.");
Assert::AreEqual(1000.f+player->GetBaseStat("Health"),player->GetStat("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, 1000 health, and 100 attack.
Assert::AreEqual(100.f+player->GetBaseStat("Defense %"),player->GetStat("Defense %"));
Assert::AreEqual(100.f+player->GetBaseStat("Attack %"),player->GetStat("Attack %"));
Assert::AreEqual(100.f+player->GetBaseStat("Move Spd %"),player->GetStat("Move Spd %"));
Assert::AreEqual(100.f+player->GetBaseStat("CDR"),player->GetStat("CDR"));
Assert::AreEqual(100.f+player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"));
Assert::AreEqual(100.f+player->GetBaseStat("Crit Dmg"),player->GetStat("Crit Dmg"));
Assert::AreEqual(100.f+player->GetBaseStat("Health %"),player->GetStat("Health %"));
Assert::AreEqual(100.f+player->GetBaseStat("HP6 Recovery %"),player->GetStat("HP6 Recovery %"));
//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->GetStat("Defense %"),L"Defense % stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("Attack %"),player->GetStat("Attack %"),L"Attack % stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("Move Spd %"),player->GetStat("Move Spd %"),L"Move Spd % stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("CDR"),player->GetStat("CDR"),L"CDR stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"),L"Crit Rate % stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("Crit Dmg"),player->GetStat("Crit Dmg"),L"Critical Damage stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("Health %"),player->GetStat("Health %"),L"Health Points was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("HP6 Recovery %"),player->GetStat("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 defense, 1000 health, and 100 attack.
Assert::AreEqual(100.f+player->GetBaseStat("HP4 Recovery %"),player->GetStat("HP4 Recovery %"));
Assert::AreEqual(100.f+player->GetBaseStat("Damage Reduction"),player->GetStat("Damage Reduction"));
//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->GetStat("HP4 Recovery %"),L"HP/4s Recovery stat was not increased by 100%.");
Assert::AreEqual(100.f+player->GetBaseStat("Damage Reduction"),player->GetStat("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 defense, 1000 health, and 100 attack.
Assert::AreEqual(100.f+player->GetBaseStat("HP Recovery %"),player->GetStat("HP Recovery %"));
Assert::AreEqual(50.f+player->GetBaseStat("Attack Spd"),player->GetStat("Attack Spd"));
Assert::AreEqual(100.f+player->GetBaseStat("Mana"),player->GetStat("Mana"));
//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->GetStat("HP Recovery %"),L"HP Recovery % stat was not increased by 100%.");
Assert::AreEqual(50.f+player->GetBaseStat("Attack Spd"),player->GetStat("Attack Spd"),L"Attack Speed stat was not increased by 50%.");
Assert::AreEqual(100.f+player->GetBaseStat("Mana"),player->GetStat("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->GetStat("Crit Rate"),L"Base Crit Rate does not match initial Crit Rate");
Assert::AreEqual(player->GetBaseStat("Crit Dmg"),player->GetStat("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->GetStat("Crit Rate"),L"Crit Rate does not increase by 5% with 2 Bone Equips (Set Bonus)");
Assert::AreEqual(player->GetBaseStat("Crit Dmg"),player->GetStat("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->GetStat("Crit Rate"),L"Removing an armor piece does not remove the crit rate set effect");
Assert::AreEqual(player->GetBaseStat("Crit Dmg"),player->GetStat("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->GetStat("Crit Rate"),L"Crit Rate does not increase by 5% with 4 Bone Equips (Set Bonus)");
Assert::AreEqual(7+player->GetBaseStat("Crit Dmg"),player->GetStat("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->GetStat("Move Spd %"),L"Base Move Spd %does not match initial Move Spd %");
Assert::AreEqual(player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"),L"Base Crit Rate does not match initial Crit Rate");
Assert::AreEqual(player->GetBaseStat("Mana"),player->GetStat("Mana"),L"Base Mana does not match initial Mana");
Inventory::EquipItem(testRing,EquipSlot::RING1);
Assert::AreEqual(3+player->GetBaseStat("Move Spd %"),player->GetStat("Move Spd %"),L"Move Spd % increased incorrectly when ring 1 equipped!");
Assert::AreEqual(2+player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"),L"Crit Rate increased incorrectly when ring 1 equipped!");
Assert::AreEqual(5+player->GetBaseStat("Mana"),player->GetStat("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->GetStat("Move Spd %"),L"Move Spd % increased incorrectly when ring 1 equipped!");
Assert::AreEqual(2+player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"),L"Crit Rate increased incorrectly when ring 1 equipped!");
Assert::AreEqual(2+player->GetBaseStat("Mana"),player->GetStat("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->GetStat("Move Spd %"),L"Base Move Spd %does not match initial Move Spd % after unequipping the ring.");
Assert::AreEqual(player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"),L"Base Crit Rate does not match initial Crit Rate after unequipping the ring.");
Assert::AreEqual(player->GetBaseStat("Mana"),player->GetStat("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->GetStat("Move Spd %"),L"Move Spd % increased incorrectly when both rings equipped!");
Assert::AreEqual(4+player->GetBaseStat("Crit Rate"),player->GetStat("Crit Rate"),L"Crit Rate increased incorrectly when both rings equipped!");
Assert::AreEqual(7+player->GetBaseStat("Mana"),player->GetStat("Mana"),L"Mana increased incorrectly when both rings equipped!");
}
};
}

@ -1219,7 +1219,8 @@ void Item::RandomizeStats(){
randomizedStats=it->RandomizeStats();
};
const Stats ItemInfo::GetMinStats()const{return minStats;
const Stats ItemInfo::GetMinStats()const{
return minStats;
}
const Stats ItemInfo::GetMaxStats()const{
return maxStats;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 9851
#define VERSION_BUILD 9852
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save