|
|
|
@ -45,6 +45,17 @@ namespace Models.Game
|
|
|
|
|
Dice2.Roll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs an operation on the values of two dice based on the provided operation.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="o">The operation to perform. This can be LOWER, HIGHER, SUBTRACTION, ADDITION, or MULTIPLICATION.</param>
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// The result of the operation. If the operation is LOWER or HIGHER, it returns the lower or higher value of the two dice respectively.
|
|
|
|
|
/// If the operation is SUBTRACTION, it returns the difference between the higher and lower value of the two dice.
|
|
|
|
|
/// If the operation is ADDITION, it returns the sum 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.
|
|
|
|
|
/// </returns>
|
|
|
|
|
public int ResultOperation(Operation o)
|
|
|
|
|
{
|
|
|
|
|
switch (o)
|
|
|
|
@ -65,7 +76,7 @@ namespace Models.Game
|
|
|
|
|
return Dice2.Value * Dice1.Value;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -111,13 +122,16 @@ namespace Models.Game
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes the game.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void InitializeGame()
|
|
|
|
|
{
|
|
|
|
|
_isRunning = true;
|
|
|
|
|
GameStarted?.Invoke(this, new GameStartedEventArgs(CurrentPlayer));
|
|
|
|
|
|
|
|
|
|
GameLoop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async void GameLoop()
|
|
|
|
|
{
|
|
|
|
|