From b102f2793d39999f160acfdcc43ee19b199c80c7 Mon Sep 17 00:00:00 2001 From: Malcolm Roberts Date: Fri, 5 Jan 2024 15:55:17 -0600 Subject: [PATCH] Started working on an API, implemented ForWho I think --- common/api.iss | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ mr.iss | 2 +- test.iss | 41 ++++++---------------------- 3 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 common/api.iss diff --git a/common/api.iss b/common/api.iss new file mode 100644 index 0000000..dacf05c --- /dev/null +++ b/common/api.iss @@ -0,0 +1,72 @@ +#ifndef _mr_api_ +#define _mr_api_ +objectdef MRApi +{ + static member:bool IsForMe(string forWhoTarget) + { + variable string target = ${forWhoTarget}; + variable string prefix = ${forWhoTarget.Token[1, ":"]}; + variable bool negate = FALSE; + + + + if ${target.Count[":"]} > 0 + { + negate:Set[${prefix.Equal["not"]}] + target:Set[${forWhoTarget.Token[2, ":"]}]; + } + + echo "Target: ${target}" + echo "negate: ${negate}" + + if ${prefix.Equal["igw"]} + { + return ${Me.Group["${target}"](exists)} + } + + if ${prefix.Equal["igwbn"]} + { + + return !${Me.Name.Equal["${target}"]) && ${Me.Group["${target}"](exists)} + } + + if ${prefix.Equal["irw"]} + { + return ${Me.Raid["${target}"](exists)} + } + + if ${prefix.Equal["irwbn"]} + { + + return !${Me.Name.Equal["${target}"]) && ${Me.Raid["${target}"](exists)} + } + + if ${target.Equal["${Me.Name}"]} || ${target.Equal["all"]} + { + return !${negate}; + } + + if ${target.Equal["${Me.Class}"]} || ${target.Equal["${Me.SubClass}"]} || ${target.Equal["${Me.Archetype}"]} + { + return !${negate}; + } + + if ${target.Equal["melee"]} && (${Me.Archetype.Equal["fighter"]} || ${Me.Archetype.Equal["scout"]}) + { + echo "melee match" + return !${negate}; + } + + if ${target.Equal["caster"]} && (${Me.Archetype.Equal["mage"]} || ${Me.Archetype.Equal["priest"]}) + { + return !${negate}; + } + + return ${negate}; + + } + +} + + +#endif diff --git a/mr.iss b/mr.iss index 77838ea..5238d15 100644 --- a/mr.iss +++ b/mr.iss @@ -17,6 +17,6 @@ function main(... params) elseif ${params[1].Lower.Equal["test"]} { ConsoleClear - run mr/test + run mr/test ${params[2]} } } \ No newline at end of file diff --git a/test.iss b/test.iss index 76a7d55..afb97e3 100644 --- a/test.iss +++ b/test.iss @@ -1,39 +1,14 @@ -#include "${LavishScript.HomeDirectory}/Scripts/mr/common/KnowledgeBook.iss" +#include "${LavishScript.HomeDirectory}/Scripts/mr/common/api.iss" -function main() +function main(string forWho) { - variable jsonvalue effect - effect:SetValue[$$>{ - "description": "Inflicts 559 disease damage on targets in Area of Effect." - }<$$] - - variable string description - - description:Set["${effect.Get["description"]}"] - - if ${description.Left[8].NotEqual["Inflicts"]} + echo "Checking forWho ${forWho}" + if ${MRApi.IsForMe["${forWho}"]} { - echo "0" - return 0 + echo "This is for me!" } - - variable int64 minDamage - variable int64 maxDamage - variable string damageType - - minDamage:Set["${description.Token[2, " "].Replace[",", ""]}"] - if ${description.Token[3, " "].Equal["-"]} + else { - maxDamage:Set["${description.Token[4, " "].Replace[",", ""]}"] - damageType:Set["${description.Token[5, " "]}"] + echo "This is not for me!" } - else - { - maxDamage:Set["${description.Token[2, " "].Replace[",", ""]}"] - damageType:Set["${description.Token[3, " "]}"] - } - - echo "${description}" - echo "${minDamage} - ${maxDamage} ${damageType} damage" -} - \ No newline at end of file +} \ No newline at end of file