1 package org.inigma.utopia; 2 3 import java.util.Calendar; 4 import java.util.TimeZone; 5 import java.util.UUID; 6 7 public class Kingdom { 8 private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); 9 10 private String id; 11 private Coordinate location; 12 private String name; 13 private Relation relation; 14 private Stance stance; 15 private int warCount; 16 private int warNetworthDiff; 17 private int warWins; 18 private Calendar lastUpdate; 19 private long totalAcres; 20 private long totalNetworth; 21 22 public Kingdom() { 23 this(Coordinate.UNKNOWN); 24 } 25 26 public Kingdom(Coordinate cord) { 27 this.id = UUID.randomUUID().toString(); 28 this.location = cord; 29 this.stance = Stance.Normal; 30 this.relation = Relation.None; 31 this.lastUpdate = Calendar.getInstance(UTC); 32 this.lastUpdate.setTimeInMillis(0); 33 } 34 35 public String getId() { 36 return id; 37 } 38 39 public Calendar getLastUpdate() { 40 return lastUpdate; 41 } 42 43 public Coordinate getLocation() { 44 return location; 45 } 46 47 public String getName() { 48 if (name == null) { 49 return "[Unknown]"; 50 } 51 return name; 52 } 53 54 public Relation getRelation() { 55 return relation; 56 } 57 58 public Stance getStance() { 59 return stance; 60 } 61 62 public long getTotalAcres() { 63 return totalAcres; 64 } 65 66 public long getTotalNetworth() { 67 return totalNetworth; 68 } 69 70 public int getWarCount() { 71 return warCount; 72 } 73 74 public int getWarNetworthDiff() { 75 return warNetworthDiff; 76 } 77 78 public int getWarWins() { 79 return warWins; 80 } 81 82 public void setId(String id) { 83 this.id = id; 84 } 85 86 public void setLastUpdate(Calendar time) { 87 this.lastUpdate = time; 88 this.lastUpdate.setTimeZone(UTC); 89 } 90 91 public void setLocation(Coordinate location) { 92 this.location = location; 93 } 94 95 public void setName(String name) { 96 this.name = name; 97 } 98 99 public void setRelation(Relation rel) { 100 this.relation = rel; 101 } 102 103 public void setStance(Stance mode) { 104 this.stance = mode; 105 } 106 107 public void setTotalAcres(long totalAcres) { 108 this.totalAcres = totalAcres; 109 } 110 111 public void setTotalNetworth(long totalNetworth) { 112 this.totalNetworth = totalNetworth; 113 } 114 115 public void setWarCount(int warCount) { 116 this.warCount = warCount; 117 } 118 119 public void setWarNetworthDiff(int warNetworthDiff) { 120 this.warNetworthDiff = warNetworthDiff; 121 } 122 123 public void setWarWins(int winCount) { 124 this.warWins = winCount; 125 } 126 127 @Override 128 public String toString() { 129 StringBuilder sb = new StringBuilder(); 130 sb.append(name).append(" "); 131 sb.append(location); 132 return sb.toString(); 133 } 134 }