Example #1
0
  /** Creates a character with default traits */
  public Character(BetrayalAssetManager res) {
    id = generateRandomID();

    this.res = res;
    inventory = new Inventory(res);
    equips = new Equips(inventory, res);
    preview = new Preview(equips, res);
    job = new Job();
    stats = new Stats(equips);
    equips.setStats(stats);
    preview.update();
    room = new Room(this);
  }
Example #2
0
 @Override
 public void fromJson(JSONObject data) {
   try {
     id = data.getInt("id");
     name = data.getString("name");
     isReady = data.getBoolean("isReady");
     job.setJob(data.getString("job"));
     preview.fromJson(data.getJSONObject("preview"));
     equips.fromJson(data.getJSONObject("equips"));
     stats.fromJson(data.getJSONObject("stats"));
     inventory.fromJson(data.getJSONObject("inventory"));
     room.setRoomID(data.getInt("roomid"));
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
Example #3
0
 // Json methods
 @Override
 public JSONObject toJson() {
   JSONObject data = new JSONObject();
   try {
     data.put("id", id);
     data.put("name", name);
     data.put("job", job.toString());
     data.put("preview", preview.toJson());
     data.put("equips", equips.toJson());
     data.put("stats", stats.toJson());
     data.put("isReady", isReady);
     data.put("inventory", inventory.toJson());
     data.put("roomid", room.getRoomID());
   } catch (JSONException e) {
     e.printStackTrace();
   }
   return data;
 }