diff --git a/assets/Data/game/races.json b/assets/Data/game/races.json index e3f549f9..041b65b3 100644 --- a/assets/Data/game/races.json +++ b/assets/Data/game/races.json @@ -3,7 +3,10 @@ { "raceId" : "human", "displayName" : "Human", - "associatedCreatureId" : "human" + "associatedCreatureId" : "human", + "structureIds": [ + "defaultHouse" + ] } ] } \ No newline at end of file diff --git a/assets/Data/game/structure.json b/assets/Data/game/structure.json index 92fe89b2..d7987140 100644 --- a/assets/Data/game/structure.json +++ b/assets/Data/game/structure.json @@ -1,8 +1,9 @@ { "data" : [ { - "id" : "test1", - "fabPath" : "Data/fab/disjointedroom1.block", + "id" : "defaultHouse", + "displayName" : "Default House", + "fabPath" : "Data/fab/defaultHouse.fab", "dimensions" : { "x" : 100, "y" : 100, diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index f7aeecfa..7ffb29d9 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1867,6 +1867,7 @@ File dialog support Editor structure tab uses file dialog to save fabs Config saving Structure data saving +Validate race data diff --git a/src/main/java/electrosphere/data/Config.java b/src/main/java/electrosphere/data/Config.java index bd3d5522..5a3eb0cb 100644 --- a/src/main/java/electrosphere/data/Config.java +++ b/src/main/java/electrosphere/data/Config.java @@ -66,6 +66,10 @@ public class Config { CommonEntityMap objectTypeLoader; SymbolMap symbolMap; + + /** + * The race data + */ RaceMap raceMap; ProjectileTypeHolder projectileTypeHolder; diff --git a/src/main/java/electrosphere/data/ConfigValidator.java b/src/main/java/electrosphere/data/ConfigValidator.java index c2da9d95..d0c6f81f 100644 --- a/src/main/java/electrosphere/data/ConfigValidator.java +++ b/src/main/java/electrosphere/data/ConfigValidator.java @@ -12,6 +12,7 @@ import electrosphere.data.crafting.RecipeValidator; import electrosphere.data.creature.CreatureData; import electrosphere.data.creature.CreatureDataValidator; import electrosphere.data.creature.CreatureTypeLoader; +import electrosphere.server.macro.race.RaceValidator; /** * Used to validate the config @@ -42,6 +43,9 @@ public class ConfigValidator { //validate recipes RecipeValidator.validate(config); + //validate races + RaceValidator.validate(config); + ConfigValidator.checkIdCollisions(config); } diff --git a/src/main/java/electrosphere/data/struct/StructureData.java b/src/main/java/electrosphere/data/struct/StructureData.java index 361d5631..3bfef2b0 100644 --- a/src/main/java/electrosphere/data/struct/StructureData.java +++ b/src/main/java/electrosphere/data/struct/StructureData.java @@ -12,6 +12,11 @@ public class StructureData { */ String id; + /** + * The display name of the structure + */ + String displayName; + /** * The path to the fab for the structure */ @@ -35,6 +40,22 @@ public class StructureData { return id; } + /** + * Gets the display name of the structure + * @return The display name + */ + public String getDisplayName(){ + return displayName; + } + + /** + * Sets the display name of the structure + * @param name The display name + */ + public void setDisplayName(String name){ + this.displayName = name; + } + /** * Gets the path to the fab for the structure * @return The path diff --git a/src/main/java/electrosphere/server/macro/race/Race.java b/src/main/java/electrosphere/server/macro/race/Race.java index 6f6551e6..ff50ad5d 100644 --- a/src/main/java/electrosphere/server/macro/race/Race.java +++ b/src/main/java/electrosphere/server/macro/race/Race.java @@ -1,5 +1,7 @@ package electrosphere.server.macro.race; +import java.util.List; + import electrosphere.server.macro.character.Character; import electrosphere.server.macro.character.data.CharacterData; import electrosphere.server.macro.character.data.CharacterDataStrings; @@ -14,11 +16,21 @@ public class Race extends CharacterData { */ String raceId; + /** + * Display name of the race + */ + String displayName; + /** * The associated creature for the race */ String associatedCreatureId; + /** + * The list of structures that this race uses + */ + List structureIds; + /** * Constructor */ @@ -41,6 +53,22 @@ public class Race extends CharacterData { public String getAssociatedCreature() { return associatedCreatureId; } + + /** + * The display name for the race + * @return The display name + */ + public String getDisplayName() { + return displayName; + } + + /** + * The list of structure IDs that this race uses + * @return The list of structure IDs + */ + public List getStructureIds() { + return structureIds; + } /** * Creates a race diff --git a/src/main/java/electrosphere/server/macro/race/RaceValidator.java b/src/main/java/electrosphere/server/macro/race/RaceValidator.java new file mode 100644 index 00000000..95cba42d --- /dev/null +++ b/src/main/java/electrosphere/server/macro/race/RaceValidator.java @@ -0,0 +1,30 @@ +package electrosphere.server.macro.race; + +import electrosphere.data.Config; + +/** + * Validates race data + */ +public class RaceValidator { + + /** + * Validates a config + * @param config The config + */ + public static void validate(Config config){ + for(Race race : config.getRaceMap().getRaces()){ + //check associated creature + if(config.getCreatureTypeLoader().getType(race.getAssociatedCreature()) == null){ + throw new Error("Race " + race.raceId + " creature does not exist: " + race.getAssociatedCreature()); + } + + //check associated structures + for(String structureId : race.getStructureIds()){ + if(config.getStructureData().getType(structureId) == null){ + throw new Error("Race " + race.raceId + " structure id does not correspond to a structure: " + structureId); + } + } + } + } + +}