Esempio n. 1
0
        /// <summary>
        /// Runs the match.
        /// </summary>
        /// <returns>The match result.</returns>
        public Winner Run()
        {
            // Initially there's no winner
            Winner winner = Winner.None;

            // Notify listeners match is about to start
            MatchStart?.Invoke(
                matchConfig,
                new string[] {
                matchData.GetThinker(PColor.White).ToString(),
                matchData.GetThinker(PColor.Red).ToString()
            });

            // Notify listeners that we have a new empty board
            BoardUpdate?.Invoke(board);

            // Game loop
            while (true)
            {
                // Next player plays
                winner = Play();
                // Break loop if a winner is found
                if (winner != Winner.None)
                {
                    break;
                }
            }

            // Notify listeners that match is over
            MatchOver?.Invoke(
                winner,
                solution,
                new string[] {
                matchData.GetThinker(PColor.White).ToString(),
                matchData.GetThinker(PColor.Red).ToString()
            });

            // Return match result
            return(winner);
        }
 private void OnMatchStart(bool IsRematch)
 {
     MatchStart?.Invoke(IsRematch, EventArgs.Empty);
 }
Esempio n. 3
0
 protected virtual void OnMatchStart(EventArgs e)
 {
     MatchStart?.Invoke(this, e);
 }