Network and Frontend #10
|
@ -17,7 +17,7 @@ public class GameController {
|
||||||
"1.1.0", OnlinePlayer_1_1_0.class
|
"1.1.0", OnlinePlayer_1_1_0.class
|
||||||
));
|
));
|
||||||
|
|
||||||
public void startOnlineGame(Class<? extends LocalPlayer> localPlayerClass, InetSocketAddress address) throws IOException {
|
public void startOnlineGame(Class<? extends LocalPlayer> localPlayerClass, InetSocketAddress address, int size) throws IOException {
|
||||||
AsyncSocket clientSocket;
|
AsyncSocket clientSocket;
|
||||||
|
|
||||||
boolean localPlayerIsServer = address.getHostName() == null;
|
boolean localPlayerIsServer = address.getHostName() == null;
|
||||||
|
@ -71,7 +71,7 @@ public class GameController {
|
||||||
OnlinePlayer onlinePlayer;
|
OnlinePlayer onlinePlayer;
|
||||||
try {
|
try {
|
||||||
localPlayer = localPlayerClass.getDeclaredConstructor().newInstance();
|
localPlayer = localPlayerClass.getDeclaredConstructor().newInstance();
|
||||||
onlinePlayer = onlinePlayerClass.getDeclaredConstructor().newInstance();
|
onlinePlayer = onlinePlayerClass.getDeclaredConstructor().newInstance((Integer)size, clientSocket);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException("Unable to instantiate players");
|
throw new RuntimeException("Unable to instantiate players");
|
||||||
|
@ -161,6 +161,10 @@ public class GameController {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException("Unable to instantiate players");
|
throw new RuntimeException("Unable to instantiate players");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localPlayer.createBoard(size);
|
||||||
|
aiPlayer.createBoard(size);
|
||||||
|
|
||||||
startGameWithInstancedPlayers(localPlayer, aiPlayer);
|
startGameWithInstancedPlayers(localPlayer, aiPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ public abstract class OnlinePlayer extends Player implements AsyncSocketListener
|
||||||
private AsyncSocket socket;
|
private AsyncSocket socket;
|
||||||
|
|
||||||
public OnlinePlayer(int size, AsyncSocket socket) {
|
public OnlinePlayer(int size, AsyncSocket socket) {
|
||||||
super(size);
|
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
//TODO Auto-generated constructor stub
|
//TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class Player {
|
public abstract class Player {
|
||||||
protected boolean myTurn;
|
protected boolean myTurn;
|
||||||
|
@ -9,7 +8,9 @@ public abstract class Player {
|
||||||
protected String name;
|
protected String name;
|
||||||
protected Board board;
|
protected Board board;
|
||||||
|
|
||||||
public Player(int size) {
|
public Player() {}
|
||||||
|
|
||||||
|
public void createBoard(int size) {
|
||||||
this.board = new Board(size);
|
this.board = new Board(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue