Exemple #1
0
    public void RoundWinner()
    {
        WinStates winner             = WinStates.None;
        int       playerOneLastIndex = answersPlayerOne.Count - 1;
        int       playerTwoLastIndex = answersPlayerTwo.Count - 1;

        if (answersPlayerOne[playerOneLastIndex].WasCorrect())
        {
            winner = WinStates.PlayerOne;
        }

        if (answersPlayerTwo[playerTwoLastIndex].WasCorrect())
        {
            if (winner == WinStates.PlayerOne)
            {
                winner = WinStates.Both;
            }
            else
            {
                winner = WinStates.PlayerTwo;
            }
        }
        if (winner == WinStates.Both)
        {
            winner = answersPlayerOne[playerOneLastIndex].time < answersPlayerTwo[playerTwoLastIndex].time ? WinStates.PlayerOne : WinStates.PlayerTwo;
        }

        switch (winner)
        {
        case WinStates.None:
            textHandler.Draw();
            break;

        case WinStates.PlayerOne:
            ranks.CheckYourRank(true, false);
            textHandler.PlayerOneWinner(answersPlayerOne[playerOneLastIndex].time);
            textHandler.PlayerTwoLooser();
            playerOneWins++;
            break;

        case WinStates.PlayerTwo:
            ranks.CheckYourRank(false, true);
            textHandler.PlayerTwoWinner(answersPlayerTwo[playerTwoLastIndex].time);
            textHandler.PlayerOneLooser();
            playerTwoWins++;
            break;

        default:
            break;
        }
    }