rwx-yxu / blackjack

A simple commandline black jack simulator written in Go
Apache License 2.0
0 stars 0 forks source link

Test Cases #7

Open rwx-yxu opened 1 year ago

rwx-yxu commented 1 year ago

Starting to create test cases for the game. Current ones done:

Ones to do:

rwx-yxu commented 1 year ago

Hitting a hurdle with the blackjack score test. I have a draw phase which sets the score to 21 if they initially draw an Ace and a ten value card. Issue is that I pass through the deck which isn't easy to test because I want to pass specific cards that I make for testing purposes.

This is why I have been using the Hit method instead because I can pass through specific cards that I generate. That method does not have the logic to scan over the entire hand to check for the presence of an Ace and Ten value card. Either I remove the concept of a "Draw Phase" and just call the hit method with that logic in there or I repeat the logic in the hit method.

rwx-yxu commented 1 year ago

NVM. I made a big mistake into thinking that Ace was 10 or 1 this entire time. Changing the default to 11 and altering the corrector minus if it is over 21 in Hit method makes test pass. https://github.com/rwx-yxu/blackjack/issues/1#issuecomment-1367678500

rwx-yxu commented 1 year ago

There is an opportunity to reduce the logic code in the DrawPhase method by calling Hit from it rather than using incorrect game logic to check if the cards being drawn are aces and ten value cards.

rwx-yxu commented 1 year ago

New tests added: