As i am coding a poker game at the moment, i am facing with the problem of a new player joining or rejoining a hand already in progress. That being said i have drawn an image to better illustrate what i'm asking for.
In the picture above there is already a hand in progress with only 3 players seated on seat 1, 3 and 5 respectively. Dealer is seat 1, SB is seat 3 and BB is seat 5. The other seats are empty. There are three possible scenarios when joining a game and three others when you are rejoining after being away for a while.
I will post here my current knowledge of what can happen in each of the situations. Please feel free to correct me if i'm wrong.
Joining the game for the first time.
Case 1: The new player takes seat 6. The next hand he can post the BB and be dealt a hand. Nothing changes.
Case 2: The new player takes seat 4. The next hand he is not allowed to play until the dealer has passed him. The dealer will be seat 3, SB will be seat 5 and BB will be seat 6.
Case 3: The new player takes seat 2. The next hand the dealer will jump over him and he will be asked to either post the BB and be dealt a hand or wait for the BB.
Rejoining the game (sitting back in).
Case 1: The player is on seat 6. If the blinds didn't make a table round then the player will post BB and be dealt a hand. Nothing changes.
Case 2: The player is on seat 4. He missed only the big blind. He needs to post only the SB (dead money) to be dealt a hand or wait for BB. No sure about this one.
Case 3: The player is on seat 2. Having missed both blinds, the dealer will jump over him and he will be asked to either post SB + BB and be dealt a hand or wait for the big blind. If he chooses to post both blinds, the small blind will be considered 'dead', will be added to the pot and it will not count as a raise to the other players.
UPDATE
After reading Jon's answer and a bit of testing on pokerstars play money i realized that i have overcomplicated things in my previous cases. The only difference between a new player at the table and a returning one is that the latter might have missed some blinds while being away. With this in mind i think there are only three cases in total.
Case #1: Player is on seat 6. The next hand he will naturally be the big blind so regardless of being a new player or a returning player he will post only the big blind.
Case #2: Player is on seat 2. The next hand the dealer will jump over him and he can either wait for the big blind or post any missed blinds.
Case #3: Player is on seat 4. The next hand he is not allowed to play it but only after the dealer. The hand after is case #2 all over again.
The things get complicated and i do not understand what happens when there are two players playing head-to-head and a third player joins.
The solution here is that the players keep playing head up until the new player, or returning is in a position to take the big blind. At this point the player whom had the Small blind the last hand will get the button.
According to you, in the left side of the image above, on the next hand the new player (seat 2) is in the position to take the big blind. That is because the button will move to seat 3, seat 1 will be SB and seat 2 will be big blind but i know its wrong because i have tested it. So the only explanation is that i am missing something or i have misunderstood you, Jon.
You say that i should't code a special case when a third player joins and that is exactly what i am trying to figure it out, the general rule. But to me this seems to be a special case especially when the third hand the dealer will have to stay on the same seat while the blinds accommodate. It's as if the big blind always moves instead of the button.
According to the three conclusions i have come across in the update above a new player joining between the button and the big blind will have to wait for the dealer to pass them before they can be dealt a hand and post any missed blinds (if any). In the picture, on the left side, the next hand the dealer will pass over the new player and because he/she will not be in between the blinds anymore he/she should be able to play the hand.