소스 검색

Fixing JSON errors for skills.
Removed redundant data.
Added class skill list.
Fixed regular expressions for skills.
Added special case for "Speak Language" bard skill, which has no associated ability.

Sam Jaffe 9 년 전
부모
커밋
b3749bbaa1

+ 8 - 8
resources/Potato.json

@@ -51,14 +51,14 @@
   },
   
   "skills":[
-    {"name":"Concentration","ability":"CON","isClassSkill":true,"requiresTraining":false,"ranks":3.0,"pointsSpent":3},
-    {"name":"Climb","ability":"INT","isClassSkill":true,"requiresTraining":false,"ranks":4.0,"pointsSpent":4},
-    {"name":"Diplomacy","ability":"CHA","isClassSkill":true,"requiresTraining":false,"ranks":1.0,"pointsSpent":1},
-    {"name":"Heal","ability":"WIS","isClassSkill":true,"requiresTraining":false,"ranks":4.0,"pointsSpent":4},
-    {"name":"Knowledege (Arcana)","ability":"INT","isClassSkill":true,"requiresTraining":true,"ranks":6.0,"pointsSpent":6},
-    {"name":"Knowledege (Religion)","ability":"INT","isClassSkill":true,"requiresTraining":true,"ranks":5.0,"pointsSpent":5},
-    {"name":"Knowledege (Nature)","ability":"INT","isClassSkill":true,"requiresTraining":true,"ranks":6.0,"pointsSpent":6},
-    {"name":"Perform (Sing)","ability":"CHA","isClassSkill":true,"requiresTraining":true,"ranks":3.0,"pointsSpent":3}
+    {"name":"Concentration","ranks":3.0,"pointsSpent":3},
+    {"name":"Craft (blacksmithing)","ranks":4.0,"pointsSpent":4},
+    {"name":"Diplomacy","ranks":1.0,"pointsSpent":1},
+    {"name":"Heal","ranks":4.0,"pointsSpent":4},
+    {"name":"Knowledge (arcana)","ranks":6.0,"pointsSpent":6},
+    {"name":"Knowledge (religion)","ranks":5.0,"pointsSpent":5},
+    {"name":"Knowledge (nature)","ranks":6.0,"pointsSpent":6},
+    {"name":"Perform (sing)","ranks":3.0,"pointsSpent":3}
   ],
   
   "inventory":{

+ 27 - 0
resources/classes/Bard.json

@@ -14,6 +14,33 @@
     ],
     []
   ],
+  "skills":[
+    "Appraise",
+    "Balance",
+    "Bluff",
+    "Climb",
+    "Concentration",
+    "Craft (*)",
+    "Decipher Script",
+    "Diplomacy",
+    "Disguise",
+    "Escape Artist",
+    "Gather Information",
+    "Hide",
+    "Jump",
+    "Knowledge (*)",
+    "Listen",
+    "Move Silently",
+    "Perform (*)",
+    "Profession (*)",
+    "Sense Motive",
+    "Sleight of Hand",
+    "Speak Language",
+    "Spellcraft",
+    "Swim",
+    "Tumble",
+    "Use Magic Device"
+  ],
   "spells":{
     "group":"ARCANE",
     "known":[

+ 12 - 0
resources/classes/Cleric.json

@@ -11,6 +11,18 @@
       }
     ]
   ],
