geobalas / Poker

An online poker app
MIT License
207 stars 158 forks source link

The `call` and `raise to` CTAs take stale value from previous hand. #18

Open xtoss opened 3 years ago

xtoss commented 3 years ago

Reproduce:

  1. login with two players and play heads up for a few hands.
  2. raise a few hands
  3. maybe try sit out and sit back in for one player
  4. notice the raise to CTA takes stale value from previous raised hand.

For example, Jamie raised to 14 in previous hand but in current hand, the call should be 1 and raise to should default to 4:

Screen Shot 2021-03-29 at 3 16 29 PM
xtoss commented 3 years ago

unfortunately fix by https://github.com/Froren above might have introduced a different bug in which the raise to button was removed entirely:

Screen Shot 2021-03-30 at 12 22 05 AM
lesereli000 commented 6 months ago

Project: https://github.com/geobalas/Poker Symptoms: For Example, in a 2 player game, player 1 will ‘raise to’ any amount (state a). If player 2 folds, then after the blinds are posted in the next hands the active player will be prompted to call or raise on the prefold biggest bet in state (a). Hypothesis: Errors in the end of round or round initialization code are not setting the biggest bid amount back to 0. Outcome: disproven. I put biggestBet = 0 in both sections in appropriate locations and the error continued Hypothesis: The fold code does not properly end the round Outcome: disproven. All fields of the table object are properly changed at the end of the round and for initialization Fact: Biggest Bet is 0 when the small blind and big blind are posted, so either it gets changed between the when the blinds are posted and when the browser calls the callAmount function, or the callAmount function is receiving infectious data when it is called Hypothesis: The table data is not being updated at the end of the fold method as it should be Outcome: While this did not fix the bug, I believe it to still be true. Emitting the ‘table data’ update signal should occur after the end of round code, not before. Hypothesis: The frontend code is somehow pulling different data than is being set in the backend methods. Outcome: True. when using the chrome debugger on the front end, I confirmed that the biggestBid that the front end method calls were retrieving was infact the old value, despite having inserted code to change it and observing the biggest bid benign correctly set in the backend many times. I looked for where the value of biggest bet was being set and found that the code should be setting this.public.biggestBet = 0 instead. Fix and Location: I tried moving the original emit clause back to where it was and it worked, so it appears that the minimal, actual cause was just that the public BiggestBet variable was never properly set, adding in the line “this.public.biggestBet = 0;” on line 215, is sufficient to fix the bug and restore proper functionality.

lesereli000 commented 6 months ago

@xtoss If you are still interested in updating this issue, this should fix it for you. 😃