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

118 lines
2.2 KiB

using QwirkleClassLibrary;
using System.Text;
using static System.Console;
static void addPlayer(Game game)
{
string? enterline = "";
do
{
WriteLine("Enter name of player (enter quit to quit) : ");
enterline = ReadLine();
if (enterline != "quit")
{
bool r = game.AddPlayerInGame(enterline);
if (r == false)
{
WriteLine("ERROR : Name is invalid.");
}
}
} while (enterline != "quit");
}
static void MainMenu(Game game)
{
game.TilsBagPlayer();
String TagPlayerPlay;
TagPlayerPlay = game.NextPlayer();
Write(" --------------------- GAME ! ------------------------ \n");
Write(TagPlayerPlay + " you have main now ! \n");
Write("\n --------------------- YOUR TILES ------------------------ \n");
int pos = game.GetPlayingPlayerPosition();
StringBuilder stringBuilder = new StringBuilder();
for(int i = 0; i < game.PlayerList[pos].Tiles.Count(); i++)
{
stringBuilder.AppendLine(game.PlayerList[pos].Tiles[i].ToString());
}
Write(stringBuilder);
Write("\n --------------------- CHOICES ------------------------ \n");
Write("[1] Place your tiles \n");
Write("[2] Swap your tiles \n");
int enter = Convert.ToInt32(ReadLine());
switch (enter)
{
case 1:
CaseOneAddTile(game);
break;
case 2:
break;
}
}
static void CaseOneAddTile(Game game)
{
Tile tile = null;
Write("Enter no tile : ");
int no = Convert.ToInt32(ReadLine());
if (no >= 0 && no <= 5)
{
tile = game.TileOfPlayerWithPos(no);
Write("Enter x : ");
int x = Convert.ToInt32(ReadLine());
Write("Enter y : ");
int y = Convert.ToInt32(ReadLine());
if (game.PlaceTileGame(tile, x, y) == true)
{
Write("ok ! your tile is placed \n");
}
else
{
Write("no no no \n");
}
}
else
{
Write("No is out of range\n");
}
}
static void testJeremy()
{
Game game = new Game();
addPlayer(game);
game.StartGame();
if (game.GameRunning == true)
{
MainMenu(game);
}
}
testJeremy();