Create variable parser. Need to fix up when it parses the name and description and all references for its arguments.
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 1m25s
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Failing after 1m25s
This commit is contained in:
parent
62ef4d2815
commit
93298e05d3
@ -87,6 +87,37 @@ const std::string Ability::GetNameWithPlayerModifiers()const{
|
||||
if(modifiers.newName)newName=modifiers.newName.value();
|
||||
if(suffixName.length()>0&&modifiers.preName)suffixName+=" ";
|
||||
suffixName+=modifiers.postName.value_or("");
|
||||
|
||||
const auto ParseVariables=[&](const std::string_view abilityText)->std::string{
|
||||
std::string finalText{};
|
||||
size_t marker{};
|
||||
std::string variableName{};
|
||||
bool bracesFound{false};
|
||||
|
||||
const auto FindAndParse=[&finalText,&bracesFound,&variableName](datafile&data)->bool{
|
||||
if(data.HasProperty(variableName)){
|
||||
if(finalText.length()>0)finalText+=' ';
|
||||
finalText+=data.GetProperty(variableName).GetFullString();
|
||||
bracesFound=false;
|
||||
variableName="";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
while(abilityText.length()>marker){
|
||||
const char c{abilityText[marker]};
|
||||
if(!bracesFound&&c=='{')bracesFound=true;
|
||||
else if(bracesFound&&c=='}'){ //Parse the variable.
|
||||
if(!FindAndParse(enchant["Ability Settings"]))
|
||||
if(!FindAndParse(enchant))
|
||||
if(!FindAndParse((*(*newEnchant.GetAbility())->abilityConfig).get()))
|
||||
ERR(std::format("Could not find variable {} for enchant Ability Settings of enchantment {}",variableName,newEnchant.Name()));
|
||||
}else if(bracesFound)variableName+=c;
|
||||
marker++;
|
||||
}
|
||||
return finalText;
|
||||
};
|
||||
}
|
||||
return std::format("{}{}{}",prefixName,newName,suffixName);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ All rights reserved.
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
#include "Key.h"
|
||||
#include "olcPixelGameEngine.h"
|
||||
#include <string_view>
|
||||
#include "olcUTIL_DataFile.h"
|
||||
|
||||
class InputGroup;
|
||||
|
||||
@ -90,6 +90,7 @@ struct Ability{
|
||||
static std::string tooltipText;
|
||||
static std::string tooltipTitle;
|
||||
static Pixel tooltipTitleCol;
|
||||
std::optional<std::reference_wrapper<datafile>>abilityConfig;
|
||||
constexpr static float MAX_DESCRIPTION_HOVER_TIME{0.3f};
|
||||
Ability();
|
||||
//NOTE: icon expects the actual name relative to the "Ability Icons" directory for this constructor!
|
||||
|
@ -3011,6 +3011,11 @@ void AiL::InitializeClasses(){
|
||||
Trapper::CreateOriginalCopies();
|
||||
Wizard::CreateOriginalCopies();
|
||||
Witch::CreateOriginalCopies();
|
||||
|
||||
for(int classBitCount{0b1};const std::string&cl:DATA["class_list"].GetValues()){
|
||||
classutils::classList[Class(classBitCount)]=cl;
|
||||
classBitCount<<=1;
|
||||
}
|
||||
}
|
||||
|
||||
std::string AiL::GetString(std::string key){
|
||||
|
@ -56,6 +56,7 @@ enum Class{
|
||||
};
|
||||
|
||||
namespace classutils{//Classes have bit-wise operator capabilities.
|
||||
inline std::unordered_map<Class,std::string>classList;
|
||||
static inline Class StringToClass(std::string className){
|
||||
const std::vector<std::string>&classList=DATA["class_list"].GetValues();
|
||||
auto it=std::find(classList.begin(),classList.end(),className);
|
||||
@ -63,4 +64,7 @@ namespace classutils{//Classes have bit-wise operator capabilities.
|
||||
int element=int(std::distance(classList.begin(),it));
|
||||
return Class(1<<element); //Yes...It's bitwise flags, who in god's name knows why I did this.
|
||||
};
|
||||
static inline std::string ClassToString(const Class&cl){
|
||||
return classList.at(cl);
|
||||
}
|
||||
};
|
@ -120,12 +120,13 @@ void ItemEnchantInfo::Initialize(){
|
||||
ItemEnchantInfo::AbilityDescriptionModifiers modifiers;
|
||||
if(enchant.HasProperty("Ability Settings")){
|
||||
for(const auto&[key,size]:enchant["Ability Settings"]){
|
||||
if(key=="Pre-Name")modifiers.preName=enchant["Ability Settings"][key].GetString();
|
||||
else if(key=="Post-Name")modifiers.postName=enchant["Ability Settings"][key].GetString();
|
||||
else if(key=="Name")modifiers.newName=enchant["Ability Settings"][key].GetString();
|
||||
else if(key=="Pre-Description")modifiers.preDescription=enchant["Ability Settings"][key].GetString();
|
||||
else if(key=="Post-Description")modifiers.postDescription=enchant["Ability Settings"][key].GetString();
|
||||
else if(key=="Description")modifiers.newDescription=enchant["Ability Settings"][key].GetString();
|
||||
|
||||
if(key=="Pre-Name")modifiers.preName=ParseVariables(enchant["Ability Settings"][key].GetString());
|
||||
else if(key=="Post-Name")modifiers.postName=ParseVariables(enchant["Ability Settings"][key].GetString());
|
||||
else if(key=="Name")modifiers.newName=ParseVariables(enchant["Ability Settings"][key].GetString());
|
||||
else if(key=="Pre-Description")modifiers.preDescription=ParseVariables(enchant["Ability Settings"][key].GetString());
|
||||
else if(key=="Post-Description")modifiers.postDescription=ParseVariables(enchant["Ability Settings"][key].GetString());
|
||||
else if(key=="Description")modifiers.newDescription=ParseVariables(enchant["Ability Settings"][key].GetString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,6 +775,7 @@ private:
|
||||
{#class".Right Click Ability.Precast Time"_F,#class".Right Click Ability.Casting Range"_I/100.f*24,#class".Right Click Ability.Casting Size"_I/100.f*24}, \
|
||||
bool( #class".Right Click Ability.CancelCast"_I ) \
|
||||
}; \
|
||||
class::rightClickAbility.abilityConfig=std::ref(DATA.GetProperty(#class".Right Click Ability")); \
|
||||
class::ability1={ \
|
||||
#class".Ability 1.Name"_S, \
|
||||
#class".Ability 1.Short Name"_S, \
|
||||
@ -788,6 +789,7 @@ private:
|
||||
{#class".Ability 1.Precast Time"_F,#class".Ability 1.Casting Range"_I/100.f*24,#class".Ability 1.Casting Size"_I/100.f*24}, \
|
||||
bool(#class".Ability 1.CancelCast"_I) \
|
||||
}; \
|
||||
class::ability1.abilityConfig=std::ref(DATA.GetProperty(#class".Ability 1")); \
|
||||
class::ability2={ \
|
||||
#class".Ability 2.Name"_S, \
|
||||
#class".Ability 2.Short Name"_S, \
|
||||
@ -801,6 +803,7 @@ private:
|
||||
{#class".Ability 2.Precast Time"_F,#class".Ability 2.Casting Range"_I/100.f*24,#class".Ability 2.Casting Size"_I/100.f*24}, \
|
||||
bool(#class".Ability 2.CancelCast"_I) \
|
||||
}; \
|
||||
class::ability2.abilityConfig=std::ref(DATA.GetProperty(#class".Ability 2")); \
|
||||
class::ability3={ \
|
||||
#class".Ability 3.Name"_S, \
|
||||
#class".Ability 3.Short Name"_S, \
|
||||
@ -814,6 +817,7 @@ private:
|
||||
{#class".Ability 3.Precast Time"_F,#class".Ability 3.Casting Range"_I/100.f*24,#class".Ability 3.Casting Size"_I/100.f*24}, \
|
||||
bool(#class".Ability 3.CancelCast"_I) \
|
||||
}; \
|
||||
class::ability3.abilityConfig=std::ref(DATA.GetProperty(#class".Ability 3")); \
|
||||
class::ability4; \
|
||||
Player::ABILITY_LIST.emplace_back(class::original_rightClickAbility); \
|
||||
Player::ABILITY_LIST.emplace_back(class::original_ability1); \
|
||||
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 12161
|
||||
#define VERSION_BUILD 12164
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -64,9 +64,8 @@ Ranger
|
||||
# Whether or not this ability cancels casts.
|
||||
CancelCast = 0
|
||||
|
||||
Description = Shoots {ARROW COUNT} arrows rapidly. Total Damage: {TotalDamageMult}
|
||||
Description = Shoots {ARROW COUNT} arrows rapidly. Total Damage: {DamageMult:TotalDamageMult}
|
||||
|
||||
DAMAGE = 5.0x
|
||||
ARROW COUNT = four
|
||||
|
||||
#RGB Values. Color 1 is the circle at full cooldown, Color 2 is the color at empty cooldown.
|
||||
@ -91,7 +90,7 @@ Ranger
|
||||
# Hitbox radius of the arrows
|
||||
ArrowRadius = 100
|
||||
|
||||
TotalDamageMult = 4.0
|
||||
TotalDamageMult = 4.0x
|
||||
|
||||
Sound = Ranger Rapid Fire
|
||||
}
|
||||
@ -139,7 +138,7 @@ Ranger
|
||||
# Whether or not this ability cancels casts.
|
||||
CancelCast = 0
|
||||
|
||||
Description = Prepares and fires a fan of densely packed arrows.
|
||||
Description = Prepares and fires a fan of {ArrowCount} packed arrows. Total Damage: {DamageMult}
|
||||
|
||||
#RGB Values. Color 1 is the circle at full cooldown, Color 2 is the color at empty cooldown.
|
||||
Cooldown Bar Color 1 = 64, 0, 0, 192
|
||||
|
@ -52,7 +52,7 @@ theme_img_directory = themes/
|
||||
# Path to class configuration files
|
||||
class_directory = classes/
|
||||
|
||||
# Class list to be loaded into the game.
|
||||
# Class list to be loaded into the game. SHOULD BE IN ORDER BASED ON Class.h
|
||||
class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch
|
||||
|
||||
# Items Config
|
||||
|
@ -165,8 +165,8 @@ Item Enchants
|
||||
Description = "Charged Shot's cast time increases by {CAST TIME INCREASE} seconds. Now deals {DAMAGE INCREASE MULT}x more damage."
|
||||
Affects = Ability 2
|
||||
|
||||
CAST TIME INCREASE = 1.5s
|
||||
DAMAGE INCREASE MULT = 2x
|
||||
CAST TIME INCREASE = 1.5
|
||||
DAMAGE INCREASE MULT = 2
|
||||
|
||||
# Stat, Lowest, Highest Value
|
||||
# Stat Modifier[0] = ..., 0, 0
|
||||
@ -202,7 +202,7 @@ Item Enchants
|
||||
# Use "Pre-Name" and "Post-Name" keys to add to the front or back of a current ability name.
|
||||
# Use "Name" to completely overwrite the default ability name (be careful of conflicts with another modification!)
|
||||
Pre-Name = "Multi-"
|
||||
Post-Description = "Holds up to {EXTRA CHARGE COUNT} charges. Cooldown Reduced by {COOLDOWN REDUCTION PCT}%."
|
||||
Post-Description = "Holds up to {EXTRA CHARGE COUNT} charges. Cooldown Reduced by {COOLDOWN REDUCTION PCT}."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user