Ejemplo n.º 1
0
 public CreatureImpl(
     String name,
     Genome genome,
     Sex sex,
     GeneticMakeup makeup,
     int matingsAvailable,
     Map<String, String> properties,
     CreatureSet parents,
     Model model) {
   this.model = model;
   this.data = new JSONObject();
   data.put(NAME, Helper.wrapString(name));
   // data.put(GENOME, genome.getJSON());
   data.put(SEX, sex.getJSON());
   data.put(MAKEUP, makeup.getJSON());
   data.put(MATINGSAVAILABLE, Helper.wrapNumber(matingsAvailable));
   data.put(PROPERTIES, new JSONObject());
   data.put(PARENTS, parents != null ? parents.getJSON() : new JSONObject());
   data.put(READONLY, JSONBoolean.getInstance(false));
   addProperties(properties);
   data.put(UUID, Helper.wrapString(generateUUID()));
   model.setCreatureData(data);
 }
Ejemplo n.º 2
0
 public void setName(String name) {
   data.put(NAME, Helper.wrapString(name));
 }
Ejemplo n.º 3
0
 public String getName() {
   return Helper.unwrapString(data.get(NAME));
 }
Ejemplo n.º 4
0
 CreatureImpl(JSONObject data, Model model) {
   this.model = model;
   this.data = model.getCreatureData(Helper.unwrapString(data.get(UUID)));
 }
Ejemplo n.º 5
0
 @Override
 public String getUUID() {
   return Helper.unwrapString(data.get(UUID));
 }
Ejemplo n.º 6
0
 public void mated() {
   int matingsAvailable = getMatingsAvailable();
   matingsAvailable--;
   data.put(MATINGSAVAILABLE, Helper.wrapNumber(matingsAvailable));
   updateMatings();
 }
Ejemplo n.º 7
0
 public int getMatingsAvailable() {
   return Math.round(Helper.unwrapNumber(data.get(MATINGSAVAILABLE)));
 }