@ -1,10 +1,12 @@
using QwirkleClassLibrary ;
using System.Net.Quic ;
using System.Text ;
using System.Transactions ;
using static System . Console ;
static void testJeremy ( )
{
Game game = new Game ( ) ;
static void addPlayer ( Game game )
{
string? enterline = "" ;
do
@ -20,69 +22,141 @@ static void testJeremy()
}
}
} while ( enterline ! = "quit" ) ;
} while ( game . PlayerList . Count < 4 & & enterline ! = "quit" ) ;
}
game . StartGame ( ) ;
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 ( ) ;
if ( game . GameRunning = = true )
do
{
game . TilsBagPlayer ( ) ;
String TagPlayerPlay ;
TagPlayerPlay = game . NextPlayer ( ) ;
Write ( " --------------------- GAME ! ------------------------ \n" ) ;
Write ( TagPlayerPlay + " you have main now ! \n" ) ;
string s = game . ShowTileOfPlayer ( game . GetPlayingPlayerPosition ( ) ) ;
Write ( s + "\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" ) ;
int pos = game . GetPlayingPlayerPosition ( ) ;
StringBuilder stringBuilder = new StringBuilder ( ) ;
for ( int i = 0 ; i < game . PlayerList [ pos ] . Tiles . Count ( ) ; i + + )
{
stringBuilder . Append ( "[" + ( i + 1 ) + "] " ) ;
stringBuilder . AppendLine ( game . PlayerList [ pos ] . Tiles [ i ] . ToString ( ) ) ;
}
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 ( ) ) ;
Tile tile = null ;
enter = Convert . ToInt32 ( ReadLine ( ) ) ;
switch ( enter )
{
case 1 :
// si good faire des boucles demain
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" ) ;
}
CaseOneAddTile ( game ) ;
break ;
case 2 :
break ;
case 3 :
return ;
}
} while ( enter ! = 3 ) ;
}
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 + 1 ) ;
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 ( "ERROR : Cell already use \n" ) ;
}
}
else
{
Write ( "No is out of range\n" ) ;
}
}
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 ( ) ;
while ( game . GameRunning = = false )
{
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 ( ) ;