Пример #1
0
        private Profile.Gather GetGather()
        {
            var      gather = new Profile.Gather();
            XElement xGather;

            try
            {
                xGather = _xRoot.Descendants().Single(e => e.Name == "Gather" || e.Name == "ExGather");
            }
            catch (Exception)
            {
                this._errorMessages.add("Multiple Gather tags are not supported. Gather tag and target set to default values");
                return(new Profile.Gather());
            }
            gather.exGather.Enabled = (xGather.Name == "ExGather");
            this.TryGetGatherWhileCondition(xGather, ref gather);
            this.TryGetGatherTarget(xGather, ref gather);
            if ((string)xGather.Attribute("DiscoverUnknowns") != null)
            {
                gather.exGather.DiscoverUnknowns = (xGather.Attribute("DiscoverUnknowns").Value == "True");
            }

            if ((string)xGather.Attribute("CordialType") != null)
            {
                try
                {
                    gather.exGather.CordialType = (Profile.CordialType)Enum.Parse(typeof(Profile.CordialType), xGather.Attribute("CordialType").Value);
                }
                catch (Exception) { _errorMessages.add("Failed parsing CordialType. Disabling."); }
            }
            return(gather);
        }
Пример #2
0
        private bool TryGetGatherTarget(XElement xGather, ref Profile.Gather gather)
        {
            var xGatherObjects = xGather.Descendants("GatherObject");

            if (xGatherObjects.Count() > 0)
            {
                gather.Target = xGatherObjects.First().Value;
                return(true);
            }
            else
            {
                this._errorMessages.add("GatherObject tag not found");
                return(false);
            }
        }
Пример #3
0
 private Profile.Gather GetGather()
 {
     try
     {
         var    gather    = new Profile.Gather();
         var    mainLoop  = _document.Descendants("While").First();
         string condition = mainLoop.Attribute("Condition").Value;
         gather.Infinite = condition.Equals("true", StringComparison.CurrentCultureIgnoreCase);
         gather.ItemId   = GetItemId(condition);
         gather.Hq       = condition.Contains("HqItemCount");
         gather.Quantity = GetItemQuantity(condition);
         gather.Target   = GetGatherObject();
         gather.exGather = GetExGather();
         return(gather);
     }
     catch (Exception err)
     {
         Log.Bot.print(err.Message);
     }
     throw new ParsingException("Could not parse gathering conditions");
 }
Пример #4
0
        /// <summary>
        /// sets gather: infinite, itemdId and quantity.
        /// </summary>
        /// <returns></returns>
        private bool TryGetGatherWhileCondition(XElement xGather, ref Profile.Gather gather)
        {
            if ((string)xGather.Attribute("while") != null)
            {
                if (xGather.Attribute("while").Value == "True")
                {
                    gather.Infinite = true;
                    return(true);
                }
            }
            else
            {
                this._errorMessages.add("Missing while condition in gather tag");
            }

            var match = new Regex(@"ItemCount\((\d+)\) .* (\d+)").Match(xGather.Attribute("while").Value);

            if (match.Success)
            {
                gather.ItemId = match.Groups[1].Value;
                int quantity;
                if (Int32.TryParse(match.Groups[2].Value, out quantity))
                {
                    gather.Infinite = false;
                    gather.Quantity = quantity;
                    return(true);
                }
                else
                {
                    this._errorMessages.add("Quantity parse failed.");
                }
            }
            else
            {
                this._errorMessages.add("Failed to parse gather while condition. Line: " + xGather.ToString());
            }
            gather.Infinite = true;
            return(false);
        }