Skip to content

Commit

Permalink
Fix up sights in getInfo("campaign")
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvanderlinde committed Dec 1, 2023
1 parent cbbbc5b commit faeb004
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.rptools.maptool.model.Light;
import net.rptools.maptool.model.LightSource;
import net.rptools.maptool.model.LookupTable;
import net.rptools.maptool.model.ShapeType;
import net.rptools.maptool.model.SightType;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
Expand Down Expand Up @@ -358,7 +359,7 @@ private JsonObject getCampaignInfo() throws ParserException {
JsonObject linfo = new JsonObject();
linfo.addProperty("name", ls.getName());
linfo.addProperty("max range", ls.getMaxRange());
linfo.addProperty("type", ls.getType().toString());
linfo.addProperty("type", ls.getType().name());
linfo.addProperty("scale", ls.isScaleWithToken());
// List<Light> lights = new ArrayList<Light>();
// for (Light light : ls.getLightList()) {
Expand Down Expand Up @@ -420,11 +421,28 @@ private JsonObject getCampaignInfo() throws ParserException {
JsonObject sightInfo = new JsonObject();
for (SightType sightType : c.getSightTypeMap().values()) {
JsonObject si = new JsonObject();
si.addProperty("arc", sightType.getArc());
si.addProperty("distance", sightType.getArc());
if (sightType.getShape() == ShapeType.BEAM) {
si.addProperty("width", sightType.getWidth());
si.addProperty("offset", sightType.getOffset());
}
if (sightType.getShape() == ShapeType.CONE) {
si.addProperty("arc", sightType.getArc());
si.addProperty("offset", sightType.getOffset());
}
si.addProperty("distance", sightType.getDistance());
si.addProperty("multiplier", sightType.getMultiplier());
si.addProperty("shape", sightType.getShape().toString());
si.addProperty("type", sightType.getOffset());
si.addProperty("shape", sightType.getShape().name());
si.addProperty("scale", sightType.isScaleWithToken());

JsonArray lightList = null;
if (sightType.getPersonalLightSource() != null) {
lightList = new JsonArray();
for (Light light : sightType.getPersonalLightSource().getLightList()) {
lightList.add(gson.toJsonTree(light));
}
}
si.add("personal lights", lightList);

sightInfo.add(sightType.getName(), si);
}
cinfo.add("sight", sightInfo);
Expand Down

0 comments on commit faeb004

Please sign in to comment.