Correction des opérations

pull/87/head
Remi NEVEU 1 year ago
parent 8cc8435b3f
commit e90f8cb185

@ -76,7 +76,7 @@ class Program
static void OnDiceRolled(object sender, DiceRolledEventArgs e) static void OnDiceRolled(object sender, DiceRolledEventArgs e)
{ {
Console.WriteLine($"Dice 1: {e.Dice1Value} | Dice 2: {e.Dice2Value}"); Console.WriteLine($"Dice 1: {e.Dice1Value} | Dice 2: {e.Dice2Value}");
Operation playerOperation = GetPlayerOperation(); Operation playerOperation = GetPlayerOperation(sender);
((Game)sender).HandlePlayerOperation(playerOperation); ((Game)sender).HandlePlayerOperation(playerOperation);
} }
@ -230,7 +230,7 @@ class Program
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
/// <exception cref="ArgumentOutOfRangeException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception>
static Operation GetPlayerOperation() static Operation GetPlayerOperation(object? sender)
{ {
DisplayOperationOptions(); DisplayOperationOptions();
string? op = Console.ReadLine(); string? op = Console.ReadLine();
@ -239,6 +239,14 @@ class Program
Console.WriteLine("Invalid operation. Please choose again."); Console.WriteLine("Invalid operation. Please choose again.");
op = Console.ReadLine(); op = Console.ReadLine();
} }
int test = Convert.ToInt32(op);
while(((Game)sender).UsedMap.CheckOperationPossible(test-1))
{
Console.WriteLine("Invalid operation. Please choose again.");
Console.WriteLine();
op = Console.ReadLine();
test = Convert.ToInt32(op);
}
return op switch return op switch
{ {

@ -94,7 +94,7 @@ namespace Models.Game
/// If the operation is MULTIPLICATION, it returns the product of the values of the two dice. /// If the operation is MULTIPLICATION, it returns the product of the values of the two dice.
/// If the operation is not one of the operations, it throws an ArgumentOutOfRangeException. /// If the operation is not one of the operations, it throws an ArgumentOutOfRangeException.
/// </returns> /// </returns>
private int ResultOperation(Operation o) public int ResultOperation(Operation o)
{ {
int result = o switch int result = o switch
{ {

@ -74,5 +74,10 @@
} }
return operationGrid; return operationGrid;
} }
public bool CheckOperationPossible(int x)
{
return OperationGrid[x * 4 + 3].IsChecked;
}
} }
} }

@ -17,6 +17,7 @@ namespace Models.Game
/// <param name="y"></param> /// <param name="y"></param>
public OperationCell(int x, int y) : base(x, y) public OperationCell(int x, int y) : base(x, y)
{ {
IsChecked = false;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save