コード例 #1
0
ファイル: ActionTests.cs プロジェクト: trippleflux/jezatools
 public void ActionTest()
 {
     Action action = new Action("0");
     // ReSharper disable UseObjectOrCollectionInitializer
     ActionParameters actionParameters = new ActionParameters();
     // ReSharper restore UseObjectOrCollectionInitializer
     actionParameters.Id = "0";
     action.AddActionParameters(actionParameters);
     Assert.IsNotNull(action.ActionParameters);
     Assert.AreEqual(1, action.ActionParameters.Count);
     Assert.IsNull(action.GetActionParameters("99"));
     Assert.IsNotNull(action.GetActionParameters("0"));
     Assert.AreEqual("0", action.GetActionParameters("0").Id);
 }
コード例 #2
0
        public void ActionContainerTest()
        {
            Action action = new Action("1");
            ActionParameters actionParameters = new ActionParameters();
            actionParameters.Id = "1";
            action.AddActionParameters(actionParameters);
            ActionList actionList = new ActionList();
            actionList.AddAction("1", action);
            ActionContainer actionContainer = new ActionContainer();
            actionContainer.AddActionList("C:\\asd.xml", actionList);

            Assert.IsNotNull(actionContainer.ActionsContainer);
            Assert.AreEqual(1, actionContainer.ActionsContainer.Count);
            Assert.IsNotNull(actionList.ActionsList);
            Assert.AreEqual(1, actionList.ActionsList.Count);
            Assert.IsNull(actionList.GetAction("99"));
            Assert.IsNotNull(actionList.GetAction("1"));
            Assert.AreEqual("1", actionList.GetAction("1").GetActionParameters("1").Id);
            Assert.AreEqual("1", actionContainer.GetActionList("C:\\asd.xml").GetAction("1").GetActionParameters("1").Id);
        }
コード例 #3
0
 private int GetAvailableUnitCount(ActionParameters parameters)
 {
     int villageId = parameters.VillageId;
     string url = String.Format(CultureInfo.InvariantCulture, "{0}?newdid={1}", serverInfo.Dorf1Url, villageId);
     string pageSource = Http.SendData(url, null, serverInfo.CookieContainer, serverInfo.CookieCollection);
     HtmlParser htmlParser = new HtmlParser(pageSource);
     htmlParser.ParseUnitsInVillage(serverInfo, villageId);
     Unit units = serverInfo.GetVillage(villageId).GetUnit(parameters.UnitName);
     return units != null ? units.UnitCount : 0;
 }
コード例 #4
0
        private void ExecuteAttack(ActionParameters parameters)
        {
            //b=1&t1=&t4=&t7=&t9=&t2=&t5=&t8=&t10=&t3=29&t6=&c=4&dname=&x=-16&y=-93&s1.x=22&s1.y=8&s1=ok
            //<input type="hidden" name="id" value="39">
            //<input type="hidden" name="a" value="18979">
            //<input type="hidden" name="c" value="4">
            //<input type="hidden" name="kid" value="396080">

            //id=39&a=47889&c=4&kid=395278&t1=0&t2=0&t3=29&t4=0&t5=0&t6=0&t7=0&t8=0&t9=0&t10=0&t11=0&s1.x=39&s1.y=9&s1=ok
            StringBuilder troops = new StringBuilder();
            for (int t = 0; t < 11; t++)
            {
                troops.AppendFormat("&t{0}={1}", (t + 1), t == parameters.UnitId ? parameters.UnitCount : 0);
            }
            Random rnd = new Random();
            String postData = String.Format(CultureInfo.InvariantCulture,
                                            "id=39&a={0}&c={1}&kid={2}{3}{4}",
                                            rnd.Next(10001, 99999),
                                            parameters.SendTroopType,
                                            Misc.ConvertXY(parameters.CoordinateX, parameters.CoordinateY),
                                            troops,
                                            String.Format("&s1.x={0}&s1.y={1}&s1=ok", rnd.Next(0, 79), rnd.Next(0, 19)));

            string url = String.Format(CultureInfo.InvariantCulture, "{0}?newdid={1}", serverInfo.SendUnitsUrl, parameters.VillageId);
            Http.SendData(url, postData, serverInfo.CookieContainer, serverInfo.CookieCollection);
        }
コード例 #5
0
ファイル: Action.cs プロジェクト: trippleflux/jezatools
 public void AddActionParameters(ActionParameters parameters)
 {
     actionParameters.Add(parameters);
 }
