I have a list container the current players for a game, and I keep track of the current turn with another integer. When a player leaves, I remove them from the players list. However, there are cases where I need to also adjust the turn value (when a player leaves).
I've found that if the index of a particular player is LESS than the turn value, then I need to decrement the turn variable. For example
1) A B C(t=2) D E => B leaves
2) A C(t=1) D E
Since B's index was before turn, turn is decremented. Conversely
1) A B C(t=2) D E => D leaves
2) A B C(t=2) E
Here, we do not have to change the turn value, since the player that left is AFTER turn.
So my question is, how can I determine the index of a particular string in a list? (non-blocking). If this is not possible, is there maybe another solution?