ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

Combining tables after the break started doesn't show new players #1405

Closed ctm closed 1 month ago

ctm commented 2 months ago

Fix so that if a player busts on the hand that starts a break and that causes tables to be merged, then the players who get moved into the table show up for everyone.

This just happened when table 5831 broke in event 5261 after hand 404024.

ctm commented 1 month ago

FWIW, Break mesages are already preceded by Status messages, however, the Break (and preceding Status) are being generated in between the Bust and the MovedTo messages:

mb2=> select id, received_at at time zone 'america/denver', substr(message::text, 0, 160) from public_table_messages where player_id is null and hand_id = 404024 order by received_at;
...
 10841307 | 2024-05-06 18:55:20.045649 | {"EndOfHand": {"penalties": [], "player_amounts": [[[20, [1745, 0]], [17, [0, 1744]]], [[20, [4720, 0]], [17, [0, 4720]]]], "split_hand_names": ["Top Board", "
 10841308 | 2024-05-06 18:55:20.138974 | {"Bust": [32, null, 0, 20, 25, null, true, 2]}
 10841309 | 2024-05-06 18:55:20.179081 | {"Bust": [11, null, 0, 20, 25, null, true, 3]}
 10841310 | 2024-05-06 18:55:20.186481 | {"OnLevel": ["Break", [300000, "2024-05-07T01:00:20.017016096Z"], true, 9]}
 10841311 | 2024-05-06 18:55:20.192589 | {"Status": {"board": {"grid": [{"row": 1, "column": 0}, {"row": 3, "column": 0}, {"row": 1, "column": 1}, {"row": 3, "column": 1}, {"row": 1, "column": 2}, {"r
 10841312 | 2024-05-06 18:55:20.207558 | {"Break": [300000, "2024-05-07T01:00:20.017016096Z"]}
 10841317 | 2024-05-06 18:55:27.039995 | {"MovedTo": [17, 5830]}
 10841319 | 2024-05-06 18:55:27.06131  | {"MovedTo": [13, 5830]}
 10841321 | 2024-05-06 18:55:27.08897  | {"MovedTo": [20, 5830]}
 10841322 | 2024-05-06 18:55:27.095205 | "TableFinished"
 10841324 | 2024-05-06 18:55:31.624773 | {"Chat": [11, "gg"]}

That's surprising to me, but it's been a while since I've revisited the relevant code.

ctm commented 1 month ago

Sure enough, we call pause, then send HandFinished, and HandFinished causes the break to start, but the resumption of the pause is what causes the table to be combined. That actually makes sense, because by doing it in that order, we don't have to extend the break by the amount of the pause and we also give people a chance to see what happened.

The solution is to have the rebalance code see if the rebalance has caused any players to move during a break and if so, send a new status for all the affected tables.

When I do that, I should also verify that we don't have a similar problem when a late registration causes a table split during a break. I have a vague recollection that we used to have that problem and I fixed it, although late registration had enough edge cases that I've fixed that I may be misremembering.

ctm commented 1 month ago

Done. Deploying now.