package edu.miamioh.cse283.htw;

import java.io.*;
import java.net.Socket;

/**
 * Proxy client object.
 */
public class ClientProxy {
	/**
	 * This socket is connected to a client.
	 */
	protected Socket s;

	/**
	 * Used to read from the client's socket.
	 */
	protected BufferedReader in;

	/**
	 * Used to write to the client's socket.
	 */
	protected PrintWriter out;

	/**
	 * Constructor.
	 */
	public ClientProxy(Socket s) throws Exception {
		this.s = s;
		this.out = new PrintWriter(s.getOutputStream(), true);
		this.in = new BufferedReader(new InputStreamReader(s.getInputStream()));
	}

	/**
	 * Handoff this client to the given cave.
	 */
	public void handoff(CaveProxy cave) {
		out.println(cave.getRemoteClientAddress().getHostName());
		out.println(cave.getRemoteClientPort());
	}

	/**
	 * Send a message to the client.
	 */
	public void message(String msg) {
		out.println(msg);
	}

	/**
	 * Send a sensory message to the client.
	 */
	public void senses(String msg) {
		out.println(msg);
	}

	/**
	 * Get an action from the client.
	 */
	public String getAction() throws Exception {
		return in.readLine();
	}
}

@@ -367,16 +367,100 @@
 r out;%0A%0A
+%09/**%0A%09 * The current room that this player is in%0A%09 */%0A%09protected Room currentRoom;%0A%0A
 %09/**%0A%09 *
@@ -669,24 +669,277 @@
 Stream()));%0A
+%09%09this.currentRoom = null;%0A%09%7D%0A%0A%09public Room getCurrentRoom() %7B%0A%09%09return currentRoom;%0A%09%7D%0A%0A%09public void setCurrentRoom(Room newRoom) %7B%0A%09%09if (currentRoom != null) %7B%0A%09%09%09currentRoom.removePlayer(this);%0A%09%09%7D%0A%09%09newRoom.addPlayer(this);%0A%09%09currentRoom = newRoom;%0A
 %09%7D%0A%0A%09/**%0A%09 *

add currentRoom field to ClientProxy