예제 #1
0
        public void ProcessAnalysisResult(IPlayerNotifier playerNotifier, Result result, string errorMessage,
                                          AttemptGameState attemptGameState)
        {
            if (result != null)
            {
                attemptGameState.SetLatestResult(result);
                var feedback           = CreateFeedback(attemptGameState);
                var latestResult       = attemptGameState.LatestResult;
                var kataFullyCompleted = latestResult.PlayerFeedback.KataCompleted &&
                                         !latestResult.PlayerFeedback.AllLevelsCompleted;
                if (kataFullyCompleted)
                {
                    var kataDuration = attemptGameState.KataTimer.KataDuration;

                    feedback.Message = feedback.Message + Environment.NewLine + Environment.NewLine + "Time taken: " + kataDuration;
                    var kataCompletedView = new Views.KataCompletedView();
                    kataCompletedView.SetMessage(feedback.Message);
                    kataCompletedView.ShowActivated = true;
                    kataCompletedView.Show();
                }
                else
                {
                    playerNotifier.DisplayMessage("Test State", feedback.Message, feedback.KataStateIcon, feedback.PlayerTestStateIcon);
                }
            }
            if (!string.IsNullOrEmpty(errorMessage))
            {
                playerNotifier.DisplayErrorMessage(errorMessage);
            }
        }
예제 #2
0
        internal string GenerateMessage(AttemptGameState attemptGameState)
        {
            var result = attemptGameState.LatestResult;

            var feedback = result.PlayerFeedback;

            if (feedback == null)
            {
                return("");
            }
            var messages = new List <string>();

            messages.Add(feedback.Progress);
            if (_settingsManager.IsShowHintOn())
            {
                var hint = GenerateHint(result);
                if (!string.IsNullOrEmpty(hint))
                {
                    messages.Add("Hint:" + Environment.NewLine + hint);
                }
            }
            var finalMessage = string.Join(Environment.NewLine, messages);

            return(finalMessage);
        }
예제 #3
0
        private static NotifyIcon GetKataStateIcon(AttemptGameState attemptGameState)
        {
            var isWarningIcon = attemptGameState.IsWarningIcon();
            var myIcon        = isWarningIcon ? NotifyIcon.Warning : NotifyIcon.TwoThumbs;

            return(myIcon);
        }
예제 #4
0
        private static double GetProgressLevel(AttemptGameState attemptGameState)
        {
            var playerImplementationLevel = attemptGameState.LatestResult.PlayerImplementationLevel;
            var playerTestLevel           = attemptGameState.LatestResult.PlayerTestLevel;
            var playerLevel   = playerImplementationLevel + playerTestLevel;
            var kataMaxLevel  = attemptGameState.KataMaxLevel * 2;
            var progressLevel = Math.Round((((double)playerLevel / kataMaxLevel) * 100), MidpointRounding.AwayFromZero);

            return(progressLevel);
        }
예제 #5
0
 public void SetCurrentKataAttempt(IKataAttempt currentKataAttempt)
 {
     if (_currentKataAttempt == currentKataAttempt)
     {
         return;
     }
     _currentKataAttempt = currentKataAttempt;
     UpdateCurrentKataAttemptSettings(currentKataAttempt);
     AttemptGameState          = new AttemptGameState(new List <Result>(), new KataHelper());
     AttemptGameState.KataName = currentKataAttempt.Config.KataName;
 }
예제 #6
0
        internal Feedback CreateFeedback(AttemptGameState attemptGameState)
        {
            var feedback = new Feedback();

            if (attemptGameState.KataTimerHasNotStarted())
            {
                feedback.Message =
                    "The timer has not started. If you have the default constructor test that comes with solution, please ensure that you build the solution before writing your first test";
                feedback.KataStateIcon       = NotifyIcon.Warning;
                feedback.PlayerTestStateIcon = NotifyIcon.Red;
            }
            if (attemptGameState.ImplementationLevelHasFallen())
            {
                feedback.Message =
                    "A test that was previously passing has broken! Perhaps undo the change you made and try again, or try and see why the test broke.";
                feedback.KataStateIcon       = NotifyIcon.Warning;
                feedback.PlayerTestStateIcon = NotifyIcon.Red;
            }
            if (attemptGameState.HasImplementationBeenWrittenWithoutFailingTest())
            {
                feedback.Message =
                    "You are not allowed to write any production code unless it is to make a failing unit test pass. Please undo or comment out your implementation for your test and run your tests";
                feedback.KataStateIcon       = NotifyIcon.Warning;
                feedback.PlayerTestStateIcon = NotifyIcon.Red;
            }
            if (attemptGameState.HasTestBeenWrittenWithoutAFailingTestForPreviousImplementation())
            {
                feedback.Message =
                    "You have written a test without having a failing test for your previous implementation. Please undo or comment out your test and the implementation for your previous test and run your tests";
                feedback.KataStateIcon       = NotifyIcon.Warning;
                feedback.PlayerTestStateIcon = NotifyIcon.Red;
            }
            if (attemptGameState.HasTestBeenWrittenWithoutAPassingTestForPreviousImplementation())
            {
                feedback.Message =
                    "You have written a test without first running tests after writing your previous implementation. Please undo or comment out your current test and run your tests";
                feedback.KataStateIcon       = NotifyIcon.Warning;
                feedback.PlayerTestStateIcon = NotifyIcon.Red;
            }
            if (!string.IsNullOrEmpty(feedback.Message))
            {
                return(feedback);
            }
            feedback.Message             = GenerateMessage(attemptGameState);
            feedback.PlayerTestStateIcon = GetPlayerTestStateIcon(attemptGameState);
            feedback.KataStateIcon       = GetKataStateIcon(attemptGameState);
            return(feedback);
        }
예제 #7
0
 private void KataraiApp_OnAttemptGameStateChanged(object sender, EventArgs eventArgs)
 {
     DeregisterForKataProgress();
     _attemptGameState = _kataraiApp.AttemptGameState;
     RegisterForKataProgress();
 }