GameRule.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GameRule.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. #region Using Statements
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Text;
  13. #endregion
  14. namespace CardsFramework
  15. {
  16. /// <summary>
  17. /// Represents a rule in card game.
  18. /// </summary>
  19. /// <remarks>
  20. /// Inherit from this class and write your code
  21. /// </remarks>
  22. public abstract class GameRule
  23. {
  24. /// <summary>
  25. /// An event which triggers when the rule conditions are matched.
  26. /// </summary>
  27. public event EventHandler RuleMatch;
  28. /// <summary>
  29. /// Checks whether the rule conditions are met. Should call
  30. /// <see cref="FireRuleMatch"/>.
  31. /// </summary>
  32. public abstract void Check();
  33. /// <summary>
  34. /// Fires the rule's event.
  35. /// </summary>
  36. /// <param name="e">Event arguments.</param>
  37. protected void FireRuleMatch(EventArgs e)
  38. {
  39. if (RuleMatch != null)
  40. {
  41. RuleMatch(this, e);
  42. }
  43. }
  44. }
  45. }