You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.0 KiB
95 lines
2.0 KiB
using QwirkleClassLibrary;
|
|
using static System.Console;
|
|
|
|
static Game InitializerGame()
|
|
{
|
|
OutputEncoding = System.Text.Encoding.UTF8;
|
|
|
|
List<Player> Players = new List<Player>();
|
|
|
|
WriteLine("Enter number of player play : ");
|
|
try
|
|
{
|
|
int nbplayer = Convert.ToInt32(ReadLine());
|
|
|
|
|
|
while (nbplayer <= 1 || nbplayer > 4)
|
|
{
|
|
WriteLine("ERROR : Enter minmun one player or four max !");
|
|
nbplayer = Convert.ToInt32(ReadLine());
|
|
}
|
|
|
|
|
|
for (int i = 0; i < nbplayer; i++)
|
|
{
|
|
WriteLine("Enter name of player " + (i + 1) + " : \n");
|
|
|
|
String? name = ReadLine();
|
|
|
|
bool nameInvalid = string.IsNullOrWhiteSpace(name);
|
|
|
|
while (nameInvalid == true)
|
|
{
|
|
WriteLine("ERROR Incorrect name, please enter name of player " + (i + 1) + " : \n");
|
|
name = ReadLine();
|
|
nameInvalid = string.IsNullOrWhiteSpace(name);
|
|
}
|
|
|
|
for (int j = 0; j < Players.Count; j++)
|
|
{
|
|
if (Players[j].GetNameTag == name)
|
|
{
|
|
name = (name + "bis");
|
|
}
|
|
}
|
|
|
|
Player p = new Player(name);
|
|
Players.Add(p);
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{ Console.WriteLine(e.Message); }
|
|
|
|
return new Game(Players);
|
|
}
|
|
|
|
static void NextPlayer(Game game)
|
|
{
|
|
int posPlayerPlay = game.PositionPlayerPlay();
|
|
|
|
int posPlayerNextPlay = game.PositionPlayerPlay() + 1;
|
|
|
|
if (posPlayerNextPlay >= game.GetNbPlayers)
|
|
{
|
|
posPlayerNextPlay = 0;
|
|
}
|
|
|
|
game.SetNextPlayer(posPlayerPlay, posPlayerNextPlay);
|
|
}
|
|
|
|
|
|
|
|
|
|
static void testJeremy()
|
|
{
|
|
Game game = InitializerGame();
|
|
Write("\n -------------------------------------------------------- \n");
|
|
|
|
NextPlayer(game);
|
|
NextPlayer(game);
|
|
NextPlayer(game);
|
|
NextPlayer(game);
|
|
|
|
game.TilsBagPlayer();
|
|
|
|
for (int i = 0; i < game.GetNbPlayers; i++)
|
|
{
|
|
game.ShowTileOfPlayer(i);
|
|
}
|
|
}
|
|
|
|
|
|
testJeremy();
|