kedoska / engine-blackjack

Javascript library to make blackjack engines
GNU General Public License v2.0
33 stars 29 forks source link

How do I make a game with non-default parameters? #57

Closed funcdoor closed 6 years ago

funcdoor commented 6 years ago

I'm not sure what arguments to give to new Game() for things like standOnSoft17

kedoska commented 6 years ago

hi @funcdoor,

the Game cto needs 2 arguments:

  1. the eventual initial state
  2. the set of rules.
constructor (initialState: State, rules: Rule = getRules({}))

Assuming the default settings returned by the function getRules() is not what you want for your players, you can override the rules like this:

const { presets, actions, Game } = require('engine-blackjack')

const overrideRules = {
  decks: 6
}

const rules = presets.getRules(overrideRules)

const game = new Game(null, rules)

const stateAfterDeal = game.dispatch(actions.deal({ bet: 100 }))

console.dir(stateAfterDeal)
funcdoor commented 6 years ago

Thanks very much, I got it working! I actually wanted to turn off "standOnSoft17"; I've found that "hit on soft 17" is the norm in Las Vegas tables.