Package com.poker.analyst.parse

Examples of com.poker.analyst.parse.BufferParser


        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{
View Full Code Here


  public static PlayWindow fillPlayWindow(PlayWindow playWnd, String strBuffer) throws Exception{

    PokerControl pControl = new PokerControl();
    PokerData pdata = new PokerData();
    final BufferParser bufferParser = pdata.getRoomSettings().getBufferParser("");

    // Opening buffer
    File file = new File(strBuffer);
    FileReader fr = new FileReader(file);
    char[] buffer = new char[10000];   
    fr.read(buffer);   
    strBuffer = new String(buffer);
    strBuffer = strBuffer.trim();
    //System.out.println(strBuffer);


    ParserResult     parserResult = null;
    ParserResult     parserResultPrev = null;

    Board board     = pControl.createBoardShablon(pdata);
    board       = prerareBoard(board, 10, 0, 9, 0.2f);
    board.getPlayers().get(0).setStack(6.0f);
   

    Board boardPrev = null;
    Board boardPrevNew = null;

    try {           
      parserResult = bufferParser.getParserResult(strBuffer,null);

      if (parserResult.getCurrentRound() != Rounds.PREFLOP){
        boardPrevNew = pControl.createBoardShablon(pdata);
        boardPrevNew = prerareBoard(boardPrevNew, 10, 0, 9, 0.2f);
        boardPrevNew.getPlayers().get(0).setStack(4.9f);
        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) {
View Full Code Here

TOP

Related Classes of com.poker.analyst.parse.BufferParser

Copyright © 2018 www.massapicom. 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.