Package edu.villanova.studs.poker.transport

Examples of edu.villanova.studs.poker.transport.TableDataCommunity


    }
   
   
    public static void main(String[] args) {
       
        TableDataIntf td = new TableDataCommunity();
        Hashtable<String, Object> opts = new Hashtable<String, Object>();
        Locale.setDefault( Locale.GERMAN );
        try {
            Player p = new Player();
            p.addCard( new Card(1,1) );
            p.addCard( new Card(1,2) );
            td.addPlayer( p );
            td.addPlayer( new Player() );
        } catch (TransportException e) {
          e.printStackTrace(System.out);
            CalcEngineException ex = new CalcEngineException( "My message" , e);
            System.out.println(ex.getLocalizedMessage( Locale.GERMAN) );
            return;
        }
        opts.put( CalcEngineFactory.ENGINE_PROPH_SIMS, -1 );
        td.setOptions( opts );
       
        CalculateResults results = new CalculateResults();
               
        //Object o = TransportUtils.getDeserializedResult(new CalcHandResults().getResults( td ), res.getClass() );
        results = (CalculateResults)TransportUtils.getDeserializedResult(new CalcHandResults().getResults( TransportUtils.getSerializedResult( td ), 1 ), results.getClass() );
View Full Code Here


        QName opGetResults = new QName( QUALIFIED_CLASS_NAME, "getResults" );
       
        //The processing servlet will need to build the table data from the UI.
        //Here just create a community table data instance that will use the
        //random card calc engine
        TableDataCommunity td = new TableDataCommunity();
        Hashtable<String, Object> opts = new Hashtable<String, Object>();
        opts.put( CalcEngineFactory.ENGINE_PROPH_RAND, new Random( (new Random()).nextLong() ).nextInt( 6 ) + 1 );
        td.setOptions( opts );
       
        //Set a serialzied byte array to pass as a service parameter
        byte[] b =  TransportUtils.getSerializedResult( td );
       
        //Setup an array of input arguments - include the flag indicating the
View Full Code Here

    pokerTable.setOptions(options);
  }

  @Override
  public void createNewPokerTable() {
    this.pokerTable = new TableDataCommunity();
  }
View Full Code Here

    }

  @Test
  public void calculate() throws Exception {
    CalculatorIntf calculator = new CalculatorLocalImpl();
    TableDataIntf tableData = new TableDataCommunity();
    Player p1 = new Player(), p2 = new Player();
    Card p1c1 = new Card(TransportUtils.ACE, TransportUtils.SPADES),
      p1c2 = new Card(TransportUtils.TWO, TransportUtils.SPADES),
      p2c1 = new Card(TransportUtils.ACE, TransportUtils.HEARTS),
      p2c2 = new Card(TransportUtils.TWO, TransportUtils.HEARTS);
   
    p1.addCard(p1c1);
    p1.addCard(p1c2);
   
    p2.addCard(p2c1);
    p2.addCard(p2c2);
   
    tableData.addPlayer(p1);
    tableData.addPlayer(p2);
   
    Hashtable <String, Object> opts = new Hashtable <String, Object> ();
    opts.put(CalcEngineFactory.ENGINE_PROPH_SIMS, 50);
    tableData.setOptions(opts);
   
    CalculateResults results = calculator.calculate(tableData);
   
    //check that results were actually returned
    assertNotNull(results);
View Full Code Here

    private Player p;
   
    public CalcEngineProphesierTest(String sTestName) {
        super(sTestName);

        td = new TableDataCommunity();
        proph = new CalcEngineProphesier();
        cards = new ArrayList<Card>();
        p = new Player();
    }
View Full Code Here

    return "cc" + spot;
  }
 
  public static TableDataIntf buildTableData(ServletRequest req) throws TransportException {
   
            TableDataCommunity tableData = new TableDataCommunity();
            Table table = new Table();
            ArrayList<Card> communityCards = new ArrayList<Card>();
            Card tmpCard = null;
            Player tmpPlayer = null;
            String playerFold = null;

      int numOfPlayers = Integer.parseInt(req.getParameter(REQ_PARAM_NUM_PLAYERS));
      // loop through all the players
      for (int i = 1; i <= numOfPlayers; i++) {
              tmpPlayer = new Player();
              tmpCard = convertValueToCard(req.getParameter(getPlayerParamName(i, 1)));
              if (tmpCard.getRank() != TransportUtils.UNKNOWN
                              && tmpCard.getSuit() != TransportUtils.UNKNOWN) {
                      tmpPlayer.addCard(tmpCard);
              }

              tmpCard = convertValueToCard(req.getParameter(getPlayerParamName(i, 2)));
              if (tmpCard.getRank() != TransportUtils.UNKNOWN
                              && tmpCard.getSuit() != TransportUtils.UNKNOWN) {
                      tmpPlayer.addCard(tmpCard);
              }
             
              playerFold = req.getParameter(getPlayerFoldParamName(i));
              tmpPlayer.setFolded(REQ_VALUE_FOLD.equals(playerFold));

              tableData.addPlayer(tmpPlayer);
      }

      // loop through the community cards
      boolean stop = false;
      for (int i = 1; !stop && i <= 5; i++) {
              tmpCard = convertValueToCard(req.getParameter(getCommunityParamName(i)));
              if (tmpCard.getRank() != TransportUtils.UNKNOWN
                              && tmpCard.getSuit() != TransportUtils.UNKNOWN) {
                      communityCards.add(tmpCard);
              }
      }
      table.setCommunity(communityCards);
      tableData.setGameTable(table);

      // set the options
      Hashtable<String, Object> options = new Hashtable<String, Object>();
      int accuracyLevel = 1;
     
      accuracyLevel = Integer.parseInt(req.getParameter(REQ_PARAM_ACCURACY_LEVEL));
     
      options.put(CalcEngineFactory.ENGINE_PROPH_SIMS, accuracyLevel);
      tableData.setOptions(options);
           
            return tableData;
  }
View Full Code Here

TOP

Related Classes of edu.villanova.studs.poker.transport.TableDataCommunity

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.