diff --git a/Adventures in Lestoria/CharacterMenuWindow.cpp b/Adventures in Lestoria/CharacterMenuWindow.cpp index b4919001..84aed64e 100644 --- a/Adventures in Lestoria/CharacterMenuWindow.cpp +++ b/Adventures in Lestoria/CharacterMenuWindow.cpp @@ -66,10 +66,10 @@ namespace CharacterMenuWindow{ AttributeData{"Health",[]()->int{return game->GetPlayer()->GetMaxHealth();}}, AttributeData{"Attack",[]()->int{return game->GetPlayer()->GetAttack();}}, AttributeData{"Defense",[]()->int{return game->GetPlayer()->GetDefense();}}, - AttributeData{"Move Spd %",[]()->int{return ceil(game->GetPlayer()->GetMoveSpdMult()*100);}}, - AttributeData{"CDR",[]()->int{return ceil(game->GetPlayer()->GetCooldownReductionPct()*100);}}, - AttributeData{"Crit Rate",[]()->int{return ceil(game->GetPlayer()->GetCritRatePct()*100);}}, - AttributeData{"Crit Dmg",[]()->int{return ceil(game->GetPlayer()->GetCritDmgPct()*100);}}, + AttributeData{"Move Spd %",[]()->int{return round(game->GetPlayer()->GetMoveSpdMult()*100);}}, + AttributeData{"CDR",[]()->int{return round(game->GetPlayer()->GetCooldownReductionPct()*100);}}, + AttributeData{"Crit Rate",[]()->int{return round(game->GetPlayer()->GetCritRatePct()*100);}}, + AttributeData{"Crit Dmg",[]()->int{return round(game->GetPlayer()->GetCritDmgPct()*100);}}, }; const static std::arrayslotNames{"Helmet","Weapon","Armor","Gloves","Pants","Shoes","Ring 1","Ring 2"}; template diff --git a/Adventures in Lestoria/ItemEnchant.cpp b/Adventures in Lestoria/ItemEnchant.cpp index 4df506e3..c5b7f20b 100644 --- a/Adventures in Lestoria/ItemEnchant.cpp +++ b/Adventures in Lestoria/ItemEnchant.cpp @@ -170,17 +170,11 @@ ItemEnchant::ItemEnchant(const std::string_view enchantName) for(const auto&[attr,val]:ItemEnchantInfo::ENCHANT_LIST.at(this->enchantName).minStatModifiers){ float minVal=ItemEnchantInfo::ENCHANT_LIST.at(this->enchantName).minStatModifiers.A_Read(attr); float maxVal=ItemEnchantInfo::ENCHANT_LIST.at(this->enchantName).maxStatModifiers.A_Read(attr); - if(minVal==maxVal)A(attr)=minVal; + if(minVal==maxVal)SetAttribute(attr.ActualName(),minVal); else{ const auto&randRange{std::ranges::iota_view(int(minVal),int(maxVal+1))}; - A(attr)=randRange[util::random()%randRange.size()]; + SetAttribute(attr.ActualName(),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(),A_Read(attr))}; - description=description.replace(configValInd,wrappedConfigStr.length(),formattedFloat); } } @@ -248,3 +242,29 @@ const std::string ItemEnchant::RollRandomEnchant(){ return filteredEnchants[util::random()%filteredEnchants.size()].Name(); } + +void ItemEnchant::UpdateDescription(){ + description=ItemEnchantInfo::ENCHANT_LIST.at(this->enchantName).Description(); + for(const auto&[attr,val]:ItemEnchantInfo::ENCHANT_LIST.at(this->enchantName).minStatModifiers){ + 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(),GetAttribute(attr.ActualName()))}; + description=description.replace(configValInd,wrappedConfigStr.length(),formattedFloat); + } +} + +void ItemEnchant::SetAttribute(const std::string_view attr,const float val){ + stats.A(attr)=val; + UpdateDescription(); +} +const float&ItemEnchant::GetAttribute(const std::string_view attr)const{ + return stats.A_Read(attr); +} + +std::map::const_iterator ItemEnchant::begin()const{ + return stats.begin(); +} +std::map::const_iterator ItemEnchant::end()const{ + return stats.end(); +} \ No newline at end of file diff --git a/Adventures in Lestoria/ItemEnchant.h b/Adventures in Lestoria/ItemEnchant.h index 6bb337d4..af56f50a 100644 --- a/Adventures in Lestoria/ItemEnchant.h +++ b/Adventures in Lestoria/ItemEnchant.h @@ -95,7 +95,7 @@ private: static std::unordered_mapENCHANT_CATEGORIES; }; -class ItemEnchant:public ItemAttributable{ +class ItemEnchant{ public: ItemEnchant(const std::string_view enchantName); const std::string Name(ItemEnchantInfo::TextStyle style=ItemEnchantInfo::TextStyle::NORMAL)const; @@ -104,8 +104,14 @@ public: const std::optional&AbilitySlot()const; //Rolls a class-appropriate random enchant. const static std::string RollRandomEnchant(); + void SetAttribute(const std::string_view attr,const float val); + const float&GetAttribute(const std::string_view attr)const; + std::map::const_iterator begin()const; + std::map::const_iterator end()const; private: + void UpdateDescription(); const ItemEnchantInfo&GetEnchantInfo()const; std::string enchantName; std::string description; + ItemAttributable stats; }; \ No newline at end of file diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 11406080..82575ee8 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -1328,8 +1328,8 @@ void EntityStats::RecalculateEquipStats(){ if(slot==EquipSlot::RING2&&equip.lock()->HasEnchant()){ //Special doubling-up ring logic. const bool IsNonCommonEnchant{equip.lock()->HasEnchant()&&equip.lock()->GetEnchant().value().Category()!=ItemEnchantInfo::ItemEnchantCategory::GENERAL}; const bool Slot1HasSameEnchant{!ISBLANK(Inventory::GetEquip(EquipSlot::RING1))&&Inventory::GetEquip(EquipSlot::RING1).lock()->HasEnchant()&&Inventory::GetEquip(EquipSlot::RING1).lock()->GetEnchant().value().Name()==equip.lock()->GetEnchant().value().Name()}; - if(!IsNonCommonEnchant||!Slot1HasSameEnchant)equipStats.A(key)+=equip.lock()->GetEnchant().value().A_Read(key); - }else if(equip.lock()->HasEnchant())equipStats.A(key)+=equip.lock()->GetEnchant().value().A_Read(key); + if(!IsNonCommonEnchant||!Slot1HasSameEnchant)equipStats.A(key)+=equip.lock()->GetEnchant().value().GetAttribute(key); + }else if(equip.lock()->HasEnchant())equipStats.A(key)+=equip.lock()->GetEnchant().value().GetAttribute(key); } } diff --git a/Adventures in Lestoria/SaveFile.cpp b/Adventures in Lestoria/SaveFile.cpp index c7b1a071..c091e081 100644 --- a/Adventures in Lestoria/SaveFile.cpp +++ b/Adventures in Lestoria/SaveFile.cpp @@ -380,7 +380,7 @@ void SaveFile::LoadFile(){ newItem.lock()->enchant=ItemEnchant{data["Enchant"]["Name"].GetString()}; if(loadFile.GetProperty(std::format("Items.{}.Enchant",key)).HasProperty("Attributes")){ for(auto&[attr,data]:loadFile.GetProperty(std::format("Items.{}.Enchant.Attributes",key)).GetOrderedKeys()){ - newItem.lock()->enchant.value().A(attr)=data.GetReal(); + newItem.lock()->enchant.value().SetAttribute(attr,data.GetReal()); } } } diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 8ed3f602..d51b1421 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 -#define VERSION_BUILD 10720 +#define VERSION_BUILD 10729 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 3a312ff3..212f5362 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