Exemplo n.º 1
0
        protected ButtonRuleSet GenerateButtonRuleSet(bool useDefault = false)
        {
            var buttonRuleSet = new ButtonRuleSet();

            if (useDefault)
            {
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Hold, mkQuery(QueryableButtonProperty.IsButtonColor, "color", ButtonColor.blue), mkQuery(QueryableButtonProperty.IsButtonInstruction, "instruction", ButtonInstruction.Abort)));
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Press, mkQuery(QueryableProperty.MoreThanXBatteries, "batteryCount", 1), mkQuery(QueryableButtonProperty.IsButtonInstruction, "instruction", ButtonInstruction.Detonate)));
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Hold, mkQuery(QueryableButtonProperty.IsButtonColor, "color", ButtonColor.white), mkQuery(QueryableProperty.IndicatorXLit, "label", "CAR")));
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Press, mkQuery(QueryableProperty.MoreThanXBatteries, "batteryCount", 2), mkQuery(QueryableProperty.IndicatorXLit, "label", "FRK")));
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Hold, mkQuery(QueryableButtonProperty.IsButtonColor, "color", ButtonColor.yellow)));
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Press, mkQuery(QueryableButtonProperty.IsButtonColor, "color", ButtonColor.red), mkQuery(QueryableButtonProperty.IsButtonInstruction, "instruction", ButtonInstruction.Hold)));
                buttonRuleSet.RuleList.Add(mkRule(ButtonSolutions.Hold, mkQuery(QueryableButtonProperty.ButtonOtherwise)));

                buttonRuleSet.HoldRuleList.Add(mkRule(ButtonSolutions.ReleaseOnTimerText("4"), mkQuery(QueryableButtonProperty.IsIndicatorColor, "color", BigButtonLEDColor.Blue)));
                buttonRuleSet.HoldRuleList.Add(mkRule(ButtonSolutions.ReleaseOnTimerText("1"), mkQuery(QueryableButtonProperty.IsIndicatorColor, "color", BigButtonLEDColor.White)));
                buttonRuleSet.HoldRuleList.Add(mkRule(ButtonSolutions.ReleaseOnTimerText("5"), mkQuery(QueryableButtonProperty.IsIndicatorColor, "color", BigButtonLEDColor.Yellow)));
                buttonRuleSet.HoldRuleList.Add(mkRule(ButtonSolutions.ReleaseOnTimerText("1"), mkQuery(QueryableButtonProperty.IndicatorOtherwise)));

                return(buttonRuleSet);
            }

            BuildQueryLists();
            while (buttonRuleSet.RuleList.Count < MaxInitialRules && PrimaryQueryList.Count > 0)
            {
                var baseQuery = PopQueryFromList(PrimaryQueryList);
                var num       = rand.Next(2);
                if (num == 0)
                {
                    buttonRuleSet.RuleList.Add(CreateRule(baseQuery, null, false));
                }
                for (var i = 0; i < num; i++)
                {
                    buttonRuleSet.RuleList.Add(CreateRule(baseQuery, PopQueryFromList(SecondaryQueryList), false));
                }
            }
            var rule = new Rule();

            rule.Queries.Add(OtherwiseQuery());
            rule.Solution     = ButtonSolutions.Hold;
            rule.SolutionArgs = new Dictionary <string, object>();
            buttonRuleSet.RuleList.Add(rule);
            while (buttonRuleSet.HoldRuleList.Count < MaxHoldRules && IndicatorColorQueryList.Count > 0)
            {
                var baseQuery2 = PopQueryFromList(IndicatorColorQueryList);
                buttonRuleSet.HoldRuleList.Add(CreateRule(baseQuery2, null, true));
            }
            buttonRuleSet.HoldRuleList.Add(CreateRule(IndicatorOtherwiseQuery(), null, true));
            RuleSet = buttonRuleSet;
            return(buttonRuleSet);
        }
Exemplo n.º 2
0
        protected List <Solution> CreateHoldSolutionsList()
        {
            var list = new List <Solution>
            {
                ButtonSolutions.ReleaseOnTimerText("5"),
                ButtonSolutions.ReleaseOnTimerText("1"),
                ButtonSolutions.ReleaseOnTimerText("2"),
                ButtonSolutions.ReleaseOnTimerText("3"),
                ButtonSolutions.ReleaseOnTimerText("4")
            };

            if (CommonReflectedTypeInfo.IsModdedSeed)
            {
                list.AddRange(new []
                {
                    ButtonSolutions.ReleaseOnTimerText("6"),
                    ButtonSolutions.ReleaseOnTimerText("7"),
                    ButtonSolutions.ReleaseOnTimerText("8"),
                    ButtonSolutions.ReleaseOnTimerText("9"),
                    ButtonSolutions.ReleaseOnTimerText("0")
                });
                for (var i = 0; i < 10; i++)
                {
                    list.Add(ReleaseWhenLeastSignificantSecondIs(i));
                }
                list.Add(ReleaseAtAnyTime);
                list.Add(ReleaseOneSecondAfterSecondsAddToMultipleOfFour);
                list.Add(ReleaseWhenSecondsDigitsAddsToFive);
                list.Add(ReleaseWhenSecondsDigitsAddsToSeven);
                list.Add(ReleaseWhenSecondsDigitsAddsToThreeOrThirteen);
                list.Add(ReleaseWhenSecondsIsMultipleOfSeven);
                list.Add(ReleaseWhenSecondsPrimeOrZero);
            }
            foreach (var key in list)
            {
                if (!solutionWeights.ContainsKey(key))
                {
                    solutionWeights.Add(key, 1f);
                }
            }
            return(list);
        }