nextplayer push

test_old_branch
Jérémy Mouyon 1 year ago
parent f687f17262
commit cf35c60518

@ -12,27 +12,35 @@ namespace QwirkleClassLibrary
private TileBag bag; private TileBag bag;
private List<Player> players; private List<Player> players;
public Game(List<Player> pl) { public Game(List<Player> pl)
{
players = pl; players = pl;
bag = new TileBag(); bag = new TileBag();
} }
public void SetNextPlayer(Player player_old, Player player_new) public int PositionPlayerPlay()
{ {
for(int i = 0; i < players.Count; i++) for (int i = 0; i < players.Count; i++)
{ {
if (players[i] == player_old) if (players[i].IsPlaying == true)
{
players[i].IsPlaying = false;
}
if (players[i] == player_new)
{ {
players[i].IsPlaying = true; return i;
} }
} }
return -1;
}
public void SetNextPlayer(int old, int neew)
{
players[old].IsPlaying = false;
players[neew].IsPlaying = false;
Console.WriteLine(players[neew].GetName + "you have main now !");
} }
} }
}
} }

@ -54,4 +54,16 @@ static Game InitializerGame()
return new Game(Players); return new Game(Players);
} }
Game game = InitializerGame(); static void NextPlayer(Game game)
{
int posPlayerPlay = game.PositionPlayerPlay();
int posPlayerNextPlay = (game.PositionPlayerPlay() + 1);
game.SetNextPlayer(posPlayerPlay, posPlayerNextPlay);
}
Game game = InitializerGame();
NextPlayer(game);
Loading…
Cancel
Save