From 08589876ce11e967fa3f09585021afb484916c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Sat, 18 May 2024 09:32:00 +0200 Subject: [PATCH 1/2] =?UTF-8?q?D=C3=A9coupage=20en=202=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Models/Events/GameEndedEventArgs.cs | 12 ++++++++++++ source/Trek-12/Models/Events/GameStartedEventArgs.cs | 10 ---------- 2 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 source/Trek-12/Models/Events/GameEndedEventArgs.cs diff --git a/source/Trek-12/Models/Events/GameEndedEventArgs.cs b/source/Trek-12/Models/Events/GameEndedEventArgs.cs new file mode 100644 index 0000000..5c53a2e --- /dev/null +++ b/source/Trek-12/Models/Events/GameEndedEventArgs.cs @@ -0,0 +1,12 @@ +using Models.Game; +namespace Models.Events; + +public class GameEndedEventArgs : EventArgs +{ + public Player CurrentPlayer { get; } + + public GameEndedEventArgs(Player winner) + { + CurrentPlayer = winner; + } +} \ No newline at end of file diff --git a/source/Trek-12/Models/Events/GameStartedEventArgs.cs b/source/Trek-12/Models/Events/GameStartedEventArgs.cs index 4006df9..a35389d 100644 --- a/source/Trek-12/Models/Events/GameStartedEventArgs.cs +++ b/source/Trek-12/Models/Events/GameStartedEventArgs.cs @@ -9,14 +9,4 @@ public class GameStartedEventArgs : EventArgs { CurrentPlayer = selectedPlayer; } -} - -public class GameEndedEventArgs : EventArgs -{ - public Player CurrentPlayer { get; } - - public GameEndedEventArgs(Player winner) - { - CurrentPlayer = winner; - } } \ No newline at end of file From 70c62923f68549705d5b19ca9e290b627fddae8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Sat, 18 May 2024 09:32:49 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Documentation=20de=20m=C3=A9thodes=20&=20?= =?UTF-8?q?=C3=A9venements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Models/Game/Game.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/Trek-12/Models/Game/Game.cs b/source/Trek-12/Models/Game/Game.cs index 39d242f..94e7e21 100644 --- a/source/Trek-12/Models/Game/Game.cs +++ b/source/Trek-12/Models/Game/Game.cs @@ -45,6 +45,17 @@ namespace Models.Game Dice2.Roll(); } + /// + /// Performs an operation on the values of two dice based on the provided operation. + /// + /// The operation to perform. This can be LOWER, HIGHER, SUBTRACTION, ADDITION, or MULTIPLICATION. + /// + /// 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. + /// 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(); } } @@ -83,13 +94,16 @@ namespace Models.Game } + /// + /// Initializes the game. + /// public void InitializeGame() { _isRunning = true; GameStarted?.Invoke(this, new GameStartedEventArgs(CurrentPlayer)); - GameLoop(); } + private async void GameLoop() {