Example #1
0
        private void findRule3()
        {
            _rule3 = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();

            var rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();

            Assert.AreSame(_rule3, rule);

            rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();
            Assert.AreSame(_rule3, rule);

            rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();
            Assert.AreSame(_rule3, rule);

            rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();
            Assert.AreSame(_rule3, rule);
        }
Example #2
0
        private void findRule3()
        {
            _rule3 = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();

            var rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();

            _rule3.ShouldBeTheSameAs(rule);

            rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();
            _rule3.ShouldBeTheSameAs(rule);

            rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();
            _rule3.ShouldBeTheSameAs(rule);

            rule = container.GetInstance <Rule>().ShouldBeOfType <ColorRule>();
            _rule3.ShouldBeTheSameAs(rule);
        }
Example #3
0
        public void unable_to_determine_a_dependency()
        {
            var colorRule = new ColorRule("Red");
            var source    = ConcreteType.SourceFor(
                new Policies(PluginGraph.CreateRoot()),
                ConcreteType.SetterProperty,
                "SomeProp",
                typeof(IGateway),
                colorRule)
                            .ShouldBeOfType <DependencyProblem>();

            source.Name.ShouldBe("SomeProp");
            source.Type.ShouldBe(ConcreteType.SetterProperty);
            source.ReturnedType.ShouldBe(typeof(IGateway));
            source.Message.ShouldBe(ConcreteType.UnableToDetermineDependency.ToFormat(
                                        typeof(IGateway).GetFullName(), colorRule));
        }
Example #4
0
        public FunctionCall ifcolor(string arg_txt)
        {
            string[]     args          = arg_txt.Split(',');
            int          X             = Int32.Parse(args[0]);
            int          Y             = Int32.Parse(args[1]);
            ColorChecker color_checker = ColorRule.Parse(args[2]);
            string       file_path     = (args.Length > 3 ? args[3] : null);

            return(delegate()
            {
                if (color_checker(screen_capturer.GetColorOfPx(X + script.XRef,
                                                               Y + script.YRef)))
                {
                    return ExecFileBreakable(file_path);
                }
                return FunctionResult.Continue;
            });
        }
Example #5
0
        public FunctionCall waitforpx(string arg_txt)
        {
            string[]        args          = arg_txt.Split(',');
            int             x             = Int32.Parse(args[0]);
            int             y             = Int32.Parse(args[1]);
            ColorChecker    color_checker = ColorRule.Parse(args[2]);
            NumberGenerator timeout_ms    = (args.Length > 3 ? NumberGenerator.Parse(args[3]) : new StaticNumber(0));
            string          file_path     = (args.Length > 4 ? args[4] : null);

            return(delegate()
            {
                if (!screen_color_detector.WaitForPx(new Point(x + script.XRef, y + script.YRef),
                                                     color_checker, timeout_ms.GetInt()))
                {
                    // timed out
                    return ExecFileBreakable(file_path);
                }
                return FunctionResult.Continue;
            });
        }
Example #6
0
        public FunctionCall ifarea(string arg_txt)
        {
            string[]     args          = arg_txt.Split(',');
            int          x1            = Int32.Parse(args[0]);
            int          y1            = Int32.Parse(args[1]);
            int          x2            = Int32.Parse(args[2]);
            int          y2            = Int32.Parse(args[3]);
            ColorChecker color_checker = ColorRule.Parse(args[4]);
            string       file_path     = args.Length > 5 ? args[5] : null;

            return(delegate()
            {
                Rectangle screen_area = Rectangle.FromLTRB(x1 + script.XRef,
                                                           script.YRef + y1, script.XRef + x2, script.YRef + y2);
                if (screen_color_detector.ScreenAreaIncludesColor(screen_area, color_checker))
                {
                    return ExecFileBreakable(file_path);
                }
                return FunctionResult.Continue;
            });
        }
Example #7
0
        public FunctionCall movetocolor(string arg_txt)
        {
            string[]        args          = arg_txt.Split(',');
            NumberGenerator x1            = NumberGenerator.Parse(args[0]);
            NumberGenerator y1            = NumberGenerator.Parse(args[1]);
            NumberGenerator x2            = NumberGenerator.Parse(args[2]);
            NumberGenerator y2            = NumberGenerator.Parse(args[3]);
            ColorChecker    color_checker = ColorRule.Parse(args[4]);
            NumberGenerator timeout       = new StaticNumber(0);

            string file_path = null;

            if (args.Length > 5)
            {
                timeout = NumberGenerator.Parse(args[5]);
                if (args.Length > 6)
                {
                    file_path = args[6];
                }
            }

            return(delegate()
            {
                if (!script.MouseMover.MoveToColor(
                        Rectangle.FromLTRB(x1.GetInt() + script.XRef,
                                           y1.GetInt() + script.YRef,
                                           x2.GetInt() + script.XRef,
                                           y2.GetInt() + script.YRef),
                        color_checker, timeout.GetInt(), script.MouseSpeed.GetDouble()))
                {
                    // timed out
                    return ExecFileBreakable(file_path);
                }

                return FunctionResult.Continue;
            });
        }
Example #8
0
        public static bool IsWinningPalette(Color canvasColor, Palette activePlayerPalette, List <Palette> opponentPalettes, ColorRule colorRule)
        {
            switch (colorRule.Color)
            {
            case Color.Red:
                return(IsWinningRedRule(activePlayerPalette, opponentPalettes));

            case Color.Orange:
                return(IsWinningOrangeRule(activePlayerPalette, opponentPalettes));

            case Color.Yellow:
                return(IsWinningYellowRule(activePlayerPalette, opponentPalettes));

            case Color.Green:
                return(IsWinningGreenRule(activePlayerPalette, opponentPalettes));

            case Color.Blue:
                return(IsWinningBlueRule(activePlayerPalette, opponentPalettes));

            case Color.Indigo:
                return(IsWinningIndigoRule(activePlayerPalette, opponentPalettes));

            case Color.Violet:
                return(IsWinningVioletRule(activePlayerPalette, opponentPalettes));

            default:
                throw new Exception($"No corresponding Color Rule for {canvasColor.ToString()}");
            }
        }