예제 #1
0
 /// <summary>
 /// Invoke the 'SetGameEnded' event handler if it is set.
 /// </summary>
 /// <param name="arg">The event hadler argumentum.</param>
 private void OnSetGameEnded(ReversiSetGameEndedEventArgs arg)
 {
     if (SetGameEnded != null)
     {
         SetGameEnded(this, arg);
     }
 }
        /// <summary>
        /// Játék végének eseménykezelése.
        /// </summary>
        private async void Model_SetGameEnded(object sender, ReversiSetGameEndedEventArgs e)
        {
            _model.Pause();

            MessageDialog dialog;

            if (e.Player1Points > e.Player2Points)
            {
                dialog = new MessageDialog("Player 1 won." + Environment.NewLine + "Player 1 points: " + e.Player1Points.ToString() + ", player 2 points: " + e.Player2Points.ToString() + ".");
            }
            else if (e.Player1Points < e.Player2Points)
            {
                dialog = new MessageDialog("Player 2 won." + Environment.NewLine + "Player 1 points: " + e.Player1Points.ToString() + ", player 2 points: " + e.Player2Points.ToString() + ".");
            }
            else
            {
                dialog = new MessageDialog("It is a tie." + Environment.NewLine + "Player 1 points: " + e.Player1Points.ToString() + ", player 2 points: " + e.Player2Points.ToString() + ".");
            }

            await dialog.ShowAsync();

            _model.Unpause();
        }
        private void model_SetGameEnded(Object sender, ReversiSetGameEndedEventArgs e)
        {
            _eventSetGameEndedInvoked = true;

            if (!_simpleEvents)
            {
                removeStep(e);
            }
        }
        /// <summary>
        /// We finished a game. We delete the last put downs backwords, then if it not ended
        /// (_remainingSteps[0,0] != 0) we set _remainingSteps[0,0] to 1.
        /// </summary>
        /// <param name="e"></param>
        private void removeStep(ReversiSetGameEndedEventArgs e)
        {
            if (e.Player1Points > e.Player2Points)
            {
                _possibleResults[0] += 1;
            }
            else if (e.Player1Points < e.Player2Points)
            {
                _possibleResults[1] += 1;
            }
            else
            {
                _possibleResults[2] += 1;
            }

            while (_remainingSteps[_remainingSteps[0, 0], 0] == 0)
            {
                --(_remainingSteps[0, 0]);
                if (_remainingSteps[_remainingSteps[0, 0], 0] != 0)
                {
                    _remainingSteps[_remainingSteps[0, 0], 0] -= 2;
                }

                if (_remainingSteps[0, 0] == 0)
                {
                    break;
                }
            }

            if (_remainingSteps[0, 0] != 0)
            {
                _remainingSteps[0, 0] = 1;
                _currentPassingCount = 0;
            }

            ++_possibleGameCount;
        }
 /// <summary>
 /// Invoke the 'SetGameEnded' event handler if it is set.
 /// </summary>
 /// <param name="arg">The event hadler argumentum.</param>
 private void OnSetGameEnded(ReversiSetGameEndedEventArgs arg)
 {
     if (SetGameEnded != null)
     {
         SetGameEnded(this, arg);
     }
 }