recipe validation, loot pool validation, data fix
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				studiorailgun/Renderer/pipeline/head There was a failure building this commit
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	studiorailgun/Renderer/pipeline/head There was a failure building this commit
				
			This commit is contained in:
		
							parent
							
								
									6c6efbebf6
								
							
						
					
					
						commit
						5cc5ea5bc9
					
				| @ -46,17 +46,7 @@ | ||||
|             }, | ||||
|             "healthSystem" : { | ||||
|                 "maxHealth" : 5, | ||||
|                 "onDamageIFrames" : 0, | ||||
|                 "lootPool" : { | ||||
|                     "tickets" : [ | ||||
|                         { | ||||
|                             "itemId" : "mat:Rock", | ||||
|                             "rarity" : 1.0, | ||||
|                             "minQuantity" : 1, | ||||
|                             "maxQuantity" : 1 | ||||
|                         } | ||||
|                     ] | ||||
|                 } | ||||
|                 "onDamageIFrames" : 0 | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -203,7 +203,7 @@ | ||||
|                             "maxQuantity" : 5 | ||||
|                         }, | ||||
|                         { | ||||
|                             "itemId" : "block:wood", | ||||
|                             "itemId" : "block:Wood", | ||||
|                             "rarity" : 0.8, | ||||
|                             "minQuantity" : 0, | ||||
|                             "maxQuantity" : 5 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| { | ||||
|     "recipes": [ | ||||
|         { | ||||
|             "displayName": "Refiend Wood", | ||||
|             "displayName": "Refined Wood", | ||||
|             "craftingTag" : "HAND", | ||||
|             "ingredients": [ | ||||
|                 { | ||||
| @ -11,7 +11,7 @@ | ||||
|             ], | ||||
|             "products": [ | ||||
|                 { | ||||
|                     "itemType": "block:refined_wood", | ||||
|                     "itemType": "block:Wood (Refined)", | ||||
|                     "count": 16 | ||||
|                 } | ||||
|             ] | ||||
| @ -27,7 +27,7 @@ | ||||
|             ], | ||||
|             "products": [ | ||||
|                 { | ||||
|                     "itemType": "block:brick_fant", | ||||
|                     "itemType": "block:Brick (Fantasy)", | ||||
|                     "count": 16 | ||||
|                 } | ||||
|             ] | ||||
| @ -37,13 +37,13 @@ | ||||
|             "craftingTag" : "HAND", | ||||
|             "ingredients": [ | ||||
|                 { | ||||
|                     "itemType": "vox:rock_shale", | ||||
|                     "itemType": "vox:Rock (Shale)", | ||||
|                     "count": 1 | ||||
|                 } | ||||
|             ], | ||||
|             "products": [ | ||||
|                 { | ||||
|                     "itemType": "block:brick_fant", | ||||
|                     "itemType": "block:Brick (Fantasy)", | ||||
|                     "count": 16 | ||||
|                 } | ||||
|             ] | ||||
|  | ||||
| @ -1,37 +1,5 @@ | ||||
| { | ||||
|     "recipes": [ | ||||
|         { | ||||
|             "displayName": "Katana (Two Hand)", | ||||
|             "craftingTag" : "DEBUG", | ||||
|             "ingredients": [ | ||||
|                 { | ||||
|                     "itemType": "katana2H", | ||||
|                     "count": 1 | ||||
|                 } | ||||
|             ], | ||||
|             "products": [ | ||||
|                 { | ||||
|                     "itemType": "katana2H", | ||||
|                     "count": 1 | ||||
|                 } | ||||
|             ] | ||||
|         }, | ||||
|         { | ||||
|             "displayName": "Katana (One Hand)", | ||||
|             "craftingTag" : "DEBUG", | ||||
|             "ingredients": [ | ||||
|                 { | ||||
|                     "itemType": "katana", | ||||
|                     "count": 1 | ||||
|                 } | ||||
|             ], | ||||
|             "products": [ | ||||
|                 { | ||||
|                     "itemType": "katana", | ||||
|                     "count": 1 | ||||
|                 } | ||||
|             ] | ||||
|         } | ||||
|     ], | ||||
|     "files": [ | ||||
| 
 | ||||
|  | ||||
| @ -8,6 +8,7 @@ import java.util.stream.Collectors; | ||||
| 
 | ||||
| import electrosphere.data.common.CommonEntityType; | ||||
| import electrosphere.data.common.CommonEntityValidator; | ||||
| import electrosphere.data.crafting.RecipeValidator; | ||||
| import electrosphere.data.creature.CreatureData; | ||||
| import electrosphere.data.creature.CreatureDataValidator; | ||||
| import electrosphere.data.creature.CreatureTypeLoader; | ||||
| @ -27,15 +28,20 @@ public class ConfigValidator { | ||||
|         for(CreatureData creatureData : creatureTypeLoader.getTypes()){ | ||||
|             CreatureDataValidator.validate(creatureData); | ||||
|         } | ||||
| 
 | ||||
|         //validate common entity data | ||||
|         List<CommonEntityType> allData = new LinkedList<CommonEntityType>(); | ||||
|         allData.addAll(config.getCreatureTypeLoader().getTypeIds().stream().map((String id) -> {return config.getCreatureTypeLoader().getType(id);}).collect(Collectors.toList())); | ||||
|         allData.addAll(config.getFoliageMap().getTypeIds().stream().map((String id) -> {return config.getFoliageMap().getType(id);}).collect(Collectors.toList())); | ||||
|         allData.addAll(config.getItemMap().getTypeIds().stream().map((String id) -> {return config.getItemMap().getType(id);}).collect(Collectors.toList())); | ||||
|         allData.addAll(config.getObjectTypeMap().getTypeIds().stream().map((String id) -> {return config.getObjectTypeMap().getType(id);}).collect(Collectors.toList())); | ||||
|         for(CommonEntityType type : allData){ | ||||
|             CommonEntityValidator.validate(type); | ||||
|             CommonEntityValidator.validate(config, type); | ||||
|         } | ||||
| 
 | ||||
|         //validate recipes | ||||
|         RecipeValidator.validate(config); | ||||
| 
 | ||||
|         ConfigValidator.checkIdCollisions(config); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,8 @@ | ||||
| package electrosphere.data.common; | ||||
| 
 | ||||
| import electrosphere.data.Config; | ||||
| import electrosphere.data.common.life.loot.LootPool; | ||||
| import electrosphere.data.common.life.loot.LootTicket; | ||||
| import electrosphere.logger.LoggerInterface; | ||||
| 
 | ||||
| /** | ||||
| @ -9,9 +12,10 @@ public class CommonEntityValidator { | ||||
|      | ||||
|     /** | ||||
|      * Validates a common entity | ||||
|      * @param config The config | ||||
|      * @param data The data | ||||
|      */ | ||||
|     public static void validate(CommonEntityType data){ | ||||
|     public static void validate(Config config, CommonEntityType data){ | ||||
|         if(data.getId() == null || data.getId().length() == 0){ | ||||
|             String message = "Id undefined for entity type!"; | ||||
|             LoggerInterface.loggerEngine.WARNING(message); | ||||
| @ -21,6 +25,24 @@ public class CommonEntityValidator { | ||||
|             String message = "Display name undefined for entity type " + data.getId(); | ||||
|             LoggerInterface.loggerEngine.WARNING(message); | ||||
|         } | ||||
| 
 | ||||
|         //validate loot pool | ||||
|         if(data.getHealthSystem() != null && data.getHealthSystem().getLootPool() != null){ | ||||
|             CommonEntityValidator.validateLootPool(config, data.getHealthSystem().getLootPool()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Validates a loot pool | ||||
|      * @param config The config | ||||
|      * @param data The loot pool | ||||
|      */ | ||||
|     private static void validateLootPool(Config config, LootPool data){ | ||||
|         for(LootTicket ticket : data.getTickets()){ | ||||
|             if(config.getItemMap().getItem(ticket.getItemId()) == null){ | ||||
|                 throw new Error("Loot pool has undefined item: " + ticket.getItemId()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,31 @@ | ||||
| package electrosphere.data.crafting; | ||||
| 
 | ||||
| import electrosphere.data.Config; | ||||
| 
 | ||||
| /** | ||||
|  * Validates recipes | ||||
|  */ | ||||
| public class RecipeValidator { | ||||
|      | ||||
|     /** | ||||
|      * Validates all recipes in a config | ||||
|      * @param config The config | ||||
|      */ | ||||
|     public static void validate(Config config){ | ||||
|         for(RecipeData recipeData : config.getRecipeMap().getTypes()){ | ||||
|             //validate that all reagents are items in the config | ||||
|             for(RecipeIngredientData reagent : recipeData.getIngredients()){ | ||||
|                 if(config.getItemMap().getType(reagent.getItemType()) == null){ | ||||
|                     throw new Error("Item does not exist: " + reagent.getItemType()); | ||||
|                 } | ||||
|             } | ||||
|             //validate that all products are items in the config | ||||
|             for(RecipeIngredientData reagent : recipeData.getProducts()){ | ||||
|                 if(config.getItemMap().getType(reagent.getItemType()) == null){ | ||||
|                     throw new Error("Item does not exist: " + reagent.getItemType()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user