예제 #1
0
 @Override
 public void payRent(Player player) {
   if (player.getBalance() > getRent()) {
     player.addToBalance(-getRent());
     owner.addToBalance(getRent());
     GUI.showMessage(Texts.getText("husleje") + owner.getName());
     GUI.setBalance(player.getName(), player.getBalance());
     GUI.setBalance(owner.getName(), owner.getBalance());
   } else {
     owner.addToBalance(player.getBalance());
     player.bankrupt();
     GUI.removeAllCars(player.getName());
   }
 }
예제 #2
0
파일: Main.java 프로젝트: Wiwe1/CDIO2
  public static void spilloop(
      Spiller player, Terning tern, Felt felt, Konto konto, Tur tur, Strings string) {
    if (GUI.getUserButtonPressed(
            player.getNavn() + string.getButtonPress(), string.getButtonPressAnswer())
        .equals(string.getButtonPressAnswer())) {
      GUI.removeAllCars(player.getNavn());
      GUI.setCar(tern.kast() - 1, player.getNavn());
      GUI.showMessage("" + string.getFeltDesc((tern.getVærdi() - 2)));
      int feltværdi = felt.getFeltVærdi((tern.getVærdi() - 2), string);
      if (feltværdi > 0) {
        konto.deposit(feltværdi);
        GUI.setBalance(player.getNavn(), konto.getBeholdning());
        if (konto.getBeholdning() >= 3000) {
          GUI.showMessage(player.getNavn() + string.getWinText());
          if (GUI.getUserButtonPressed(
                  string.getNewGameText(),
                  string.getNewGameTextPositive(),
                  string.getNewGameTextNegative())
              .equals(string.getNewGameTextPositive())) {
            GUI.showMessage(string.getExitMessage());
            System.exit(0);
          } else {
            System.exit(0);
          }
        }
      } else if (feltværdi < 0) {
        if (feltværdi < konto.getBeholdning()) {
          konto.withdraw(-feltværdi);
          GUI.setBalance(player.getNavn(), konto.getBeholdning());
        } else {
          konto.withdraw(konto.getBeholdning());
        }
      }

      if (tern.getVærdi() - 2 != 8) tur.skift();
    }
  }
예제 #3
0
 // Removes all properties and cars from player, and subtracts 1 from the variable activePlayers
 private void bankRupt(Player player) {
   GUI.showMessage(player.getName() + Text.bankrupt);
   GUI.removeAllCars(player.getName());
   removeOwnership(player);
   activePlayers -= 1;
 }