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 LocationGenDataSpec {
010
011        //id    tags    freqYOUNG       freqAVERAGE     freqOLD
012        
013        private String id;
014        private float freqYOUNG, freqAVERAGE, freqOLD;
015        private Set<String> tags = new HashSet<String>();
016        
017        public LocationGenDataSpec(JSONObject row) throws JSONException {
018                id = row.getString("id");
019                
020                freqYOUNG = (float) row.optDouble("freqYOUNG", 0);
021                freqAVERAGE = (float) row.optDouble("freqAVERAGE", 0);
022                freqOLD = (float) row.optDouble("freqOLD", 0);
023                
024                String tags = row.optString("tags", null);
025                if (tags != null) {
026                        String [] split = tags.split(",");
027                        for (String tag : split) {
028                                tag = tag.trim();
029                                if (tag.isEmpty()) continue;
030                                addTag(tag);
031                        }
032                }
033        }
034
035        public String getId() {
036                return id;
037        }
038
039        public void setId(String id) {
040                this.id = id;
041        }
042
043        public float getFreqYOUNG() {
044                return freqYOUNG;
045        }
046
047        public void setFreqYOUNG(float freqYOUNG) {
048                this.freqYOUNG = freqYOUNG;
049        }
050
051        public float getFreqAVERAGE() {
052                return freqAVERAGE;
053        }
054
055        public void setFreqAVERAGE(float freqAVERAGE) {
056                this.freqAVERAGE = freqAVERAGE;
057        }
058
059        public float getFreqOLD() {
060                return freqOLD;
061        }
062
063        public void setFreqOLD(float freqOLD) {
064                this.freqOLD = freqOLD;
065        }
066
067        public void setTags(Set<String> tags) {
068                this.tags = tags;
069        }
070
071        public Set<String> getTags() {
072                return tags;
073        }
074        
075        public void addTag(String tag) {
076                tags.add(tag);
077        }
078
079        public boolean hasTag(String tag) {
080                return tags.contains(tag);
081        }
082}