+  "skills":[
+    "Concentration",
+    "Craft (*)",
+    "Diplomacy",
+    "Heal",
+    "Knowledge (arcana)",
+    "Knowledge (history)",
+    "Knowledge (religion)",
+    "Knowledge (the planes)",
+    "Profession (*)",
+    "Spellcraft"
+  ],
   "spells":{
     "group":"DIVINE",
     "known":[ ],

+ 1 - 0
resources/skills/skills.json

@@ -23,6 +23,7 @@
   {"name":"Search","ability":"INT","requiresTraining":false},
   {"name":"Sense Motive","ability":"WIS","requiresTraining":false},
   {"name":"Sleight of Hand","ability":"DEX","requiresTraining":true},
+  {"name":"Speak Language","requiresTraining":true},
   {"name":"Spellcraft","ability":"INT","requiresTraining":true},
   {"name":"Spot","ability":"WIS","requiresTraining":false},
   {"name":"Survival","ability":"WIS","requiresTraining":false},

+ 4 - 0
src/org/leumasjaffe/charsheet/model/DDCharacter.java

@@ -80,4 +80,8 @@ public class DDCharacter {
 	public int getWillSave() {
 		return classes.stream().mapToInt(c -> c.getWill()).sum();
 	}
+	
+	public boolean isClassSkill(final String skillName) {
+		return classes.stream().anyMatch( cc -> cc.isClassSkill(skillName) );
+	}
 }

+ 4 - 0
src/org/leumasjaffe/charsheet/model/DDCharacterClass.java

@@ -64,4 +64,8 @@ public class DDCharacterClass {
 	public int getWill() {
 		return name.base.getWill().getBonus(level);
 	}
+	
+	public boolean isClassSkill(final String skill) {
+		return name.base.isClassSkill(skill);
+	}
 }

+ 10 - 0
src/org/leumasjaffe/charsheet/model/DDClass.java

@@ -3,6 +3,7 @@ package org.leumasjaffe.charsheet.model;
 import java.io.File;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
 
 import org.leumasjaffe.charsheet.model.magic.DDSpellList;
 
@@ -30,6 +31,8 @@ public class DDClass {
 	
 	@Getter(AccessLevel.NONE) @NonNull List<List<DDFeature>> features;
 	
+	@NonNull Set<String> skills;
+	
 	@Getter(AccessLevel.NONE) @NonNull Optional<DDSpellList> spells;
 	
 	@SneakyThrows
@@ -38,4 +41,11 @@ public class DDClass {
 		mapper.registerModule(new Jdk8Module());
 		return mapper.readValue(new File("resources/classes/" + name + ".json"), DDClass.class);
 	}
+	
+	public boolean isClassSkill(final String skillName) {
+		if (skillName.contains("(")) {
+			return skills.contains(skillName) || skills.contains(skillName.replaceFirst("\\(.*\\)", "(*)"));
+		}
+		return skills.contains(skillName);
+	}
 }

+ 10 - 12
src/org/leumasjaffe/charsheet/model/skill/DDSkill.java

@@ -3,6 +3,8 @@ package org.leumasjaffe.charsheet.model.skill;
 import lombok.AccessLevel;
 import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.Getter;
+import lombok.experimental.Delegate;
 import lombok.Setter;
 import lombok.experimental.FieldDefaults;
 
@@ -10,25 +12,21 @@ import lombok.experimental.FieldDefaults;
 @Data
 @FieldDefaults(level=AccessLevel.PRIVATE)
 public class DDSkill {
-	final String name;
-	final boolean requiresTraining;
-	String ability;
+	final @Getter(AccessLevel.NONE) @Delegate DDSkillPrototype name;
 
-	boolean isClassSkill = false;
+//	boolean isClassSkill = false;
 	@Setter(value=AccessLevel.PRIVATE) float ranks = 0.0f; // realistically, int + .0/.5
 	// This would be 2x ranks if cross-class, 1x if class.
 	// Unless you gain it as a class skill later, in which case it might be in-between
 	@Setter(value=AccessLevel.PRIVATE) int pointsSpent = 0;
 	
 	public DDSkill(DDSkillPrototype proto) {
-		this.name = proto.getName();
-		this.requiresTraining = proto.isRequiresTraining();
-		this.ability = proto.getAbility();
+		this.name = proto;
 	}
 	
-	public void allocatePoints(int points) {
-		pointsSpent += points;
-		if ( isClassSkill ) { ranks += points; }
-		else { ranks += ( points / 2.0 ); }
-	}
+//	public void allocatePoints(int points) {
+//		pointsSpent += points;
+//		if ( isClassSkill ) { ranks += points; }
+//		else { ranks += ( points / 2.0 ); }
+//	}
 }

+ 8 - 1
src/org/leumasjaffe/charsheet/model/skill/DDSkillPrototype.java

@@ -42,9 +42,16 @@ public class DDSkillPrototype {
 		prototypes = Collections.unmodifiableMap(tmp);
 	}
 	
+	public DDSkillPrototype(String name) {
+		DDSkillPrototype base = getPrototype(name).get();
+		this.name = name;
+		this.requiresTraining = base.requiresTraining;
+		this.ability = base.ability;
+	}
+	
 	public static Optional<DDSkillPrototype> getPrototype(String name) {
 		if (name.contains("(")) {
-			DDSkillPrototype proto = prototypes.get(name.replaceFirst("(.*)", "(*)"));
+			DDSkillPrototype proto = prototypes.get(name.replaceFirst("\\(.*\\)", "(*)"));
 			if ( proto == null ) return Optional.empty();
 			return Optional.of(new DDSkillPrototype(name, proto.requiresTraining, proto.ability));
 		} else {

+ 25 - 14
src/org/leumasjaffe/charsheet/view/skills/SkillLine.java

@@ -8,6 +8,7 @@ import org.leumasjaffe.charsheet.model.observable.IntValue;
 import org.leumasjaffe.charsheet.model.skill.DDSkill;
 import org.leumasjaffe.charsheet.util.StringHelper;
 import org.leumasjaffe.observer.IndirectObservableListener;
+import org.leumasjaffe.observer.Observable;
 import org.leumasjaffe.observer.ObservableListener;
 
 import lombok.AccessLevel;
@@ -45,7 +46,7 @@ public class SkillLine extends JPanel {
 		
 		JCheckBox checkBoxIsClassSkill = new JCheckBox("");
 		checkBoxIsClassSkill.setToolTipText("Class Skill?");
-		checkBoxIsClassSkill.setSelected(skill.isClassSkill());
+		checkBoxIsClassSkill.setSelected(chara.isClassSkill(skill.getName()));
 		checkBoxIsClassSkill.setEnabled(false);
 		GridBagConstraints gbc_checkBoxIsClassSkill = new GridBagConstraints();
 		gbc_checkBoxIsClassSkill.insets = new Insets(1, 0, 0, 0);
@@ -158,20 +159,30 @@ public class SkillLine extends JPanel {
 		add(misc, gbc_misc);
 		misc.setColumns(10);
 		
-		totalListener = new IndirectObservableListener<>(total,
-				(c, v) -> {
-					final float skillRanks = skill.getRanks();
-					final int mod = Ability.modifier(Ability.fields.get(skill.getAbility())
-							.apply(chara.getAbilities().getBase()).value());
-					c.setText(StringHelper.toString(skillRanks + mod));
-				});
-		modifierListener = new ObservableListener<>(modifier, 
-				( c, v ) -> c.setText(StringHelper.toString(Ability.modifier(v.value()))));
 		
-		final IntValue abilScore = Ability.fields.get(skill.getAbility())
-				.apply(chara.getAbilities().getBase());
-		totalListener.setObserved(chara, abilScore);
-		modifierListener.setObserved(abilScore);
+		if ( skill.getAbility().isEmpty() ) {
+			totalListener = new IndirectObservableListener<>(total,
+					(c, v) -> {
+						c.setText(StringHelper.toString(skill.getRanks()));
+					});
+			modifierListener = null;
+			totalListener.setObserved(chara, new Observable());
+		} else {
+			totalListener = new IndirectObservableListener<>(total,
+					(c, v) -> {
+						final float skillRanks = skill.getRanks();
+						final int mod = Ability.modifier(Ability.fields.get(skill.getAbility())
+								.apply(chara.getAbilities().getBase()).value());
+						c.setText(StringHelper.toString(skillRanks + mod));
+					});
+			modifierListener = new ObservableListener<>(modifier, 
+					( c, v ) -> c.setText(StringHelper.toString(Ability.modifier(v.value()))));
+			
+			final IntValue abilScore = 	Ability.fields.get(skill.getAbility())
+					.apply(chara.getAbilities().getBase());
+			totalListener.setObserved(chara, abilScore);
+			modifierListener.setObserved(abilScore);
+		}
 	}
 	
 }