Exemple #1
0
        private void Button_Pressed(object sender, EventArgs e)
        {
            //CrossVibrate.Current.Vibration(TimeSpan.FromMilliseconds(50));

            var            ButtonSender = (Image)sender;
            MacroContainer Macro        = CurrentPageMacros[(Int32.Parse(ButtonSender.ClassId) - 1)];

            if (Macro.Type == "Folder")
            {
                List <MacroContainer> NewMacroPage = GetMacroPage(Macro.MacroID);

                SetButtons(NewMacroPage);
            }
            else
            {
                Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
                                         ProtocolType.Udp);

                IPAddress serverAddr = IPAddress.Parse(ServerIP);

                IPEndPoint endPoint = new IPEndPoint(serverAddr, 10000);

                string text        = Macro.MacroID;
                byte[] send_buffer = Encoding.ASCII.GetBytes(text);

                sock.SendTo(send_buffer, endPoint);
            }
        }
        public void Successfully_RegisterAllMacros()
        {
            var registry = new MacroRegistry();
            var cont     = new MacroContainer(2);

            registry.RegisterType(cont);
            Assert.IsTrue(registry.Contains("a"));
            Assert.IsTrue(registry.Contains("b"));
            Assert.IsFalse(registry.Contains("c"));
            Assert.IsTrue(registry.Contains("z"));

            var conf = new RollerConfig()
            {
                MacroRegistry = registry, GetRandomBytes = GetRNG(Roll9())
            };

            EvaluateRoll("1d20 + [a]", conf, 1, "1d20 + [a] => 9 + 1 => 10");
            EvaluateRoll("[b]d20", conf, 2, "2d20 => 9 + 9 => 18");
            EvaluateRoll("[z]d20", conf, 2, "2d20 => 9 + 9 => 18");
        }
        public void Successfully_ShadowConfigWithData()
        {
            var registry1 = new MacroRegistry();
            var registry2 = new MacroRegistry();
            var cont      = new MacroContainer(3);

            registry1.RegisterType(cont);
            registry2.RegisterMacro("a", cont.B);

            var config = new RollerConfig()
            {
                MacroRegistry = registry1
            };
            var data = new RollData()
            {
                MacroRegistry = registry2
            };

            EvaluateRoll("[b]", config, data, 0, "[b] => 3 => 3");
            EvaluateRoll("[a]", config, data, 0, "[a] => 3 => 3");
        }
Exemple #4
0
        public List <MacroContainer> GetMacroPage(string Page)
        {
            var           client   = new RestClient("http://" + ServerIP + ":5000" + "/page/" + Page);
            var           request  = new RestRequest(Method.GET);
            IRestResponse response = client.Execute(request);

            RootObject MacroPage = JsonConvert.DeserializeObject <RootObject>(response.Content);

            List <MacroContainer> MacroList = new List <MacroContainer>();

            for (int ItemCounter = 0; ItemCounter < MacroPage.items.Count; ItemCounter++)
            {
                MacroContainer Macro = new MacroContainer();
                Macro.Image   = MacroPage.items[ItemCounter].Image;
                Macro.MacroID = MacroPage.items[ItemCounter].MacroID;
                Macro.Type    = MacroPage.items[ItemCounter].Type;

                MacroList.Add(Macro);
            }

            CurrentPageMacros = MacroList;
            return(MacroList);
        }