Ejemplo n.º 1
0
  @Override
  public void tableCreated(Table table, LobbyTableAttributeAccessor acc) {
    super.tableCreated(table, acc);
    PokerVariant variant = template.getVariant();

    // Create state.
    PokerState pokerState = stateCreator.newPokerState();
    GameType gameType = GameTypeFactory.createGameType(variant);
    String externalTableId = "TABLE::" + UUID.randomUUID();
    PokerSettings settings = createSettings(table, externalTableId);
    pokerState.init(gameType, settings);
    pokerState.setAdapterState(new FirebaseState());
    pokerState.setTableId(table.getId());
    table.getGameState().setState(pokerState);

    // Set lobby attributes
    acc.setIntAttribute(TABLE_TEMPLATE.name(), template.getId());
    acc.setIntAttribute(PokerLobbyAttributes.VISIBLE_IN_LOBBY.name(), 0);
    acc.setStringAttribute(PokerLobbyAttributes.SPEED.name(), template.getTiming().getName());
    acc.setStringAttribute(PokerLobbyAttributes.ANTE.name(), template.getAnte().toPlainString());
    acc.setStringAttribute(
        PokerLobbyAttributes.SMALL_BLIND.name(), settings.getSmallBlindAmount().toPlainString());
    acc.setStringAttribute(
        PokerLobbyAttributes.BIG_BLIND.name(), settings.getBigBlindAmount().toPlainString());
    acc.setStringAttribute(
        PokerLobbyAttributes.BETTING_GAME_BETTING_MODEL.name(),
        settings.getBetStrategyType().name());
    acc.setStringAttribute(
        PokerLobbyAttributes.CURRENCY_CODE.name(), settings.getCurrency().getCode());
    acc.setStringAttribute(PokerLobbyAttributes.MONETARY_TYPE.name(), "REAL_MONEY");
    acc.setStringAttribute(PokerLobbyAttributes.VARIANT.name(), variant.name());
    acc.setStringAttribute(
        PokerLobbyAttributes.MIN_BUY_IN.name(), pokerState.getMinBuyIn().toPlainString());
    acc.setStringAttribute(
        PokerLobbyAttributes.MAX_BUY_IN.name(), pokerState.getMaxBuyIn().toPlainString());
    int deckSize = TELESINA_DECK_UTIL.createDeckCards(pokerState.getTableSize()).size();
    acc.setIntAttribute(PokerLobbyAttributes.DECK_SIZE.name(), deckSize);
    acc.setStringAttribute(PokerLobbyAttributes.TABLE_EXTERNAL_ID.name(), externalTableId);

    // Announce table
    // FirebaseCallbackFactory callbackFactory = cashGameBackendService.getCallbackFactory();
    AnnounceTableRequest announceRequest =
        new AnnounceTableRequest(
            new TableId(
                table.getMetaData().getGameId(),
                table.getId())); // TODO: this should be the id from the table record
    cashGameBackendService.announceTable(announceRequest);
  }
Ejemplo n.º 2
0
  private PokerSettings createSettings(Table table, String externalTableId) {
    BigDecimal minBuyIn = template.getMinBuyIn();
    BigDecimal maxBuyIn = template.getMaxBuyIn();

    /*if (template.getBetStrategy() == BetStrategyType.FIXED_LIMIT) {
        maxBuyIn = Integer.MAX_VALUE;
    }*/

    int seats = table.getPlayerSet().getSeatingMap().getNumberOfSeats();
    RakeSettings rake = template.getRakeSettings();
    // Map<Serializable,Serializable> attributes = Collections.emptyMap();
    Map<Serializable, Serializable> attributes =
        Collections.<Serializable, Serializable>singletonMap(
            TABLE_EXTERNAL_ID.name(), externalTableId);
    BigDecimal smallBlindAmount = template.getSmallBlind();
    BigDecimal bigBlindAmount = template.getBigBlind();
    BlindsLevel level = new BlindsLevel(smallBlindAmount, bigBlindAmount, template.getAnte());
    Currency currency = cashGameBackendService.getCurrency(template.getCurrency());
    return new PokerSettings(
        level,
        template.getBetStrategy(),
        minBuyIn,
        maxBuyIn,
        template.getTiming(),
        seats,
        rake,
        currency,
        attributes);
  }