public MarketPlaceCalculator(Account account, HtmlDocument htmlDocument, HtmlWeb htmlWeb, MarketPlaceQueue queue,
     Settings settings, Languages languages)
 {
     this.account = account;
     this.htmlDocument = htmlDocument;
     this.htmlWeb = htmlWeb;
     this.queue = queue;
     this.settings = settings;
     language = languages.GetLanguage(settings.LanguageId);
 }
예제 #2
0
        public void CalculatorDestinationBellowPercent()
        {
            DeserializeLanguage();
            Language language = Languages.GetLanguage("sl-SI");
            Assert.IsNotNull(language, "Language is null!");

            HtmlDocument htmlDocument = new HtmlDocument();
            htmlDocument.Load("..\\..\\Test Files\\Marketplace.php.html");
            HtmlParser htmlParser = new HtmlParser(htmlDocument, language);
            MarketPlace marketPlaceDestination = htmlParser.MarketPlace();
            Assert.IsNotNull(marketPlaceDestination, "NULL");
            Village destinationVillage = new Village();
            destinationVillage.AddId(123).AddName("01");
            Production productionDestination = htmlParser.GetProduction();
            Assert.IsNotNull(productionDestination, "NULL");
            destinationVillage.UpdateProduction(productionDestination);

            htmlDocument = new HtmlDocument();
            htmlDocument.Load("..\\..\\Test Files\\Marketplace.idle.php.html");
            htmlParser = new HtmlParser(htmlDocument, language);
            MarketPlace marketPlaceSource = htmlParser.MarketPlace();
            Assert.IsNotNull(marketPlaceSource, "NULL");
            Village sourceVillage = new Village();
            sourceVillage.AddId(321).AddName("02");
            Production productionSource = htmlParser.GetProduction();
            Assert.IsNotNull(productionSource, "NULL");
            sourceVillage.UpdateProduction(productionSource);

            DateTime dt = new DateTime(DateTime.Now.Ticks);
            MarketPlaceQueue queue = new MarketPlaceQueue
                {
                    DestinationVillage = destinationVillage,
                    SourceVillage = sourceVillage,
                    Goods = 80,
                    SendWood = true,
                    SendClay = true,
                    SendIron = true,
                    SendCrop = true,
                    SendGoodsType = SendGoodsType.DestinationBellowPercent,
                    LastSend = dt.AddDays(-1),
                    RepeatMinutes = 10,
                };

            MarketPlaceCalculator calculator = new MarketPlaceCalculator
                {
                    Destination = destinationVillage,
                    Source = sourceVillage,
                    MarketPlaceDestination = marketPlaceDestination,
                    MarketPlaceSource = marketPlaceSource,
                    Queue = queue,
                };
            calculator.Calculate();
            Assert.AreEqual("&r1=0&r2=1246&r3=1004&r4=0", calculator.PostParameters, "PostParameters");
            Assert.IsTrue(calculator.TimeToSend(dt), "Last send time");
        }
예제 #3
0
 private void buttonMarketPlaceRepeatAddTask_Click(object sender, EventArgs e)
 {
     Village sourceVillage = comboBoxMarketPlaceRepeatSourceVillage.SelectedItem as Village;
     if (sourceVillage != null)
     {
         if (sourceVillage.Id > -1)
         {
             bool sendWood = checkBoxMarketPlaceRepeatWood.Checked;
             bool sendClay = checkBoxMarketPlaceRepeatClay.Checked;
             bool sendIron = checkBoxMarketPlaceRepeatIron.Checked;
             bool sendCrop = checkBoxMarketPlaceRepeatCrop.Checked;
             MarketPlaceQueue queue = new MarketPlaceQueue
                 {
                     DestinationVillage = new Village
                         {
                             CoordinateX = Misc.String2Number(textBoxMarketPlaceRepeatX.Text),
                             CoordinateY = Misc.String2Number(textBoxMarketPlaceRepeatY.Text),
                             Name = textBoxMarketPlaceRepeatX.Text + "|" + textBoxMarketPlaceRepeatY.Text,
                         },
                     SourceVillage = sourceVillage,
                     SendWood = sendWood,
                     SendClay = sendClay,
                     SendIron = sendIron,
                     SendCrop = sendCrop,
                     SendGoodsType = SendGoodsType.Repeat,
                     Goods = Misc.String2Number(textBoxMarketPlaceRepeatGoods.Text),
                     RepeatMinutes = Misc.String2Number(comboBoxMarketPlaceRepeatHour.Text)*60,
                     LastSend = DateTime.Now,
                 };
             actions.MarketPlaceQueue.Add(queue);
             SerializeActions();
             DeserializeActions();
             UpdateStatus("New Market place task.");
         }
         else
         {
             UpdateComboBoxVillages(comboBoxMarketPlaceSourceVillage);
             UpdateComboBoxVillages(comboBoxMarketPlaceDestinationVillage);
             UpdateComboBoxVillages(comboBoxMarketPlaceRepeatSourceVillage);
         }
     }
 }
예제 #4
0
 private void buttonMarketPlaceAddTask_Click(object sender, EventArgs e)
 {
     Village sourceVillage = comboBoxMarketPlaceSourceVillage.SelectedItem as Village;
     Village destinationVillage = comboBoxMarketPlaceDestinationVillage.SelectedItem as Village;
     if (sourceVillage != null && destinationVillage != null)
     {
         if (sourceVillage.Id > -1 && destinationVillage.Id > -1)
         {
             int destinationPercent = Misc.String2Number(textBoxMarketPlaceDestinationBellow.Text.Trim());
             int sourcePercent = Misc.String2Number(textBoxMarketPlaceSourceOver.Text.Trim());
             bool sendWood = checkBoxMarketPlaceWood.Checked;
             bool sendClay = checkBoxMarketPlaceClay.Checked;
             bool sendIron = checkBoxMarketPlaceIron.Checked;
             bool sendCrop = checkBoxMarketPlaceCrop.Checked;
             MarketPlaceQueue queue = new MarketPlaceQueue
                 {
                     DestinationVillage = destinationVillage,
                     SourceVillage = sourceVillage,
                     SendWood = sendWood,
                     SendClay = sendClay,
                     SendIron = sendIron,
                     SendCrop = sendCrop,
                     SendGoodsType =
                         radioButtonMarketPlaceDestinationBellow.Checked
                             ? SendGoodsType.DestinationBellowPercent
                             : SendGoodsType.SourceOverPercent,
                     Goods =
                         radioButtonMarketPlaceDestinationBellow.Checked
                             ? destinationPercent
                             : sourcePercent,
                     GoodsToSend = Misc.String2Number(textBoxMarketPlaceSourceOverSendGods.Text),
                     LastSend = new DateTime(DateTime.Now.Ticks),
                     RepeatMinutes = Misc.String2Number(comboBoxMarketPlaceCheck.Text),
                 };
             actions.MarketPlaceQueue.Add(queue);
             SerializeActions();
             DeserializeActions();
             UpdateStatus("New Market place task.");
         }
         else
         {
             UpdateComboBoxVillages(comboBoxMarketPlaceSourceVillage);
             UpdateComboBoxVillages(comboBoxMarketPlaceDestinationVillage);
             UpdateComboBoxVillages(comboBoxMarketPlaceRepeatSourceVillage);
         }
     }
 }