Sfoglia il codice sorgente

Adding Bard spells to Potato, as well as the technology to display them.

Sam Jaffe 8 anni fa
parent
commit
a62e103b33

+ 13 - 1
resources/Potato.json

@@ -26,7 +26,19 @@
     },
     },
     {
     {
       "level":2,
       "level":2,
-      "name":"Bard"
+      "name":"Bard",
+      "spellBook":{
+        "@type":"Spontaneous",
+        "spellInfo":{
+          "0":{
+            "spellsPerDay":3,
+            "spellsPerDayRemaining":3,
+            "spellsKnown":[
+              "Know Direction"
+            ]
+          }
+        }
+      }
     }
     }
   ],
   ],
   "race":"Half-Elemental (E)",
   "race":"Half-Elemental (E)",

+ 1 - 0
resources/classes/Bard.json

@@ -54,6 +54,7 @@
       [3, 0]
       [3, 0]
     ],
     ],
     "spellList":[
     "spellList":[
+      ["Know Direction"]
     ]
     ]
   }
   }
 }
 }

+ 12 - 0
resources/spells/default.json

@@ -12,5 +12,17 @@
     "savingThrow":"None",
     "savingThrow":"None",
     "spellResistence":false,
     "spellResistence":false,
     "description":"This spell generates wholesome, drinkable water, just like clean rain water. Water can be created in an area as small as will actually contain the liquid, or in an area three times as large—possibly creating a downpour or filling many small receptacles. Note: Conjuration spells can't create substances or objects within a creature. Water weighs about 8 pounds per gallon. One cubic foot of water contains roughly 8 gallons and weighs about 60 pounds."
     "description":"This spell generates wholesome, drinkable water, just like clean rain water. Water can be created in an area as small as will actually contain the liquid, or in an area three times as large—possibly creating a downpour or filling many small receptacles. Note: Conjuration spells can't create substances or objects within a creature. Water weighs about 8 pounds per gallon. One cubic foot of water contains roughly 8 gallons and weighs about 60 pounds."
+  },
+  "Know Direction":{
+    "name":"Know Direction",
+    "school":"Divination",
+    "keywords":[],
+    "components":["V","S"],
+    "castingTime":"Standard",
+    "range":"Personal",
+    "target":"You",
+    "duration":"Instantaneous",
+    "savingThrow":"None",
+    "description":"You instantly know the direction of north from your current position. The spell is effective in any environment in which \"north\" exists, but it may not work in extraplanar settings. Your knowledge of north is correct at the moment of casting, but you can get lost again within moments if you don’t find some external reference point to help you keep track of direction."
   }
   }
 }
 }

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

@@ -28,5 +28,9 @@ public interface DDSpellbook {
 	
 	
 	int numSpellsPerDayAtLevel( int level );
 	int numSpellsPerDayAtLevel( int level );
 	
 	
+	default int numSpellsPerDayRemainingAtLevel(int level) {
+		return spellsPreparedAtLevel( level ).size();
+	}
+	
 	void castSpell( int level, final DDSpell spell );
 	void castSpell( int level, final DDSpell spell );
 }
 }

+ 7 - 2
src/org/leumasjaffe/charsheet/model/magic/impl/Spontaneous.java

