return playWnd;
}
public PlayWindow fillPlayWnd(final PokerData pdata, PlayWindow playWnd) throws Exception{
final BufferParser bufferParser = pdata.getRoomSettings().getBufferParser(pdata.getProgramSettings().getHeroName());
String strBuffer;
ParserResult parserResult = null;
ParserResult parserResultPrev = null;
turnOnConsoleBuffer(pdata, playWnd);
Board board = createBoardShablon(pdata);
Board boardPrev = null;
Board boardPrevNew = null;
//getting buffer
strBuffer = getConsoleBuffer(pdata, playWnd);
parserResult = bufferParser.getParserResult(strBuffer,null);
if (parserResult == null) throw new ParserException();
if (parserResult.getCurrentRound() != Rounds.PREFLOP){
boardPrevNew = createBoardShablon(pdata);
switch (parserResult.getCurrentRound()) {
case FLOP:
parserResultPrev = bufferParser.getParserResult(strBuffer,Rounds.PREFLOP);
break;
case TURN:
parserResultPrev = bufferParser.getParserResult(strBuffer,Rounds.FLOP);
break;
case RIVER:
parserResultPrev = bufferParser.getParserResult(strBuffer,Rounds.TURN);
break;
}
if (parserResultPrev == null) throw new ParserException();
}
playWnd.setCurrentRound(parserResult.getCurrentRound());
BufferedImage[] hStacks = getStacksImages(pdata, playWnd);
hStacks = getPreparedStacksImages(pdata, hStacks, 2);
final String[] strStacks = getStacksStrings(pdata, hStacks);
final Float[] flStacks = getStacksFloats(pdata, strStacks);
final Boolean[] activePlayers = getPlayersWithCards(pdata, playWnd);
final Boolean[] sitoutPlayers = getSitoutPlayers(pdata, playWnd);
final Boolean[] emptyPlaces = getEmptyPlace(pdata, playWnd);
final Boolean[] foldPlayers = getFoldPlayers(pdata, playWnd);
Player player;
for (int i = 0; i < board.getPlayers().size(); i++) {
player = board.getPlayers().get(i);
if (activePlayers[i]) {
player.setPlayerState(PlayerState.PRS_IN_ACTION);
} else if (sitoutPlayers[i]) {
player.setPlayerState(PlayerState.PRS_SITOUT);
} else if (emptyPlaces[i]) {
player.setPlayerState(PlayerState.PRS_NONE);
} else if (foldPlayers[i]) {
player.setPlayerState(PlayerState.PRS_FOLD);
} else {
player.setPlayerState(PlayerState.PRS_SITOUT);
}
if (board.getHero() == i) {
player.setPlayerState(PlayerState.PRS_IN_ACTION);
}
player.setStack(flStacks[i]);
}
board.setDealer(findTheButtonPosition(pdata, playWnd));
System.out.println("first auction: " + parserResult.isFirstAuction());
if (parserResult.getCurrentRound() == Rounds.PREFLOP){
board.setFirstAuction(parserResult.isFirstAuction());
if (parserResult.isFirstAuction()){
board = setNamesToBoard(pdata, board,bufferParser.getPlayersName(strBuffer),parserResult,true);
}else{
for(int i = 0; i< board.getPlayers().size(); i++){
board.getPlayers().get(i).setName(playWnd.getPreflopBoard().getPlayers().get(i).getName());
}
board = setNamesToBoard(pdata, board,bufferParser.getPlayersName(strBuffer),parserResult,false);
}
}else{
boardPrevNew.setDealer(board.getDealer());
if (parserResult.getCurrentRound() == Rounds.FLOP){
for(int i = 0; i< board.getPlayers().size(); i++){
boardPrevNew.getPlayers().get(i).setName(playWnd.getPreflopBoard().getPlayers().get(i).getName());
boardPrevNew.getPlayers().get(i).setPlayerState(board.getPlayers().get(i).getPlayerState());
}
boardPrevNew = setNamesToBoard(pdata, boardPrevNew,bufferParser.getPlayersName(strBuffer),parserResultPrev,false);
for(int i = 0; i< board.getPlayers().size(); i++){
board.getPlayers().get(i).setName(boardPrevNew.getPlayers().get(i).getName());
}
}
else{