Package com.poker.test

Source Code of com.poker.test.PlayWindowFactory

package com.poker.test;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;

import com.poker.analyst.element.Board;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.Player;
import com.poker.analyst.element.Rounds;
import com.poker.analyst.elements.state.PlayerState;
import com.poker.analyst.parse.BufferParser;
import com.poker.analyst.parse.ParserResult;
import com.poker.control.PokerControl;
import com.poker.data.PokerData;
import com.poker.ui.settings.rooms.events.EventType;
import com.poker.ui.windows.PlayWindow;

public class PlayWindowFactory {
 
 
  public static PlayWindow getPlayWindow() throws Exception{
   
    PlayWindow playWnd = new PlayWindow(0, 10);   
    PokerControl pControl = new PokerControl();
    PokerData pdata = new PokerData();
    playWnd.setCurrentEvent(EventType.ET_IN_GAME);
    return playWnd;
  }/*
  public static PlayWindow fillBoard(final PokerData pdata, final PlayWindow playWnd) {
     
      final BufferParser bufferParser = pdata.getRoomSettings().getBufferParser();
        String strBuffer;
        ParserResult     parserResult = null;
        ParserResult     parserResultPrev = null;
        turnOnConsoleBuffer(pdata, playWnd);
        Board board     = createBoardShablon(pdata);
        Board boardPrev = null; //= createBoardShablon(pdata);
        Board boardPrevNew = null;
              
        try {
            strBuffer = getConsoleBuffer(pdata, playWnd);
            parserResult = bufferParser.getParserResult(strBuffer,null);
                              
            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 Exception("prev buffer taking exception");
            }           
        } catch (final Exception e) {
            System.err.println("buffer taking exception");
            e.printStackTrace();
            return null;
        }
        playWnd.setCurrentRound(parserResult.getCurrentRound());
       
        switch(parserResult.getCurrentRound()){
          case PREFLOP :
            playWnd.setPreflopBoard(null);
            playWnd.setFlopBoard(null);
            playWnd.setTurnBoard(null);
            playWnd.setRiverBoard(null);
            break;
          case FLOP :
            boardPrev = playWnd.getPreflopBoard();
            break;
          case TURN :
            boardPrev = playWnd.getFlopBoard();
            break;
          case RIVER :
            boardPrev = playWnd.getTurnBoard();
            break;
        } 
       
        if (parserResult.getCurrentRound() != Rounds.PREFLOP)
          for (int i = 0; i< boardPrev.getPlayers().size() ; i++)
            boardPrevNew.getPlayers().get(i).setPlayerState(boardPrev.getPlayers().get(i).getPlayerState());       
       
        System.out.println("===========================================================");
          
        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));
        board = setNamesToBoard(board,bufferParser.getPlayersName(strBuffer));
        board = setParserResultsToBoard(pdata, this, board, parserResult);
       
        if (boardPrevNew != null){
          boardPrevNew.setDealer(board.getDealer());
          boardPrevNew = setNamesToBoard(boardPrevNew,bufferParser.getPlayersName(strBuffer));
          boardPrevNew = setParserResultsToBoard(pdata, this, boardPrevNew, parserResultPrev);
        }
       
        switch(parserResult.getCurrentRound()){
        case PREFLOP :         
          break;
        case FLOP :
          playWnd.setPreflopBoard(boardPrevNew);
          break;
        case TURN :
          playWnd.setFlopBoard(boardPrevNew);
          break;
        case RIVER :
          playWnd.setTurnBoard(boardPrevNew);
          break;
      } 
        switch(parserResult.getCurrentRound()){
        case PREFLOP :
          playWnd.setPreflopBoard(board);
          break;
        case FLOP :
          playWnd.setFlopBoard(board);
          break;
        case TURN :
          playWnd.setTurnBoard(boardPrevNew);
          break;
        case RIVER :
          playWnd.setRiverBoard(board);
          break;
      }
       
        if (boardPrevNew != null){
          System.out.println("------BoardPrev-----------------------------");
          System.out.println("Round " + boardPrevNew.getCurrentRound());
          for (int i = 0; i < boardPrevNew.getPlayers().size(); i++) {
              player = boardPrevNew.getPlayers().get(i);
              System.out.print(i + ": ");
              if (boardPrevNew.getDealer() == i) {
                  System.out.print(" D ");
              } else {
                  System.out.print("   ");
              }
 
              System.out.format("%20s  ", player.getName());
              if (player.getStack() != -1) {
                  System.out.format("%5.2f", player.getStack());
              } else {
                  System.out.format("    ");
              }
              switch (player.getPlayerState()) {
              case PRS_IN_ACTION:
                  System.out.print(" ++ ");
                  break;
              case PRS_FOLD:
                  System.out.print(" F  ");
                  break;
              case PRS_SITOUT:
                  System.out.print(" _  ");
                  break;
              case PRS_NONE:
                  System.out.print("    ");
                  break;
              default:
                  System.out.print(" O  ");
                  break;
              }
              if (player.getBet() != 0) {
                  System.out.format("%5.2f", player.getBet());
              } else {
                  System.out.format("    ");
              }
 
              System.out.print("  " + player.getReaction());
              System.out.println();
          }
          System.out.println("================================");
        }
       
       
        //Painting The Board
        if (board.getPlayingCards() != null) {
            System.out.print("HCards: ");
            if (board.getPlayingCards().getPlayerCards() != null) {
                for (final Card card : board.getPlayingCards().getPlayerCards()) {
                    System.out.print(card + ", ");
                }
            }
            System.out.println();

            if (board.getPlayingCards().getTableCards() != null) {
                System.out.print("TCards: ");
            }
            for (final Card card : board.getPlayingCards().getTableCards()) {
                System.out.print(card + ", ");
            }
            System.out.println();
            if (board.getBlindPlayers() != null)
              for (Player pl: board.getBlindPlayers()){
                System.out.println(pl.getName() + ": " + pl.getBet());
              }
           
            System.out.println("Dead blinds: " + board.getDeathBlind());
            System.out.println("-----------------------------------");
                       
        }
        System.out.println("RType : " + board.getCurrentRound());
               
        System.out.println("Total : " + getAllRoundTotal(playWnd));
        System.out.println("------Board-----------------------------");
        for (int i = 0; i < board.getPlayers().size(); i++) {
            player = board.getPlayers().get(i);
            System.out.print(i + ": ");
            if (board.getDealer() == i) {
                System.out.print(" D ");
            } else {
                System.out.print("   ");
            }

            System.out.format("%20s  ", player.getName());
            if (player.getStack() != -1) {
                System.out.format("%5.2f", player.getStack());
            } else {
                System.out.format("    ");
            }
            switch (player.getPlayerState()) {
            case PRS_IN_ACTION:
                System.out.print(" ++ ");
                break;
            case PRS_FOLD:
                System.out.print(" F  ");
                break;
            case PRS_SITOUT:
                System.out.print(" _  ");
                break;
            case PRS_NONE:
                System.out.print("    ");
                break;
            default:
                System.out.print(" O  ");
                break;
            }
            if (player.getBet() != 0) {
                System.out.format("%5.2f", player.getBet());
            } else {
                System.out.format("    ");
            }

            System.out.print("  " + player.getReaction());
            System.out.println();
        }
        System.out.println("================================");
      

        return null;
    }*/
 
 
}
 
TOP

Related Classes of com.poker.test.PlayWindowFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.