Moved array parsing for ability descriptions from being its own symbol to being integrated with the other symbols when they are parsed. Updated Trapper skill descriptions with dynamic text. Release Build 13641.
This commit is contained in:
parent
10c949779d
commit
48529d8c54
@ -103,12 +103,12 @@ const std::string Ability::GetDescriptionWithPlayerModifiers()const{
|
||||
std::unordered_map<SpecialKey,TranslateFunc>specialPrefixes{
|
||||
#define TranslateFunc [&](const datafile&data,const std::string&val)->std::string
|
||||
{"DamageMult",TranslateFunc{
|
||||
float damageMult{stof(data.at(val).GetString())};
|
||||
float damageMult{stof(val)};
|
||||
int finalDmg{int(damageMult*game->GetPlayer()->GetAttack())};
|
||||
return std::format("{}",finalDmg);
|
||||
}},
|
||||
{"Pct",TranslateFunc{
|
||||
float percentage{stof(data.at(val).GetString())};
|
||||
float percentage{stof(val)};
|
||||
return std::format("{}%",percentage*100);
|
||||
}},
|
||||
};
|
||||
@ -117,73 +117,71 @@ const std::string Ability::GetDescriptionWithPlayerModifiers()const{
|
||||
#define OUT
|
||||
|
||||
const auto FindAndParse=[&specialPrefixes,&specialValCol](datafile&data,OUT std::string&finalText,OUT bool&bracesFound,OUT std::string&variableName)->bool{
|
||||
if(data.HasProperty(variableName)){
|
||||
finalText+=specialValCol.toHTMLColorCode()+data.GetProperty(variableName).GetFullString()+WHITE.toHTMLColorCode();
|
||||
const auto GetPairStringProperty=[&data](const std::string&variableName)->std::optional<std::string>{
|
||||
const bool IS_ARRAY_VARIABLE{variableName.contains('[')};
|
||||
std::vector<std::string>parsedArrVariable{util::Tokenize(variableName,'[')};
|
||||
const std::string&key{parsedArrVariable[0]};
|
||||
if(parsedArrVariable.size()>1){
|
||||
const size_t&index{std::stoul(parsedArrVariable[1])};
|
||||
if(const datafile&propData{data.GetProperty(key)};IS_ARRAY_VARIABLE&&index<data.GetKeys().size())return propData.GetString(index);
|
||||
}else if(data.HasProperty(key))return data.GetProperty(key).GetFullString();
|
||||
return {};
|
||||
};
|
||||
|
||||
enum SymbolIndicator{
|
||||
MULTIPLICATION, //*
|
||||
KEY_VALUE_PAIR,
|
||||
NOT_FOUND,
|
||||
};
|
||||
|
||||
const auto AddToDescription=[&finalText,&bracesFound,&variableName](const std::string&descriptionTextAddon){
|
||||
finalText+=descriptionTextAddon;
|
||||
bracesFound=false;
|
||||
variableName="";
|
||||
};
|
||||
|
||||
SymbolIndicator indicator{NOT_FOUND};
|
||||
safemap<char,SymbolIndicator>recognizedSymbols;
|
||||
recognizedSymbols[':']=KEY_VALUE_PAIR;
|
||||
recognizedSymbols['*']=MULTIPLICATION;
|
||||
recognizedSymbols.SetInitialized();
|
||||
|
||||
for(auto&[c,symbolIndicator]:recognizedSymbols){
|
||||
if(variableName.find(c)!=std::string::npos){
|
||||
indicator=symbolIndicator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(indicator){
|
||||
case MULTIPLICATION:{
|
||||
std::vector<std::string>tokens{util::Tokenize(variableName,'*')};
|
||||
std::optional<float>numb{};
|
||||
for(const std::string&token:tokens){
|
||||
if(!numb)numb=std::stof(*GetPairStringProperty(token));
|
||||
else *numb*=std::stof(*GetPairStringProperty(token));
|
||||
}
|
||||
if(!numb)ERR("WARNING! Somehow did not populate a number. Variable: "<<variableName);
|
||||
AddToDescription(specialValCol.toHTMLColorCode()+std::format("{:.2f}",*numb)+WHITE.toHTMLColorCode());
|
||||
return true;
|
||||
}break;
|
||||
case KEY_VALUE_PAIR:{
|
||||
std::vector<std::string>tokens{util::Tokenize(variableName,':')};
|
||||
if(tokens.size()!=2)ERR(": variable syntax only allows 2 arguments. Ex. Key:Value. Arguments found: "<<tokens.size());
|
||||
std::string separatorKey{tokens.at(0)};
|
||||
std::string separatorVal{*GetPairStringProperty(tokens.at(1))};
|
||||
if(!specialPrefixes.count(separatorKey))ERR(std::format("Could not find translation function for key {} inside special prefixes map!",separatorKey))
|
||||
else {
|
||||
AddToDescription(specialValCol.toHTMLColorCode()+specialPrefixes[separatorKey](data,separatorVal)+WHITE.toHTMLColorCode());
|
||||
return true;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
if(std::optional<std::string>unpackedVar{GetPairStringProperty(variableName)};unpackedVar){
|
||||
finalText+=specialValCol.toHTMLColorCode()+*unpackedVar+WHITE.toHTMLColorCode();
|
||||
bracesFound=false;
|
||||
variableName="";
|
||||
return true;
|
||||
}else {
|
||||
enum SymbolIndicator{
|
||||
MULTIPLICATION, //*
|
||||
KEY_VALUE_PAIR,
|
||||
ARRAY, //[
|
||||
NOT_FOUND,
|
||||
};
|
||||
|
||||
const auto AddToDescription=[&finalText,&bracesFound,&variableName](const std::string&descriptionTextAddon){
|
||||
finalText+=descriptionTextAddon;
|
||||
bracesFound=false;
|
||||
variableName="";
|
||||
};
|
||||
|
||||
SymbolIndicator indicator{NOT_FOUND};
|
||||
safemap<char,SymbolIndicator>recognizedSymbols;
|
||||
recognizedSymbols[':']=KEY_VALUE_PAIR;
|
||||
recognizedSymbols['*']=MULTIPLICATION;
|
||||
recognizedSymbols['[']=ARRAY;
|
||||
recognizedSymbols.SetInitialized();
|
||||
|
||||
for(auto&[c,symbolIndicator]:recognizedSymbols){
|
||||
if(variableName.find(c)!=std::string::npos){
|
||||
indicator=symbolIndicator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(indicator){
|
||||
case MULTIPLICATION:{
|
||||
std::vector<std::string>tokens{util::Tokenize(variableName,'*')};
|
||||
std::optional<float>numb{};
|
||||
for(const std::string&token:tokens){
|
||||
if(!numb)numb=std::stof(data.GetProperty(token).GetString());
|
||||
else *numb*=std::stof(data.GetProperty(token).GetString());
|
||||
}
|
||||
if(!numb)ERR("WARNING! Somehow did not populate a number. Variable: "<<variableName);
|
||||
AddToDescription(specialValCol.toHTMLColorCode()+std::format("{:.2f}",*numb)+WHITE.toHTMLColorCode());
|
||||
return true;
|
||||
}break;
|
||||
case KEY_VALUE_PAIR:{
|
||||
std::vector<std::string>tokens{util::Tokenize(variableName,':')};
|
||||
if(tokens.size()!=2)ERR(": variable syntax only allows 2 arguments. Ex. Key:Value. Arguments found: "<<tokens.size());
|
||||
std::string separatorKey{tokens.at(0)};
|
||||
std::string separatorVal{tokens.at(1)};
|
||||
if(!specialPrefixes.count(separatorKey))ERR(std::format("Could not find translation function for key {} inside special prefixes map!",separatorKey))
|
||||
else {
|
||||
if(!data.HasProperty(separatorVal))return false; //Could not be found in this section, will need to seek in another location.
|
||||
AddToDescription(specialValCol.toHTMLColorCode()+specialPrefixes[separatorKey](data,separatorVal)+WHITE.toHTMLColorCode());
|
||||
return true;
|
||||
}
|
||||
}break;
|
||||
case ARRAY:{
|
||||
std::vector<std::string>tokens{util::Tokenize(variableName,'[')};
|
||||
if(tokens.size()!=2)ERR("[] variable syntax only allows 2 arguments. Ex. Key[ind]. Arguments found: "<<tokens.size());
|
||||
std::string separatorKey{tokens.at(0)};
|
||||
size_t index{stoul(tokens.at(1))};
|
||||
if(!data.HasProperty(separatorKey))return false; //Could not be found in this section, will need to seek in another location.
|
||||
AddToDescription(specialValCol.toHTMLColorCode()+data.GetProperty(separatorKey).GetString(index)+WHITE.toHTMLColorCode());
|
||||
return true;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -62,7 +62,7 @@ BulletDestroyState BearTrap::MonsterHit(Monster&monster,const uint8_t markStacks
|
||||
fadeOutTime=0.5f;
|
||||
animation.ChangeState(internal_animState,"bear_trap.png");
|
||||
|
||||
const float bleedDamage{"Trapper.Ability 2.Marked Target Bleed"_f[0]/100.f*game->GetPlayer()->GetAttack()};
|
||||
const float bleedDamage{"Trapper.Ability 2.Marked Target Bleed"_f[0]*game->GetPlayer()->GetAttack()};
|
||||
float bleedDuration{"Trapper.Ability 2.Marked Target Bleed"_f[1]};
|
||||
const float timeBetweenTicks{"Trapper.Ability 2.Marked Target Bleed"_f[2]};
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 13630
|
||||
#define VERSION_BUILD 13641
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
||||
@ -32,7 +32,7 @@ Trapper
|
||||
{
|
||||
Name = Sprint
|
||||
Short Name = SPRINT
|
||||
Description = Gain 60% bonus movement speed for 3 seconds.
|
||||
Description = Gain {Movement Speed Buff[0]} bonus movement speed for {Movement Speed Buff[1]}.
|
||||
Icon = sprint.png
|
||||
Cooldown = 7s
|
||||
Mana Cost = 0
|
||||
@ -40,7 +40,7 @@ Trapper
|
||||
CancelCast = 0
|
||||
|
||||
# Movement speed increase, duration
|
||||
Movement Speed Buff = 60%, 3s
|
||||
Movement Speed Buff = 60%, 3 seconds
|
||||
|
||||
#RGB Values. Color 1 is the circle at full cooldown, Color 2 is the color at empty cooldown.
|
||||
Cooldown Bar Color 1 = 0, 0, 64, 192
|
||||
@ -54,14 +54,14 @@ Trapper
|
||||
{
|
||||
Name = Mark Target
|
||||
Short Name = MARK
|
||||
Description = Marks an enemy. Lasts 7 seconds/5 hits. Marks detonate for 60% of ATK from every hit/ability.
|
||||
Description = Marks an enemy. Lasts {Duration}/{Stack Count} hits. Marks detonate for {Damage Increase Bonus} of ATK from every hit/ability.
|
||||
Icon = mark_target.png
|
||||
Cooldown = 12
|
||||
Mana Cost = 25
|
||||
# Whether or not this ability cancels casts.
|
||||
CancelCast = 0
|
||||
|
||||
Duration = 7s
|
||||
Duration = 7 seconds
|
||||
Stack Count = 5
|
||||
Damage Increase Bonus = 60%
|
||||
|
||||
@ -77,7 +77,7 @@ Trapper
|
||||
{
|
||||
Name = Bear Trap
|
||||
Short Name = TRAP
|
||||
Description = Sets down a trap. If caught target is already marked, reapplies the mark and causes bleeding.
|
||||
Description = Sets down a trap. Deals {DamageMult:DamageMult} damage; Causes bleeding to marked targets dealing {DamageMult:Marked Target Bleed[0]} damage every {Marked Target Bleed[2]} for {Marked Target Bleed[1]}.
|
||||
Icon = bear_trap.png
|
||||
Cooldown = 15
|
||||
Mana Cost = 0
|
||||
@ -89,7 +89,7 @@ Trapper
|
||||
# What to reset the stack count to if a marked target runs into the trap.
|
||||
Marked Target Stack Count Reset = 5
|
||||
# % of Attack, Duration, Time per tick
|
||||
Marked Target Bleed = 10%, 10s, 1s
|
||||
Marked Target Bleed = 0.1x, 10 seconds, 1 second
|
||||
Trap Radius = 11px
|
||||
Knockup Amount = 0.3s
|
||||
Slowdown Amount = 100%
|
||||
|
||||
@ -53,16 +53,16 @@ David Barr, aka javidx9, <20>OneLoneCoder 2019, 2020, 2021, 2022
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "olcPixelGameEngine.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <stack>
|
||||
#include <sstream>
|
||||
#include <numeric>
|
||||
#include "Error.h"
|
||||
#include"olcPixelGameEngine.h"
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<unordered_map>
|
||||
#include<functional>
|
||||
#include<fstream>
|
||||
#include<stack>
|
||||
#include<sstream>
|
||||
#include<numeric>
|
||||
#include"Error.h"
|
||||
#include<ranges>
|
||||
#include"util.h"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user