Package org.jpokemon.trainer

Examples of org.jpokemon.trainer.Player


      sendToPlayer.put("direction", player.getLocation().getDirection());
      sendToPlayer.put("map", mapId);
      sendToPlayer.put("otherPlayers", otherPlayersArray);

      for (String playerId : map.getPlayers()) {
        Player otherPlayer = PlayerManager.getPlayer(playerId);
        PlayerManager.pushJson(otherPlayer, sendToOthers);
        JSONObject otherPlayerJson = new JSONObject();

        otherPlayerJson.put("name", otherPlayer.id());
        otherPlayerJson.put("spriteheight", 56);
        otherPlayerJson.put("spritewidth", 42);
        otherPlayerJson.put("image", otherPlayer.getAvatar());
        otherPlayerJson.put("x", otherPlayer.getLocation().getLeft());
        otherPlayerJson.put("y", otherPlayer.getLocation().getTop());
        otherPlayerJson.put("z", map.getEntityZ());
        otherPlayerJson.put("direction", otherPlayer.getLocation().getDirection());
        otherPlayersArray.put(otherPlayerJson);
      }

      map.addPlayer(player.id());
      PlayerManager.pushJson(player, sendToPlayer);
View Full Code Here


  }

  private void configure(JSONObject json, Player player) throws JSONException {
    String configure = json.getString("configure");
    String otherPlayerName = json.getString("name");
    Player otherPlayer = PlayerManager.getPlayer(otherPlayerName);

    if (otherPlayer == null) { return; }
    if (otherPlayer.getBlocked().contains(player.id())) { return; }

    if (configure.equals("add")) {
      sendFriendRequest(player, otherPlayer);
    }
    else if (configure.equals("accept")) {
View Full Code Here

    return true;
  }

  public static Player getPlayer(String name) {
    Player player;

    synchronized (players) {
      player = players.get(name);
    }
View Full Code Here

    if (playerId == null) {
      login(socket, request);
      return;
    }

    Player player = getPlayer(playerId);

    if (request.has("load")) {
      String serviceName = request.getString("load");
      JPokemonService service = services.get(serviceName);
View Full Code Here

    if (playerId == null) {
      return;
    }

    Player player = getPlayer(playerId);

    System.out.println(player + " session closed");

    File file = new File(JPokemonServer.savepath, playerId + ".jpkmn");

    try {
      Writer writer = new BufferedWriter(new PrintWriter(file));
      writer.write(player.toXml().printToString(0, "\t"));
      writer.close();
    }
    catch (IOException e) {
      e.printStackTrace();
    }

    for (JPokemonService service : services.values()) {
      service.logout(player);
    }

    while (hasActivity(player)) {
      activities.get(player.id()).pop().logout(player);
    }
    activities.remove(playerId);

    synchronized (players) {
      sessions.remove(socket);
View Full Code Here

      Message message = new Message("error", "Player '" + name + "' save not found!");
      socket.sendJson(message.toJson());
      return;
    }

    Player player = new Player(name);

    System.out.println(player + " session opened");

    String filename = name + ".jpkmn";
    File file = new File(JPokemonServer.savepath, filename);

    try {
      player.loadXML(XmlParser.parse(file).get(0));
    }
    catch (FileNotFoundException e) {
    }

    synchronized (players) {
View Full Code Here

  public void loadOrSetName(String name) {
    File file = new File(".", name + ".jpkmn");

    if (file.exists()) {
      player = new Player("undefined");
      try {
        player.loadXML(XmlParser.parse(file).get(0));
      }
      catch (FileNotFoundException e) {
      }
View Full Code Here

        }
        synchronized (pendingList) {
          pendingList.add(lobby.getHost());
        }

        Player player = PlayerManager.getPlayer(name);
        PlayerManager.pushJson(player, load(new JSONObject(), player));
      }
    }
  }
View Full Code Here

        }
        synchronized (pendingList) {
          pendingList.remove(lobby.getHost());
        }

        Player player = PlayerManager.getPlayer(name);
        PlayerManager.pushJson(player, load(new JSONObject(), player));
      }
    }
  }
View Full Code Here

    int teamNumber = 0;
    for (List<String> teamMembers : lobby.getTeams()) {
      for (String teamMember : teamMembers) {
        if ("yes".equals(responses.get(teamMember))) {
          Player player = PlayerManager.getPlayer(teamMember);
          battle.addTrainer(player, teamNumber);
          playersInBattle.add(player);
        }
      }
View Full Code Here

TOP

Related Classes of org.jpokemon.trainer.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.