You could have a boolean instance variable in the Player Class
that keeps track of whether the player skips her next turn. When you get to the point of checking if that value is true or false and it evaluate to true (ie yes, she skips her turn), then skip what you would normally do for a turn, but set the boolean to false before you move on to the next Player
or Turn
or what have you.
EDIT (based on user response):
Pseudocode:
I’m assuming that you’re keeping track of whose turn it would be via an array or list or something comparable to that. I’m going to refer to that as playerList. If, for example, we have three players, then we would keep looping on playerList[0]
,playerList[1]
,playerList[2]
.
while (gameNotOver())
{
if (!playerList[currentPlayer].skipNextTurn())
{
//do what you would normally do
}
else
{
playerList[currentPlayer].setSkipNextTurn(false);
}
}
0
solved Coin game. How to make a player lose their next turn if they meet a certain criteria