Starsector API
Loading...
Searching...
No Matches
ObjectiveGenDataSpec.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 ObjectiveGenDataSpec {
10
11 private String id;
12 private String category;
13 private float frequency;
14 private Set<String> tags = new HashSet<String>();
15
16 public ObjectiveGenDataSpec(JSONObject row) throws JSONException {
17 id = row.getString("id");
18 category = row.getString("category");
19 frequency = (float) row.optDouble("frequency", 0);
20
21 String tags = row.optString("tags", null);
22 if (tags != null) {
23 String [] split = tags.split(",");
24 for (String tag : split) {
25 tag = tag.trim();
26 if (tag.isEmpty()) continue;
27 addTag(tag);
28 }
29 }
30 }
31
32 public String getId() {
33 return id;
34 }
35
36 public void setId(String id) {
37 this.id = id;
38 }
39
40 public String getCategory() {
41 return category;
42 }
43
44 public void setCategory(String category) {
45 this.category = category;
46 }
47
48 public float getFrequency() {
49 return frequency;
50 }
51
52 public void setFrequency(float frequency) {
53 this.frequency = frequency;
54 }
55
56 public void setTags(Set<String> tags) {
57 this.tags = tags;
58 }
59
60 public Set<String> getTags() {
61 return tags;
62 }
63
64 public void addTag(String tag) {
65 tags.add(tag);
66 }
67
68 public boolean hasTag(String tag) {
69 return tags.contains(tag);
70 }
71}