Starsector API
Loading...
Searching...
No Matches
CategoryGenDataSpec.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.procgen;
2
3import java.util.HashMap;
4import java.util.Map;
5
6import org.json.JSONException;
7import org.json.JSONObject;
8
9public class CategoryGenDataSpec {
10 private String category;
11 private float frequency;
12
13 private Map<String, Float> multipliers = new HashMap<String, Float>();
14
15 public CategoryGenDataSpec(JSONObject row) throws JSONException {
16 category = row.getString("category");
17 frequency = (float) row.getDouble("frequency");
18
19 for (String key : JSONObject.getNames(row)) {
20 float frequency = (float) row.optDouble(key, 1f);
21 if (frequency != 1) {
22 multipliers.put(key, frequency);
23 }
24
25 }
26 }
27
28 public String toString() {
29 return getCategory();
30 }
31
32 public String getCategory() {
33 return category;
34 }
35
36 public float getFrequency() {
37 return frequency;
38 }
39
40 public float getMultiplier(String key) {
41 if (!multipliers.containsKey(key)) return 1f;
42 return multipliers.get(key);
43 }
44
45 public Map<String, Float> getMultipliers() {
46 return multipliers;
47 }
48
49
50}