Skip to content

Commit

Permalink
Changed getInfo("server") macro to use ServerPolicy.toJSON directly (#…
Browse files Browse the repository at this point in the history
…738)

Updated getInfo("server") macro function to pull JSON object from ServerPolicy instead of having duplicated code.
Updated ServerPolicy.toJSON() to include isAutoRevealMovement and isUseIndividualFOW.
  • Loading branch information
Phergus authored and JamzTheMan committed Sep 23, 2019
1 parent a9ae928 commit 68706c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.ui.token.BarTokenOverlay;
import net.rptools.maptool.client.ui.token.BooleanTokenOverlay;
import net.rptools.maptool.client.ui.tokenpanel.InitiativePanel;
import net.rptools.maptool.client.ui.zone.ZoneRenderer;
import net.rptools.maptool.client.walker.WalkerMetric;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.Campaign;
import net.rptools.maptool.model.CampaignProperties;
Expand Down Expand Up @@ -203,47 +201,10 @@ private String getTimeDate() {
* @return the server side preferences
*/
private JSONObject getServerInfo() {
Map<String, Object> sinfo = new HashMap<String, Object>();
ServerPolicy sp = MapTool.getServerPolicy();
JSONObject sinfo = sp.toJSON();

sinfo.put(
"tooltips for default roll format",
sp.getUseToolTipsForDefaultRollFormat() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"players can reveal", sp.getPlayersCanRevealVision() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"auto reveal on movement", sp.isAutoRevealOnMovement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("movement locked", sp.isMovementLocked() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"restricted impersonation",
sp.isRestrictedImpersonation() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual views", sp.isUseIndividualViews() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual fow", sp.isUseIndividualFOW() ? BigDecimal.ONE : BigDecimal.ZERO);

sinfo.put(
"strict token management",
sp.useStrictTokenManagement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"players receive campaign macros",
sp.playersReceiveCampaignMacros() ? BigDecimal.ONE : BigDecimal.ZERO);
WalkerMetric metric =
MapTool.isPersonalServer()
? AppPreferences.getMovementMetric()
: MapTool.getServerPolicy().getMovementMetric();
sinfo.put("movement metric", metric.toString());

sinfo.put("timeInMs", sp.getSystemTime());
sinfo.put("timeDate", sp.getTimeDate());

sinfo.put("gm", MapTool.getGMs());

InitiativePanel ip = MapTool.getFrame().getInitiativePanel();
if (ip != null) {
sinfo.put(
"initiative owner permissions",
ip.isOwnerPermissions() ? BigDecimal.ONE : BigDecimal.ZERO);
}
return JSONObject.fromObject(sinfo);
return (sinfo);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/rptools/maptool/server/ServerPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ public JSONObject toJSON() {
"GM reveals vision for unowned tokens",
getGmRevealsVisionForUnownedTokens() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("players can reveal", getPlayersCanRevealVision() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"auto reveal on movement", isAutoRevealOnMovement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("movement locked", isMovementLocked() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"restricted impersonation", isRestrictedImpersonation() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual views", isUseIndividualViews() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual fow", isUseIndividualFOW() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"strict token management", useStrictTokenManagement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
Expand Down

0 comments on commit 68706c6

Please sign in to comment.