Skip to content

Commit

Permalink
Completed
Browse files Browse the repository at this point in the history
Cleanup and JS Token Functions
  • Loading branch information
ColdAnkles committed Dec 19, 2024
1 parent 7c55046 commit 581a103
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -668,39 +668,31 @@ public void childEvaluateSetTopologyImmunity(
for (JsonElement entry : setList) {
newSet.add(entry.getAsString());
}
// token.setTokenVBLImmunity(newSet);
MapTool.serverCommand()
.updateTokenProperty(
token, Token.Update.setTokenVBLImmunity, newSet.toString().replaceAll("^\\[|]$", ""));
} else if (functionName.equalsIgnoreCase("addTokenVBLImmunity")) {
// token.addTokenVBLImmunity(parameters.get(1).toString());
MapTool.serverCommand()
.updateTokenProperty(
token, Token.Update.addTokenVBLImmunity, parameters.get(1).toString());
} else if (functionName.equalsIgnoreCase("removeTokenVBLImmunity")) {
// token.removeTokenVBLImmunity(parameters.get(1).toString());
MapTool.serverCommand()
.updateTokenProperty(
token, Token.Update.removeTokenVBLImmunity, parameters.get(1).toString());
} else if (functionName.equalsIgnoreCase("setGlobalVBLImmunity")) {
// token.setGlobalVBLImmunity(parameters.get(1).toString(),
// BigDecimal.ONE.equals(parameters.get(2)));
MapTool.serverCommand()
.updateTokenProperty(
token,
Token.Update.setGlobalVBLImmunity,
parameters.get(1).toString(),
BigDecimal.ONE.equals(parameters.get(2)));
} else if (functionName.equalsIgnoreCase("toggleGlobalVBLImmunity")) {
// token.toggleGlobalVBLImmunity(parameters.get(1).toString());
MapTool.serverCommand()
.updateTokenProperty(
token, Token.Update.toggleGlobalVBLImmunity, parameters.get(1).toString());
} else if (functionName.equalsIgnoreCase("clearTokenVBLImmunity")) {
// token.clearTokenVBLImmunity();
MapTool.serverCommand().updateTokenProperty(token, Token.Update.clearTokenVBLImmunity);
} else if (functionName.equalsIgnoreCase("clearGlobalVBLImmunity")) {
// token.clearGlobalVBLImmunity();
MapTool.serverCommand().updateTokenProperty(token, Token.Update.clearGlobalVBLImmunity);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package net.rptools.maptool.client.script.javascript.api;

import com.google.gson.JsonArray;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -350,4 +351,63 @@ public void setNPC() {
public String getType() {
return this.token.getType().name();
}

@HostAccess.Export
public String getGlobalVBLImmunity() {
JsonArray returnValue = new JsonArray();
token
.getGlobalVBLImmunity()
.forEach(
(key, value) -> {
if (value) {
returnValue.add(key);
}
});
return returnValue.toString();
}

@HostAccess.Export
public String getTokenVBLImmunity() {
JsonArray returnValue = new JsonArray();
token
.getTokenVBLImmunity()
.forEach(
(value) -> {
returnValue.add(value);
});
return returnValue.toString();
}

@HostAccess.Export
public void setGlobalVBLImmunity(String vblSelector, boolean setTo) {
MapTool.serverCommand()
.updateTokenProperty(token, Token.Update.setGlobalVBLImmunity, vblSelector, setTo);
}

@HostAccess.Export
public void toggleGlobalVBLImmunity(String vblSelector) {
MapTool.serverCommand()
.updateTokenProperty(token, Token.Update.toggleGlobalVBLImmunity, vblSelector);
}

@HostAccess.Export
public void addTokenVBLImmunity(String tokenID) {
MapTool.serverCommand().updateTokenProperty(token, Token.Update.addTokenVBLImmunity, tokenID);
}

@HostAccess.Export
public void removeTokenVBLImmunity(String tokenID) {
MapTool.serverCommand()
.updateTokenProperty(token, Token.Update.removeTokenVBLImmunity, tokenID);
}

@HostAccess.Export
public void clearTokenVBLImmunity() {
MapTool.serverCommand().updateTokenProperty(token, Token.Update.clearTokenVBLImmunity);
}

@HostAccess.Export
public void clearGlobalVBLImmunity() {
MapTool.serverCommand().updateTokenProperty(token, Token.Update.clearGlobalVBLImmunity);
}
}

0 comments on commit 581a103

Please sign in to comment.