Implemented Emergency Recovery unique enchant. Added unit test. 126/126 unit tests passing. Release Build 10653.

mac-build
sigonasr2 4 months ago
parent 94bd702ee8
commit 62086cbd92
  1. 1
      Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj
  2. 20
      Adventures in Lestoria Tests/EnchantTests.cpp
  3. 4
      Adventures in Lestoria.sln
  4. 24
      Adventures in Lestoria/Player.cpp
  5. 2
      Adventures in Lestoria/Version.h
  6. 2
      Adventures in Lestoria/assets/config/items/ItemEnchants.txt
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -67,6 +67,7 @@
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>discord_game_sdk.dll.lib;freetype.lib;steam_api64.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<PreBuildEvent> <PreBuildEvent>
<Command>powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File ../unit-testing-prebuild.ps1</Command> <Command>powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File ../unit-testing-prebuild.ps1</Command>

@ -240,5 +240,25 @@ namespace EnchantTests
player->Heal(11); player->Heal(11);
Assert::AreEqual(0.0_Pct,player->GetHPRecoveryPct(),L"HP Recovery Pct is now 0% since Second Wind should no longer activate above 20% health."); Assert::AreEqual(0.0_Pct,player->GetHPRecoveryPct(),L"HP Recovery Pct is now 0% since Second Wind should no longer activate above 20% health.");
} }
TEST_METHOD(EmergencyRecoveryCheck){
Assert::AreEqual(0.0_Pct,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is 0% at the start.");
Assert::AreEqual(0.0_Pct,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is 0% at the start.");
std::weak_ptr<Item>nullRing{Inventory::AddItem("Null Ring"s)};
Inventory::EquipItem(nullRing,EquipSlot::RING1);
nullRing.lock()->EnchantItem("Emergency Recovery");
Assert::AreEqual(1.0_Pct,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is base 1% even with full HP.");
Assert::AreEqual(0.0_Pct,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is still 0% since the player is not lower than 30% health.");
for(int i:std::ranges::iota_view(1,7)){
player->Hurt(10,player->OnUpperLevel(),player->GetZ());
Assert::AreEqual(1.0_Pct+0.5_Pct*i,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is increasing by 0.5% per 10% missing health.");
}
player->Hurt(10,player->OnUpperLevel(),player->GetZ());
Assert::AreEqual(0.0_Pct,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is now 0% as the HP Recovery/4 sec version should have activated.");
Assert::AreEqual(4.5_Pct,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is now 4.5%");
for(int i:std::ranges::iota_view(1,3)){
player->Hurt(10,player->OnUpperLevel(),player->GetZ());
Assert::AreEqual(4.5_Pct+0.5_Pct*i,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is increasing by 0.5% per 10% missing health.");
}
}
}; };
} }

@ -43,8 +43,8 @@ Global
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x64.Build.0 = Release Desktop|x64 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x64.Build.0 = Release Desktop|x64
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x86.ActiveCfg = Release Desktop|Win32 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x86.ActiveCfg = Release Desktop|Win32
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x86.Build.0 = Release Desktop|Win32 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x86.Build.0 = Release Desktop|Win32
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.ActiveCfg = Release Desktop|x64 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.ActiveCfg = Unit Testing|x64
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.Build.0 = Release Desktop|x64 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.Build.0 = Unit Testing|x64
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x86.ActiveCfg = Unit Testing|Win32 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x86.ActiveCfg = Unit Testing|Win32
{8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x86.Build.0 = Unit Testing|Win32 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x86.Build.0 = Unit Testing|Win32
{11969B7B-3D50-4825-9584-AF01D15B88E0}.Debug|x64.ActiveCfg = Unit Testing|x64 {11969B7B-3D50-4825-9584-AF01D15B88E0}.Debug|x64.ActiveCfg = Unit Testing|x64

@ -1466,11 +1466,35 @@ const float Player::GetHPRecoveryPct()const{
const float Player::GetHP6RecoveryPct()const{ const float Player::GetHP6RecoveryPct()const{
float modHPRecoveryPct=0; float modHPRecoveryPct=0;
modHPRecoveryPct+=GetEquipStat("HP6 Recovery %")/100; modHPRecoveryPct+=GetEquipStat("HP6 Recovery %")/100;
#pragma region Emergency Recovery Enchant Bonuses
const bool UseHP4RecoveryInstead{GetHealthRatio()<="Emergency Recovery"_ENC["FOUR SECOND HP THRESHOLD"]/100.f};
if(HasEnchant("Emergency Recovery")&&!UseHP4RecoveryInstead){
const float missingHealthRatio{std::ceil(((1-GetHealthRatio())*100))/100};
const float effectBonusBasedOnMissingHealth{"Emergency Recovery"_ENC["GAIN AMOUNT PCT"]/100.f*int(missingHealthRatio/("Emergency Recovery"_ENC["MISSING HEALTH BONUS PCT"]/100.f))};
modHPRecoveryPct+="Emergency Recovery"_ENC["HP RECOVERY PCT"]/100.f;
modHPRecoveryPct+=effectBonusBasedOnMissingHealth;
}
#pragma endregion
return modHPRecoveryPct; return modHPRecoveryPct;
} }
const float Player::GetHP4RecoveryPct()const{ const float Player::GetHP4RecoveryPct()const{
float modHPRecoveryPct=0; float modHPRecoveryPct=0;
modHPRecoveryPct+=GetEquipStat("HP4 Recovery %")/100; modHPRecoveryPct+=GetEquipStat("HP4 Recovery %")/100;
#pragma region Emergency Recovery Enchant Bonuses
const bool UseHP4RecoveryInstead{GetHealthRatio()<="Emergency Recovery"_ENC["FOUR SECOND HP THRESHOLD"]/100.f};
if(HasEnchant("Emergency Recovery")&&UseHP4RecoveryInstead){
const float missingHealthRatio{std::ceil(((1-GetHealthRatio())*100))/100};
const float effectBonusBasedOnMissingHealth{"Emergency Recovery"_ENC["GAIN AMOUNT PCT"]/100.f*int(missingHealthRatio/("Emergency Recovery"_ENC["MISSING HEALTH BONUS PCT"]/100.f))};
modHPRecoveryPct+="Emergency Recovery"_ENC["HP RECOVERY PCT"]/100.f;
modHPRecoveryPct+=effectBonusBasedOnMissingHealth;
}
#pragma endregion
return modHPRecoveryPct; return modHPRecoveryPct;
} }

@ -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 10646 #define VERSION_BUILD 10653
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -593,7 +593,7 @@ Item Enchants
} }
Emergency Recovery Emergency Recovery
{ {
Description = "Gain {HP RECOVERY PCT}% HP Recovery every 6 seconds. Effect increases by {GAIN AMOUNT PCT}% for every {MISSING HEALTH BONUS PCT}% health missing. Below {FOUR SECOND HP THRESHOLD}% Health Recovery happens every 4 seconds." Description = "Gain {HP RECOVERY PCT}% HP Recovery every 6 seconds. Effect increases by {GAIN AMOUNT PCT}% for every {MISSING HEALTH BONUS PCT}% health missing. Below {FOUR SECOND HP THRESHOLD}% HP, Health Recovery happens every 4 seconds."
HP RECOVERY PCT = 1% HP RECOVERY PCT = 1%
GAIN AMOUNT PCT = 0.5% GAIN AMOUNT PCT = 0.5%

Loading…
Cancel
Save