فهرست منبع

Removing redundant information from spell list; changing from [map spell.name -> spell] to [array spell]

(cherry picked from commit f445d27fd87189f4747a5589bb8289a85de6df56)
Samuel Jaffe 8 سال پیش
والد
کامیت
187c485474
2فایلهای تغییر یافته به همراه11 افزوده شده و 9 حذف شده
  1. 6 6
      resources/spells/default.json
  2. 5 3
      src/main/lombok/org/leumasjaffe/charsheet/model/magic/DDSpellFactory.java

+ 6 - 6
resources/spells/default.json

@@ -1,5 +1,5 @@
-{
-  "Create Water":{
+[
+  {
     "name":"Create Water",
     "classToLevel":{
       "Cleric":0,
@@ -22,7 +22,7 @@
     "allowsSpellResistance":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."
   },
-  "Cure Light Wounds":{
+  {
     "name":"Cure Light Wounds",
     "classToLevel":{
       "Bard":1,
@@ -50,7 +50,7 @@
     "allowsSpellResistance":true,
     "description":"When laying your hand upon a living creature, you channel positive energy that cures 1d8 points of damage +1 point per caster level (maximum +5). Since undead are powered by negative energy, this spell deals damage to them instead of curing their wounds. An undead creature can apply spell resistance, and can attempt a Will save to take half damage."
   },
-  "Flame Strike":{
+  {
     "name":"Flame Strike",
     "classToLevel":{
       "Cleric":5,
@@ -79,7 +79,7 @@
     "allowsSpellResistance":false,
     "description":"A flame strike produces a vertical column of divine fire roaring downward. The spell deals 1d6 points of damage per caster level (maximum 15d6). Half the damage is fire damage, but the other half results directly from divine power and is therefore not subject to being reduced by resistance to fire-based attacks, such as that granted by protection from energy (fire), fire shield (chill shield), and similar magic."
   },
-  "Know Direction":{
+  {
     "name":"Know Direction",
     "classToLevel":{
       "Bard":0,
@@ -95,4 +95,4 @@
     "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."
   }
-}
+]

+ 5 - 3
src/main/lombok/org/leumasjaffe/charsheet/model/magic/DDSpellFactory.java

@@ -1,8 +1,10 @@
 package org.leumasjaffe.charsheet.model.magic;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -42,11 +44,11 @@ public final class DDSpellFactory {
 	@Synchronized
 	@SneakyThrows
 	private void loadIfAbsent(final String rname) {
-		final Map<String, DDSpell> temp = mapper.readValue(
+		final List<DDSpell> temp = mapper.readValue(
 				new File(rname),
-				new TypeReference<Map<String, DDSpell>>() {
+				new TypeReference<ArrayList<DDSpell>>() {
 				});
 		resourcesLoaded.add(rname);
-		spellStore.putAll(temp);
+		temp.forEach(s -> spellStore.put(s.getName(), s));
 	}
 }