Пример #1
0
        void Play(object obj)
        {
            if (!MatchEnded)
            {
                _isPlaying = true;

                OnPropertyChanged(nameof(IsPaused));
                P1_Point_Command.ChangeCanExecute();
                P2_Point_Command.ChangeCanExecute();
                P1_Ace_Command.ChangeCanExecute();
                P2_Ace_Command.ChangeCanExecute();
                P1_Fault_Command.ChangeCanExecute();
                P2_Fault_Command.ChangeCanExecute();
                P1_ForehandWinner_Command.ChangeCanExecute();
                P2_ForehandWinner_Command.ChangeCanExecute();
                P1_BackhandWinner_Command.ChangeCanExecute();
                P2_BackhandWinner_Command.ChangeCanExecute();
                P1_ForehandUnforcedError_Command.ChangeCanExecute();
                P2_ForehandUnforcedError_Command.ChangeCanExecute();
                P1_BackhandUnforcedError_Command.ChangeCanExecute();
                P2_BackhandUnforcedError_Command.ChangeCanExecute();
                P1_ForcedError_Command.ChangeCanExecute();
                P2_ForcedError_Command.ChangeCanExecute();
            }
        }
Пример #2
0
        void P2_Won_Game()
        {
            if (match.FirstPlayerToServe)
            {
                match.P2_BreakPointsWon++;
                OnPropertyChanged(nameof(P2_BreakPointsWon));
                OnPropertyChanged(nameof(BreakPointsWon));
            }

            P1_ActualScore                    = "0";
            P2_ActualScore                    = "0";
            match.P1_Advantage                = false;
            match.P2_Advantage                = false;
            match.TiebreakEnabled             = false;
            FirstPlayerToServe                = match.DidFirstPlayerServeLastGame;
            match.DidFirstPlayerServeLastGame = !match.DidFirstPlayerServeLastGame;

            switch (ActualSet)
            {
            case 0:
                P2_FirstSet = (match.P2_GamesWon[0] + 1).ToString();
                break;

            case 1:
                P2_SecondSet = (match.P2_GamesWon[1] + 1).ToString();
                break;

            case 2:
                P2_ThirdSet = (match.P2_GamesWon[2] + 1).ToString();
                break;

            case 3:
                P2_FourthSet = (match.P2_GamesWon[3] + 1).ToString();
                break;

            case 4:
                P2_FifthSet = (match.P2_GamesWon[4] + 1).ToString();
                break;
            }

            if ((match.P2_GamesWon[ActualSet] >= match.GamesToWin && match.P2_GamesWon[ActualSet] >= match.P1_GamesWon[ActualSet] + 2) || (match.P2_GamesWon[ActualSet] > match.GamesToWin && match.P1_GamesWon[ActualSet] == match.GamesToWin)) // if set won
            {
                match.P2_SetsWon++;
                if (match.P2_SetsWon >= match.SetsToWin) // if match won
                {
                    MatchEnded = true;
                    IsPlaying  = false;

                    OnPropertyChanged(nameof(FirstPlayerToServe));
                    OnPropertyChanged(nameof(SecondPlayerToServe));

                    P1_Point_Command.ChangeCanExecute();
                    P2_Point_Command.ChangeCanExecute();
                }
                else
                {
                    ActualSet++;
                }
            }

            if (match.P2_GamesWon[(int)ActualSet] == match.GamesToWin && match.P1_GamesWon[(int)ActualSet] == match.GamesToWin)
            {
                match.TiebreakEnabled = true;
            }
        }