private bool WriteChildrenLink <T>(DocItem parent, string title, bool includeInnerChildren)
        {
            bool hasTitle = title is null;

            foreach (DocItem child in KnownItems.Where(i => i.Parent == parent).OrderBy(i => i.Id))
            {
                if (child is T)
                {
                    if (!hasTitle)
                    {
                        hasTitle = true;
                        WriteLine($"### {title}");
                    }

                    WriteLine($"- {GetLink(child)}");
                }

                if (includeInnerChildren)
                {
                    hasTitle = WriteChildrenLink <T>(child, hasTitle ? null : title, true);
                }
            }

            return(hasTitle);
        }
Пример #2
0
 public static async Task <int> BuyKnownItem(uint ItemId, int qty)
 {
     if (KnownItems.TryGetValue(ItemId, out var itemInfo))
     {
         Logger.Info($"Found Known item {ItemId}");
         return(await BuyItem(ItemId, qty, itemInfo.Item1, itemInfo.Item2));
     }
     return(0);
 }
Пример #3
0
 public void Prioritize()
 {
     if (KnownItems.Count > 0)
     {
         KnownItems.OrderBy(i => i.Location.DistanceTo(this.Location)) // order items by closest
         .ThenByDescending(i => i is Consumable);                      // give priority to consumables
     }
     if (KnownEntities.Count > 0)
     {
         KnownEntities.OrderBy(e => e.Location.DistanceTo(this.Location)) // order enemies by closest
         .ThenBy(e => e.CurrentHp.Value)                                  // and those that have less hp remaining
         .ThenByDescending(e => hasLineOfSightTo(e));                     // and are in line of sight
     }
 }
Пример #4
0
 private void addToKnown(List <IMappable> knownObjects)
 {
     foreach (var obj in knownObjects)
     {
         if (obj is Entity)
         {
             KnownEntities.Add(obj as Entity);
         }
         else if (obj is Item)
         {
             KnownItems.Add(obj as Item);
         }
     }
 }