/** * Handles a pickup packet from the server. The level then gives the appropriate player the item * parsed in the packet. * * @param username - username of the player picking up the item * @param tileID - ID of the tile that the item was on * @param itemID - ID of the item to be picked up */ public void handlePickUp(String username, int tileID, int itemID) { Player player = getPlayer(username); // We do not want to handle a pickup from the player on this computer if (player.equals(game.getPlayer())) return; Room currentRoom = player.getRoom(); Tile tile = currentRoom.getTile(player, tileID); if (tile != null) tile.onEnter(player); else System.err.println("Tile is NULL"); }
/** * Handles an interact packet sent from the server. Interactions are then performed by the * appropriate player on the appropriate tile. * * @param username - username of the player interacting * @param ID - ID of the tile to interact with */ public void handleInteract(String username, int ID) { Player player = getPlayer(username); // We do not want to handle an interact from the player on this computer if (player.equals(game.getPlayer())) return; Room currentRoom = player.getRoom(); Tile tile = currentRoom.getTile(player, ID); if (tile != null) { // System.out.println(tile.getClass().getName()); tile.onInteract(player); } for (Player p : players) { // System.out.println(p.getUsername() + " is in: " // + p.getRoom().getName()); } }