start game stuff - both online and offline #13
|
@ -25,6 +25,9 @@ public class GameController {
|
||||||
public static int semesterToBoardSize(int semester) {
|
public static int semesterToBoardSize(int semester) {
|
||||||
return semester + 13;
|
return semester + 13;
|
||||||
}
|
}
|
||||||
|
public static int boardSizeToSemester(int size) {
|
||||||
|
return size - 13;
|
||||||
|
}
|
||||||
|
|
||||||
public static HashMap<String, Class<? extends OnlinePlayer>> supportedVersions = new HashMap<>(Map.of(
|
public static HashMap<String, Class<? extends OnlinePlayer>> supportedVersions = new HashMap<>(Map.of(
|
||||||
"1.1.0", OnlinePlayer_1_1_0.class
|
"1.1.0", OnlinePlayer_1_1_0.class
|
||||||
|
@ -93,7 +96,7 @@ public class GameController {
|
||||||
localPlayer.isServer = localPlayerIsServer;
|
localPlayer.isServer = localPlayerIsServer;
|
||||||
onlinePlayer.isServer = !localPlayerIsServer;
|
onlinePlayer.isServer = !localPlayerIsServer;
|
||||||
|
|
||||||
startGameWithInstancedPlayers(localPlayer, onlinePlayer);
|
startGameWithInstancedPlayers(localPlayer, onlinePlayer, size);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unexpected Package received before game initialisation");
|
throw new RuntimeException("Unexpected Package received before game initialisation");
|
||||||
|
@ -178,13 +181,15 @@ public class GameController {
|
||||||
localPlayer.createBoard(size);
|
localPlayer.createBoard(size);
|
||||||
aiPlayer.createBoard(size);
|
aiPlayer.createBoard(size);
|
||||||
|
|
||||||
startGameWithInstancedPlayers(localPlayer, aiPlayer);
|
startGameWithInstancedPlayers(localPlayer, aiPlayer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void startGameWithInstancedPlayers(LocalPlayer p1, Player p2) {
|
private static void startGameWithInstancedPlayers(LocalPlayer p1, Player p2, int boardSize) {
|
||||||
p1.setEnemy(p2);
|
p1.setEnemy(p2);
|
||||||
p2.setEnemy(p1);
|
p2.setEnemy(p1);
|
||||||
|
|
||||||
|
mainFrame.showPanelSLG("GameBoard", boardSizeToSemester(boardSize), p1, p2);
|
||||||
|
|
||||||
// TODO: frontend configuration
|
// TODO: frontend configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue