Added newline character parsing to olcDataFile config parser. Fix bug with enchants not being able to choose the actual highest value roll on stat enchants. Added stat descriptions to Magical Protection and Aura of the Beast. Release Build 10720.

mac-build
sigonasr2 4 months ago
parent 5dc46664eb
commit d28f27f59d
  1. 4
      Adventures in Lestoria Tests/EnchantTests.cpp
  2. 5
      Adventures in Lestoria/Item.h
  3. 4
      Adventures in Lestoria/ItemEnchant.cpp
  4. 2
      Adventures in Lestoria/Version.h
  5. 4
      Adventures in Lestoria/assets/config/items/ItemEnchants.txt
  6. 14
      Adventures in Lestoria/olcUTIL_DataFile.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -112,10 +112,12 @@ namespace EnchantTests
std::weak_ptr<Item>nullRing2{Inventory::AddItem("Null Ring"s)};
Assert::AreEqual(100,player->GetMaxHealth(),L"Player starts with 100 health.");
Inventory::EquipItem(nullRing,EquipSlot::RING1);
std::unordered_map<int,uint32_t>statDistribution;
for(int i:std::ranges::iota_view(0,1000)){
nullRing.lock()->EnchantItem("Health Boost");
Test::InRange(player->GetMaxHealth(),{103,105},L"Max Health not in expected range.");
statDistribution[player->GetMaxHealth()]++;
}
Assert::AreEqual(size_t(3),statDistribution.size(),L"There should be three entries generated. If not, then the RNG picking is likely not working!");
Inventory::EquipItem(nullRing2,EquipSlot::RING2);
for(int i:std::ranges::iota_view(0,1000)){
nullRing2.lock()->EnchantItem("Health Boost");

@ -169,6 +169,10 @@ namespace PlayerTests{
class PlayerTest;
};
namespace EnchantTests{
class EnchantTest;
};
using IncreaseAmount=int;
using RefineResult=std::pair<ItemAttribute,IncreaseAmount>;
@ -180,6 +184,7 @@ class Item{
friend void Merchant::PurchaseItem(IT item,uint32_t amt);
friend void Merchant::SellItem(std::weak_ptr<Item>,uint32_t amt);
friend class PlayerTests::PlayerTest;
friend class EnchantTests::EnchantTest;
private:
//The amount in the current item stack.
uint32_t amt;

@ -172,14 +172,14 @@ ItemEnchant::ItemEnchant(const std::string_view enchantName)
float maxVal=ItemEnchantInfo::ENCHANT_LIST.at(this->enchantName).maxStatModifiers.A_Read(attr);
if(minVal==maxVal)A(attr)=minVal;
else{
const auto&randRange{std::ranges::iota_view(int(minVal),int(maxVal))};
const auto&randRange{std::ranges::iota_view(int(minVal),int(maxVal+1))};
A(attr)=randRange[util::random()%randRange.size()];
}
const std::string wrappedConfigStr{std::vformat("{{{}}}",std::make_format_args(attr.ActualName()))};
size_t configValInd{description.find(wrappedConfigStr)};
if(configValInd==std::string::npos)continue;
std::string formattedFloat{std::format("{}{}#FFFFFF",ItemEnchantInfo::enchantAttributeCol.toHTMLColorCode(),val)};
std::string formattedFloat{std::format("{}{}#FFFFFF",ItemEnchantInfo::enchantAttributeCol.toHTMLColorCode(),A_Read(attr))};
description=description.replace(configValInd,wrappedConfigStr.length(),formattedFloat);
}
}

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

@ -554,7 +554,7 @@ Item Enchants
Magical Protection
{
Description = "Provides a defensive aura granting many boons."
Description = "Provides a defensive aura granting many boons.\n\nHealth +{Health %}%\nDamage Reduction +{Damage Reduction}%\nMove Spd: +{Move Spd %}%\nRestores {HP6 Recovery %}% HP every 6 seconds."
# Stat, Lowest, Highest Value
Stat Modifier[0] = Health %, 2, 3
Stat Modifier[1] = Damage Reduction, 2, 3
@ -563,7 +563,7 @@ Item Enchants
}
Aura of the Beast
{
Description = "Provides an offensive aura granting many boons."
Description = "Provides an offensive aura granting many boons.\n\nAttack: +{Attack %}%\nCrit Rate: +{Crit Rate}%\nCDR: +{CDR}%\nCrit Damage: +{Crit Dmg}%"
# Stat, Lowest, Highest Value
Stat Modifier[0] = Attack %, 2, 3
Stat Modifier[1] = Crit Rate, 2, 3

@ -408,10 +408,18 @@ namespace olc::utils
// elements may exist in quotes a, b, c, "d, e", f. So we need to iterate
// character by character and break up the value
bool bInQuotes = false;
bool bEscapeChar = false;
std::string sToken;
size_t nTokenCount = 0;
for (const auto c : sPropValue)
{
if (bEscapeChar&&c == 'n') //Parse a newline.
{
sToken.append(1, '\n');
bEscapeChar=false;
continue;
}
bEscapeChar=false;
// Is character a quote...
if (c == '\"')
{
@ -419,6 +427,12 @@ namespace olc::utils
bInQuotes = !bInQuotes;
}
else
if (c == '\\')
{
// ...yes, so toggle quote state
bEscapeChar=true;
}
else
{
// ...no, so proceed creating token. If we are in quote state
// then just append characters until we exit quote state.

Loading…
Cancel
Save