コード例 #1
0
ファイル: EventCard.java プロジェクト: ShaeBrown/Monopoly
 /*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
ファイル: EventCard.java プロジェクト: ShaeBrown/Monopoly
  /*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
ファイル: EventCard.java プロジェクト: ShaeBrown/Monopoly
 // is this supposed to be relative or absolute??
 // the advance to GO card moves the player 0 spaces.
 private void moveto_effect(AbstractPlayer player) {
   // Move player and if they pass go they collect $200
   int location = player.getLocation() + this.amount;
   if (location > (Game.BOARDSIZE - 1)) {
     location = location - (Game.BOARDSIZE - 1);
     player.addMoney(200);
   }
   player.setLocation(location);
 }
コード例 #4
0
ファイル: EventCard.java プロジェクト: ShaeBrown/Monopoly
 /*What effect does a GAINMONEY card have on a player?*/
 private void gainmoney_effect(AbstractPlayer player) {
   player.addMoney(this.amount);
 }