kedoska / engine-blackjack

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

Error when no bet is provided to deal() #15

Closed markbrouch closed 7 years ago

markbrouch commented 7 years ago

What kind of issue is this? "Bug" or "New Feature"

Bug

Actual behavior

Unexpected exception 'TypeError: Cannot read property 'bet' of undefined'

How can we reproduce it? From "Stage" -> "Action" -> Cards

const game = new blackjack.Game();
game.dispatch(blackjack.actions.deal());

Error goes away by providing a bet value of 0 to deal({ bet: 0 }), but I think if bet is omitted it should automatically default 0 instead of throwing error.

kedoska commented 7 years ago

@markbrouch default value of bet was arbitrarily sets to 10 since the beginning. Last commit provides better defaults but in real situations, when you are actually using the engine, passing values from the client, it should not be an issue.

This is off course a lack of documentation in this project...

markbrouch commented 7 years ago

@kedoska awesome thanks for the quick fix! I'm using the engine in a little blackjack training app that doesn't actually play a whole game so the betting doesn't matter much to me. I just passed an arbitrary value so it wouldn't error. https://github.com/markbrouch/alexa-blackjack-trainer