|
@@ -1,7 +1,8 @@
|
|
|
package org.leumasjaffe.charsheet.model.magic.dimension;
|
|
package org.leumasjaffe.charsheet.model.magic.dimension;
|
|
|
|
|
|
|
|
|
|
+import org.leumasjaffe.charsheet.util.StringHelper;
|
|
|
|
|
+
|
|
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|
|
-import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
|
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
|
|
|
|
|
|
|
import lombok.AccessLevel;
|
|
import lombok.AccessLevel;
|
|
@@ -9,7 +10,7 @@ import lombok.NonNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.experimental.FieldDefaults;
|
|
import lombok.experimental.FieldDefaults;
|
|
|
|
|
|
|
|
-@JsonTypeInfo(use=Id.CLASS, include=As.PROPERTY, property="class")
|
|
|
|
|
|
|
+@JsonTypeInfo(use=Id.NAME)
|
|
|
public interface Area {
|
|
public interface Area {
|
|
|
public static enum Emission { BURST, EMANATION, SPREAD, NONE }
|
|
public static enum Emission { BURST, EMANATION, SPREAD, NONE }
|
|
|
public static enum Shape { CONE, CYLINDER, LINE, SPHERE }
|
|
public static enum Shape { CONE, CYLINDER, LINE, SPHERE }
|
|
@@ -20,7 +21,8 @@ public interface Area {
|
|
|
int distance;
|
|
int distance;
|
|
|
|
|
|
|
|
public String toString() {
|
|
public String toString() {
|
|
|
- return distance + " ft. line from you";
|
|
|
|
|
|
|
+ final Range.__Pair p = new Range.__Pair(distance);
|
|
|
|
|
+ return StringHelper.format("{} {} line from you", p.value[0], p.measure);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -42,24 +44,20 @@ public interface Area {
|
|
|
boolean aroundYou;
|
|
boolean aroundYou;
|
|
|
|
|
|
|
|
public String toString() {
|
|
public String toString() {
|
|
|
|
|
+ final Range.__Pair p = new Range.__Pair(Math.max(5, radius));
|
|
|
// TODO size/level spheres like Otiluke’s Resilient Sphere PH258
|
|
// TODO size/level spheres like Otiluke’s Resilient Sphere PH258
|
|
|
- final StringBuilder str = new StringBuilder();
|
|
|
|
|
- if ( radius == 0 ) { str.append("5-ft.-diameter "); }
|
|
|
|
|
- else { str.append(radius).append("-ft.-radius "); }
|
|
|
|
|
|
|
+ return StringHelper.format(
|
|
|
|
|
+ "{}-{}-{?diameter:radius} {} {?, centered around you:}",
|
|
|
|
|
+ p.value[0], p.measure, radius == 0,
|
|
|
|
|
+ getEminationString(), aroundYou);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ private String getEminationString() {
|
|
|
switch (emit) {
|
|
switch (emit) {
|
|
|
- case NONE:
|
|
|
|
|
- str.append("sphere");
|
|
|
|
|
- break;
|
|
|
|
|
- case EMANATION:
|
|
|
|
|
- str.append("spherical ");
|
|
|
|
|
- default:
|
|
|
|
|
- str.append(emit);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ case NONE: return "sphere";
|
|
|
|
|
+ case EMANATION: return "spherical " + emit;
|
|
|
|
|
+ default: return emit.toString();
|
|
|
}
|
|
}
|
|
|
- if ( aroundYou ) { str.append(", centered around you"); }
|
|
|
|
|
-
|
|
|
|
|
- return str.toString();
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -71,10 +69,9 @@ public interface Area {
|
|
|
|
|
|
|
|
public String toString() {
|
|
public String toString() {
|
|
|
// TODO Grow by level cylinder (e.g. Control Winds PH214)
|
|
// TODO Grow by level cylinder (e.g. Control Winds PH214)
|
|
|
- final StringBuilder str = new StringBuilder("Cylinder (");
|
|
|
|
|
- str.append(radius).append("-ft. radius, ");
|
|
|
|
|
- str.append(height).append("-ft. high)");
|
|
|
|
|
- return str.toString();
|
|
|
|
|
|
|
+ final Range.__Pair p = new Range.__Pair(radius, height);
|
|
|
|
|
+ return StringHelper.format("Cylinder ({}-{2} radius, {}-{} high)",
|
|
|
|
|
+ p.value[0], p.value[1], p.measure);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|