|
@@ -6,6 +6,7 @@ import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
import org.leumasjaffe.charsheet.model.observable.IntValue;
|
|
|
|
|
+import org.leumasjaffe.observer.Observable;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
@@ -13,58 +14,59 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
import lombok.AccessLevel;
|
|
import lombok.AccessLevel;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
|
-import lombok.NonNull;
|
|
|
|
|
|
|
+import lombok.EqualsAndHashCode;
|
|
|
import lombok.experimental.FieldDefaults;
|
|
import lombok.experimental.FieldDefaults;
|
|
|
|
|
|
|
|
@Data
|
|
@Data
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
public class Ability {
|
|
public class Ability {
|
|
|
- public static final Map<String, Function<Scores, IntValue>> fields;
|
|
|
|
|
|
|
+ public static final Map<String, Function<Ability, Scores>> fields;
|
|
|
|
|
|
|
|
static {
|
|
static {
|
|
|
- Map<String, Function<Scores, IntValue>> tmp = new HashMap<>();
|
|
|
|
|
- tmp.put("STR", Scores::getStr);
|
|
|
|
|
- tmp.put("DEX", Scores::getDex);
|
|
|
|
|
- tmp.put("CON", Scores::getCon);
|
|
|
|
|
- tmp.put("INT", Scores::getInt);
|
|
|
|
|
- tmp.put("WIS", Scores::getWis);
|
|
|
|
|
- tmp.put("CHA", Scores::getCha);
|
|
|
|
|
|
|
+ Map<String, Function<Ability, Scores>> tmp = new HashMap<>();
|
|
|
|
|
+ tmp.put("STR", Ability::getStr);
|
|
|
|
|
+ tmp.put("DEX", Ability::getDex);
|
|
|
|
|
+ tmp.put("CON", Ability::getCon);
|
|
|
|
|
+ tmp.put("INT", Ability::getInt);
|
|
|
|
|
+ tmp.put("WIS", Ability::getWis);
|
|
|
|
|
+ tmp.put("CHA", Ability::getCha);
|
|
|
|
|
|
|
|
fields = Collections.unmodifiableMap(tmp);
|
|
fields = Collections.unmodifiableMap(tmp);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Data
|
|
@Data
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
|
|
+ @EqualsAndHashCode(callSuper=false)
|
|
|
@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
|
|
|
- public static class Scores {
|
|
|
|
|
- IntValue str;
|
|
|
|
|
- IntValue dex;
|
|
|
|
|
- IntValue con;
|
|
|
|
|
- @JsonProperty(value="int") IntValue Int;
|
|
|
|
|
- IntValue wis;
|
|
|
|
|
- IntValue cha;
|
|
|
|
|
|
|
+ public static class Scores extends Observable {
|
|
|
|
|
+ IntValue base, temp;
|
|
|
|
|
|
|
|
@JsonCreator
|
|
@JsonCreator
|
|
|
- Scores() {
|
|
|
|
|
- this.str = new IntValue();
|
|
|
|
|
- this.dex = new IntValue();
|
|
|
|
|
- this.con = new IntValue();
|
|
|
|
|
- this.Int = new IntValue();
|
|
|
|
|
- this.wis = new IntValue();
|
|
|
|
|
- this.cha = new IntValue();
|
|
|
|
|
|
|
+ public Scores() {
|
|
|
|
|
+ this.base = new IntValue(-1);
|
|
|
|
|
+ this.temp = new IntValue(-1);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public int baseScore() { return base.value(); }
|
|
|
|
|
+ public int score() { return temp.value() == -1 ? base.value() : temp.value(); }
|
|
|
|
|
+ public int baseModifier() { return Ability.modifier(baseScore()); }
|
|
|
|
|
+ public int modifier() { return Ability.modifier(score()); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @NonNull Scores base;
|
|
|
|
|
- @NonNull Scores temp;
|
|
|
|
|
|
|
+ Scores str, dex, con, wis, cha;
|
|
|
|
|
+ @JsonProperty(value="int") Scores Int;
|
|
|
|
|
|
|
|
public Ability() {
|
|
public Ability() {
|
|
|
- this.base = new Scores();
|
|
|
|
|
- this.temp = new Scores();
|
|
|
|
|
|
|
+ this.str = new Scores();
|
|
|
|
|
+ this.dex = new Scores();
|
|
|
|
|
+ this.con = new Scores();
|
|
|
|
|
+ this.Int = new Scores();
|
|
|
|
|
+ this.wis = new Scores();
|
|
|
|
|
+ this.cha = new Scores();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static int modifier(int val) {
|
|
public static int modifier(int val) {
|
|
|
- return val / 2 - 5;
|
|
|
|
|
|
|
+ return val == -1 ? 0 : val / 2 - 5;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|