Exemplo n.º 1
0
  private Player loadPlayerStatus(BufferedReader r, GameContainer c, GameBoard b, Profession p)
      throws SlickException, IOException {
    // TODO stuff
    r.readLine();
    int tileX = Integer.parseInt(r.readLine());
    int tileY = Integer.parseInt(r.readLine());
    int currentEXP = Integer.parseInt(r.readLine());
    int currentHP = Integer.parseInt(r.readLine());
    int currentMP = Integer.parseInt(r.readLine());
    ArrayList<Item> inventory = InteractiveEntity.loadItems(r.readLine().split(","));
    ArrayList<Item> equips = InteractiveEntity.loadItems(r.readLine().split(","));

    Player player = new Player(p, c.getInput());

    player.setLocation(b.getTileAt(tileX, tileY), Tile.LAYER_ACTIVE);
    player.EXP = currentEXP;
    player.HP = currentHP;
    player.MP = currentMP;
    player.getInventory().addAll(inventory);
    for (int i = 0; i < equips.size(); i++) {
      if (equips.get(i) != null) {
        player.equipItem((Equip) equips.get(i));
      }
    }

    return player;
  }
Exemplo n.º 2
0
 private static void savePlayerStatus(BufferedWriter w, Player p) throws IOException {
   w.newLine();
   w.write(Integer.toString(p.getX()));
   w.newLine();
   w.write(Integer.toString(p.getY()));
   w.newLine();
   w.write(Integer.toString(p.EXP));
   w.newLine();
   w.write(Integer.toString(p.HP));
   w.newLine();
   w.write(Integer.toString(p.MP));
   w.newLine();
   w.write(InteractiveEntity.getInventoryAsString(p.getInventory(), p.inventorySize));
   w.newLine();
   w.write(InteractiveEntity.getInventoryAsString(p.getEquips(), p.inventorySize));
 }