Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void visitChangeRoom(final ChangeRoom changeRoom) throws IOException {
- System.out.println("Received Room Change Request");
- MapRoom room = null;
- MapRoom changedroom = null;
- for (MapRoom x : client.map.rooms) {
- if (x.number == client.character.roomNumber) {
- room = x;
- }
- }
- boolean roomfound = false;
- if (room != null) {
- for (MapRoom x : room.connections) {
- if(x.number == changeRoom.roomNumber)
- {
- roomfound = true;
- changedroom = x;
- room.playersinroom.remove(client.character);
- client.character.roomNumber = x.number;
- x.playersinroom.add(client.character);
- }
- }
- if(roomfound == false)
- {
- Writer badroom = new Writer();
- String msg = "Room you are trying to go is inappropriate";
- Error error = Error.badRoom(msg);
- error.writeTo(badroom);
- client.socket.getOutputStream().write(badroom.getBytes());
- }
- if(roomfound == true)
- {
- for (MapRoom x : changedroom.connections) {
- Writer con = new Writer();
- Connection connection = new Connection(x.number,x.name,x.description);
- connection.writeTo(con);
- client.socket.getOutputStream().write(con.getBytes());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement