Exemple #1
0
 // Method for the player turn - The player can only use the turn if their balance is not 0
 private void playerTurn(Player player) {
   if (player.getAccount().getBalance() != 0) {
     GUI.showMessage(player.getName() + Text.roll); // The player is asked to roll the dice						
     GUI.removeCar(
         player.getPosition(), player.getName()); // car is removed from previous position
     player.addPosition(dicecup.roll()); // Dice is rolled, and the players position is saved
     GUI.setDice(
         dicecup.getDie1().getLastRoll(),
         dicecup.getDie2().getLastRoll()); // Dice is shown on screen
     GUI.setCar(player.getPosition(), player.getName()); // Car is moved to field
     landedOnField(player); // Runs the operation for the field the player landed on
     GUI.setBalance(
         player.getName(),
         player.getAccount().getBalance()); // Shows current player balance on GUI game board
     if (player.getAccount().getBalance() == 0)
       bankRupt(
           player); // Player is removed from the game if their balance is 0, after their turn.
   }
 }
Exemple #2
0
 public void move(int move) {
   GUI.removeCar(felt + 1, "" + number);
   felt += move;
   felt = felt % 21; // sætter feltet til 0-20
   GUI.setCar(felt + 1, "" + number);
 }