GameRule.cs 1.3 KB

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