Starsector API
Loading...
Searching...
No Matches
LocationGenDataSpec.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.procgen;
2
3import java.util.HashSet;
4import java.util.Set;
5
6import org.json.JSONException;
7import org.json.JSONObject;
8
9public class LocationGenDataSpec {
10
11 //id tags freqYOUNG freqAVERAGE freqOLD
12
13 private String id;
14 private float freqYOUNG, freqAVERAGE, freqOLD;
15 private Set<String> tags = new HashSet<String>();
16
17 public LocationGenDataSpec(JSONObject row) throws JSONException {
18 id = row.getString("id");
19
20 freqYOUNG = (float) row.optDouble("freqYOUNG", 0);
21 freqAVERAGE = (float) row.optDouble("freqAVERAGE", 0);
22 freqOLD = (float) row.optDouble("freqOLD", 0);
23
24 String tags = row.optString("tags", null);
25 if (tags != null) {
26 String [] split = tags.split(",");
27 for (String tag : split) {
28 tag = tag.trim();
29 if (tag.isEmpty()) continue;
30 addTag(tag);
31 }
32 }
33 }
34
35 public String getId() {
36 return id;
37 }
38
39 public void setId(String id) {
40 this.id = id;
41 }
42
43 public float getFreqYOUNG() {
44 return freqYOUNG;
45 }
46
47 public void setFreqYOUNG(float freqYOUNG) {
48 this.freqYOUNG = freqYOUNG;
49 }
50
51 public float getFreqAVERAGE() {
52 return freqAVERAGE;
53 }
54
55 public void setFreqAVERAGE(float freqAVERAGE) {
56 this.freqAVERAGE = freqAVERAGE;
57 }
58
59 public float getFreqOLD() {
60 return freqOLD;
61 }
62
63 public void setFreqOLD(float freqOLD) {
64 this.freqOLD = freqOLD;
65 }
66
67 public void setTags(Set<String> tags) {
68 this.tags = tags;
69 }
70
71 public Set<String> getTags() {
72 return tags;
73 }
74
75 public void addTag(String tag) {
76 tags.add(tag);
77 }
78
79 public boolean hasTag(String tag) {
80 return tags.contains(tag);
81 }
82}