private void ProduceTroopSetting_Load(object sender, EventArgs e) { mui.RefreshLanguage(this); if (TravianData == null) { return; } CV = TravianData.Villages[RUVillageID]; listBox1.Items.Clear(); if (checkBox3.Checked) { numericUpDown1.Value = 1; numericUpDownTransferCount.Value = 0; numericUpDown1.Enabled = false; numericUpDownTransferCount.Enabled = false; checkBox1.Enabled = false; listBox1.Enabled = false; } else { numericUpDown1.Value = 0; numericUpDownTransferCount.Value = 1; numericUpDown1.Enabled = numericUpDownTransferCount.Enabled = checkBox1.Enabled = listBox1.Enabled = true; if (CanProduce != null) { foreach (var p in CanProduce) { if (p.Researched | checkBox1.Checked) { listBox1.Items.Add(p); } } } } }
public void NewParseTroopsCrazy() { Travian target = new Travian(); target.TD = new Data(); int villageId = 1; TVillage village = new TVillage(); target.TD.Villages[villageId] = village; TTroop troops = new TTroop(); village.Troop = troops; target.SetGidLang(16, "Rally Point"); target.NewParseTroops(villageId, Properties.Resources.RallyPointCrazy); Assert.AreEqual(15, troops.Troops.Count); TTInfo troop = troops.Troops[0]; Assert.AreEqual(2, troop.Tribe); Assert.AreEqual("Crazy", troop.Owner); Assert.AreEqual("Return from Jeffo Village", troop.VillageName); Assert.AreEqual(1, troop.Troops[3]); Assert.IsTrue(troop.FinishTime > DateTime.Now.AddMinutes(6)); Assert.IsTrue(troop.FinishTime < DateTime.Now.AddMinutes(8)); Assert.AreEqual(TTroopType.Incoming, troop.TroopType); troop = troops.Troops[1]; Assert.AreEqual(2, troop.Tribe); Assert.AreEqual("Crazy", troop.Owner); Assert.AreEqual("Return from laraelaine40 Village", troop.VillageName); Assert.AreEqual(4, troop.Troops[0]); Assert.IsTrue(troop.FinishTime > DateTime.Now.AddMinutes(10)); Assert.IsTrue(troop.FinishTime < DateTime.Now.AddMinutes(15)); Assert.AreEqual(TTroopType.Incoming, troop.TroopType); troop = troops.Troops[7]; Assert.AreEqual(2, troop.Tribe); Assert.AreEqual("Crazy", troop.Owner); Assert.AreEqual("Own troops", troop.VillageName); Assert.AreEqual(4, troop.Troops[0]); Assert.AreEqual(1, troop.Troops[10]); Assert.AreEqual(TTroopType.InVillage, troop.TroopType); troop = troops.Troops[8]; Assert.AreEqual(TTroopType.Outgoing, troop.TroopType); Assert.AreEqual(2, troop.Tribe); Assert.AreEqual("Crazy", troop.Owner); Assert.AreEqual("Raid on hotmamapam Village", troop.VillageName); Assert.AreEqual(4, troop.Troops[0]); }
private void TransferSetting_Load(object sender, EventArgs e) { mui.RefreshLanguage(this); if (TravianData == null) { return; } CV = TravianData.Villages[FromVillageID]; foreach (var v in TravianData.Villages) { if (v.Key != FromVillageID) { comboBoxTargetVillage.Items.Add(v.Key + " " + v.Value.Coord + " " + v.Value.Name); } else { comboBoxTargetVillage.SelectedIndex = comboBoxTargetVillage.Items.Count - 1; } } if (File.Exists("Transfer")) { var ts = File.ReadAllLines("Transfer"); foreach (var t in ts) { string[] opt = t.Split(new char[] { '|' }, 3); if (opt.Length < 3) { continue; } int x = 0, y = 0; if (int.TryParse(opt[0], out x) && int.TryParse(opt[1], out y)) { if (Math.Abs(x) <= 400 && Math.Abs(y) <= 400) { comboBoxTargetVillage2.Items.Add(opt[0] + "|" + opt[1] + " " + opt[2]); } } } } numericUpDown1.Increment = numericUpDown2.Increment = numericUpDown3.Increment = numericUpDown4.Increment = CV.Market.SingleCarry; numericUpDown1.Maximum = numericUpDown2.Maximum = numericUpDown3.Maximum = numericUpDown4.Maximum = CV.Market.SingleCarry * CV.Market.MaxMerchant; numericUpDownMerchantCount.Maximum = CV.Market.MaxMerchant; }
public void NewParseTroopsTiny() { Travian target = new Travian(); target.TD = new Data(); int villageId = 1; TVillage village = new TVillage(); target.TD.Villages[villageId] = village; TTroop troops = new TTroop(); village.Troop = troops; target.SetGidLang(16, "Rally Point"); target.NewParseTroops(villageId, Properties.Resources.RallyPointTiny); Assert.AreEqual(3, troops.Troops.Count); TTInfo troop = troops.Troops[0]; Assert.AreEqual("Tiny", troop.Owner); Assert.AreEqual(270225, troop.OwnerVillageZ); Assert.AreEqual("Own troops", troop.VillageName); Assert.AreEqual(8, troop.Troops[0]); Assert.AreEqual(TTroopType.InVillage, troop.TroopType); Assert.AreEqual(DateTime.MinValue, troop.FinishTime); Assert.AreEqual(3, troop.Tribe); troop = troops.Troops[1]; Assert.AreEqual("Crazy", troop.Owner); Assert.AreEqual(217466, troop.OwnerVillageZ); Assert.AreEqual("abc's troops", troop.VillageName); Assert.AreEqual(1, troop.Troops[3]); Assert.AreEqual(TTroopType.InVillage, troop.TroopType); Assert.AreEqual(DateTime.MinValue, troop.FinishTime); Assert.AreEqual(2, troop.Tribe); troop = troops.Troops[2]; Assert.AreEqual("Tiny", troop.Owner); Assert.AreEqual(270225, troop.OwnerVillageZ); Assert.AreEqual("Reinforcement for lalala Village", troop.VillageName); Assert.AreEqual(1, troop.Troops[10]); Assert.AreEqual(TTroopType.Outgoing, troop.TroopType); Assert.IsTrue(troop.FinishTime.AddHours(-11) > DateTime.Now); Assert.IsTrue(troop.FinishTime.AddHours(-12) < DateTime.Now); Assert.AreEqual(3, troop.Tribe); }
private void comboBoxTargetVillage_SelectedIndexChanged(object sender, EventArgs e) { this.TV = null; if (comboBoxTargetVillage.SelectedIndex == 0) { this.txtX.Enabled = this.txtY.Enabled = true; targetVillageID = 0; } else { this.comboBoxTargetVillage2.SelectedIndex = 0; comboBoxTargetVillage2_SelectedIndexChanged(this, e); this.txtX.Enabled = this.txtY.Enabled = false; this.targetVillageID = Convert.ToInt32((comboBoxTargetVillage.SelectedItem as string).Split(' ')[0]); if (TravianData.Villages.ContainsKey(this.targetVillageID)) { TVillage village = TravianData.Villages[this.targetVillageID]; this.txtX.Text = village.X.ToString(); this.txtY.Text = village.Y.ToString(); if (village.isBuildingInitialized == 2) { this.TV = village; } } } if (this.TV == null) { this.radioNormalTarget.Enabled = false; this.buttonTarget.Enabled = false; if (this.radioNormalTarget.Checked) { this.radioNormalMe.Checked = true; } } else { this.radioNormalTarget.Enabled = true; this.buttonTarget.Enabled = true; } numericUpDownMechantCount_ValueChanged(sender, e); }
public void TestInitialize() { this.travianData = new Data() { Server = "none", Username = "******" }; Dictionary <string, string> Options = new Dictionary <string, string>(); this.travian = new Travian(travianData, Options); this.villageID = 1; this.village = new TVillage(); this.travianData.Villages[villageID] = village; this.village.Name = "Home"; this.village.isTroopInitialized = 2; this.village.Troop = this.troop = new TTroop(); int[] troopsAtHome = new int[11]; troopsAtHome[0] = 8; TTInfo troopAtHome = new TTInfo { Troops = troopsAtHome, Owner = this.village.Name, TroopType = TTroopType.InVillage, VillageName = "Own troops" }; this.troop.Troops.Add(troopAtHome); int[] troopsOnTheRood = new int[11]; troopsOnTheRood[0] = 5; TTInfo troopOnTheRoad = new TTInfo { Troops = troopsAtHome, TroopType = TTroopType.MyReturnWay, FinishTime = DateTime.Now.AddSeconds(100), VillageName = "Raid on abc Village" }; this.troop.Troops.Add(troopOnTheRoad); this.troops = new int[11]; this.troops[0] = 5; this.targets = new List <TPoint>(); this.targets.Add(new TPoint(1, 2)); this.targets.Add(new TPoint(0, 0)); this.target = new RaidQueue() { UpCall = this.travian, VillageID = this.villageID, Troops = this.troops, Targets = this.targets, RaidType = RaidType.AttackRaid, }; this.pageQuerier = new MockPageQuerier(this.villageID); this.travian.pageQuerier = pageQuerier; }