diff options
Diffstat (limited to 'Events/GameFinishedEvent.cs')
| -rw-r--r-- | Events/GameFinishedEvent.cs | 50 |
1 files changed, 50 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(); + } + } +} |
