예제 #1
0
            public ButtonModule(BombInfo info)
            {
                numBatteries = info.NumBatteries;
                carIsLit     = info.CarIndicatorIsLit;
                frkIsLit     = info.FrkIndicatorIsLit;

                colorOfButton = buttonColor.NotSet;
                textOfButton  = buttonText.NotSet;
                theSolution   = buttonSolution.MissingInfo;

                displayBatteryWarning = false;
                displayCarWarning     = false;
                displayFrkWarning     = false;
            }
예제 #2
0
            private void CalculateSolution()
            {
                if (colorOfButton == buttonColor.NotSet ||
                    textOfButton == buttonText.NotSet)
                {
                    displayBatteryWarning = false;
                    displayCarWarning     = false;
                    displayFrkWarning     = false;
                    return;
                }

                int whichStepDidWeGetTo = 0;

                // 1. If the button is blue and the button says "Abort", hold
                if (colorOfButton == buttonColor.Blue &&
                    textOfButton == buttonText.Abort)
                {
                    theSolution         = buttonSolution.Hold;
                    whichStepDidWeGetTo = 1;
                }
                // 2. If there is more than one battery and the button says
                //    "Detonate", press and release
                else if (numBatteries > 1 && textOfButton == buttonText.Detonate)
                {
                    theSolution         = buttonSolution.PressAndRelease;
                    whichStepDidWeGetTo = 2;
                }
                // 3. If the button is white and CAR is lit, hold
                else if (colorOfButton == buttonColor.White &&
                         carIsLit.HasValue && carIsLit.Value)
                {
                    theSolution         = buttonSolution.Hold;
                    whichStepDidWeGetTo = 3;
                }
                // 4. If more than 2 batteries and FRK is lit, press and release
                else if (numBatteries > 2 &&
                         frkIsLit.HasValue && frkIsLit.Value)
                {
                    theSolution         = buttonSolution.PressAndRelease;
                    whichStepDidWeGetTo = 4;
                }
                // 5. If button is yellow, hold
                else if (colorOfButton == buttonColor.Yellow)
                {
                    theSolution         = buttonSolution.Hold;
                    whichStepDidWeGetTo = 5;
                }
                // 6. If button is red and says "Hold", press and release
                else if (colorOfButton == buttonColor.Red &&
                         textOfButton == buttonText.Hold)
                {
                    theSolution         = buttonSolution.PressAndRelease;
                    whichStepDidWeGetTo = 6;
                }
                // 7. Hold
                else
                {
                    theSolution         = buttonSolution.Hold;
                    whichStepDidWeGetTo = 7;
                }

                // Battery display warning
                if (whichStepDidWeGetTo >= 2 && textOfButton == buttonText.Detonate ||
                    whichStepDidWeGetTo >= 4)
                {
                    displayBatteryWarning = true;
                }
                else
                {
                    displayBatteryWarning = false;
                }

                // CAR display warning
                if (whichStepDidWeGetTo >= 3 && colorOfButton == buttonColor.White)
                {
                    displayCarWarning = true;
                }
                else
                {
                    displayCarWarning = false;
                }

                // FRK display warning
                if (whichStepDidWeGetTo >= 4 && numBatteries > 2)
                {
                    displayFrkWarning = true;
                }
                else
                {
                    displayFrkWarning = false;
                }
            }