コード例 #6
0
ファイル: ActionParser.cs プロジェクト: trippleflux/jezatools
        public static void ReadAction(ActionList actionList,
            XmlReader xmlReader)
        {
            xmlReader.Read();
            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                    case "attackAction":
                    {
                        // ReSharper disable UseObjectOrCollectionInitializer
                        ActionParameters actionParameters = new ActionParameters();
                        // ReSharper restore UseObjectOrCollectionInitializer
                        actionParameters.Id = ReadAttribute(xmlReader, "id");
                        actionParameters.Enabled = Int32.Parse(ReadAttribute(xmlReader, "enabled"));
                        actionParameters.CoordinateX = Int32.Parse(ReadAttribute(xmlReader, "coordinateX"));
                        actionParameters.CoordinateY = Int32.Parse(ReadAttribute(xmlReader, "coordinateY"));
                        actionParameters.SendTroopType = Int32.Parse(ReadAttribute(xmlReader, "sendTroopType"));
                        actionParameters.UnitCount = Int32.Parse(ReadAttribute(xmlReader, "unitCount"));
                        actionParameters.UnitId = Int32.Parse(ReadAttribute(xmlReader, "unitId"));
                        actionParameters.UnitName = ReadAttribute(xmlReader, "unitName");
                        actionParameters.VillageId = Int32.Parse(ReadAttribute(xmlReader, "villageId"));
                        actionParameters.Comment = ReadAttribute(xmlReader, "comment");
                        actionParameters.PlayerName = ReadAttribute(xmlReader, "playername");
                        actionParameters.Population = Int32.Parse(ReadAttribute(xmlReader, "population"));
                        actionParameters.VillageName = ReadAttribute(xmlReader, "villagename");
                        actionParameters.Aliance = ReadAttribute(xmlReader, "aliance");
                        Action action = new Action(actionParameters.Id);
                        action.AddActionParameters(actionParameters);
                        actionList.AddAction(actionParameters.Id, action);
                        xmlReader.Read();
                        break;
                    }

                    case "trooSenderAction":
                    {
                        TroopSenderParamaters troopSenderParamaters = new TroopSenderParamaters();
                        troopSenderParamaters.Id = ReadAttribute(xmlReader, "id");
                        troopSenderParamaters.Time = ReadAttribute(xmlReader, "time");
                        troopSenderParamaters.UseKatas = Int32.Parse(ReadAttribute(xmlReader, "useKatas"));
                        troopSenderParamaters.KataDest1 = Int32.Parse(ReadAttribute(xmlReader, "kataDest1"));
                        troopSenderParamaters.KataDest2 = Int32.Parse(ReadAttribute(xmlReader, "kataDest2"));
                        troopSenderParamaters.TroopList = ReadAttribute(xmlReader, "troopList");
                        troopSenderParamaters.DestX = Int32.Parse(ReadAttribute(xmlReader, "destX"));
                        troopSenderParamaters.DestY = Int32.Parse(ReadAttribute(xmlReader, "destY"));
                        troopSenderParamaters.VillageId = Int32.Parse(ReadAttribute(xmlReader, "villageId"));
                        troopSenderParamaters.AttackType = Int32.Parse(ReadAttribute(xmlReader, "attackType"));
                        Action action = new Action(troopSenderParamaters.Id);
                        action.AddTroopSenderParameters(troopSenderParamaters);
                        actionList.AddTroopSenderAction(action);
                        xmlReader.Read();
                        break;
                    }

                    case "fakeAttack":
                    {
                        FakeParamaters fakeParamaters = new FakeParamaters();
                        fakeParamaters.Id = ReadAttribute(xmlReader, "id");
                        fakeParamaters.VillageId = Int32.Parse(ReadAttribute(xmlReader, "villageId"));
                        fakeParamaters.UnitId = Int32.Parse(ReadAttribute(xmlReader, "unitId"));
                        fakeParamaters.UserIdUrl = ReadAttribute(xmlReader, "uid");
                        Action action = new Action(fakeParamaters.Id);
                        action.AddFakeParameters(fakeParamaters);
                        actionList.AddFakeAction(action);
                        xmlReader.Read();
                        break;
                    }

                    case "sendResources":
                    {
                        SendResourcesParameters sendResourcesParameters = new SendResourcesParameters();
                        sendResourcesParameters.Id = ReadAttribute(xmlReader, "id");
                        sendResourcesParameters.Enabled = Int32.Parse(ReadAttribute(xmlReader, "enabled"));
                        sendResourcesParameters.SourceVillageId = Int32.Parse(ReadAttribute(xmlReader, "sourceVillageId"));
                        sendResourcesParameters.DestinationVillageX = Int32.Parse(ReadAttribute(xmlReader, "destX"));
                        sendResourcesParameters.DestinationVillageY = Int32.Parse(ReadAttribute(xmlReader, "destY"));
                        sendResourcesParameters.WoodAmount = Int32.Parse(ReadAttribute(xmlReader, "woodAmount"));
                        sendResourcesParameters.ClayAmount = Int32.Parse(ReadAttribute(xmlReader, "clayAmount"));
                        sendResourcesParameters.IronAmount = Int32.Parse(ReadAttribute(xmlReader, "ironAmount"));
                        sendResourcesParameters.CropAmount = Int32.Parse(ReadAttribute(xmlReader, "cropAmount"));
                        Action action = new Action(sendResourcesParameters.Id);
                        action.AddSendResourcesParameters(sendResourcesParameters);
                        actionList.AddSendResourcesAction(action);
                        xmlReader.Read();
                        break;
                    }

                    default:
                    {
                        throw new NotSupportedException(xmlReader.Name + " not supported");
                    }
                }
            }
            xmlReader.Read();
        }