gt: 								+ ((Player) theApp.getPlayerList().get(
context: /******************************************************************************************
   * LowChicago.java                 PokerApp                                               *
   *                                                                                        *
   *   Revision History                                                                     *
   * +---------+----------+---------------------------------------------------------------+ *
   * | Version | DATE     | Description                                                   | *
   * +---------+----------+---------------------------------------------------------------+ *
   * |  0.99   | 05/19/05 | Initial documented release                                    | *
   * |  1.00   | 06/07/05 | Added logging.                                                | *
   * |  1.00   | 08/02/07 | Prepare for open source.  Header/comments/package/etc...      | *
   * +---------+----------+---------------------------------------------------------------+ *
   *                                                                                        *
   * PokerApp Copyright (C) 2004  Dan Puperi                                                *
   *                                                                                        *
   *   This program is free software: you can redistribute it and/or modify                 *
   *   it under the terms of the GNU General Public License as published by                 *
   *   the Free Software Foundation, either version 3 of the License, or                    *
   *   (at your option) any later version.                                                  *
   *                                                                                        *
   *   This program is distributed in the hope that it will be useful,                      *
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of                       *
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                        *
   *   GNU General Public License for more details.                                         *
   *                                                                                        *
   *   You should have received a copy of the GNU General Public License                    *
   *   along with this program.  If not, see <http://www.gnu.org/licenses/>                 *
   *                                                                                        *
   ******************************************************************************************/
  
  package net.sourceforge.pokerapp.games;
  
  import net.sourceforge.pokerapp.*;
  import java.util.ArrayList;
  
  /****************************************************
   * Seven card stud with low chicago game definition.
   * 
   * @author Dan Puperi
   * @version 1.00
   * 
   **/
  public class LowChicago extends SevenCardStud {
  
  	/**
  	 * The index of the player who has low chicago.
  	 **/
  	protected int chicagoIndex;
  	/**
  	 * The card that wins low chicago.
  	 **/
  	protected Card chicagoCard;
  
  	private boolean rememberNoLimit; // If the game was started as no limit,
  										// make it bet limit, but change back
  										// after the game.
  	private boolean rememberPotLimit; // If the game was started as pot limit,
  										// make it bet limit, but change back
  										// after the game.
  	private boolean rememberBetLimit; // Remember if the game was started as bet
  										// limit, so it doesn't try to change it
  										// after the game.
  
  	/***********************
  	 * Constructor creates an instance of a game of LowChicago
  	 * 
  	 * @param a
  	 *            The StartPoker instance to which this game belongs
  	 * 
  	 **/
  	public LowChicago(StartPoker a) {
  		super(a, "Seven Card Stud with Low Chicago", true);
  		if (theApp.getPlayerList().size() < 2) {
  			return;
  		}
  		theApp.log("Constructing a game of Low Chicago", 3);
  		rememberNoLimit = theApp.noLimit;
  		rememberPotLimit = theApp.potLimit;
  		rememberBetLimit = theApp.betLimit;
  		chicagoIndex = -1;
  		chicagoCard = new Card();
  		if (theApp.noLimit) {
  			theApp.betLimit = true;
  			theApp.noLimit = false;
  			theApp.updateRules();
  			theApp.broadcastRules();
  			theApp.broadcastMessage("REFRESH");
  		}
  		if (theApp.potLimit) {
  			theApp.betLimit = true;
  			theApp.potLimit = false;
  			theApp.updateRules();
  			theApp.broadcastRules();
  			theApp.broadcastMessage("REFRESH");
  		}
  	}
  
  	/***********************
  	 * Constructor creates an instance of a game of Seven Card Stud This
  	 * constructor is used by other games which can extends this game
  	 * 
  	 * @param a
  	 *            The StartPoker instance to which this game belongs
  	 * @param gameName
  	 *            The name of the game
  	 * @param selfInit
  	 *            Whether or not the game can initialize itself.
  	 * 
  	 **/
  	public LowChicago(StartPoker a, String gameName, boolean selfInit) {
  		super(a, gameName, selfInit);
  		if (theApp.getPlayerList().size() < 2) {
  			return;
  		}
  		theApp.log("Constructing a game of Low Chicago", 3);
  		rememberNoLimit = theApp.noLimit;
  		rememberPotLimit = theApp.potLimit;
  		rememberBetLimit = theApp.betLimit;
  		chicagoIndex = -1;
  		chicagoCard = new Card();
  		if (theApp.noLimit) {
  			theApp.betLimit = true;
  			theApp.noLimit = false;
  			theApp.updateRules();
  			theApp.broadcastRules();
  			theApp.broadcastMessage("REFRESH");
  		}
  		if (theApp.potLimit) {
  			theApp.betLimit = true;
  			theApp.potLimit = false;
  			theApp.updateRules();
  			theApp.broadcastRules();
  			theApp.broadcastMessage("REFRESH");
  		}
  	}
  
  	/**********************
  	 * calcChicago() used to calculate the player who has the low spade in the
  	 * hole. There are two overloaded methods because the first on just uses the
  	 * player list the other one uses an argument for the player list.
  	 * 
  	 * @return The index of the player with the low Chicago
  	 * 
  	 **/
  	protected int calcChicago() {
  		theApp.log("LowChicago.calcChicago()", 3);
  		int lowPlayer = -1;
  		chicagoCard = new Card("Ace of Spades");
  		for (int i = 0; i < theApp.getPlayerList().size(); i++) {
  			Player p = (Player) theApp.getPlayerList().get(i);
  			if (p.in) {
  				for (int j = 0; j < 3; j++) {
  					Card c = p.getHand().getHoleCard(j);
  					if ((c.getSuit() == Card.SPADES)
  							&& (((c.getRank() < chicagoCard.getRank()) && (c
  									.getRank() != Card.ACE)) || (chicagoCard
  									.getRank() == Card.ACE))) {
  						lowPlayer = i;
  						chicagoCard = c;
  					}
  				}
  			}
  		}
  		return lowPlayer;
  	}
  
  	/**********************
  	 * calcChicago() used to calculate the player who has the low spade in the
  	 * hole. There are two overloaded methods because the first on just uses the
  	 * player list the other one uses an argument for the player list.
  	 * 
  	 * @param players
  	 *            A String array of player names who are eligible for the low
  	 *            Chicago
  	 * @return The index in the array of the player with low Chicago
  	 * 
  	 **/
  	protected int calcChicago(String[] players) {
  		theApp.log("LowChicago.calcChicago( " + players + " )", 3);
  		int lowPlayer = -1;
  		chicagoCard = new Card("Ace of Spades");
  		for (int i = 0; i < players.length; i++) {
  			Player p = (Player) theApp.getPlayerList().get(
  					theApp.playerIndex(players[i]));
  			if (p.in) {
  				for (int j = 0; j < 3; j++) {
  					Card c = p.getHand().getHoleCard(j);
  					if ((c.getSuit() == Card.SPADES)
  							&& (((c.getRank() < chicagoCard.getRank()) && (c
  									.getRank() != Card.ACE)) || (chicagoCard
  									.getRank() == Card.ACE))) {
  						lowPlayer = theApp.playerIndex(players[i]);
  						chicagoCard = c;
  					}
  				}
  			}
  		}
  		return lowPlayer;
  	}
  
  	/**********************
  	 * show() called at the showdown
  	 **/
  	protected void show() {
  		theApp.log("LowChicago.show()", 3);
  		theApp.playedInLastGame = new ArrayList();
  		for (int i = 0; i < theApp.getPlayerList().size(); i++) {
  			theApp.playedInLastGame
  					.add(((Player) theApp.getPlayerList().get(i)).getName());
  		}
  		theApp.broadcastMessage("MESSAGE &Calculating winner...");
  		chicagoIndex = calcChicago();
  		calcWinner();
  		showCards();
  		if (chicagoIndex >= 0) {
  			showPlayer((Player) theApp.getPlayerList().get(chicagoIndex), true);
  		}
  		theApp.betLimit = rememberBetLimit;
  		theApp.noLimit = rememberNoLimit;
  		theApp.potLimit = rememberPotLimit;
  		theApp.updateRules();
  		theApp.broadcastRules();
  		theApp.resetPot();
  		theApp.nextDealer();
  		theApp.updateMoneyLine(new PokerMoney(0.0f), "  ");
  		theApp.nullifyGame();
  		theApp.broadcastMessage("DISABLE BUTTONS");
  	}
  
  	/**********************
  	 * calcWinner() calculate the winner(s) of the game.
  	 **/
  	protected void calcWinner() {
  		theApp.log("LowChicago.calcWinner()", 3);
  		int highPlayer = 0;
  		float highHand = 0.0f;
  		String winningHand = new String();
  		int numWinners = 0;
  		int winner[] = new int[MAX_PLAYERS];
  		playerHandValues = new float[MAX_PLAYERS];
  
  		for (int i = 0; i < theApp.getPlayerList().size(); i++) {
  			Player p = (Player) theApp.getPlayerList().get(i);
  			if (p.in) {
  				playerHandValues[i] = bestHand(p.getHand());
  				if (playerHandValues[i] > highHand) {
  					highHand = playerHandValues[i];
  					highPlayer = i;
  				}
  			}
  		}
  		for (int i = 0; i < theApp.getPlayerList().size(); i++) {
  			Player p = (Player) theApp.getPlayerList().get(i);
  			if (p.in) {
  				if ((playerHandValues[i] == highHand) || (chicagoIndex == i)) {
  					winner[numWinners] = i;
  					numWinners++;
  				}
  			}
  		}
  		winningHand = HandEvaluator.nameHand(highHand);
  		minValueToShow = highHand;
  
  		PokerMoney winnersTake = new PokerMoney(theApp.getPot().amount());
  		if (sidePots.size() != 0) {
  			for (int i = 0; i < sidePots.size(); i++) {
  				winnersTake.subtract(((SidePot) sidePots.get(i)).getPot()
  						.amount());
  			}
  		}
  
  		if (numWinners == 1) {
  			if (chicagoIndex >= 0) {
  				theApp.log(
  						""
  