edit of program cs and game cs : check number of player and stop while + add color + add while for next player and switch

test_old_branch
Jérémy Mouyon 1 year ago
parent 867f542f3d
commit 138a04cd54

@ -83,22 +83,6 @@ namespace QwirkleClassLibrary
get { return players.Count; }
}
// a passer en program cs
public string ShowTileOfPlayer(int posplayer)
{
List<Tile> tiles = players[posplayer].Tiles.ToList();
string r = ("Tile of " + posplayer + " : ");
StringBuilder stringBuilder = new StringBuilder(); // A UTILISER !!!
foreach (Tile tile in tiles)
{
r = (r + " " + tile.NameColorTile());
}
return r;
}
public Tile TileOfPlayerWithPos(int postile)
{
@ -135,7 +119,7 @@ namespace QwirkleClassLibrary
int posPlayerNextPlay = GetPlayingPlayerPosition() + 1;
if (posPlayerNextPlay >= GetNbPlayers)
if (posPlayerNextPlay > GetNbPlayers)
{
posPlayerNextPlay = 0;
}
@ -152,9 +136,18 @@ namespace QwirkleClassLibrary
public bool PlaceTileGame(Tile tile, int x, int y)
{
bool r = board.AddTileInCell(x, y, tile);
players[GetPlayingPlayerPosition()].RemoveTilePlayer(tile);
return r;
bool checkremove=false;
bool checkaddcell = board.AddTileInCell(x, y, tile);
if (checkaddcell == true)
{
checkremove = players[GetPlayingPlayerPosition()].RemoveTilePlayer(tile);
}
if (checkaddcell == checkremove)
{
return checkaddcell;
}
return false;
}
}

@ -1,5 +1,7 @@
using QwirkleClassLibrary;
using System.Net.Quic;
using System.Text;
using System.Transactions;
using static System.Console;
@ -20,13 +22,19 @@ static void addPlayer(Game game)
}
}
} while (enterline != "quit");
} while (game.PlayerList.Count<4 && enterline !="quit");
}
static void MainMenu(Game game)
{
game.TilsBagPlayer();
Console.ForegroundColor = ConsoleColor.Green;
Write("The loading of the game is well done! Good game :p\n");
Console.ResetColor();
do
{
String TagPlayerPlay;
TagPlayerPlay = game.NextPlayer();
@ -35,6 +43,14 @@ static void MainMenu(Game game)
Write(TagPlayerPlay + " you have main now ! \n");
MenuSwitch(game);
} while (game.GetPlayingPlayerPosition() != 3); // cette boucle permet juste de faire un tour, quand le score fonctionnera il faudra la faire arreter quand la partie sera finis :)
}
static void ShowTiles(Game game)
{
Write("\n --------------------- YOUR TILES ------------------------ \n");
@ -49,12 +65,23 @@ static void MainMenu(Game game)
Write(stringBuilder);
}
static void MenuSwitch(Game game)
{
int enter = 0;
do
{
ShowTiles(game);
Write("\n --------------------- CHOICES ------------------------ \n");
Write("[1] Place your tiles \n");
Write("[2] Swap your tiles \n");
Write("[3] Skip \n");
int enter = Convert.ToInt32(ReadLine());
enter = Convert.ToInt32(ReadLine());
switch (enter)
{
@ -63,12 +90,18 @@ static void MainMenu(Game game)
break;
case 2:
break;
case 3:
return;
}
} while (enter != 3);
}
static void CaseOneAddTile(Game game)
{
Tile tile = null;
Tile? tile = null;
Write("Enter no tile : ");
int no = Convert.ToInt32(ReadLine());
@ -86,7 +119,7 @@ static void CaseOneAddTile(Game game)
}
else
{
Write("no no no \n");
Write("ERROR : Cell already use \n");
}
}
else
@ -96,22 +129,33 @@ static void CaseOneAddTile(Game game)
}
static void testJeremy()
static void MainGame()
{
Game game = new Game();
Console.BackgroundColor = ConsoleColor.DarkGreen;
Write("WELCOME IN QWIRKLE GAME ! \n For start the game please enter 2 / 4 players ;) \n \n");
Console.ResetColor();
addPlayer(game);
game.StartGame();
if (game.GameRunning == true)
while (game.GameRunning == false)
{
MainMenu(game);
}
game = new Game();
Console.ForegroundColor= ConsoleColor.Red;
Write("ERROR : Please enter minimun 2 valid player ! \n");
Console.ResetColor();
addPlayer(game);
game.StartGame();
}
MainMenu(game);
}
testJeremy();
MainGame();

Loading…
Cancel
Save