package scotlandyard.server.services;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import scotlandyard.client.network.rpc.GameService;
import scotlandyard.server.GameServer;
import scotlandyard.shared.BoardState;
import scotlandyard.shared.Player;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class GameServiceImpl extends RemoteServiceServlet implements GameService {
@Override
public BoardState getBoardState() {
HttpServletRequest request = this.getThreadLocalRequest();
HttpSession session = request.getSession();
GameServer game = (GameServer)session.getAttribute("GameServerInstance");
return game.getBoardState();
}
@Override
public void move(int destination) {
HttpServletRequest request = this.getThreadLocalRequest();
HttpSession session = request.getSession();
GameServer game = (GameServer)session.getAttribute("GameServerInstance");
Player player = (Player)session.getAttribute("PlayerInstance");
System.out.println(player.getName()+" esta tentando se mover para "+destination);
game.move(player, destination);
}
@Override
public void interfaceReady() {
HttpServletRequest request = this.getThreadLocalRequest();
HttpSession session = request.getSession();
GameServer game = (GameServer)session.getAttribute("GameServerInstance");
Player player = (Player)session.getAttribute("PlayerInstance");
game.checkAllInterfaceLoaded(player);
}
@Override
public String getMyGameName() {
HttpServletRequest request = this.getThreadLocalRequest();
HttpSession session = request.getSession();
GameServer game = (GameServer)session.getAttribute("GameServerInstance");
return game.getGameName();
}
}