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.
sae201_qwirkle/Qwirkle/QwirkleConsoleApp/Program.cs

69 lines
1.6 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].GetName == 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);
game.SetNextPlayer(posPlayerPlay, posPlayerNextPlay);
}
Game game = InitializerGame();
NextPlayer(game);