}
@Override
public void holeCardsChangedCommandReceived(PlayerHoleCardsChangedCommand command)
{
final PlayerInfo p = m_pokerTable.getPlayer(command.getPlayerPos());
if (p != null)
{
if (command.isPlaying())
{
p.setPlaying();
}
else
{
p.setNotPlaying();
}
final List<Integer> ids = command.getCardsId();
final Card gc0 = Card.getInstance(ids.get(0));
final Card gc1 = Card.getInstance(ids.get(1));
p.setCards(gc0, gc1);
m_gameObserver.playerHoleCardsChanged(p);
}
}
@Override
public void playerJoinedCommandReceived(PlayerJoinedCommand command)
{
final PlayerInfo p = new PlayerInfo(command.getPlayerPos(), command.getPlayerName(), command.getPlayerMoney());
if (p != null)
{
m_pokerTable.forceJoinTable(p, command.getPlayerPos());
m_gameObserver.playerJoined(p);
}
}
@Override
public void playerLeftCommandReceived(PlayerLeftCommand command)
{
final PlayerInfo p = m_pokerTable.getPlayer(command.getPlayerPos());
if (p != null)
{
m_pokerTable.leaveTable(p);
m_gameObserver.playerLeaved(p);
}
}
@Override
public void playerMoneyChangedCommandReceived(PlayerMoneyChangedCommand command)
{
final PlayerInfo p = m_pokerTable.getPlayer(command.getPlayerPos());
if (p != null)
{
p.setMoneySafeAmnt(command.getPlayerMoney());
m_gameObserver.playerMoneyChanged(p);
}
}
@Override
public void playerTurnBeganCommandReceived(PlayerTurnBeganCommand command)
{
final PlayerInfo p = m_pokerTable.getPlayer(command.getPlayerPos());
final PlayerInfo last = m_pokerTable.getPlayer(command.getLastPlayerNoSeat());
if (p != null)
{
m_pokerTable.setNoSeatCurrPlayer(command.getPlayerPos());
m_gameObserver.playerActionNeeded(p, last);
}
}
@Override
public void playerTurnEndedCommandReceived(PlayerTurnEndedCommand command)
{
if (m_pokerTable.getHigherBet() < command.getPlayerBet())
{
m_pokerTable.setHigherBet(command.getPlayerBet());
}
m_pokerTable.setTotalPotAmnt(command.getTotalPot());
final PlayerInfo p = m_pokerTable.getPlayer(command.getPlayerPos());
if (p != null)
{
if (command.getActionType() == PlayerActionType.RAISED)
{
m_pokerTable.setNoSeatLastRaise(p.getNoSeat());
}
final int a = command.getActionAmount();
p.setMoneyBetAmnt(command.getPlayerBet());
p.setMoneySafeAmnt(command.getPlayerMoney());
if (command.isPlaying())
{
p.setPlaying();
}
else
{
p.setNotPlaying();
}
m_gameObserver.playerActionTaken(p, command.getActionType(), a);
}
}
@Override
public void playerWonPotCommandReceived(PlayerWonPotCommand command)
{
final PlayerInfo p = m_pokerTable.getPlayer(command.getPlayerPos());
if (p != null)
{
p.setMoneySafeAmnt(command.getPlayerMoney());
m_gameObserver.playerWonPot(p, new PotInfo(command.getPotID(), command.getShared()), command.getShared());
}
}
@Override
public void tableClosedCommandReceived(TableClosedCommand command)
{
m_gameObserver.everythingEnded();
}
@Override
public void tableInfoCommandReceived(TableInfoCommand command)
{
m_pokerTable.setTotalPotAmnt(command.getTotalPotAmount());
m_pokerTable.setBetLimit(command.getLimit());
final List<Integer> amounts = command.getPotsAmount();
m_pokerTable.getPots().clear();
for (int i = 0; i < amounts.size() && amounts.get(i) > 0; ++i)
{
m_pokerTable.getPots().add(new PotInfo(i, amounts.get(i)));
}
final Card[] cards = new Card[5];
for (int i = 0; i < 5; ++i)
{
cards[i] = Card.getInstance(command.getBoardCardIDs().get(i));
}
m_pokerTable.setCards(cards[0], cards[1], cards[2], cards[3], cards[4]);
for (final PlayerInfo p : m_pokerTable.getPlayers())
{
m_pokerTable.leaveTable(p);
}
for (int i = 0; i < command.getNbPlayers(); ++i)
{
final TuplePlayerInfo seat = command.getSeats().get(i);
if (seat.m_isEmpty)
{
continue;
}
final int noSeat = seat.m_noSeat;
final PlayerInfo p = new PlayerInfo(noSeat, seat.m_playerName, seat.m_money);
m_pokerTable.forceJoinTable(p, noSeat);
final List<Integer> ids = seat.m_holeCardIDs;
p.setCards(Card.getInstance(ids.get(0)), Card.getInstance(ids.get(1)));
if (seat.m_isPlaying)
{
p.setPlaying();
}
if (seat.m_isDealer)
{
m_pokerTable.setNoSeatDealer(noSeat);
}
if (seat.m_isSmallBlind)
{
m_pokerTable.setNoSeatSmallBlind(noSeat);
}
if (seat.m_isBigBlind)
{
m_pokerTable.setNoSeatBigBlind(noSeat);
}
if (seat.m_isCurrentPlayer)
{
m_pokerTable.setNoSeatCurrPlayer(noSeat);
}
p.setMoneyBetAmnt(seat.m_bet);
m_gameObserver.playerHoleCardsChanged(p);
}
m_gameObserver.gameGenerallyUpdated();