Пример #1
0
 /*What effect does a GAINMONEY_FROMEVERYONE card have on a player?*/
 private void gaminmoney_fromeveryone_effect(
     List<AbstractPlayer> playerList, AbstractPlayer player) {
   for (AbstractPlayer p : playerList) {
     if (p.getMoney() < this.amount) {
       // TODO: Remove player p because they're bankrupt
       player.addMoney(p.getMoney());
     } else {
       p.removeMoney(this.amount);
       player.addMoney(this.amount);
     }
   }
 }
Пример #2
0
  /*What effect does a LOSEMONEY_TOEVERYONE card have on a player?*/
  private void losemoney_toeveryone_effect(List<AbstractPlayer> playerList, AbstractPlayer player) {
    int numPlayers = playerList.size();

    if (player.getMoney() < (this.amount * numPlayers)) {
      // TODO: Remove player because they're bankrupt
      // Distribute all the money the player has left
      int leftover = player.getMoney() / numPlayers;
      for (AbstractPlayer p : playerList) {
        p.addMoney(leftover);
      }
    } else {
      for (AbstractPlayer p : playerList) {
        p.addMoney(this.amount);
        player.removeMoney(this.amount);
      }
    }
  }
Пример #3
0
 /*What effect does a LOSEMONEY card have on a player?*/
 private void losemoney_effect(AbstractPlayer player) {
   player.removeMoney(this.amount);
 }