@@ -20,7 +20,7 @@ public class Spontaneous implements DDSpellbook {
 	@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
 	@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
 	private static class Level {
 	private static class Level {
 		@NonNull List<DDSpell> spellsKnown;
 		@NonNull List<DDSpell> spellsKnown;
-		@NonFinal int spellsPerDay;
+		@NonFinal int spellsPerDay, spellsPerDayRemaining;
 	}
 	}
 	
 	
 	@NonNull Map<Integer, Spontaneous.Level> spellInfo;
 	@NonNull Map<Integer, Spontaneous.Level> spellInfo;
@@ -29,6 +29,11 @@ public class Spontaneous implements DDSpellbook {
 	public int numSpellsPerDayAtLevel( int level ) {
 	public int numSpellsPerDayAtLevel( int level ) {
 		return spellInfo.get( level ).spellsPerDay;
 		return spellInfo.get( level ).spellsPerDay;
 	}
 	}
+	
+	@Override
+	public int numSpellsPerDayRemainingAtLevel( int level ) {
+		return spellInfo.get( level ).spellsPerDayRemaining;
+	}
 
 
 	@Override
 	@Override
 	public Collection<DDSpell> spellsKnownAtLevel(int level) {
 	public Collection<DDSpell> spellsKnownAtLevel(int level) {
@@ -42,6 +47,6 @@ public class Spontaneous implements DDSpellbook {
 
 
 	@Override
 	@Override
 	public void castSpell(int level, DDSpell spell) {
 	public void castSpell(int level, DDSpell spell) {
-		--spellInfo.get( level ).spellsPerDay;
+		--spellInfo.get( level ).spellsPerDayRemaining;
 	}
 	}
 }
 }

+ 5 - 0
src/org/leumasjaffe/charsheet/view/magic/SpellLevelPanel.java

@@ -14,6 +14,11 @@ import org.jdesktop.swingx.VerticalLayout;
 import org.leumasjaffe.charsheet.model.magic.DDSpell;
 import org.leumasjaffe.charsheet.model.magic.DDSpell;
 
 
 public class SpellLevelPanel extends JPanel {
 public class SpellLevelPanel extends JPanel {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
 	public SpellLevelPanel(JPanel header, Collection<DDSpell> spells) {
 	public SpellLevelPanel(JPanel header, Collection<DDSpell> spells) {
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		gridBagLayout.columnWidths = new int[]{0, 0, 0};
 		gridBagLayout.columnWidths = new int[]{0, 0, 0};

+ 4 - 5
src/org/leumasjaffe/charsheet/view/magic/SpellPanel.java

@@ -6,7 +6,6 @@ import javax.swing.JScrollPane;
 import java.awt.GridBagLayout;
 import java.awt.GridBagLayout;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.List;
 import java.util.List;
-import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.function.Function;
 
 
 import javax.swing.JTabbedPane;
 import javax.swing.JTabbedPane;
@@ -47,12 +46,12 @@ public class SpellPanel extends JPanel {
 		
 		
 		JScrollPane preparedPane = new JScrollPane();
 		JScrollPane preparedPane = new JScrollPane();
 		spellsPane.addTab("Prepared", null, preparedPane, "Spells the character can use today");
 		spellsPane.addTab("Prepared", null, preparedPane, "Spells the character can use today");
-		generateSpellTree((l, e) -> new SpellsPerDayHeader(l, e, model.numSpellsPerDayAtLevel(l)),
+		generateSpellTree((l) -> new SpellsPerDayHeader(l, model.numSpellsPerDayRemainingAtLevel(l), model.numSpellsPerDayAtLevel(l)),
 				i -> model.spellsPreparedAtLevel(i), preparedPane);
 				i -> model.spellsPreparedAtLevel(i), preparedPane);
 
 
 		JScrollPane knownPane = new JScrollPane();
 		JScrollPane knownPane = new JScrollPane();
 		spellsPane.addTab("Known", null, knownPane, "Spells the player knows for this class");
 		spellsPane.addTab("Known", null, knownPane, "Spells the player knows for this class");
-		generateSpellTree((l, e) -> new SpellsKnownHeader(l, model.numSpellsKnownAtLevel(l)), 
+		generateSpellTree((l) -> new SpellsKnownHeader(l, model.numSpellsKnownAtLevel(l)), 
 				i -> model.spellsKnownAtLevel(i), knownPane);
 				i -> model.spellsKnownAtLevel(i), knownPane);
 	}
 	}
 
 
@@ -72,14 +71,14 @@ public class SpellPanel extends JPanel {
 		return level;
 		return level;
 	}
 	}
 
 
-	private void generateSpellTree(final BiFunction<Integer, Integer, JPanel> getPanel,
+	private void generateSpellTree(final Function<Integer, JPanel> getPanel,
 			final Function<Integer, Collection<DDSpell>> getSpells, final JScrollPane preparedPane) {
 			final Function<Integer, Collection<DDSpell>> getSpells, final JScrollPane preparedPane) {
 		JPanel root = new JPanel();
 		JPanel root = new JPanel();
 		root.setLayout(new VerticalLayout());
 		root.setLayout(new VerticalLayout());
 		
 		
 		for (int i = 0; i < highestSpellLevel; ++i) {
 		for (int i = 0; i < highestSpellLevel; ++i) {
 			Collection<DDSpell> spells = getSpells.apply(i);
 			Collection<DDSpell> spells = getSpells.apply(i);
-			root.add(new SpellLevelPanel(getPanel.apply(i, spells.size()), spells));
+			root.add(new SpellLevelPanel(getPanel.apply(i), spells));
 		}
 		}
 		
 		
 		preparedPane.setViewportView(root);
 		preparedPane.setViewportView(root);