I'm writing a poker app and need to implement the betting logic for the no-limit games. The basic rules behind min-raise/reopen have been discussed here before and I'm trying to express them (semi-) formally like this:
When it's a player's turn to act, there is a current bet CB and a previous raise PR. Also, there is a player OP who opened the betting round.
Pre-flop, CB and PR are both initially equal to the Big Blind, and the player sitting in the Big Blind is the OP.
Post-flop, CB and PR are intially 0 and the player first to act is the OP.
Checks, calls, and folds do not change CB, PR, or OP.
To raise, a player must make the new bet at least CB+PR, or at least the Big Blind (whichever is greater).
When a player raises, CB and PR get updated accordingly: CB now becomes the new bet, PR the difference to the previous bet (PR = CB_new - CB_old). Also, this player becomes the new OP (exception see next point).
If a player doesn't have enough chips to make a full-raise, but still more than needed for just a call, they can do an all-in raise. In this case, there now is a new CB. Also, PR get reduced by CB_new - CB_old, i.e. the min raise amount remains unchanged. The OP remains unchanged (some casinos/home games differ, but let's assume a full raise is required to reopen).
A betting round is completed when the action is back on the OP. Two exceptions:
pre-flop, if that player sits in the Big Blind, and CB still equals the Big Blind ("option" for Big Blind in an unraised pot).
at least one player at the table made an all-in raise according to (7) which didn't reopen, but there are players on the table which didn't have a chance to act yet after the all-in raise. In this case, the action continues until all these players have acted, too, but they do not have the option to raise (only call or fold).
Does all this correctly reflect the poker betting rules in no-limit games? Did I miss anything?