001package com.fs.starfarer.api.impl.campaign.procgen;
002
003import java.util.HashSet;
004import java.util.Set;
005
006import org.json.JSONException;
007import org.json.JSONObject;
008
009public class ObjectiveGenDataSpec {
010
011        private String id;
012        private String category;
013        private float frequency;
014        private Set<String> tags = new HashSet<String>();
015        
016        public ObjectiveGenDataSpec(JSONObject row) throws JSONException {
017                id = row.getString("id");
018                category = row.getString("category");
019                frequency = (float) row.optDouble("frequency", 0);
020                
021                String tags = row.optString("tags", null);
022                if (tags != null) {
023                        String [] split = tags.split(",");
024                        for (String tag : split) {
025                                tag = tag.trim();
026                                if (tag.isEmpty()) continue;
027                                addTag(tag);
028                        }
029                }
030        }
031
032        public String getId() {
033                return id;
034        }
035
036        public void setId(String id) {
037                this.id = id;
038        }
039
040        public String getCategory() {
041                return category;
042        }
043
044        public void setCategory(String category) {
045                this.category = category;
046        }
047
048        public float getFrequency() {
049                return frequency;
050        }
051
052        public void setFrequency(float frequency) {
053                this.frequency = frequency;
054        }
055
056        public void setTags(Set<String> tags) {
057                this.tags = tags;
058        }
059
060        public Set<String> getTags() {
061                return tags;
062        }
063        
064        public void addTag(String tag) {
065                tags.add(tag);
066        }
067
068        public boolean hasTag(String tag) {
069                return tags.contains(tag);
070        }
071}