Advertisement
Zubda_Tahir

Untitled

Apr 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. public void visitChangeRoom(final ChangeRoom changeRoom) throws IOException {
  2. System.out.println("Received Room Change Request");
  3. MapRoom room = null;
  4. MapRoom changedroom = null;
  5. for (MapRoom x : client.map.rooms) {
  6.  
  7. if (x.number == client.character.roomNumber) {
  8. room = x;
  9. }
  10. }
  11. boolean roomfound = false;
  12. if (room != null) {
  13. for (MapRoom x : room.connections) {
  14. if(x.number == changeRoom.roomNumber)
  15. {
  16. roomfound = true;
  17. changedroom = x;
  18. room.playersinroom.remove(client.character);
  19. client.character.roomNumber = x.number;
  20. x.playersinroom.add(client.character);
  21. }
  22.  
  23. }
  24. if(roomfound == false)
  25. {
  26. Writer badroom = new Writer();
  27. String msg = "Room you are trying to go is inappropriate";
  28. Error error = Error.badRoom(msg);
  29. error.writeTo(badroom);
  30. client.socket.getOutputStream().write(badroom.getBytes());
  31.  
  32. }
  33. if(roomfound == true)
  34. {
  35. for (MapRoom x : changedroom.connections) {
  36. Writer con = new Writer();
  37. Connection connection = new Connection(x.number,x.name,x.description);
  38. connection.writeTo(con);
  39. client.socket.getOutputStream().write(con.getBytes());
  40. }
  41. }
  42.  
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement