/** * Method that will check the number of players alive and returns them * * @return the number of player still alive */ private int playersStillAlive() { int counter = 0; for (Player playerToTest : this.getPlayerList()) { if (playerToTest.isAlive()) counter++; } return counter; }
/** * launchGame isn't less than the main turn method which will launch every player turn aswell as * taking care of who will be the winner and such * * @throws InterruptedException */ public void launchGame() throws InterruptedException { // first reinforcement and capital choice turn for every players for (Player firstTurnOfPlayer : this.playerList) { this.setCurrentPlayer(firstTurnOfPlayer); firstTurnOfPlayer.reinforcementStep((int) (100 / this.playerList.size())); firstTurnOfPlayer.capitalAttribution(); Window.MAIN_GAMING_WINDOW.getContentPane().repaint(); } // all game turns in there while ( /*this.playersStillAlive() >= 2*/ true) { for (Player currentPlayer : this.getPlayerList()) { this.setCurrentPlayer(currentPlayer); this.print("Tour de : " + currentPlayer.name); Window.MAIN_GAMING_WINDOW.getContentPane().repaint(); currentPlayer.reinforcementStep(currentPlayer.unitReinforcements()); Window.MAIN_GAMING_WINDOW.getContentPane().repaint(); currentPlayer.attackStep(); Window.MAIN_GAMING_WINDOW.getContentPane().repaint(); currentPlayer.forceMouvementStep(); } // check up of the players to see if one of them is dead (no // regions left) // for (Player isPlayerDead : this.getPlayerList()) { // if (isPlayerDead.playerRegions().length == 0) isPlayerDead.setDead(); // } // check up of the capitals to see if a player possess them all : // if it is the case, the player have won the game // for (Player playerToFetchCapitals : this.getPlayerList()) { // if (playerToFetchCapitals.victoryByCapitals()) for (Player playerToSetDead : // this.getPlayerList()) // playerToSetDead.setDead(); // playerToFetchCapitals.setAlive(); // } } // print of the name of the player // for (Player isPlayerTheWinner : this.getPlayerList()) // if (isPlayerTheWinner.isAlive()) this.print("Partie remportée par " + // isPlayerTheWinner.name); }