Modified ability export to better handle numerical types, modified the settings controller to handle updated exports
This commit is contained in:
parent
33b9ab6f43
commit
2df0795b56
@ -1,158 +0,0 @@
|
|||||||
objectdef CastStackAbility
|
|
||||||
{
|
|
||||||
variable string Name
|
|
||||||
variable string AbilityTarget
|
|
||||||
variable string AbilityType
|
|
||||||
variable int Percentage
|
|
||||||
variable string Tag
|
|
||||||
|
|
||||||
method Initialize(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
This:FromJSON[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
Name:Set["${jo.Get[Name]~}"]
|
|
||||||
AbilityTarget:Set["${jo.Get[AbilityTarget]~}"]
|
|
||||||
AbilityType:Set["${jo.Get[AbilityType]~}"]
|
|
||||||
Percentage:Set[${jo.Get[Percentage]~}]
|
|
||||||
; Tag:Set["${jo.Get[Tag]~}"]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="{}"
|
|
||||||
jo:SetString[Name, "${Name~}"]
|
|
||||||
jo:SetString[AbilityTarget, "${AbilityTarget~}"]
|
|
||||||
jo:SetString[AbilityType, "${AbilityType~}"]
|
|
||||||
jo:SetString[Percentage, ${Percentage~}]
|
|
||||||
jo:SetString[Tag, "${Tag~}"]
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
objectdef CastStackContainer
|
|
||||||
{
|
|
||||||
variable index:CastStackAbility Abilities
|
|
||||||
|
|
||||||
method AddAbilityFromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[object]}
|
|
||||||
{
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
Abilities:Insert[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="[]"
|
|
||||||
variable iterator abilityIterator
|
|
||||||
Abilities:GetIterator[abilityIterator]
|
|
||||||
|
|
||||||
if ${abilityIterator:First(exists)}
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
jo:Add["${abilityIterator.Value.AsJSON~}"]
|
|
||||||
}
|
|
||||||
while ${abilityIterator:Next(exists)}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
objectdef Profile
|
|
||||||
{
|
|
||||||
variable string Name
|
|
||||||
variable jsonvalue Settings = "{}"
|
|
||||||
variable jsonvalue Setup
|
|
||||||
variable jsonvalue Aliases
|
|
||||||
variable CastStackContainer CastStack
|
|
||||||
|
|
||||||
method Initialize(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
This:FromJSON[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:bool GetSettingValue(string key)
|
|
||||||
{
|
|
||||||
echo "Profile.GetSettingValue[${key}]"
|
|
||||||
return ${This.Settings.Get["${key}"]}
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
Name:Set["${jo.Get["Name"]~}"]
|
|
||||||
Settings:SetValue["${jo.Get["Settings"]~}"]
|
|
||||||
Setup:SetValue["${jo.Get["Setup"]~}"]
|
|
||||||
Aliases:SetValue["${jo.Get["Aliases"]~}"]
|
|
||||||
jo.Get["CastStack"]:ForEach["CastStack:AddAbilityFromJSON[ForEach.Value]"]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="{}"
|
|
||||||
jo:Set["Name", "${This.Name.AsJSON~}"]
|
|
||||||
jo:Set["Settings", "${Settings.AsJSON~}"]
|
|
||||||
jo:Set["Setup", "${Setup.AsJSON~}"]
|
|
||||||
jo:Set["Aliases", "${Aliases.AsJSON~}"]
|
|
||||||
jo:Set["CastStack", "${CastStack.AsJSON~}"]
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
objectdef BotSettings
|
|
||||||
{
|
|
||||||
variable string DefaultProfile
|
|
||||||
variable collection:Profile Profiles
|
|
||||||
|
|
||||||
method FromFile(string filename)
|
|
||||||
{
|
|
||||||
variable jsonvalue settingsJson
|
|
||||||
variable BotSettings settings
|
|
||||||
settingsJson:ParseFile["${filename}"]
|
|
||||||
|
|
||||||
This:FromJSON[settingsJson]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:bool IsSettingChecked(string key)
|
|
||||||
{
|
|
||||||
echo "BotSettings.IsSettingChecked[${key}]"
|
|
||||||
return ${This.CurrentProfile.GetSettingValue["${key}"].Equal[TRUE]}
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
DefaultProfile:Set[${jo.Get["DefaultProfile"]}]
|
|
||||||
variable jsoniterator profileIterator
|
|
||||||
jo.Get["Profiles"]:GetIterator[profileIterator]
|
|
||||||
if ${profileIterator:First(exists)}
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Profiles:Set[${profileIterator.Key}, profileIterator.Value]
|
|
||||||
}
|
|
||||||
while ${profileIterator:Next(exists)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="{}"
|
|
||||||
jo:Set[DefaultProfile, "${DefaultProfile.AsJSON~}"]
|
|
||||||
jo:Set[Profiles, "${Profiles.AsJSON~}"]
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
|
|
||||||
member:weakref CurrentProfile()
|
|
||||||
{
|
|
||||||
return Profiles.Element["${This.DefaultProfile}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -64,14 +64,14 @@ function:bool hasMatchingEffect(jsonvalueref effects, jsonvalueref specialEffect
|
|||||||
function:jsonvalueref extractDamageFromEffect(jsonvalueref effectJo)
|
function:jsonvalueref extractDamageFromEffect(jsonvalueref effectJo)
|
||||||
{
|
{
|
||||||
variable string description
|
variable string description
|
||||||
|
|
||||||
description:Set["${effectJo.Get["description"]}"]
|
description:Set["${effectJo.Get["description"]}"]
|
||||||
|
|
||||||
|
|
||||||
if ${description.Left[8].NotEqual["Inflicts"]}
|
if ${description.Left[8].NotEqual["Inflicts"]}
|
||||||
{
|
{
|
||||||
return "{}"
|
return "{}"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable int64 minDamage
|
variable int64 minDamage
|
||||||
variable int64 maxDamage
|
variable int64 maxDamage
|
||||||
variable string damageType
|
variable string damageType
|
||||||
@ -91,8 +91,8 @@ function:jsonvalueref extractDamageFromEffect(jsonvalueref effectJo)
|
|||||||
variable jsonvalue damage
|
variable jsonvalue damage
|
||||||
damage:SetValue["$$>{
|
damage:SetValue["$$>{
|
||||||
"type": "${damageType}",
|
"type": "${damageType}",
|
||||||
"min": "${minDamage}",
|
"min": ${minDamage},
|
||||||
"max": "${maxDamage}"
|
"max": ${maxDamage}
|
||||||
}<$$"]
|
}<$$"]
|
||||||
|
|
||||||
if !${damageType(exists)}
|
if !${damageType(exists)}
|
||||||
@ -140,46 +140,48 @@ function main()
|
|||||||
echo "Exporting (${Counter} / ${MyAbilities.Used}) - ${MyAbilitiesIterator.Value.ToAbilityInfo.Name} (ID: ${MyAbilitiesIterator.Value.ID})"
|
echo "Exporting (${Counter} / ${MyAbilities.Used}) - ${MyAbilitiesIterator.Value.ToAbilityInfo.Name} (ID: ${MyAbilitiesIterator.Value.ID})"
|
||||||
|
|
||||||
currentAbility:SetValue["$$>{
|
currentAbility:SetValue["$$>{
|
||||||
"id": "${MyAbilitiesIterator.Value.ID}",
|
"id": ${MyAbilitiesIterator.Value.ID},
|
||||||
"name": "${MyAbilitiesIterator.Value.ToAbilityInfo.Name}",
|
"name": "${MyAbilitiesIterator.Value.ToAbilityInfo.Name}",
|
||||||
"description": ${MyAbilitiesIterator.Value.ToAbilityInfo.Description.AsJSON~},
|
"description": ${MyAbilitiesIterator.Value.ToAbilityInfo.Description.AsJSON~},
|
||||||
"level": "${MyAbilitiesIterator.Value.ToAbilityInfo.Class[${Me.SubClass}].Level}",
|
"level": ${MyAbilitiesIterator.Value.ToAbilityInfo.Class[${Me.SubClass}].Level},
|
||||||
"tier": "${MyAbilitiesIterator.Value.ToAbilityInfo.Tier}",
|
"tier": "${MyAbilitiesIterator.Value.ToAbilityInfo.Tier}",
|
||||||
"healthCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.HealthCost}",
|
"healthCost": ${MyAbilitiesIterator.Value.ToAbilityInfo.HealthCost},
|
||||||
"powerCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.PowerCost}",
|
"powerCost": ${MyAbilitiesIterator.Value.ToAbilityInfo.PowerCost},
|
||||||
"dissonanceCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.DissonanceCost}",
|
"dissonanceCost": ${MyAbilitiesIterator.Value.ToAbilityInfo.DissonanceCost},
|
||||||
"savageryCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.SavageryCost}",
|
"savageryCost": ${MyAbilitiesIterator.Value.ToAbilityInfo.SavageryCost},
|
||||||
"concentrationCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.ConcentrationCost}",
|
"concentrationCost": ${MyAbilitiesIterator.Value.ToAbilityInfo.ConcentrationCost},
|
||||||
"mainIconID": "${MyAbilitiesIterator.Value.ToAbilityInfo.MainIconID}",
|
"mainIconID": ${MyAbilitiesIterator.Value.ToAbilityInfo.MainIconID},
|
||||||
"hoIconID": "${MyAbilitiesIterator.Value.ToAbilityInfo.HOIconID}",
|
"hoIconID": ${MyAbilitiesIterator.Value.ToAbilityInfo.HOIconID},
|
||||||
"castingTime": "${MyAbilitiesIterator.Value.ToAbilityInfo.CastingTime}",
|
"castingTime": ${MyAbilitiesIterator.Value.ToAbilityInfo.CastingTime},
|
||||||
"recoveryTime": "${MyAbilitiesIterator.Value.ToAbilityInfo.RecoveryTime}",
|
"recoveryTime": ${MyAbilitiesIterator.Value.ToAbilityInfo.RecoveryTime},
|
||||||
"recastTime": "${MyAbilitiesIterator.Value.ToAbilityInfo.RecastTime}",
|
"recastTime": ${MyAbilitiesIterator.Value.ToAbilityInfo.RecastTime},
|
||||||
"maxDuration": "${MyAbilitiesIterator.Value.ToAbilityInfo.MaxDuration}",
|
"maxDuration": ${MyAbilitiesIterator.Value.ToAbilityInfo.MaxDuration},
|
||||||
"numClasses": "${MyAbilitiesIterator.Value.ToAbilityInfo.NumClasses}",
|
"numClasses": ${MyAbilitiesIterator.Value.ToAbilityInfo.NumClasses},
|
||||||
"numEffects": "${MyAbilitiesIterator.Value.ToAbilityInfo.NumEffects}",
|
"numEffects": ${MyAbilitiesIterator.Value.ToAbilityInfo.NumEffects},
|
||||||
"backDropIconID": "${MyAbilitiesIterator.Value.ToAbilityInfo.BackDropIconID}",
|
"backDropIconID": ${MyAbilitiesIterator.Value.ToAbilityInfo.BackDropIconID},
|
||||||
"healthCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.HealthCostPerTick}",
|
"healthCostPerTick": ${MyAbilitiesIterator.Value.ToAbilityInfo.HealthCostPerTick},
|
||||||
"powerCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.PowerCostPerTick}",
|
"powerCostPerTick": ${MyAbilitiesIterator.Value.ToAbilityInfo.PowerCostPerTick},
|
||||||
"dissonanceCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.DissonanceCostPerTick}",
|
"dissonanceCostPerTick": ${MyAbilitiesIterator.Value.ToAbilityInfo.DissonanceCostPerTick},
|
||||||
"savageryCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.SavageryCostPerTick}",
|
"savageryCostPerTick": ${MyAbilitiesIterator.Value.ToAbilityInfo.SavageryCostPerTick},
|
||||||
"maxAOETargets": "${MyAbilitiesIterator.Value.ToAbilityInfo.MaxAOETargets}",
|
"maxAOETargets": ${MyAbilitiesIterator.Value.ToAbilityInfo.MaxAOETargets},
|
||||||
"isBeneficial": "${MyAbilitiesIterator.Value.ToAbilityInfo.IsBeneficial}",
|
"isBeneficial": "${MyAbilitiesIterator.Value.ToAbilityInfo.IsBeneficial.AsJSON}",
|
||||||
"doesNotExpire": "${MyAbilitiesIterator.Value.ToAbilityInfo.DoesNotExpire}",
|
"doesNotExpire": "${MyAbilitiesIterator.Value.ToAbilityInfo.DoesNotExpire.AsJSON}",
|
||||||
"groupRestricted": "${MyAbilitiesIterator.Value.ToAbilityInfo.GroupRestricted}",
|
"groupRestricted": "${MyAbilitiesIterator.Value.ToAbilityInfo.GroupRestricted.AsJSON}",
|
||||||
"allowRaid": "${MyAbilitiesIterator.Value.ToAbilityInfo.AllowRaid}",
|
"allowRaid": "${MyAbilitiesIterator.Value.ToAbilityInfo.AllowRaid.AsJSON}",
|
||||||
"effectRadius": "${MyAbilitiesIterator.Value.ToAbilityInfo.EffectRadius}",
|
"effectRadius": ${MyAbilitiesIterator.Value.ToAbilityInfo.EffectRadius},
|
||||||
"targetType": "${MyAbilitiesIterator.Value.ToAbilityInfo.TargetType}",
|
"targetType": ${MyAbilitiesIterator.Value.ToAbilityInfo.TargetType},
|
||||||
"spellBookType": "${MyAbilitiesIterator.Value.ToAbilityInfo.SpellBookType}",
|
"spellBookType": ${MyAbilitiesIterator.Value.ToAbilityInfo.SpellBookType},
|
||||||
"minRange": "${MyAbilitiesIterator.Value.ToAbilityInfo.MinRange}",
|
"minRange": ${MyAbilitiesIterator.Value.ToAbilityInfo.MinRange},
|
||||||
"maxRange": "${MyAbilitiesIterator.Value.ToAbilityInfo.MaxRange}"
|
"maxRange": ${MyAbilitiesIterator.Value.ToAbilityInfo.MaxRange}
|
||||||
}<$$"]
|
}<$$"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (idx:Set[1] ; ${idx} < ${MyAbilitiesIterator.Value.ToAbilityInfo.NumEffects} ; idx:Inc )
|
for (idx:Set[1] ; ${idx} < ${MyAbilitiesIterator.Value.ToAbilityInfo.NumEffects} ; idx:Inc )
|
||||||
{
|
{
|
||||||
abilityEffect:SetValue["$$>{
|
abilityEffect:SetValue["$$>{
|
||||||
"percentSuccess": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].PercentSuccess},
|
"percentSuccess": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].PercentSuccess.AsJSON~},
|
||||||
"indentation": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].Indentation},
|
"indentation": "${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].Indentation.AsJSON~}",
|
||||||
"description": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].Description.AsJSON~}
|
"description": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].Description.AsJSON~}
|
||||||
}<$$"]
|
}<$$"]
|
||||||
|
|
||||||
@ -187,44 +189,47 @@ function main()
|
|||||||
call matchesItemInArray stealthRequiredEffects ${abilityEffect.Get["description"]}
|
call matchesItemInArray stealthRequiredEffects ${abilityEffect.Get["description"]}
|
||||||
if ${Return}
|
if ${Return}
|
||||||
{
|
{
|
||||||
currentAbility:Set["requiresStealth", ${Return}]
|
currentAbility:Set["requiresStealth", ${Return.AsJSON~}]
|
||||||
}
|
}
|
||||||
|
|
||||||
call matchesItemInArray flankingRequiredEffects ${abilityEffect.Get["description"]}
|
call matchesItemInArray flankingRequiredEffects ${abilityEffect.Get["description"]}
|
||||||
if ${Return}
|
if ${Return}
|
||||||
{
|
{
|
||||||
currentAbility:Set["requiresFlanking", ${Return}]
|
currentAbility:Set["requiresFlanking", ${Return.AsJSON~}]
|
||||||
}
|
}
|
||||||
|
|
||||||
call matchesItemInArray noEpicEffects ${abilityEffect.Get["description"]}
|
call matchesItemInArray noEpicEffects ${abilityEffect.Get["description"]}
|
||||||
if ${Return}
|
if ${Return}
|
||||||
{
|
{
|
||||||
currentAbility:Set["noEpic", ${Return}]
|
currentAbility:Set["noEpic", ${Return.AsJSON~}]
|
||||||
}
|
}
|
||||||
|
|
||||||
call matchesItemInArray stunEffects ${abilityEffect.Get["description"]}
|
call matchesItemInArray stunEffects ${abilityEffect.Get["description"]}
|
||||||
if ${Return}
|
if ${Return}
|
||||||
{
|
{
|
||||||
currentAbility:Set["stuns", ${Return}]
|
currentAbility:Set["stuns", ${Return.AsJSON~}]
|
||||||
}
|
}
|
||||||
|
|
||||||
call matchesItemInArray interruptEffects ${abilityEffect.Get["description"]}
|
call matchesItemInArray interruptEffects ${abilityEffect.Get["description"]}
|
||||||
if ${Return}
|
if ${Return}
|
||||||
{
|
{
|
||||||
currentAbility:Set["interrupts", ${Return}]
|
currentAbility:Set["interrupts", ${Return.AsJSON~}]
|
||||||
}
|
}
|
||||||
|
|
||||||
call extractDamageFromEffect abilityEffect
|
call extractDamageFromEffect abilityEffect
|
||||||
if ${Return.Get["type"](exists)}
|
if ${Return.Get["type"](exists)}
|
||||||
{
|
{
|
||||||
variable string damageType
|
variable string damageType
|
||||||
variable int64 minDamage
|
variable int64 minDamage
|
||||||
|
|
||||||
|
; TODO: Add a loop to handle multiple damage effects.
|
||||||
|
; TODO: Modify extractDmaageFromEffect to also calculate damage for
|
||||||
|
; damage over time effects.
|
||||||
damageType:Set["${Return.Get["type"]}"]
|
damageType:Set["${Return.Get["type"]}"]
|
||||||
minDamage:Set["${Return.Get["min"]}"]
|
minDamage:Set["${Return.Get["min"]}"]
|
||||||
|
|
||||||
currentAbility:Set["doesDamage", TRUE]
|
currentAbility:Set["doesDamage", TRUE]
|
||||||
if ${currentAbility.Has["damage", ${Return.Get["type"]}]}
|
if ${currentAbility.Has["damage", "${Return.Get["type"]}"]}
|
||||||
{
|
{
|
||||||
variable int64 currentMinDamageTotal
|
variable int64 currentMinDamageTotal
|
||||||
|
|
||||||
@ -251,6 +256,8 @@ function main()
|
|||||||
abilityEffect:Clear
|
abilityEffect:Clear
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
currentAbility:Set["effects", "${effects.AsJSON~}"]
|
currentAbility:Set["effects", "${effects.AsJSON~}"]
|
||||||
effects:Clear
|
effects:Clear
|
||||||
|
|
||||||
|
|||||||
@ -1,94 +0,0 @@
|
|||||||
; function main()
|
|
||||||
; {
|
|
||||||
; variable KnowledgeBook kb
|
|
||||||
; variable index:ability MyAbilities
|
|
||||||
; variable iterator MyAbilitiesIterator
|
|
||||||
; variable jsonvalue effects = []
|
|
||||||
; variable jsonvalue abilityEffect = {}
|
|
||||||
; variable int idx = 1
|
|
||||||
; variable int Counter = 1
|
|
||||||
; variable int Timer = 0
|
|
||||||
; variable jsonvalue currentAbility = {}
|
|
||||||
|
|
||||||
|
|
||||||
; Me:QueryAbilities[MyAbilities]
|
|
||||||
; MyAbilities:GetIterator[MyAbilitiesIterator]
|
|
||||||
|
|
||||||
; if ${MyAbilitiesIterator:First(exists)}
|
|
||||||
; {
|
|
||||||
; do
|
|
||||||
; {
|
|
||||||
; if (!${MyAbilitiesIterator.Value.IsAbilityInfoAvailable})
|
|
||||||
; {
|
|
||||||
; do
|
|
||||||
; {
|
|
||||||
; wait 2
|
|
||||||
; }
|
|
||||||
; while (!${MyAbilitiesIterator.Value.IsAbilityInfoAvailable} && ${Timer:Inc} < 1500)
|
|
||||||
; }
|
|
||||||
|
|
||||||
; wait 5
|
|
||||||
; echo "Exporting (${Counter} / ${MyAbilities.Size}) - ${MyAbilitiesIterator.Value.ToAbilityInfo.Name} (ID: ${MyAbilitiesIterator.Value.ID})"
|
|
||||||
|
|
||||||
; currentAbility:SetValue["$$>{
|
|
||||||
; "ID": "${MyAbilitiesIterator.Value.ID}",
|
|
||||||
; "Name": "${MyAbilitiesIterator.Value.ToAbilityInfo.Name}",
|
|
||||||
; "Description": ${MyAbilitiesIterator.Value.ToAbilityInfo.Description.AsJSON~},
|
|
||||||
; "Level": "${MyAbilitiesIterator.Value.ToAbilityInfo.Class[${Me.SubClass}].Level}",
|
|
||||||
; "Tier": "${MyAbilitiesIterator.Value.ToAbilityInfo.Tier}",
|
|
||||||
; "HealthCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.HealthCost}",
|
|
||||||
; "PowerCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.PowerCost}",
|
|
||||||
; "DissonanceCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.DissonanceCost}",
|
|
||||||
; "SavageryCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.SavageryCost}",
|
|
||||||
; "ConcentrationCost": "${MyAbilitiesIterator.Value.ToAbilityInfo.ConcentrationCost}",
|
|
||||||
; "MainIconID": "${MyAbilitiesIterator.Value.ToAbilityInfo.MainIconID}",
|
|
||||||
; "HOIconID": "${MyAbilitiesIterator.Value.ToAbilityInfo.HOIconID}",
|
|
||||||
; "CastingTime": "${MyAbilitiesIterator.Value.ToAbilityInfo.CastingTime}",
|
|
||||||
; "RecoveryTime": "${MyAbilitiesIterator.Value.ToAbilityInfo.RecoveryTime}",
|
|
||||||
; "RecastTime": "${MyAbilitiesIterator.Value.ToAbilityInfo.RecastTime}",
|
|
||||||
; "MaxDuration": "${MyAbilitiesIterator.Value.ToAbilityInfo.MaxDuration}",
|
|
||||||
; "NumClasses": "${MyAbilitiesIterator.Value.ToAbilityInfo.NumClasses}",
|
|
||||||
; "NumEffects": "${MyAbilitiesIterator.Value.ToAbilityInfo.NumEffects}",
|
|
||||||
; "BackDropIconID": "${MyAbilitiesIterator.Value.ToAbilityInfo.BackDropIconID}",
|
|
||||||
; "HealthCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.HealthCostPerTick}",
|
|
||||||
; "PowerCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.PowerCostPerTick}",
|
|
||||||
; "DissonanceCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.DissonanceCostPerTick}",
|
|
||||||
; "SavageryCostPerTick": "${MyAbilitiesIterator.Value.ToAbilityInfo.SavageryCostPerTick}",
|
|
||||||
; "MaxAOETargets": "${MyAbilitiesIterator.Value.ToAbilityInfo.MaxAOETargets}",
|
|
||||||
; "IsBeneficial": "${MyAbilitiesIterator.Value.ToAbilityInfo.IsBeneficial}",
|
|
||||||
; "DoesNotExpire": "${MyAbilitiesIterator.Value.ToAbilityInfo.DoesNotExpire}",
|
|
||||||
; "GroupRestricted": "${MyAbilitiesIterator.Value.ToAbilityInfo.GroupRestricted}",
|
|
||||||
; "AllowRaid": "${MyAbilitiesIterator.Value.ToAbilityInfo.AllowRaid}",
|
|
||||||
; "IsBeneficial": "${MyAbilitiesIterator.Value.ToAbilityInfo.IsBeneficial}",
|
|
||||||
; "EffectRadius": "${MyAbilitiesIterator.Value.ToAbilityInfo.EffectRadius}",
|
|
||||||
; "TargetType": "${MyAbilitiesIterator.Value.ToAbilityInfo.TargetType}",
|
|
||||||
; "SpellBookType": "${MyAbilitiesIterator.Value.ToAbilityInfo.SpellBookType}",
|
|
||||||
; "MinRange": "${MyAbilitiesIterator.Value.ToAbilityInfo.MinRange}",
|
|
||||||
; "MaxRange": "${MyAbilitiesIterator.Value.ToAbilityInfo.MaxRange}"
|
|
||||||
; }<$$"]
|
|
||||||
|
|
||||||
; for (idx:Set[1] ; ${idx} < ${MyAbilitiesIterator.Value.ToAbilityInfo.NumEffects} ; idx:Inc )
|
|
||||||
; {
|
|
||||||
; abilityEffect:SetValue["$$>{
|
|
||||||
; "PercentSuccess": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].PercentSuccess},
|
|
||||||
; "Indentation": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].Indentation},
|
|
||||||
; "Description": ${MyAbilitiesIterator.Value.ToAbilityInfo.Effect[${idx}].Description.AsJSON~}
|
|
||||||
; }<$$"]
|
|
||||||
|
|
||||||
; effects:Add["${abilityEffect.AsJSON~}"]
|
|
||||||
; abilityEffect:Clear
|
|
||||||
; }
|
|
||||||
|
|
||||||
; currentAbility:Set["Effects", "${effects.AsJSON~}"]
|
|
||||||
; effects:Clear
|
|
||||||
|
|
||||||
; kb:AddAbilityFromJSON[currentAbility]
|
|
||||||
|
|
||||||
; Counter:Inc
|
|
||||||
; Timer:Set[0]
|
|
||||||
; }
|
|
||||||
; while ${MyAbilitiesIterator:Next(exists)}
|
|
||||||
; }
|
|
||||||
|
|
||||||
; kb:WriteFile["${LavishScript.HomeDirectory}/Scripts/mr/bot/ability_exports/${Me.Name}_${Me.SubClass}.json"]
|
|
||||||
; }
|
|
||||||
@ -1,4 +1,3 @@
|
|||||||
#include "${LavishScript.HomeDirectory}/scripts/mr/common/KnowledgeBook.iss"
|
|
||||||
#include "${LavishScript.HomeDirectory}/scripts/mr/common/JsonHelpers.iss"
|
#include "${LavishScript.HomeDirectory}/scripts/mr/common/JsonHelpers.iss"
|
||||||
|
|
||||||
objectdef SettingsController
|
objectdef SettingsController
|
||||||
@ -15,7 +14,29 @@ objectdef SettingsController
|
|||||||
variable jsonvalue jo
|
variable jsonvalue jo
|
||||||
|
|
||||||
jo:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/ability_exports/Ihaihu_shadowknight.json"]
|
jo:ParseFile["${LavishScript.HomeDirectory}/scripts/mr/bot/ability_exports/Ihaihu_shadowknight.json"]
|
||||||
abilityListItems:SetValue["${MRJsonHelper.FilterArray[jo, "Details.SpellBookType", "<", 2].AsJSON~}"]
|
if ${jo.Type.NotEqual["object"]}
|
||||||
|
{
|
||||||
|
echo "Error parsing ability list"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
variable jsonvalueref keys
|
||||||
|
keys:SetReference[jo.Keys]
|
||||||
|
variable int idx
|
||||||
|
for (idx:Set[1] ; ${idx} < ${keys.Used} ; idx:Inc)
|
||||||
|
{
|
||||||
|
variable string key
|
||||||
|
key:Set["${keys.Get[${idx}]}"]
|
||||||
|
variable jsonvalue abilityItem = "{}"
|
||||||
|
if ${jo.Get["${key}"].Get[1, "spellBookType"]} < 2
|
||||||
|
{
|
||||||
|
abilityItem:SetValue[$$>{
|
||||||
|
"Name": "${key~}"
|
||||||
|
}<$$]
|
||||||
|
abilityListItems:Add[${abilityItem}]
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
method Shutdown()
|
method Shutdown()
|
||||||
@ -33,7 +54,6 @@ objectdef SettingsController
|
|||||||
newCastStackItem:SetValue["$$>{
|
newCastStackItem:SetValue["$$>{
|
||||||
"action": "ability",
|
"action": "ability",
|
||||||
"name": "${abilityListItems.Get[${selectedIndex}, "Name"]}"
|
"name": "${abilityListItems.Get[${selectedIndex}, "Name"]}"
|
||||||
"id": "${abilityListItems.Get[${selectedIndex}, "CurrentID"]}"
|
|
||||||
}<$$"]
|
}<$$"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,23 @@
|
|||||||
|
#ifndef _mr_json_helper_
|
||||||
|
#define _mr_json_helper_
|
||||||
objectdef MRJsonHelper
|
objectdef MRJsonHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Returns an array of property values from items from the given json array that match the given query string
|
||||||
|
;;; for example, given the following json array:
|
||||||
|
;;; [
|
||||||
|
;;; {"Id": 1, "Name": "Obj1", "Type": { "Name": "Obj1Type" }},
|
||||||
|
;;; {"Id": 2, "Name": "Obj2", "Type": { "Name": "Obj2Type" }},
|
||||||
|
;;; ]
|
||||||
|
;;; and the query string "Type.Name", the result would be:
|
||||||
|
;;; [
|
||||||
|
;;; "Obj1Type",
|
||||||
|
;;; "Obj2Type"
|
||||||
|
;;; ]
|
||||||
|
;;; @param jsonvalueref ref - The json array to query
|
||||||
|
;;; @param str queryString - The query string to use to filter the array, i.e. "Id" or "Type.Name"
|
||||||
|
;;; @return jsonvalueref An array of property values from items from the given json array that match the given query string
|
||||||
static member:jsonvalueref QueryJsonArray(jsonvalueref ref, string queryString)
|
static member:jsonvalueref QueryJsonArray(jsonvalueref ref, string queryString)
|
||||||
{
|
{
|
||||||
if !${ref.Type.Equal[array]}
|
if !${ref.Type.Equal[array]}
|
||||||
@ -51,6 +68,23 @@ objectdef MRJsonHelper
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Returns a jsonvalue that contains the value of the given property from the given json object or array.
|
||||||
|
;;; if the given jsonvalue is an array, the result will be an array of values from the given property from each item in the array
|
||||||
|
;;;
|
||||||
|
;;; for example, given the following json array:
|
||||||
|
;;; [
|
||||||
|
;;; {"Id": 1, "Name": "Obj1", "Type": { "Name": "Obj1Type" }},
|
||||||
|
;;; {"Id": 2, "Name": "Obj2", "Type": { "Name": "Obj2Type" }},
|
||||||
|
;;; ]
|
||||||
|
;;; and the query string "Type.Name", the result would be:
|
||||||
|
;;; [
|
||||||
|
;;; "Obj1Type",
|
||||||
|
;;; "Obj2Type"
|
||||||
|
;;; ]
|
||||||
|
;;; @param jsonvalueref ref - The json array to query
|
||||||
|
;;; @param str queryString - The query string to use to filter the array, i.e. "Id" or "Type.Name"
|
||||||
|
;;; @return jsonvalueref A jsonvalue that contains the value of the given property from the given json object or array.
|
||||||
static member:jsonvalueref QueryJson(jsonvalueref ref, string queryString)
|
static member:jsonvalueref QueryJson(jsonvalueref ref, string queryString)
|
||||||
{
|
{
|
||||||
if ${ref.Type.Equal[array]}
|
if ${ref.Type.Equal[array]}
|
||||||
@ -59,11 +93,6 @@ objectdef MRJsonHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static member:jsonvalueref FilterArray(jsonvalueref ref, string queryString, string operator, int value)
|
|
||||||
{
|
|
||||||
echo "int version"
|
|
||||||
}
|
|
||||||
|
|
||||||
static member:jsonvalueref FilterArray(jsonvalueref ref, string queryString, string operator, string value)
|
static member:jsonvalueref FilterArray(jsonvalueref ref, string queryString, string operator, string value)
|
||||||
{
|
{
|
||||||
if !${ref.Type.Equal[array]}
|
if !${ref.Type.Equal[array]}
|
||||||
@ -212,6 +241,7 @@ objectdef MRJsonHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
; objectdef test
|
; objectdef test
|
||||||
|
|||||||
@ -1,315 +0,0 @@
|
|||||||
#include "${LavishScript.HomeDirectory}/Scripts/mr/common/StringHelpers.iss"
|
|
||||||
|
|
||||||
objectdef AbilityEffect
|
|
||||||
{
|
|
||||||
variable int64 ID
|
|
||||||
variable int64 Indentation
|
|
||||||
variable string Description
|
|
||||||
|
|
||||||
method Initialize(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
This:FromJSON[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
echo "AbilityEffect:FromJSON ${jo.Type}"
|
|
||||||
if !${jo.Type.Equal[object]}
|
|
||||||
{
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
|
|
||||||
ID:Set["${jo.Get[ID]~}"]
|
|
||||||
Indentation:Set["${jo.Get[Indentation]~}"]
|
|
||||||
Description:Set["${jo.Get[Description]~}"]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="{}"
|
|
||||||
|
|
||||||
jo:SetInteger[ID, "${ID~}"]
|
|
||||||
jo:SetInteger[Indentation, "${Indentation~}"]
|
|
||||||
jo:SetString[Description, "${Description~}"]
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
objectdef AbilityEffectCollection
|
|
||||||
{
|
|
||||||
variable index:AbilityEffect Effects
|
|
||||||
|
|
||||||
method AddEffectFromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[object]}
|
|
||||||
{
|
|
||||||
echo "AbilityEffectCollection:AddEffectFromJSON jo is not an object"
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
|
|
||||||
Effects:Insert[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[array]}
|
|
||||||
{
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
jo:ForEach["This:AddEffectFromJSON[ForEach.Value]"]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="[]"
|
|
||||||
variable iterator effectIterator
|
|
||||||
Effects:GetIterator[effectIterator]
|
|
||||||
|
|
||||||
if ${effectIterator:First(exists)}
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
jo:Add["${effectIterator.Value.AsJSON~}"]
|
|
||||||
}
|
|
||||||
while ${effectIterator:Next(exists)}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
objectdef AbilityDetail
|
|
||||||
{
|
|
||||||
variable int64 ID
|
|
||||||
variable string Name
|
|
||||||
variable string Description
|
|
||||||
variable int Level
|
|
||||||
variable string Tier
|
|
||||||
variable int HealthCost
|
|
||||||
variable int PowerCost
|
|
||||||
variable int DissonanceCost
|
|
||||||
variable int SavageryCost
|
|
||||||
variable int ConcentrationCost
|
|
||||||
variable float CastingTime
|
|
||||||
variable float RecoveryTime
|
|
||||||
variable float RecastTime
|
|
||||||
variable float MaxDuration
|
|
||||||
variable int HealthCostPerTick
|
|
||||||
variable int PowerCostPerTick
|
|
||||||
variable int DissonanceCostPerTick
|
|
||||||
variable int SavageryCostPerTick
|
|
||||||
variable int MaxAOETargets
|
|
||||||
variable bool IsBeneficial
|
|
||||||
variable bool DoesNotExpire
|
|
||||||
variable bool GroupRestricted
|
|
||||||
variable bool AllowRaid
|
|
||||||
variable int TargetType
|
|
||||||
variable int SpellBookType
|
|
||||||
variable float MinRange
|
|
||||||
variable float MaxRange
|
|
||||||
variable AbilityEffectCollection Effects
|
|
||||||
|
|
||||||
method Initialize(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
This:FromJSON[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[object]}
|
|
||||||
{
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Name:Set["${jo.Get[Name]~}"]
|
|
||||||
Description:Set["${jo.Get[Description]~}"]
|
|
||||||
ID:Set["${jo.Get[ID]~}"]
|
|
||||||
Level:Set["${jo.Get[Level]~}"]
|
|
||||||
Tier:Set["${jo.Get[Tier]~}"]
|
|
||||||
HealthCost:Set["${jo.Get[HealthCost]~}"]
|
|
||||||
PowerCost:Set["${jo.Get[PowerCost]~}"]
|
|
||||||
DissonanceCost:Set["${jo.Get[DissonanceCost]~}"]
|
|
||||||
SavageryCost:Set["${jo.Get[SavageryCost]~}"]
|
|
||||||
ConcentrationCost:Set["${jo.Get[ConcentrationCost]~}"]
|
|
||||||
CastingTime:Set["${jo.Get[CastingTime]~}"]
|
|
||||||
RecoveryTime:Set["${jo.Get[RecoveryTime]~}"]
|
|
||||||
RecastTime:Set["${jo.Get[RecastTime]~}"]
|
|
||||||
MaxDuration:Set["${jo.Get[MaxDuration]~}"]
|
|
||||||
HealthCostPerTick:Set["${jo.Get[HealthCostPerTick]~}"]
|
|
||||||
PowerCostPerTick:Set["${jo.Get[PowerCostPerTick]~}"]
|
|
||||||
DissonanceCostPerTick:Set["${jo.Get[DissonanceCostPerTick]~}"]
|
|
||||||
SavageryCostPerTick:Set["${jo.Get[SavageryCostPerTick]~}"]
|
|
||||||
MaxAOETargets:Set["${jo.Get[MaxAOETargets]~}"]
|
|
||||||
IsBeneficial:Set["${jo.Get[IsBeneficial]~}"]
|
|
||||||
DoesNotExpire:Set["${jo.Get[DoesNotExpire]~}"]
|
|
||||||
GroupRestricted:Set["${jo.Get[GroupRestricted]~}"]
|
|
||||||
AllowRaid:Set["${jo.Get[AllowRaid]~}"]
|
|
||||||
TargetType:Set["${jo.Get[TargetType]~}"]
|
|
||||||
SpellBookType:Set["${jo.Get[SpellBookType]~}"]
|
|
||||||
MinRange:Set["${jo.Get[MinRange]~}"]
|
|
||||||
MaxRange:Set["${jo.Get[MaxRange]~}"]
|
|
||||||
Effects:FromJSON["${jo.Get["Effects"]~}"]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="{}"
|
|
||||||
|
|
||||||
jo:SetString[Name, "${Name~}"]
|
|
||||||
jo:SetString[Description, "${Description~}"]
|
|
||||||
jo:SetString[ID, "${ID~}"]
|
|
||||||
jo:SetInteger[Level, "${Level~}"]
|
|
||||||
jo:SetString[Tier, "${Tier~}"]
|
|
||||||
jo:SetInteger[HealthCost, "${HealthCost~}"]
|
|
||||||
jo:SetInteger[PowerCost, "${PowerCost~}"]
|
|
||||||
jo:SetInteger[DissonanceCost, "${DissonanceCost~}"]
|
|
||||||
jo:SetInteger[SavageryCost, "${SavageryCost~}"]
|
|
||||||
jo:SetInteger[ConcentrationCost, "${ConcentrationCost~}"]
|
|
||||||
jo:SetNumber[CastingTime, "${CastingTime~}"]
|
|
||||||
jo:SetNumber[RecoveryTime, "${RecoveryTime~}"]
|
|
||||||
jo:SetNumber[RecastTime, "${RecastTime~}"]
|
|
||||||
jo:SetNumber[MaxDuration, "${MaxDuration~}"]
|
|
||||||
jo:SetInteger[HealthCostPerTick, "${HealthCostPerTick~}"]
|
|
||||||
jo:SetInteger[PowerCostPerTick, "${PowerCostPerTick~}"]
|
|
||||||
jo:SetInteger[DissonanceCostPerTick, "${DissonanceCostPerTick~}"]
|
|
||||||
jo:SetInteger[SavageryCostPerTick, "${SavageryCostPerTick~}"]
|
|
||||||
jo:SetInteger[MaxAOETargets, "${MaxAOETargets~}"]
|
|
||||||
jo:SetBool[IsBeneficial, "${IsBeneficial~}"]
|
|
||||||
jo:SetBool[DoesNotExpire, "${DoesNotExpire~}"]
|
|
||||||
jo:SetBool[GroupRestricted, "${GroupRestricted~}"]
|
|
||||||
jo:SetBool[AllowRaid, "${AllowRaid~}"]
|
|
||||||
jo:SetInteger[TargetType, "${TargetType~}"]
|
|
||||||
jo:SetInteger[SpellBookType, "${SpellBookType~}"]
|
|
||||||
jo:SetNumber[MinRange, "${MinRange~}"]
|
|
||||||
jo:SetNumber[MaxRange, "${MaxRange~}"]
|
|
||||||
jo:Set[Effects, "${Effects.AsJSON~}"]
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
objectdef Ability
|
|
||||||
{
|
|
||||||
|
|
||||||
variable string Name
|
|
||||||
variable AbilityDetail Details
|
|
||||||
variable int HighestLevel
|
|
||||||
variable int CurrentID
|
|
||||||
|
|
||||||
method Initialize(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
This:FromJSON[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[object]}
|
|
||||||
{
|
|
||||||
echo "Ability:FromJson jo is not an object"
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
|
|
||||||
Name:Set["${jo.Get[Name]~}"]
|
|
||||||
CurrentID:Set[${jo.GetInteger["CurrentID"]}]
|
|
||||||
HighestLevel:Set[${jo.GetInteger["HighestLevel"]}]
|
|
||||||
Details:FromJSON["${jo.Get["Details"]~}"]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="{}"
|
|
||||||
|
|
||||||
jo:SetString[Name, "${Name~}"]
|
|
||||||
jo:SetInteger[CurrentID, ${CurrentID}]
|
|
||||||
jo:SetInteger[HighestLevel, ${HighestLevel}]
|
|
||||||
jo:Set[Details, "${Details.AsJSON~}"]
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
objectdef KnowledgeBook
|
|
||||||
{
|
|
||||||
variable collection:Ability Abilities
|
|
||||||
|
|
||||||
method AddAbilityFromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
variable StringHelpers stringHelpers
|
|
||||||
variable string abilityLine = "${stringHelpers.StripRomanNumerals[${jo.Get["Name"]}]}"
|
|
||||||
|
|
||||||
if ${jo.GetInteger["Level"]} < ${Abilities.Element["${abilityLine}"].HighestLevel}
|
|
||||||
{
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
variable jsonvalue tiers = "[]"
|
|
||||||
variable jsonvalue abilityLineJSON = "{}"
|
|
||||||
|
|
||||||
abilityLineJSON:SetValue[$$>"{
|
|
||||||
"Name": "${abilityLine~}",
|
|
||||||
"HighestLevel": ${jo.GetInteger["Level"]},
|
|
||||||
"CurrentID": ${jo.GetInteger["ID"]},
|
|
||||||
"Details": ${jo.AsJSON~}
|
|
||||||
}"<$$]
|
|
||||||
|
|
||||||
Abilities:Set["${abilityLine}", abilityLineJSON]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromFile(string filename)
|
|
||||||
{
|
|
||||||
variable jsonvalue jo
|
|
||||||
|
|
||||||
jo:ParseFile["${filename}"]
|
|
||||||
|
|
||||||
This:FromJSON[jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method WriteFile(string filename)
|
|
||||||
{
|
|
||||||
This.AsJSON:WriteFile["${filename}", multiline]
|
|
||||||
}
|
|
||||||
|
|
||||||
method AddAbilityLineFromJson(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[object]}
|
|
||||||
{
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
Abilities:Set[${jo.Get["Name"].AsJSON}, jo]
|
|
||||||
}
|
|
||||||
|
|
||||||
method FromJSON(jsonvalueref jo)
|
|
||||||
{
|
|
||||||
if !${jo.Type.Equal[array]}
|
|
||||||
{
|
|
||||||
echo "jo is not an array ${jo.Type}"
|
|
||||||
return FALSE
|
|
||||||
}
|
|
||||||
jo:ForEach["This:AddAbilityLineFromJson[ForEach.Value]"]
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref AsJSON()
|
|
||||||
{
|
|
||||||
variable jsonvalue jo="[]"
|
|
||||||
variable iterator abilityIterator
|
|
||||||
Abilities:GetIterator[abilityIterator]
|
|
||||||
|
|
||||||
if ${abilityIterator:First(exists)}
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
jo:Add["${abilityIterator.Value.AsJSON~}"]
|
|
||||||
}
|
|
||||||
while ${abilityIterator:Next(exists)}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +1,22 @@
|
|||||||
|
#ifndef _MR_STRING_HELPERS_
|
||||||
|
#define _MR_STRING_HELPERS_
|
||||||
objectdef MRStringHelpers
|
objectdef MRStringHelpers
|
||||||
{
|
{
|
||||||
static member:string GetLastWord(string spellName)
|
|
||||||
|
;;;
|
||||||
|
;;; Returns the last word in a string
|
||||||
|
;;; @param str The string to get the last word from
|
||||||
|
;;; @return The last word in the string
|
||||||
|
static member:string GetLastWord(string str)
|
||||||
{
|
{
|
||||||
variable int tokenCount = ${spellName.Count[" "]}
|
variable int tokenCount = ${str.Count[" "]}
|
||||||
return ${spellName.Token[${tokenCount:Inc}, " "].Trim}
|
return ${str.Token[${tokenCount:Inc}, " "].Trim}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Checks if the given string appears to be a roman numeral
|
||||||
|
;;; @param value The string to check
|
||||||
|
;;; @return TRUE if the string appears to be a roman numeral, FALSE otherwise
|
||||||
static member:bool IsRomanNumearl(string value)
|
static member:bool IsRomanNumearl(string value)
|
||||||
{
|
{
|
||||||
variable int currentIndex
|
variable int currentIndex
|
||||||
@ -20,18 +31,23 @@ objectdef MRStringHelpers
|
|||||||
return TRUE
|
return TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
static member:string StripRomanNumerals(string spellName)
|
;;;
|
||||||
|
;;; Strips roman numerals from the end of a string, andy when working with spell names
|
||||||
|
;;; @param str The string to strip roman numerals from
|
||||||
|
;;; @return The string with roman numerals stripped from the end
|
||||||
|
static member:string StripRomanNumerals(string str)
|
||||||
{
|
{
|
||||||
variable string lastWord = ${MRStringHelpers.GetLastWord[${spellName}]}
|
variable string lastWord = ${MRStringHelpers.GetLastWord[${str}]}
|
||||||
|
|
||||||
|
|
||||||
if ${MRStringHelpers.IsRomanNumearl[${lastWord}]}
|
if ${MRStringHelpers.IsRomanNumearl[${lastWord}]}
|
||||||
{
|
{
|
||||||
variable int baseStringLength
|
variable int baseStringLength
|
||||||
baseStringLength:Set[${spellName.Length} - ${lastWord.Length}]
|
baseStringLength:Set[${str.Length} - ${lastWord.Length}]
|
||||||
return ${spellName.Mid[1, ${baseStringLength}].Trim}
|
return ${str.Mid[1, ${baseStringLength}].Trim}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ${spellName}
|
return ${str}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Loading…
x
Reference in New Issue
Block a user