Bladeren bron

Updating the Researched (Wizard) DDSpellbook implementation to include behaviors the Wizard behaviors of:
- Knows all 0th Level Spells (Cantrips)
- Learns 2 free spells every level

Sam Jaffe 8 jaren geleden
bovenliggende
commit
726c9870aa

+ 36 - 0
resources/classes/Wizard.json

@@ -0,0 +1,36 @@
+{
+  "name":"Wizard",
+  "bab":"POOR",
+  "fort":"POOR",
+  "ref":"POOR",
+  "will":"GOOD",
+  "features":[
+    [
+      {"@c":".impl.Simple", "name":"Summon Familiar"}
+    ]
+  ],
+  "skillPoints":2,
+  "skills":[
+    "Concentration",
+    "Craft (*)",
+    "Decipher Script",
+    "Knowledge (*)",
+    "Profession (*)",
+    "Spellcraft"
+  ],
+  "spells":{
+    "spellBookTypeName":"{\"@c\":\".impl.Researched\",\"classRef\":\"Wizard\",\"freeSpellsPerLevel\":2,\"spellInfo\":{}}",
+    "group":"ARCANE",
+    "ability":"INT",
+    "known":[
+      [-1, 3]
+    ],
+    "perDay":[
+      [3, 1]
+    ],
+    "spellList":[
+      ["Create Water"],
+      ["Cure Light Wounds"]
+    ]
+  }
+}

+ 18 - 2
src/main/lombok/org/leumasjaffe/charsheet/model/magic/impl/Researched.java

@@ -5,7 +5,9 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+import org.leumasjaffe.charsheet.model.DDClass;
 import org.leumasjaffe.charsheet.model.magic.DDSpell;
+import org.leumasjaffe.charsheet.model.observable.IntValue;
 
 import lombok.AccessLevel;
 import lombok.AllArgsConstructor;
@@ -23,8 +25,22 @@ public class Researched extends Prepared {
 		@NonNull List<DDSpell> spellsPrepared, spellsPreparedPreviously;
 		@NonFinal int spellsPerDay;
 	}
-	
+
+	private static class ClassReference {
+		DDClass ref;
+		@SuppressWarnings("unused")
+		public ClassReference(String name) {
+			this.ref = DDClass.getFromResource(name);
+		}
+	}
+
+	int freeSpellsPerLevel;
 	@NonNull Map<Integer, Researched.Level> spellInfo;
+	@NonNull ClassReference classRef;
+
+	public IntValue getSharedAllowedSlots() {
+		return new IntValue(freeSpellsPerLevel);
+	}
 
 	@Override
 	public boolean learnsSpells() {
@@ -38,7 +54,7 @@ public class Researched extends Prepared {
 
 	@Override
 	public Collection<DDSpell> spellsKnownAtLevel(int level) {
-		return Collections.unmodifiableCollection(get(level).spellsKnown);
+		return level == 0 ? classRef.ref.getSpellList(0) : Collections.unmodifiableCollection(get(level).spellsKnown);
 	}
 
 	@Override