kedoska / engine-blackjack

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

Random wrong stage #10

Closed kedoska closed 7 years ago

kedoska commented 7 years ago

Test

  it.only('what is this', function () {
    const cards = '♠2 ♦1 ♥5 ♣6 ♠11 ♦10'
    const actions = ['restore', 'deal', 'split', 'hitR', 'hitR', 'hitR']
    const rules = {
      decks: 1,
      standOnSoft17: true,
      double: 'any',
      split: true,
      doubleAfterSplit: true,
      surrender: true,
      insurance: true,
      showdownAfterAceSplit: true
    }
    const state = executeFlow(rules, cards, actions.map(x => functions[x]))
    if (state.stage === 'player-turn-right') {
      console.dir(state.handInfo.right)
      console.dir(state.handInfo.left)
    }
    assert.equal(state.stage, 'done', cards)
  })

This little guy, sometimes fails... and when it does... the stage is "player-turn-right" which is very strange cause

Snapshot at the moment

Right Side (still open)

{ cards: 
   [ { text: '10', suite: 'diamonds', value: 10, color: 'R' },
     { text: '2', suite: 'spades', value: 2, color: 'B' },
     { text: '3', suite: 'hearts', value: 3, color: 'R' },
     { text: 'A', suite: 'diamonds', value: 1, color: 'R' },
     { text: '5', suite: 'clubs', value: 5, color: 'B' } ],
  playerValue: { hi: 21, lo: 21 },
  playerHasBlackjack: false,
  playerHasBusted: false,
  playerHasSurrendered: false,
  playerInsuranceValue: 0,
  close: false,
  availableActions: 
   { double: false,
     split: false,
     insurance: false,
     hit: true,
     stand: true,
     surrender: false },
  bet: 10 
}

Left Side (close)

{ cards: 
   [ { text: 'J', suite: 'spades', value: 10, color: 'B' },
     { text: 'A', suite: 'diamonds', value: 1, color: 'R' } ],
  playerValue: { hi: 21, lo: 11 },
  playerHasBlackjack: true,
  playerHasBusted: false,
  playerHasSurrendered: false,
  playerInsuranceValue: 0,
  close: true,
  availableActions: 
   { double: false,
     split: false,
     insurance: false,
     hit: false,
     stand: false,
     surrender: false },
  bet: 10 
}