/** * Returns the opponent. From this, you can rerieve information about your opponent. * * @param me * @return */ public AbstractPlayer getOpponent(AbstractPlayer me) { for (AbstractPlayer player : players) { if (me.getName() != player.getName()) { return player; } } throw new IllegalArgumentException("List of players is malformed"); }
/*What effect does a GOBACK card have on a player?*/ private void goback_effect(AbstractPlayer player) { int location = player.getLocation(); if (location >= 0) location -= 3; else location = (Game.BOARDSIZE - location); player.setLocation(location); }
// 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); }
/** * Convenience method to get the total pot in the game * * @return */ public int getTotalPot() { logger.finest("Entering getTotalPot"); int totalPot = 0; for (AbstractPlayer player : players) { logger.finest(player.getName() + ":" + player.getPot()); totalPot += player.getPot(); } logger.finest("Pot: " + totalPot); return totalPot; }
/** * Return's opponent's bet, as a convenient method. If the opponent folds, checks, or calls, this * returns 0. Otherwise, it will return the amount that the player bet. * * @param me * @return */ public int getOpponentBet(AbstractPlayer me) { AbstractPlayer opponent = getOpponent(me); PlayerActivityRecord a = playerActivityRecords.get(playerActivityRecords.size() - 1); PlayerAction playerAction = a.getPlayerAction(); if (opponent.getName().equals(a.getName()) && (playerAction.getActionType() == ActionType.BET_OR_RAISE)) { return playerAction.getBet(); } else { return 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); } } }
/*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); } } }
/*What effect does a JAILFREECARD card have on a player?*/ private void jailfreecard_effect(AbstractPlayer player) { player.addJailFreeCard(); }
/*What effect does a GOTOJAIL card have on a player?*/ private void gotojail_effect(AbstractPlayer player) { // TODO: Add jail effect player.setLocation(GRIDNUM.Jail.getNum()); }
/*What effect does a LOSEMONEY card have on a player?*/ private void losemoney_effect(AbstractPlayer player) { player.removeMoney(this.amount); }
/*What effect does a GAINMONEY card have on a player?*/ private void gainmoney_effect(AbstractPlayer player) { player.addMoney(this.amount); }
/** * Returns true if the player passed in is the big blind. * * @param me * @return */ public boolean isBigBlind(AbstractPlayer me) { return playerActivityRecords.get(1).getName().equals(me.getName()); }
@Override public void set(String player, World world) { super.set(player, world); }