summaryrefslogtreecommitdiff
path: root/Events
diff options
context:
space:
mode:
Diffstat (limited to 'Events')
-rw-r--r--Events/GameFinishedEvent.cs50
-rw-r--r--Events/RoundFinishedEvent.cs28
2 files changed, 78 insertions, 0 deletions
diff --git a/Events/GameFinishedEvent.cs b/Events/GameFinishedEvent.cs
new file mode 100644
index 0000000..22cf26a
--- /dev/null
+++ b/Events/GameFinishedEvent.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Chess.Events
+{
+ public enum GameFinishedReason
+ {
+ CheckMate,
+ InsufficientMaterial,
+ Stalemate,
+
+ /// <summary>
+ /// Not implemented from here on.
+ /// </summary>
+ Resignation,
+ Move75,
+ Repetition,
+ Agreement,
+ }
+
+ public class GameFinishedEvent : EventArgs
+ {
+ public Player Winner { get; }
+ public GameFinishedReason Reason { get; set; }
+
+ public GameFinishedEvent(Player winner, GameFinishedReason reason)
+ {
+ Winner = winner;
+ Reason = reason;
+ }
+
+ public string GetWinnerName()
+ {
+ if (Winner != null)
+ {
+ return Winner.IsWhite ? "White" : "Black";
+ }
+
+ return "";
+ }
+
+ public string GetFinishReason()
+ {
+ return Reason.ToString();
+ }
+ }
+}
diff --git a/Events/RoundFinishedEvent.cs b/Events/RoundFinishedEvent.cs
new file mode 100644
index 0000000..061b31d
--- /dev/null
+++ b/Events/RoundFinishedEvent.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Chess.Events
+{
+ public class RoundFinishedEvent : EventArgs
+ {
+ public int Round { get; }
+ public PlayerMove Move1 { get; private set; }
+ public PlayerMove Move2 { get; private set; }
+
+ public bool IsDone { get { return Move1 != null && Move2 != null; } }
+
+ public RoundFinishedEvent(int round)
+ {
+ Round = round;
+ }
+
+ public void AddMove(PlayerMove move)
+ {
+ if (Move1 == null) Move1 = move;
+ else Move2 = move;
+ }
+ }
+}