39 lines
1.1 KiB
Java
39 lines
1.1 KiB
Java
public abstract class OnlinePlayer extends Player implements AsyncSocketListener {
|
|
protected AsyncSocket socket;
|
|
protected int wantedBoardSize;
|
|
|
|
protected boolean hasReceivedCoinPackage;
|
|
|
|
/**
|
|
* Constructor
|
|
* @param size the size of the board the enemy player wants to play with
|
|
* the actual board size will be determined once the semester of the online partner is known
|
|
* @param socket an AsyncSocket to communicate with the enemy through
|
|
*/
|
|
public OnlinePlayer(Integer size, AsyncSocket socket) {
|
|
this.socket = socket;
|
|
this.wantedBoardSize = size;
|
|
this.myCoin = null;
|
|
socket.setHandler(this);
|
|
//TODO Auto-generated constructor stub
|
|
}
|
|
|
|
public abstract void sendIAM();
|
|
|
|
public abstract void receive(String message);
|
|
|
|
@Override
|
|
public abstract void receiveCoin(boolean coin);
|
|
|
|
/**
|
|
* closes the socket and does player cleanup work
|
|
* @author Luca Conte
|
|
*/
|
|
@Override
|
|
public void destroy() {
|
|
super.destroy();
|
|
this.socket.close();
|
|
}
|
|
|
|
}
|