|
|
|
@ -14,6 +14,9 @@ namespace ConsoleApp;
|
|
|
|
|
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
static Game Game { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Main function of the console app
|
|
|
|
|
/// </summary>
|
|
|
|
@ -28,21 +31,21 @@ class Program
|
|
|
|
|
Player player = new Player(pseudo, "test.png");
|
|
|
|
|
|
|
|
|
|
Map map = new Map("Dunai","background");
|
|
|
|
|
Game game = new Game(persistence);
|
|
|
|
|
Game = new Game(persistence);
|
|
|
|
|
|
|
|
|
|
// Abonnement aux événements
|
|
|
|
|
game.GameStarted += OnGameStarted!;
|
|
|
|
|
game.GameEnded += OnGameEnded!;
|
|
|
|
|
game.BoardUpdated += OnBoardUpdated!;
|
|
|
|
|
game.DiceRolled += OnDiceRolled!;
|
|
|
|
|
game.OperationChosen += OnOperationChosen!;
|
|
|
|
|
game.CellChosen += OnCellChosen!;
|
|
|
|
|
game.PlayerChooseOp += OnPlayerSelectionOp!;
|
|
|
|
|
game.PlayerOption += OnPlayerOption!;
|
|
|
|
|
game.PlayerChooseCell += OnPlayerSelectionCell!;
|
|
|
|
|
Game.GameStarted += OnGameStarted!;
|
|
|
|
|
Game.GameEnded += OnGameEnded!;
|
|
|
|
|
Game.BoardUpdated += OnBoardUpdated!;
|
|
|
|
|
Game.DiceRolled += OnDiceRolled!;
|
|
|
|
|
Game.OperationChosen += OnOperationChosen!;
|
|
|
|
|
Game.CellChosen += OnCellChosen!;
|
|
|
|
|
Game.PlayerChooseOp += OnPlayerSelectionOp!;
|
|
|
|
|
Game.PlayerOption += OnPlayerOption!;
|
|
|
|
|
Game.PlayerChooseCell += OnPlayerSelectionCell!;
|
|
|
|
|
|
|
|
|
|
// Initialisation
|
|
|
|
|
game.InitializeGame(map, player);
|
|
|
|
|
Game.InitializeGame(map, player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -75,7 +78,7 @@ class Program
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.Cell = new Cell(row, column);
|
|
|
|
|
Game.PlayerCell = new Cell(row, column);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -86,11 +89,14 @@ class Program
|
|
|
|
|
if(e.Turn != 1)
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<Cell> PlayedCellsQuery =
|
|
|
|
|
from cell in e.Board
|
|
|
|
|
from cell in e.Board
|
|
|
|
|
where cell.Valid == true
|
|
|
|
|
where cell.Value != null
|
|
|
|
|
select cell;
|
|
|
|
|
foreach (var item in e.Board)
|
|
|
|
|
{
|
|
|
|
|
if (item.X == 6)
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
if (!item.Valid)
|
|
|
|
|
Console.Write(" ");
|
|
|
|
|
else if (item.Value != null)
|
|
|
|
@ -108,6 +114,7 @@ class Program
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in e.Board)
|
|
|
|
|
{
|
|
|
|
@ -134,16 +141,18 @@ class Program
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
DisplayOperationTable(((Game)sender).UsedMap.OperationGrid.ToList());
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
Console.WriteLine("1. Lower | 2. Higher | 3. Substraction | 4. Addition | 5. Multiplication");
|
|
|
|
|
Console.WriteLine("0. Lower | 1. Higher | 2. Substraction | 3. Addition | 4. Multiplication");
|
|
|
|
|
string? op = Console.ReadLine();
|
|
|
|
|
while (op != "1" && op != "2" && op != "3" && op != "4" && op != "5")
|
|
|
|
|
while (op != "0" && op != "1" && op != "2" && op != "3" && op != "4")
|
|
|
|
|
{
|
|
|
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
|
|
|
Console.WriteLine("Invalid operation. Please choose again.");
|
|
|
|
|
Console.ResetColor();
|
|
|
|
|
op = Console.ReadLine();
|
|
|
|
|
}
|
|
|
|
|
e.Operation = 3;
|
|
|
|
|
int test = Convert.ToInt32(op);
|
|
|
|
|
Game.PlayerOperation = (Operation)test;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -179,11 +188,9 @@ class Program
|
|
|
|
|
{
|
|
|
|
|
if (!item.Valid)
|
|
|
|
|
Console.Write(" ");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
else if (item.Value != null)
|
|
|
|
|
Console.Write($"{item.Value}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else Console.Write("O");
|
|
|
|
|
if (item.X == 6)
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
}
|
|
|
|
|