Task 5 should be finished I think
NOTE: There's a bug with the water board and stoneCircles tile generator. Will fix later hopefully lol Signed-off-by: Immanuel Alvaro Bhirawa <u7280427@anu.edu.au>
This commit is contained in:
parent
5a2e876a29
commit
bb364bd4c7
@ -131,21 +131,10 @@ public class Viewer extends Application {
|
|||||||
root.getChildren().clear();
|
root.getChildren().clear();
|
||||||
root.getChildren().add(controls);
|
root.getChildren().add(controls);
|
||||||
|
|
||||||
// To group the root and adjust their Px sizes accordingly
|
|
||||||
// to each other
|
|
||||||
// StackPane rootGroup = new StackPane();
|
|
||||||
|
|
||||||
// a 13 2; c 0 E; i 6 0,0 0,1 0,2 0,3 1,0 1,
|
|
||||||
// String gameArrangementState = parts[i];
|
|
||||||
// String[] gameArrangementStateParts = gameArrangementState.split(" ");
|
|
||||||
// int boardHeight = Integer.parseInt(gameArrangementStateParts[1]);
|
|
||||||
// int boardHeightPx = boardHeight * 45;
|
|
||||||
|
|
||||||
GridPane viewerGrid = new GridPane();
|
GridPane viewerGrid = new GridPane();
|
||||||
String[] parts = stateString.split("; ?");
|
String[] parts = stateString.split("; ?");
|
||||||
int boardHeight = 0;
|
int boardHeight = 0;
|
||||||
int boardHeightPx = 0;
|
int boardHeightPx = 0;
|
||||||
// int tileSize = 500;
|
|
||||||
for ( String part : parts) {
|
for ( String part : parts) {
|
||||||
String[] parseSplit = part.split(" ");
|
String[] parseSplit = part.split(" ");
|
||||||
String stateCases = parseSplit[0];
|
String stateCases = parseSplit[0];
|
||||||
@ -155,7 +144,6 @@ public class Viewer extends Application {
|
|||||||
boardHeightPx = 575;
|
boardHeightPx = 575;
|
||||||
viewerGrid.setPrefWidth(boardHeightPx);
|
viewerGrid.setPrefWidth(boardHeightPx);
|
||||||
viewerGrid.setPrefHeight(boardHeightPx);
|
viewerGrid.setPrefHeight(boardHeightPx);
|
||||||
// viewerGrid.relocate((VIEWER_WIDTH/2-viewerGrid.getPrefWidth()/2), (VIEWER_HEIGHT/2-viewerGrid.getPrefHeight()/2));
|
|
||||||
|
|
||||||
// row major order
|
// row major order
|
||||||
for(int i = 0; i < boardHeight; i++){
|
for(int i = 0; i < boardHeight; i++){
|
||||||
@ -163,10 +151,6 @@ public class Viewer extends Application {
|
|||||||
Rectangle boardMap = new Rectangle(boardHeightPx/boardHeight,
|
Rectangle boardMap = new Rectangle(boardHeightPx/boardHeight,
|
||||||
boardHeightPx/boardHeight, Color.DARKBLUE);
|
boardHeightPx/boardHeight, Color.DARKBLUE);
|
||||||
viewerGrid.add(boardMap, i, j);
|
viewerGrid.add(boardMap, i, j);
|
||||||
// Label boardLabel = new Label(i + "," + j);
|
|
||||||
// boardLabel.setFont(Font.font("Sans Serif", 12));
|
|
||||||
// boardLabel.setTextFill(Color.WHITE);
|
|
||||||
// viewerGrid.add(boardLabel, i, j);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -200,15 +184,7 @@ public class Viewer extends Application {
|
|||||||
String[] coords = parseSplit[i].split(",");
|
String[] coords = parseSplit[i].split(",");
|
||||||
int xCoord = Integer.parseInt(coords[0]);
|
int xCoord = Integer.parseInt(coords[0]);
|
||||||
int yCoord = Integer.parseInt(coords[1]);
|
int yCoord = Integer.parseInt(coords[1]);
|
||||||
// Label islandLabel = new Label(xCoord + "," + yCoord +
|
|
||||||
// "\n b " + parseSplit[1]);
|
|
||||||
// islandLabel.setTextFill(Color.GREENYELLOW);
|
|
||||||
// islandLabel.setFont(Font.font("Sans Serif", 12));
|
|
||||||
// viewerGrid.add(islandLabel, xCoord, yCoord);
|
|
||||||
// viewerGrid.setAlignment(Pos.CENTER);
|
|
||||||
viewerGrid.add(island, xCoord, yCoord);
|
viewerGrid.add(island, xCoord, yCoord);
|
||||||
|
|
||||||
// root.getChildren().add(viewerGrid);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "s":
|
case "s":
|
||||||
@ -217,7 +193,6 @@ public class Viewer extends Application {
|
|||||||
- 15, boardHeightPx/boardHeight - 15, Color.GRAY);
|
- 15, boardHeightPx/boardHeight - 15, Color.GRAY);
|
||||||
String[] coords = parseSplit[i].split(",");
|
String[] coords = parseSplit[i].split(",");
|
||||||
theRock.setTranslateX(5);
|
theRock.setTranslateX(5);
|
||||||
// theRock.setTranslateY(0);
|
|
||||||
viewerGrid.add(theRock, Integer.parseInt(coords[0]),
|
viewerGrid.add(theRock, Integer.parseInt(coords[0]),
|
||||||
Integer.parseInt(coords[1]));
|
Integer.parseInt(coords[1]));
|
||||||
}
|
}
|
||||||
@ -226,11 +201,8 @@ public class Viewer extends Application {
|
|||||||
for(int i = 1; i < parseSplit.length; i++){
|
for(int i = 1; i < parseSplit.length; i++){
|
||||||
switch(parseSplit[i]) {
|
switch(parseSplit[i]) {
|
||||||
case "C":
|
case "C":
|
||||||
// System.out.println("Start of C " + parseSplit[i]);
|
|
||||||
i++;
|
i++;
|
||||||
// System.out.println("First iteration of C" + parseSplit[i]);
|
|
||||||
while(!parseSplit[i].equals("B")){
|
while(!parseSplit[i].equals("B")){
|
||||||
// System.out.println("C loop" + parseSplit[i]);
|
|
||||||
String[] coords = parseSplit[i].split(",");
|
String[] coords = parseSplit[i].split(",");
|
||||||
Rectangle coconut = new Rectangle(boardHeightPx/boardHeight
|
Rectangle coconut = new Rectangle(boardHeightPx/boardHeight
|
||||||
- 15, boardHeightPx/boardHeight - 15, Color.BROWN);
|
- 15, boardHeightPx/boardHeight - 15, Color.BROWN);
|
||||||
@ -244,7 +216,6 @@ public class Viewer extends Application {
|
|||||||
viewerGrid.add(coconutLabel, Integer.parseInt(coords[0]),
|
viewerGrid.add(coconutLabel, Integer.parseInt(coords[0]),
|
||||||
Integer.parseInt(coords[1]));
|
Integer.parseInt(coords[1]));
|
||||||
i++;
|
i++;
|
||||||
// System.out.println("End of C loop" + parseSplit[i]);
|
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
break;
|
break;
|
||||||
@ -326,389 +297,72 @@ public class Viewer extends Application {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// String[] parseSplit = part.split(" ");
|
break;
|
||||||
// String stateCases = parseSplit[0];
|
case "p":
|
||||||
// String[] parseSplit = part.split(" ");
|
String container = "";
|
||||||
// for (String parse : parseSplit) {
|
container += "player " + parseSplit[1] + " with score: " +
|
||||||
// switch (parse) {
|
parseSplit[2] + ", coconuts: " + parseSplit[3] +
|
||||||
// case "C":
|
", bambooo: " + parseSplit[4] + ", statuettes: " +
|
||||||
// Rectangle coconut = new Rectangle(boardHeightPx/boardHeight
|
parseSplit[5] + ", placed settlers at ";
|
||||||
// - 15, boardHeightPx/boardHeight - 15,
|
int i = 9;
|
||||||
// Color.BROWN);
|
int counter = 0;
|
||||||
// String[] coords = parseSplit[i].split(",");
|
while(!parseSplit[i].equals("T")){
|
||||||
// viewerGrid.add(coconut, Integer.parseInt(coords[0]),
|
counter++;
|
||||||
// Integer.parseInt(coords[1]));
|
String[] coords = parseSplit[i].split(",");
|
||||||
|
Rectangle settlers = new Rectangle(boardHeightPx/boardHeight
|
||||||
|
- 15, boardHeightPx/boardHeight - 15, Color.PINK);
|
||||||
|
settlers.setTranslateX(5);
|
||||||
|
Label settlerLabel = new Label("Settlers");
|
||||||
|
settlerLabel.setTextFill(Color.BLACK);
|
||||||
|
settlerLabel.setFont(Font.font("Sans Serif", 9));
|
||||||
|
settlerLabel.setTranslateX(5);
|
||||||
|
viewerGrid.add(settlers, Integer.parseInt(coords[0]),
|
||||||
|
Integer.parseInt(coords[1]));
|
||||||
|
viewerGrid.add(settlerLabel, Integer.parseInt(coords[0]),
|
||||||
|
Integer.parseInt(coords[1]));
|
||||||
|
if(counter > 1) container += " and ";
|
||||||
|
container += Integer.parseInt(coords[0]) + "," +
|
||||||
|
Integer.parseInt(coords[1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
|
||||||
|
container += ", placed villages at ";
|
||||||
|
int counterT = 0;
|
||||||
|
while(i < parseSplit.length){
|
||||||
|
counter++;
|
||||||
|
String[] coords = parseSplit[i].split(",");
|
||||||
|
Rectangle village = new Rectangle(boardHeightPx/boardHeight
|
||||||
|
- 15, boardHeightPx/boardHeight - 15, Color.LIGHTGOLDENRODYELLOW);
|
||||||
|
village.setTranslateX(5);
|
||||||
|
Label villageLabel = new Label("Village");
|
||||||
|
villageLabel.setTextFill(Color.BLACK);
|
||||||
|
villageLabel.setFont(Font.font("Sans Serif", 9));
|
||||||
|
villageLabel.setTranslateX(5);
|
||||||
|
viewerGrid.add(village, Integer.parseInt(coords[0]),
|
||||||
|
Integer.parseInt(coords[1]));
|
||||||
|
viewerGrid.add(villageLabel, Integer.parseInt(coords[0]),
|
||||||
|
Integer.parseInt(coords[1]));
|
||||||
|
if(counterT > 1) container += " and ";
|
||||||
|
container += Integer.parseInt(coords[0]) + "," +
|
||||||
|
Integer.parseInt(coords[1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text playerStateText = new Text();
|
||||||
|
playerStateText.setText(container);
|
||||||
|
playerStateText.setFont(Font.font("Sans Serif",
|
||||||
|
FontWeight.BOLD, 12));
|
||||||
|
playerStateText.setX(275);
|
||||||
|
playerStateText.setY(645);
|
||||||
|
playerStateText.setTextAlignment(TextAlignment.CENTER);
|
||||||
|
root.getChildren().add(playerStateText);
|
||||||
|
playerStateText.setFill(Color.BLACK);
|
||||||
// }
|
// }
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// parts[i].matches(" c \\d [ES]")
|
|
||||||
//String[] parseSplit = part.split(" ");
|
|
||||||
// break;
|
|
||||||
//r C 1,1 B 1,2 W P 1,4 S;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewerGrid.relocate((VIEWER_WIDTH/2-viewerGrid.getPrefWidth()/2), (VIEWER_HEIGHT/2-viewerGrid.getPrefHeight()/2));
|
viewerGrid.relocate((VIEWER_WIDTH/2-viewerGrid.getPrefWidth()/2), (VIEWER_HEIGHT/2-viewerGrid.getPrefHeight()/2));
|
||||||
root.getChildren().add(viewerGrid);
|
root.getChildren().add(viewerGrid);
|
||||||
|
|
||||||
// String currentArrangementState = parts[i];
|
|
||||||
//// String[] currentArrangementStateParts = currentArrangementState.split(" ");
|
|
||||||
//// int playerId = Integer.parseInt(currentArrangementStateParts[2]);
|
|
||||||
//// String currentArrangementPhaseParts = currentArrangementStateParts[3];
|
|
||||||
//// String currentArrangementActualPhase = "";
|
|
||||||
//// switch (currentArrangementPhaseParts) {
|
|
||||||
//// case "E": {
|
|
||||||
//// currentArrangementActualPhase = "Exploration";
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// case "S": {
|
|
||||||
//// currentArrangementActualPhase = "Settler";
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// Text currentStateText = new Text();
|
|
||||||
// currentStateText.setText("The current player to move is player " +
|
|
||||||
// playerId + " in the " + currentArrangementActualPhase +
|
|
||||||
// " phase");
|
|
||||||
// currentStateText.setFont(Font.font("Sans Serif",
|
|
||||||
// FontWeight.BOLD, 20));
|
|
||||||
// currentStateText.setX(VIEWER_WIDTH / boardHeight * 3.5);
|
|
||||||
// currentStateText.setY(50);
|
|
||||||
// currentStateText.setTextAlignment(TextAlignment.CENTER);
|
|
||||||
// root.getChildren().add(currentStateText);
|
|
||||||
// currentStateText.setFill(Color.GREEN);
|
|
||||||
//
|
|
||||||
// String[] parts = stateString.split(";");
|
|
||||||
// String gameArrangementState = parts[0];
|
|
||||||
// String[] gameArrangementStateParts = gameArrangementState.split(" ");
|
|
||||||
// int boardHeight = Integer.parseInt(gameArrangementStateParts[1]);
|
|
||||||
// int boardHeightPx = boardHeight * 45;
|
|
||||||
// int tilePxSize = (boardHeightPx-45) / boardHeight;
|
|
||||||
//
|
|
||||||
// Rectangle board = new Rectangle();
|
|
||||||
// board.setWidth(boardHeightPx); // width (assume for right now the map is a square
|
|
||||||
// board.setHeight(boardHeightPx); // height
|
|
||||||
// board.setX((VIEWER_WIDTH / 2) - board.getWidth() / 2); // starting x loc
|
|
||||||
// board.setY((VIEWER_HEIGHT / 2) - board.getHeight() / 2); // starting y loc
|
|
||||||
// board.setFill(Color.DARKBLUE);
|
|
||||||
// root.getChildren().add(board);
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < parts.length; i++) {
|
|
||||||
//// if(parts[i].matches("a \\d{1,2} \\d")){
|
|
||||||
//// Rectangle board = new Rectangle();
|
|
||||||
//// board.setWidth(boardHeightPx); // width (assume for right now the map is a square
|
|
||||||
//// board.setHeight(boardHeightPx); // height
|
|
||||||
//// board.setX((VIEWER_WIDTH / 2) - board.getWidth()/2); // starting x loc
|
|
||||||
//// board.setY((VIEWER_HEIGHT / 2) - board.getHeight()/2); // starting y loc
|
|
||||||
//// board.setFill(Color.DARKBLUE);
|
|
||||||
//// root.getChildren().add(board);
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// if (parts[i].matches(" c \\d [ES]")) {
|
|
||||||
// String currentArrangementState = parts[i];
|
|
||||||
// String[] currentArrangementStateParts = currentArrangementState.split(" ");
|
|
||||||
// int playerId = Integer.parseInt(currentArrangementStateParts[2]);
|
|
||||||
// String currentArrangementPhaseParts = currentArrangementStateParts[3];
|
|
||||||
// String currentArrangementActualPhase = "";
|
|
||||||
// switch (currentArrangementPhaseParts) {
|
|
||||||
// case "E": {
|
|
||||||
// currentArrangementActualPhase = "Exploration";
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// case "S": {
|
|
||||||
// currentArrangementActualPhase = "Settler";
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Text currentStateText = new Text();
|
|
||||||
// currentStateText.setText("The current player to move is player " +
|
|
||||||
// playerId + " in the " + currentArrangementActualPhase +
|
|
||||||
// " phase");
|
|
||||||
// currentStateText.setFont(Font.font("Sans Serif",
|
|
||||||
// FontWeight.BOLD, 20));
|
|
||||||
// currentStateText.setX(VIEWER_WIDTH / boardHeight * 3.5);
|
|
||||||
// currentStateText.setY(50);
|
|
||||||
// currentStateText.setTextAlignment(TextAlignment.CENTER);
|
|
||||||
// root.getChildren().add(currentStateText);
|
|
||||||
// currentStateText.setFill(Color.GREEN);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // i 6 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 1,4 2,0 2,1;
|
|
||||||
// //a 13 2; c 0 E; i 6 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 1,4 2,0 2,1
|
|
||||||
//// a 13 2; c 0 E; i 6 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 1,4 2,0 2,1;
|
|
||||||
//// * i 6 0,5 0,6 0,7 1,6 1,7 1,8 2,6 2,7 2,8 3,7 3,8
|
|
||||||
//
|
|
||||||
// if (parts[i].matches(" i \\d{1,2} (\\d{1,2},\\d{1,2} )*\\d{1,2},\\d{1,2}")) {
|
|
||||||
// GridPane islandGrid = new GridPane();
|
|
||||||
// String[] islandString = parts[i].split(" ");
|
|
||||||
// for(int j = 3; j < islandString.length; j++){
|
|
||||||
// Rectangle islandTiles = new Rectangle(tilePxSize, tilePxSize, Color.GREEN);
|
|
||||||
// String[] coords = islandString[j].split(",");
|
|
||||||
// islandGrid.add(islandTiles, Integer.parseInt(coords[0]),
|
|
||||||
// Integer.parseInt(coords[1]));
|
|
||||||
// islandGrid.setTranslateX(board.getX());
|
|
||||||
// islandGrid.setTranslateY(board.getY());
|
|
||||||
// }
|
|
||||||
// root.getChildren().add(islandGrid);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// String[] islandString = parts[i].split(" ");
|
|
||||||
// for (int j = i; j < parts.length; j++) {
|
|
||||||
// String[] islandString = parts[i].split(" ");
|
|
||||||
// Text bonusPointIslandText = new Text();
|
|
||||||
// bonusPointIslandText.setText("The bonus point for this island is " +
|
|
||||||
// islandString[2]);
|
|
||||||
// bonusPointIslandText.setFont(Font.font("Sans Serif",
|
|
||||||
// FontWeight.BOLD, 10));
|
|
||||||
// bonusPointIslandText.setX(50);
|
|
||||||
// bonusPointIslandText.setY(150);
|
|
||||||
// bonusPointIslandText.setTextAlignment(TextAlignment.CENTER);
|
|
||||||
// root.getChildren().add(bonusPointIslandText);
|
|
||||||
// bonusPointIslandText.setFill(Color.RED);
|
|
||||||
//// System.out.println("Parts[i] : " + parts[j]);
|
|
||||||
// for (int k = 3; k < islandString.length; k++) {
|
|
||||||
// String[] islandCoords = islandString[k].split(",");
|
|
||||||
// System.out.println("IslandString: " + islandString[k]);
|
|
||||||
// Rectangle island = new Rectangle(
|
|
||||||
// Integer.parseInt(islandCoords[0]) * boardHeight,
|
|
||||||
// Integer.parseInt(islandCoords[1]) * boardHeight,
|
|
||||||
// (boardHeightPx - 100) / boardHeight,
|
|
||||||
// (boardHeightPx - 100) / boardHeight
|
|
||||||
// );
|
|
||||||
//// island.setX((VIEWER_WIDTH / 2) - (board.getWidth()/2) + 50);
|
|
||||||
//// island.setY((VIEWER_HEIGHT / 2) - (board.getHeight()/2) + 50);
|
|
||||||
// island.setTranslateX((VIEWER_WIDTH / 2) - board.getWidth() / 2 + 50);
|
|
||||||
// island.setTranslateY((VIEWER_HEIGHT / 2) - board.getHeight() / 2 + 50);
|
|
||||||
// island.setFill(Color.GREEN);
|
|
||||||
// root.getChildren().add(island);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (k == 2) {
|
|
||||||
// Text bonusPointIslandText = new Text();
|
|
||||||
// bonusPointIslandText.setText("The bonus point for this island is " +
|
|
||||||
// islandString[2]);
|
|
||||||
// bonusPointIslandText.setFont(Font.font("Sans Serif",
|
|
||||||
// FontWeight.BOLD, 10));
|
|
||||||
// bonusPointIslandText.setX(50);
|
|
||||||
// bonusPointIslandText.setY(150);
|
|
||||||
// bonusPointIslandText.setTextAlignment(TextAlignment.CENTER);
|
|
||||||
// root.getChildren().add(bonusPointIslandText);
|
|
||||||
// bonusPointIslandText.setFill(Color.RED);
|
|
||||||
// } else {
|
|
||||||
// Label rectangleLabel = new Label();
|
|
||||||
|
|
||||||
// for(int j = i+1; j < islandString.length; j++){
|
|
||||||
// Label rectangleLabel = new Label();
|
|
||||||
// if(j == 3) {
|
|
||||||
// Text bonusPointIslandText = new Text();
|
|
||||||
// bonusPointIslandText.setText("The bonus point for this island is " +
|
|
||||||
// islandString[j]);
|
|
||||||
// bonusPointIslandText.setFont(Font.font("Sans Serif",
|
|
||||||
// FontWeight.BOLD, 20));
|
|
||||||
// bonusPointIslandText.setX(50);
|
|
||||||
// bonusPointIslandText.setY(150);
|
|
||||||
// bonusPointIslandText.setTextAlignment(TextAlignment.CENTER);
|
|
||||||
// root.getChildren().add(bonusPointIslandText);
|
|
||||||
// bonusPointIslandText.setFill(Color.GREEN);
|
|
||||||
// }
|
|
||||||
// String[] islandCoords = islandString[j].split(",");
|
|
||||||
// Rectangle island = new Rectangle(
|
|
||||||
// Integer.parseInt(islandCoords[0]) * boardHeight,
|
|
||||||
// Integer.parseInt(islandCoords[1]) * boardHeight,
|
|
||||||
// boardHeightPx - 100 / boardHeight,
|
|
||||||
// boardHeightPx - 100 / boardHeight
|
|
||||||
// );
|
|
||||||
// island.setX((VIEWER_WIDTH / 2) - (board.getWidth()/2) + 50);
|
|
||||||
// island.setY((VIEWER_HEIGHT / 2) - (board.getHeight()/2) + 50);
|
|
||||||
// island.setTranslateX((VIEWER_WIDTH / 2) - board.getWidth() / 2 + 50);
|
|
||||||
// island.setTranslateY((VIEWER_HEIGHT / 2) - board.getHeight() / 2 + 50);
|
|
||||||
// island.setFill(Color.GREEN);
|
|
||||||
// root.getChildren().add(island);
|
|
||||||
// }
|
|
||||||
// System.out.println("tod");
|
|
||||||
// for (int j = 2; j < parts.length; j++) {
|
|
||||||
// String[] islandString = parts[j].split(" ");
|
|
||||||
// System.out.println("Parts[j] : " + parts[j]);
|
|
||||||
// for (int k = 3; k < islandString.length; k++) {
|
|
||||||
// Label rectangleLabel = new Label();
|
|
||||||
// String[] islandCoords = islandString[k].split(",");
|
|
||||||
// System.out.println("IslandString: " + islandString[k]);
|
|
||||||
// Rectangle island = new Rectangle(
|
|
||||||
// Integer.parseInt(islandCoords[0]) * boardHeight,
|
|
||||||
// Integer.parseInt(islandCoords[1]) * boardHeight,
|
|
||||||
// (boardHeightPx - 100) / boardHeight,
|
|
||||||
// (boardHeightPx - 100) / boardHeight
|
|
||||||
// );
|
|
||||||
//// island.setX((VIEWER_WIDTH / 2) - (board.getWidth()/2) + 50);
|
|
||||||
//// island.setY((VIEWER_HEIGHT / 2) - (board.getHeight()/2) + 50);
|
|
||||||
// island.setTranslateX((VIEWER_WIDTH / 2) - board.getWidth() / 2 + 50);
|
|
||||||
// island.setTranslateY((VIEWER_HEIGHT / 2) - board.getHeight() / 2 + 50);
|
|
||||||
// island.setFill(Color.GREEN);
|
|
||||||
// root.getChildren().add(island);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// switch(parts[i]){
|
|
||||||
// if()
|
|
||||||
// // case "a": {
|
|
||||||
// String gameArrangementState = parts[i];
|
|
||||||
// String[] gameArrangementStateParts = gameArrangementState.split(" ");
|
|
||||||
// int boardHeight = Integer.parseInt(gameArrangementStateParts[1]);
|
|
||||||
// int boardHeightPx = boardHeight * 45;
|
|
||||||
//
|
|
||||||
// Rectangle board = new Rectangle();
|
|
||||||
// board.setWidth(boardHeightPx); // width (assume for right now the map is a square
|
|
||||||
// board.setHeight(boardHeightPx); // height
|
|
||||||
// board.setX((VIEWER_WIDTH / 2) - board.getWidth()/2); // starting x loc
|
|
||||||
// board.setY((VIEWER_HEIGHT / 2) - board.getHeight()/2); // starting y loc
|
|
||||||
// board.setFill(Color.DARKBLUE);
|
|
||||||
// root.getChildren().add(board);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
/*
|
|
||||||
// Part 1 done (Game Arrangement State)
|
|
||||||
String[] parts = stateString.split(";");
|
|
||||||
String gameArrangementState = parts[0];
|
|
||||||
String[] gameArrangementStateParts = gameArrangementState.split(" ");
|
|
||||||
int boardHeight = Integer.parseInt(gameArrangementStateParts[1]);
|
|
||||||
int boardHeightPx = boardHeight * 45;
|
|
||||||
|
|
||||||
Rectangle board = new Rectangle();
|
|
||||||
board.setWidth(boardHeightPx); // width (assume for right now the map is a square
|
|
||||||
board.setHeight(boardHeightPx); // height
|
|
||||||
board.setX((VIEWER_WIDTH / 2) - board.getWidth()/2); // starting x loc
|
|
||||||
board.setY((VIEWER_HEIGHT / 2) - board.getHeight()/2); // starting y loc
|
|
||||||
board.setFill(Color.DARKBLUE);
|
|
||||||
root.getChildren().add(board);
|
|
||||||
|
|
||||||
// Part 2 (Current Arrangement State)
|
|
||||||
String currentArrangementState = parts[1];
|
|
||||||
String[] currentArrangementStateParts = currentArrangementState.split(" ");
|
|
||||||
int playerId = Integer.parseInt(currentArrangementStateParts[2]);
|
|
||||||
String currentArrangementPhaseParts = currentArrangementStateParts[3];
|
|
||||||
String currentArrangementActualPhase = "";
|
|
||||||
switch(currentArrangementPhaseParts) {
|
|
||||||
case "E": {
|
|
||||||
currentArrangementActualPhase = "Exploration";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "S": {
|
|
||||||
currentArrangementActualPhase = "Settler";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Text currentStateText = new Text();
|
|
||||||
currentStateText.setText("The current player to move is player " +
|
|
||||||
playerId + " in the " + currentArrangementActualPhase +
|
|
||||||
" phase");
|
|
||||||
currentStateText.setFont(Font.font("Sans Serif",
|
|
||||||
FontWeight.BOLD, 20));
|
|
||||||
currentStateText.setX(VIEWER_WIDTH/boardHeight*3.5);
|
|
||||||
currentStateText.setY(50);
|
|
||||||
currentStateText.setTextAlignment(TextAlignment.CENTER);
|
|
||||||
root.getChildren().add(currentStateText);
|
|
||||||
currentStateText.setFill(Color.GREEN);
|
|
||||||
|
|
||||||
// rootGroup.getChildren().addAll(currentStateText,board);
|
|
||||||
|
|
||||||
//Before doing part 3, make the board and the current state adjustable to each
|
|
||||||
// by that I mean, when the board size adjusted, the current state is also
|
|
||||||
// adjusted
|
|
||||||
|
|
||||||
// The input is below
|
|
||||||
// a 13 2; c 0 E; i 6 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 1,4 2,0 2,1;
|
|
||||||
|
|
||||||
// statement = parts
|
|
||||||
// Part 3 (Many Island Statements)
|
|
||||||
for(int i = 2; i < parts.length; i++){
|
|
||||||
String[] islandString = parts[i].split(" ");
|
|
||||||
System.out.println("Parts[i] : " + parts[i]);
|
|
||||||
for(int j = 3; j < islandString.length; j++){
|
|
||||||
Label rectangleLabel = new Label();
|
|
||||||
String[] islandCoords = islandString[j].split(",");
|
|
||||||
System.out.println("IslandString: " + islandString[j]);
|
|
||||||
Rectangle island = new Rectangle(
|
|
||||||
Integer.parseInt(islandCoords[0]) * boardHeight,
|
|
||||||
Integer.parseInt(islandCoords[1]) * boardHeight,
|
|
||||||
(boardHeightPx - 100) / boardHeight,
|
|
||||||
(boardHeightPx - 100) / boardHeight
|
|
||||||
);
|
|
||||||
// island.setX((VIEWER_WIDTH / 2) - (board.getWidth()/2) + 50);
|
|
||||||
// island.setY((VIEWER_HEIGHT / 2) - (board.getHeight()/2) + 50);
|
|
||||||
island.setTranslateX((VIEWER_WIDTH / 2) - board.getWidth()/2 + 50);
|
|
||||||
island.setTranslateY((VIEWER_HEIGHT / 2) - board.getHeight()/2 + 50);
|
|
||||||
island.setFill(Color.GREEN);
|
|
||||||
root.getChildren().add(island);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// TilePane pane = new TilePane();
|
|
||||||
// pane.setTileAlignment(Pos.CENTER);
|
|
||||||
//
|
|
||||||
// for(int i = 1; i <= boardHeight; i++){
|
|
||||||
// for(int j = 1; j <= boardHeight; j++){
|
|
||||||
// pane.getChildren().add(new Button(i + "," + j));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// root.getChildren().add(pane);
|
|
||||||
// JFrame frame = new JFrame();
|
|
||||||
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
// frame.setSize(500,500);
|
|
||||||
// frame.setVisible(true);
|
|
||||||
// frame.setLayout(new GridLayout(boardHeight, boardHeight));
|
|
||||||
//
|
|
||||||
// for(int i = 1; i <= boardHeight; i++){
|
|
||||||
// for(int j = 1; j <= boardHeight; j++){
|
|
||||||
// frame.add(new JButton(i + "," + j));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// frame.setVisible(true);
|
|
||||||
//root.getChildren().add(frame);
|
|
||||||
|
|
||||||
|
|
||||||
// TilePane tile = new TilePane();
|
|
||||||
// tile.setHgap(8);
|
|
||||||
// tile.setPrefColumns(13);
|
|
||||||
// for (int i = 0; i < 20; i++){
|
|
||||||
// root.getChildren().add(tile);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TilePane tileVer = new TilePane(Orientation.VERTICAL);
|
|
||||||
// tile.setTileAlignment(Pos.CENTER_LEFT);
|
|
||||||
// tile.setPrefRows(10);
|
|
||||||
// for (int i = 0; i < 50; i++) {
|
|
||||||
// tileVer.getChildren().add(new ImageView(...));
|
|
||||||
// }
|
|
||||||
// Make hexagonal tiles inside the board
|
|
||||||
// CoordsPx < coords * 45 as "*45" is the px constant for the board
|
|
||||||
|
|
||||||
/*
|
|
||||||
[Many Island Statements]
|
|
||||||
* islandStatement = "i ", bonus, {" ", coordinate}, ";"
|
|
||||||
*
|
|
||||||
* where bonus is a non-negative integer.
|
|
||||||
*
|
|
||||||
* e.g. "i 6 0,0 0,1 0,2 0,3 1,0 1,1 1,2 1,3 1,4 2,0 2,1;"
|
|
||||||
*
|
|
||||||
* ^ The first island (top left) of the standard map
|
|
||||||
*
|
|
||||||
* e.g. "i 6 0,5 0,6 0,7 1,6 1,7 1,8 2,6 2,7 2,8 3,7 3,8;"
|
|
||||||
*
|
|
||||||
* ^ The second island (top middle) of the standard map
|
|
||||||
*
|
|
||||||
* e.g. "i 6 7,12 8,11 9,11 9,12 10,10 10,11 11,10 11,11 11,12 12,10 12,11; i 8 0,9 0,10 0,11 1,10 1,11 1,12 2,10 2,11 3,10 3,11 3,12 4,10 4,11 5,11 5,12; i 8 4,0 5,0 5,1 6,0 6,1 7,0 7,1 7,2 8,0 8,1 8,2 9,0 9,1 9,2;"
|
|
||||||
*
|
|
||||||
* ^ A sequence of three island statements appearing in the standard game string
|
|
||||||
*/
|
|
||||||
// FIXME Task 5
|
// FIXME Task 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user