Esempio n. 1
0
 public void TroopSenderTest()
 {
     Action action = new Action("0");
     TroopSenderParamaters actionParameters = new TroopSenderParamaters();
     actionParameters.Id = "0";
     action.AddTroopSenderParameters(actionParameters);
     Assert.IsNotNull(action.TroopSenderParameters);
     Assert.AreEqual(1, action.TroopSenderParameters.Count);
     Assert.IsNull(action.GetTroopSenderParameters("99"));
     Assert.IsNotNull(action.GetTroopSenderParameters("0"));
     Assert.AreEqual("0", action.GetTroopSenderParameters("0").Id);
 }
Esempio n. 2
0
        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();
        }