/** * Player.java */ package boondock.holdem.Player; import boondock.holdem.Cards.*; /** * Class of all players that are in the game. Stores all their pertantent info. * * @author Jonathan O'Keefe * @author Scott Semonian * @author Matt Brinza * @author Hamid R. Tahsildoost * * @author The Boondock Saints * @author No Limit Texas Holdem */ public class Player { protected String PlayerName; private int PlayerChipCount, amountBetInHand, betInRound, highSet, lowSet; private double highScore = -1; protected Card card1, card2, card3, card4, card5, card6, card7; private Card highHand[], community[]; private boolean isMyTurn; private boolean inGame; private boolean inCurrentHand; private boolean currentHandCheckStatus; private boolean isDealer, isBigBlind, isSmallBlind; private int callAmount, raiseAmount; private int pot1 = 0; private int pot2 = 0; private int pot3 = 0; private int pot4 = 0; private int pot5 = 0; private int pot6 = 0; private int pot7 = 0; private int amountBetInPot1, amountBetInPot2, amountBetInPot3, amountBetInPot4, amountBetInPot5, amountBetInPot6, amountBetInPot7; /** * Sets up the player with default values */ public Player() { this.isMyTurn = false; this.inGame = false; PlayerChipCount = 0; amountBetInHand=0; //currentHandCheckStatus = true; isDealer = false; isBigBlind = false; isSmallBlind = false; }//end of default constructor /** * Provides the community cards to the Player. * * @param communityCards Card[] object that provides the community cards. */ public void setCommunityCards(Card communityCards[]) { this.community = communityCards; } /** * Gets the amount needed to call a bet. * * @return The amount needed to call a bet. */ public int getCallAmount(){ return callAmount; } /** * Sets the amount needed to call a bet. * * @param cA The amount needed to call a bet. */ public void setCallAmount(int cA){ callAmount = cA; } /** * Gets the amount a player is raising a bet. * * @return The amount that a player raised the bet. */ public int getRaiseAmount(){ return raiseAmount; } /** * Sets the amount a player is raising a bet. * * @param rA The amount that a player raised the bet. */ public void setRaiseAmount(int rA){ raiseAmount = rA; } /** * Gets the status of whether or not this player is in the current game. * * @return True if the player is in this game, False if the player is not. */ public boolean inGameStatus() { return inGame; } /** * Sets the status of whether or not this player is in the current game. * * @param isInGame Set true if the player is in this game, set false if the player is not. */ public void setInGame(boolean isInGame) { this.inGame = isInGame; } /** * Gets the name of this player. * * @return The name of this player. */ public String getName() { return PlayerName; } /** * Sets the name of this player. * * @param name The name of this player. */ public void setName(String name) { this.PlayerName = name; } /** * Gets the status of whether or not it is currently this players turn. * * @return True if it is this players turn, False if it is not this players turn. */ public boolean getIsMyTurn() { return isMyTurn; } /** * Sets the status of whether or not it is currently this players turn. * * @param isItMyTurn Set true if it is this players turn, set false if it is not this players turn. */ public void setIsMyTurn(boolean isItMyTurn) { this.isMyTurn = isItMyTurn; } /** * Gets this players chip count. * * @return The chip count of the current player. */ public int getChipCount() { return PlayerChipCount; } /** * Sets this players chip count. * * @param chips The chip count of the current player. */ public void setChipCount(int chips) { this.PlayerChipCount = chips; } /** * Sets the status of whether or not this player is in the current hand. * * @param isORnot Set true if the player is in this hand, set false if the player is not. */ public void setInCurrentHand(boolean isORnot) { this.inCurrentHand = isORnot; } /** * Gets the status of whether or not this player is in the current hand. * * @return True if the player is in this hand, False if the player is not. */ public boolean isInCurrentHand() { return inCurrentHand; } /** * Gets this players first card as a card object. * * @return Card object which is this players first card. */ public Card getFirstCard() { return card1; } /** * Sets this players first card with a card object. * * @param firstCard Card object which sets this players first card. */ public void setFirstCard(Card firstCard) { this.card1 = firstCard; } /** * Gets this players second card as a card object. * * @return Card object which is this players second card. */ public Card getSecondCard() { return card2; } /** * Sets this players second card with a card object. * * @param secondCard Card object which sets this players second card. */ public void setSecondCard(Card secondCard) { this.card2 = secondCard; } /** * Gets this players third card as a card object. * * @return Card object which is this players third card. */ public Card getThirdCard() { return card3; } /** * Sets this players third card with a card object. * * @param thirdCard Card object which sets this players third card. */ public void setThirdCard(Card thirdCard) { this.card3 = thirdCard; } /** * Gets this players fourth card as a card object. * * @return Card object which is this players fourth card. */ public Card getFourthCard() { return card4; } /** * Sets this players fourth card with a card object. * * @param fourthCard Card object which sets this players fourth card. */ public void setFourthCard(Card fourthCard) { this.card4 = fourthCard; } /** * Gets this players fifth card as a card object. * * @return Card object which is this players third card. */ public Card getFifthCard() { return card5; } /** * Sets this players fifth card with a card object. * * @param fifthCard Card object which sets this players fifthcard. */ public void setFifthCard(Card fifthCard) { this.card5 = fifthCard; } /** * Gets this players sixth card as a card object. * * @return Card object which is this players sixth card. */ public Card getSixthCard() { return card6; } /** * Sets this players sixth card with a card object. * * @param sixthCard Card object which sets this players sixth card. */ public void setSixthCard(Card sixthCard) { this.card6 = sixthCard; } /** * Gets this players seventh card as a card object. * * @return Card object which is this players seventh card. */ public Card getSeventhCard() { return card7; } /** * Sets this players seventh card with a card object. * * @param seventhCard Card object which sets this players seventh card. */ public void setSeventhCard(Card seventhCard) { this.card7 = seventhCard; } /** *Sets this players call amount for pot1 * *@param callAmount Int object which sets this players call amount for pot 1. */ public void setCallForPot1(int callAmount){ pot1 = callAmount; } /** * Gets this players call amount for pot 1 as an integer. * * @return integer which is this players call amount for pot 1. */ public int getCallForPot1() { return pot1; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot1(int amount) { this.amountBetInPot1 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot1() { return amountBetInPot1; } /** *Sets this players call amount for pot2 * *@param callAmount Int object which sets this players call amount for pot 2. */ public void setCallForPot2(int callAmount){ pot2 = callAmount; } /** *ReSets this players call amount for pot2 * *@param addAmount Int object which adds to pot 2. */ public void addCallForPot2(int addAmount){ pot2 += addAmount; } /** * Gets this players call amount for pot 2 as an integer. * * @return integer which is this players call amount for pot 2. */ public int getCallForPot2() { return pot2; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot2(int amount) { this.amountBetInPot2 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot2() { return amountBetInPot2; } /** *Sets this players call amount for pot3 * *@param callAmount Int object which sets this players call amount for pot 3. */ public void setCallForPot3(int callAmount){ pot3 = callAmount; } /** *ReSets this players call amount for pot3 * *@param addAmount Int object which adds to pot 3. */ public void addCallForPot3(int addAmount){ pot3 += addAmount; } /** * Gets this players call amount for pot 3 as an integer. * * @return integer which is this players call amount for pot 3. */ public int getCallForPot3() { return pot3; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot3(int amount) { this.amountBetInPot3 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot3() { return amountBetInPot3; } /** *Sets this players call amount for pot4 * *@param callAmount Int object which sets this players call amount for pot 4. */ public void setCallForPot4(int callAmount){ pot4 = callAmount; } /** *ReSets this players call amount for pot4 * *@param addAmount Int object which adds to pot 4. */ public void addCallForPot4(int addAmount){ pot4 += addAmount; } /** * Gets this players call amount for pot 4 as an integer. * * @return integer which is this players call amount for pot 4. */ public int getCallForPot4() { return pot4; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot4(int amount) { this.amountBetInPot4 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot4() { return amountBetInPot4; } /** *Sets this players call amount for pot5 * *@param callAmount Int object which sets this players call amount for pot 5. */ public void setCallForPot5(int callAmount){ pot5 = callAmount; } /** *ReSets this players call amount for pot5 * *@param addAmount Int object which adds to pot 5. */ public void addCallForPot5(int addAmount){ pot5 += addAmount; } /** * Gets this players call amount for pot 5 as an integer. * * @return integer which is this players call amount for pot 5. */ public int getCallForPot5() { return pot5; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot5(int amount) { this.amountBetInPot5 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot5() { return amountBetInPot5; } /** *Sets this players call amount for pot6 * *@param callAmount Int object which sets this players call amount for pot 6. */ public void setCallForPot6(int callAmount){ pot6 = callAmount; } /** *ReSets this players call amount for pot6 * *@param addAmount Int object which adds to pot 6. */ public void addCallForPot6(int addAmount){ pot6 += addAmount; } /** * Gets this players call amount for pot 6 as an integer. * * @return integer which is this players call amount for pot 6. */ public int getCallForPot6() { return pot6; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot6(int amount) { this.amountBetInPot6 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot6() { return amountBetInPot6; } /*Sets this players call amount for pot7 * *@param callAmount Int object which sets this players call amount for pot 7. */ public void setCallForPot7(int callAmount){ pot7 = callAmount; } /** *ReSets this players call amount for pot7 * *@param addAmount Int object which adds to pot 7. */ public void addCallForPot7(int addAmount){ pot7 += addAmount; } /** * Gets this players call amount for pot 7 as an integer. * * @return integer which is this players call amount for pot 7. */ public int getCallForPot7() { return pot7; } /** * Sets the amount a player has bet, so far, in this pot. * * @param amount The amount of chips this player has bet this pot, so far. */ public void setAmountBetInPot7(int amount) { this.amountBetInPot7 = amount; } /** * Gets the amount a player has bet, so far, in this pot. * * @return The amount of chips this player has bet this pot. */ public int getAmountBetInPot7() { return amountBetInPot7; } /** * Gets the amount a player has bet, so far, in this hand. * * @return The amount of chips this player has bet this hand. */ public int getAmountBetInHand() { return amountBetInHand; } /** * Sets the amount a player has bet, so far, in this hand. * * @param amount The amount of chips this player has bet this hand, so far. */ public void setAmountBetInHand(int amount) { this.amountBetInHand = amount; } /** * Gets the amount a player has bet, so far, in this round of betting. * * @return The amount of chips this player has bet in this round of betting, so far. */ public int getAmountBetInRound(){ return betInRound; } /** * Sets the amount a player has bet, so far, in this round of betting. * * @param amount The amount of chips this player has bet this round of betting, so far. */ public void setAmountBetInRound(int amount){ betInRound = amount; } /** * Gets the boolean value of whether or not the player has checked this hand. * * @return True if the player has checked this hand, False if the player has not checked this hand. */ public boolean getCurrentHandCheckStatus() { return currentHandCheckStatus; } /** * Sets the boolean value of whether or not the player has checked this hand. * * @param cStatus True if the player has checked this hand, False if the player has not checked this hand. */ public void setCurrentHandCheckStatus(boolean cStatus) { currentHandCheckStatus = cStatus; } /** * Gets the boolean value of whether or not this player is the dealer (has the dealer button). * * @return True if the player is the dealer, False if the player is not the dealer. */ public boolean getIsDealer() { return isDealer; } /** * Sets the boolean value of whether or not the player is the dealer (has the dealer button). * * @param dStatus True if the player is the dealer this hand, False if the player is not the dealer this hand. */ public void setIsDealer(boolean dStatus) { isDealer = dStatus; } /** * Gets the boolean value of whether or not this player is the big blind this hand. * * @return True if the player is the big blind this hand, False if the player is not the big blind this hand. */ public boolean getIsBigBlind() { return isBigBlind; } /** * Sets the boolean value of whether or not this player is the big blind this hand. * * @param bBStatus True if the player is the big blind this hand, False if the player is not the big blind this hand. */ public void setIsBigBlind(boolean bBStatus) { isBigBlind = bBStatus; } /** * Gets the boolean value of whether or not this player is the small blind this hand. * * @return True if the player is the small blind this hand, False if the player is not the small blind this hand. */ public boolean getIsSmallBlind() { return isSmallBlind; } /** * Sets the boolean value of whether or not this player is the small blind this hand. * * @param sBStatus True if the player is the small blind this hand, False if the player is not the small blind this hand. */ public void setIsSmallBlind(boolean sBStatus) { isSmallBlind = sBStatus; } /** * Gets the player's hand's score * * @return The score of a player's hand. */ public int getHandScore() { Card cardSet[] = new Card[7]; Card scoredCards[] = new Card[5]; ScoreHand hand; cardSet[0] = card1; cardSet[1] = card2; for(int i = 0; i < 5; i++) cardSet[2+i] = community[i]; for(int i = 0; i < 2; i++) for(int j = i+1; j < 4; j++) for(int k = j+1; k < 5; k++) for(int m = k+1; m < 6; m++) for(int n = m+1; n < 7; n++) { scoredCards[0] = cardSet[i]; scoredCards[1] = cardSet[j]; scoredCards[2] = cardSet[k]; scoredCards[3] = cardSet[m]; scoredCards[4] = cardSet[n]; hand = new ScoreHand(scoredCards); if(hand.getScore() > highScore) { highScore = hand.getScore(); highHand = hand.getHand(); highSet = hand.getHighSet(); lowSet = hand.getLowSet(); } } return (int)highScore; } /** * Gets the highest scoring hand (in Cards) * * @return The highest scoring hand. */ public Card[] getHighHand() { return highHand; } /** * Gets the high rank of eligible Cards in hand * * @return The highest ranked Card values. */ public int getHighSet() { return highSet; } /** * Gets the low rank of eligible Cards in hand * * @return The lowest ranked Card values. */ public int getLowSet() { return lowSet; } /** * Determines if this player has an equivalent hand (for ties). * * @param other The other Player. * @return True if this Player ties with the other Player. * False otherwise. */ public boolean equivalentHand(Player other) { int thisScore = this.getHandScore(); int otherScore = other.getHandScore(); if(thisScore == 5 || otherScore == 5) return false; Card temp[] = other.getHighHand(); for(int i = 0; i < 5; i++) { if(highHand[i].getNumRank() != temp[i].getNumRank()) return false; } return true; } /** * Determines if this player has a better hand. * * @param other The other Player. * @return True if this Player has a better hand than the other Player. * False otherwise. */ public boolean isBetter(Player other) { boolean win = false; int thisScore = this.getHandScore(); int otherScore = other.getHandScore(); Card temp[] = other.getHighHand(); if(thisScore > otherScore) win = true; else if(thisScore < otherScore) win = false; else if(thisScore == 8 || thisScore == 6 || thisScore == 5 || thisScore == 4 || thisScore == 0 || thisScore == -1) { for(int i = 0; i < 5; i++) { if(highHand[i].getNumRank() > temp[i].getNumRank()) win = true; } } else if(thisScore == 1) { if(this.getHighSet() > other.getHighSet()) win = true; else if(this.getHighSet() == other.getHighSet()) { for(int i = 0; i < 5; i++) { if(highHand[i].getNumRank() > temp[i].getNumRank()) win = true; } } } else if(thisScore == 2) { if(this.getHighSet() > other.getHighSet()) win = true; else if(this.getHighSet() == other.getHighSet()) { if(this.getLowSet() > other.getLowSet()) win = true; else if(this.getLowSet() == other.getLowSet()) { for(int i = 0; i < 5; i++) { if(highHand[i].getNumRank() > temp[i].getNumRank()) win = true; } } } } else if(thisScore == 3) { if(this.getHighSet() > other.getHighSet()) win = true; else if(this.getHighSet() == other.getHighSet()) { for(int i = 0; i < 5; i++) { if(highHand[i].getNumRank() > temp[i].getNumRank()) win = true; } } } else if(thisScore == 7) { if(this.getHighSet() > other.getHighSet()) win = true; else if(this.getHighSet() == other.getHighSet()) { for(int i = 0; i < 5; i++) { if(highHand[i].getNumRank() > temp[i].getNumRank()) win = true; } } } return win; } /** * Resets all the score-related information in preparation for the next hand. */ public void resetScoreInfo() { highScore = -1; highSet = 0; lowSet = 0; } public void resetPotInfo(){ pot1 = 0; pot2 = 0; pot3 = 0; pot4 = 0; pot5 = 0; pot6 = 0; pot7 = 0; amountBetInPot1 = 0; amountBetInPot2 = 0; amountBetInPot3 = 0; amountBetInPot4 = 0; amountBetInPot5 = 0; amountBetInPot6 = 0; amountBetInPot7 = 0; callAmount = 0; } }//end of player class