Here is the way I handled it using the foundation lmarkus built:lmarkus wrote:There are several answers to this question.
First, if you are using Plothos or Wrathgon's Spell Manager, you can just create at Special Ability (Action Point). This is fairly clean and has you and your players looking in the same place for spells and abilities.
Way back when, I implemented a token based Action Point mechanism. This requires a macro on each token that has action points, and the macro changes color (green = available, red=all out). The token macro also reports the number of APs available in the macro name. The Rest macro works with this to restore the token to 1 action point. The Action Point token macro does work if the number of available points is > 1, but I don't have anything that directly increases the quantity (but it should be straight forward as it is stored as a JSON:
Code:Code: Select all
"ActionPoint":{ "Type":"Daily", "Quantity":1, "Used":0, "ButtonLabel":"Action Point (1 left)" }
The Rest macro calls subResetDaily which is a nice base towards modifying the AP count:
Code: Select all
[H: tToken = getStrProp(macro.args, "Token")] [H: switchToken(tToken)] [H, IF(json.type(PrivateJSON) == "UNKNOWN" || json.isEmpty(PrivateJSON)), CODE: { };{ [H, FOREACH(prop, json.fields(PrivateJSON)), CODE: { [H: jO = json.get(PrivateJSON, prop)] [H: act = 0] [H, IF(json.contains(jO, "Type")): act = if(json.get(jO, "Type") == "Daily", 1, 0)] [H, IF(act): jO = json.set(jO, "Used", 0)] [H: act2 = if(prop == "ActionPoint", 1, 0)] [H, IF(act && act2): btnLbl = "Action Point (" + json.get(jO, "Quantity") + " left)"] [H, IF(act && act2): macroP = json.set("{}", "label", btnLbl, "color", "green")] [H, IF(act && act2): setMacroProps(json.get(jO, "ButtonLabel"), macroP)] [H, IF(act && act2): jO = json.set(jO, "ButtonLabel", btnLbl)] [H, IF(act): PrivateJSON = json.set(PrivateJSON, prop, jO)] }] }]
GiveActionPointJSON
Code: Select all
[H: assert( isGM(), "<b>" + getMacroName() + "</b> is a GM only macro.", 0 )]
[H: jO = "{}"]
[H, IF(json.type(PrivateJSON) == "UNKNOWN" || json.isEmpty(PrivateJSON)), CODE: {
[H: tAPq = 0]
[H: jO = json.set(jO, "Type", "Daily")]
[H: jO = json.set(jO, "Quantity", tAPq)]
[H: jO = json.set(jO, "Used", tAPq)]
[H: butLab = if(tAPq > 0, "Action Point (0 left)", "Action Point (USED)")]
[H: macroP = json.set("{}", "label", butLab)]
[H: jO = json.set(jO, "ButtonLabel", butLab)]
[H: PrivateJSON = json.set(PrivateJSON, "ActionPoint", jO)]
[H: butC = if(tAPq > 0, "green", "red")]
[H: macroP = json.set(macroP, "color", butC)]
};{
[H, IF(json.contains(PrivateJSON, "ActionPoint")), CODE: {
[H: jO = json.get(PrivateJSON, "ActionPoint")]
};{
[H: tAPq = 0]
[H: jO = json.set(jO, "Type", "Daily")]
[H: jO = json.set(jO, "Quantity", tAPq)]
[H: jO = json.set(jO, "Used", tAPq)]
[H: butLab = if(tAPq > 0, "Action Point (0 left)", "Action Point (USED)")]
[H: macroP = json.set("{}", "label", butLab)]
[H: jO = json.set(jO, "ButtonLabel", butLab)]
[H: PrivateJSON = json.set(PrivateJSON, "ActionPoint", jO)]
[H: butC = if(tAPq > 0, "green", "red")]
[H: macroP = json.set(macroP, "color", butC)]
}]
}]
[H, IF(json.contains(PrivateJSON, "ActionPoint")): jO = json.get(PrivateJSON, "ActionPoint")]
[H: tAPq = json.get(jO, "Quantity")]
[H: tAPu = json.get(jO, "Used")]
[IF(tAPq > 4), CODE: {
[G: "Player already at max Action Points!"]
};{
[H: tAPq = (tAPq +1)]
[H: jO = json.set(jO, "Quantity", tAPq)]
[H: butLab = if(tAPq > 0, "Action Point (" + (tAPq - tAPu) + " left)", "Action Point (USED)")]
[H: macroP = json.set("{}", "label", butLab)]
[H: jO = json.set(jO, "ButtonLabel", butLab)]
[H: PrivateJSON = json.set(PrivateJSON, "ActionPoint", jO)]
[H: butC = if(tAPq > 0, "green", "red")]
[H: macroP = json.set(macroP, "color", butC)]
[G: "Action Point received. Total Action Points:" + tAPq]
}]
**Tested and works fine now.