001package com.fs.starfarer.api.impl.campaign.procgen;
002
003import java.util.HashMap;
004import java.util.Map;
005
006import org.json.JSONException;
007import org.json.JSONObject;
008
009public class CategoryGenDataSpec {
010        private String category;
011        private float frequency;
012        
013        private Map<String, Float> multipliers = new HashMap<String, Float>();
014        
015        public CategoryGenDataSpec(JSONObject row) throws JSONException {
016                category = row.getString("category");
017                frequency = (float) row.getDouble("frequency");
018                
019                for (String key : JSONObject.getNames(row)) {
020                        float frequency = (float) row.optDouble(key, 1f);
021                        if (frequency != 1) {
022                                multipliers.put(key, frequency);
023                        }
024                        
025                }
026        }
027
028        public String toString() {
029                return getCategory();
030        }
031        
032        public String getCategory() {
033                return category;
034        }
035
036        public float getFrequency() {
037                return frequency;
038        }
039        
040        public float getMultiplier(String key) {
041                if (!multipliers.containsKey(key)) return 1f;
042                return multipliers.get(key);
043        }
044
045        public Map<String, Float> getMultipliers() {
046                return multipliers;
047        }
048        
049        
050}