From 7c8dac2aff52e97a1c227a3669ebe6e073d10f7a Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 11 May 2023 12:36:08 +1000 Subject: [PATCH] game: Squashed various bugs --- src/comp1110/ass2/gui/Game.java | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/comp1110/ass2/gui/Game.java b/src/comp1110/ass2/gui/Game.java index a9eca18..f5f26be 100644 --- a/src/comp1110/ass2/gui/Game.java +++ b/src/comp1110/ass2/gui/Game.java @@ -169,6 +169,9 @@ public class Game extends Application { sendMessage("You have placed all your villages"); return; } + } else if (currentGame.getCurrentPlayer().getSettlers().length >= (40-(currentGame.getNumPlayers()*5))){ + sendMessage("You have placed all your settlers"); + return; } // If the move is valid, do it @@ -232,23 +235,26 @@ public class Game extends Application { String message = ""; if (!currentGame.isPhaseOver()){ Player player = currentGame.getCurrentPlayer(); - player.doAIMove(currentGame); + if (player.doAIMove(currentGame)) { - if (currentGame.isPhaseOver()){ - message = "Starting next phase"; - } - if (!player.getLastMove().equals(new Coord(-1,-1))){ - Coord lastMove = player.getLastMove(); - if (currentGame.isStone(lastMove)){ - for (Resource resource : currentGame.getResources()) { - if (resource.getCoord().equals(lastMove) ) { - message = "AI "+ player.getPlayerID() + " picked up " + resource.getTypeString().toLowerCase(); + if (currentGame.isPhaseOver()) { + message = "Starting next phase"; + } + if (!player.getLastMove().equals(new Coord(-1, -1))) { + Coord lastMove = player.getLastMove(); + if (currentGame.isStone(lastMove)) { + for (Resource resource : currentGame.getResources()) { + if (resource.getCoord().equals(lastMove)) { + message = "AI " + player.getPlayerID() + " picked up " + resource.getTypeString().toLowerCase(); + } } + } else { + message = "AI " + player.getPlayerID() + " placed at " + lastMove.toString(); } } - else { - message = "AI " + player.getPlayerID() + " placed at " + lastMove.toString(); - } + } else { + message += "AI " + player.getPlayerID() + " passed"; + currentGame.nextPlayer(); } } if (currentGame.isPhaseOver()){ @@ -607,6 +613,7 @@ public class Game extends Application { hb.setSpacing(10); hb.setLayoutX(50); hb.setLayoutY(WINDOW_HEIGHT - 50); + controls.getChildren().clear(); controls.getChildren().add(hb); }