Let's suppose I have the following Dictionary:
private IDictionary<string, IPlayer> players;
where IPlayer
is an interface defined as follows:
public interface IPlayer {
bool HasTurn { get; set; }
string Name { get; set; }
}
I'm trying to code a method that finds the active player, the one who has the turn, take its turn, and then give the turn to the next player in the dictionary.
So far I have this:
private void NextTurn() {
if(!playing) return;
IPlayer actual = players.Values.First(p => p.HasTurn);
actual.HasTurn = false;
// How can I get the next player in the dictionary??
}