//public override string HintText()
        //{
        //    return $"{FirstFieldName} {Mode} {SecondFieldName}";
        //}

        public override string HintText(List <Item> items, BuildComponent.ComponentType type)
        {
            if (type != FirstType && type != SecondType)
            {
                return(null);
            }

            var secondaryItems = items.Where(i => i.ComponentType == SecondType);
            var primaryItems   = items.Where(i => i.ComponentType == FirstType);
            var primarySum     = primaryItems.Sum(i => GetValue(i, FirstFieldName));
            var secondarySum   = secondaryItems.Sum(i => GetValue(i, SecondFieldName));

            if (type == FirstType)
            {
                if (secondaryItems.Count() == 0)
                {
                    return(null);
                }

                return($"Must have {FirstFieldName} {GetModeString(Mode)} {secondarySum} ({SecondType}) (Currently {primarySum})");
            }
            if (type == SecondType)
            {
                if (primaryItems.Count() == 0)
                {
                    return(null);
                }
                return($"Must have {SecondFieldName} {GetModeString(Reverse(Mode))} {primarySum} ({FirstType}) (Currently {secondarySum})");
            }

            return(null);
        }
Beispiel #2
0
 public FieldComparisonDependency(BuildComponent.ComponentType first, string fieldFirst, BuildComponent.ComponentType second, string fieldSecond, CompareMode mode)
 {
     FirstType       = first;
     SecondType      = second;
     FirstFieldName  = fieldFirst;
     SecondFieldName = fieldSecond;
     Mode            = mode;
 }
 public FieldQuantityDependency(string name, BuildComponent.ComponentType subItem, BuildComponent.ComponentType containerItem, string?containerField = null, string?subField = null)
     : base(name)
 {
     subType            = subItem;
     containerType      = containerItem;
     containerFieldName = containerField;
     subTypeFieldName   = subField;
 }
Beispiel #4
0
        public static async Task <SearchResults> LoadCategoryFast(BuildComponent.ComponentType type, CancellationToken?token = null)
        {
            var url      = $"https://microc.bbarrett.me/MicroCenterProxy/getCachedCategory/{(int)type}";
            var response = await(token != null ? client.GetAsync(url, token.Value) : client.GetAsync(url));

            if (response.IsSuccessStatusCode)
            {
                var body = await response.Content.ReadAsStringAsync();

                var result = JsonConvert.DeserializeObject <SearchResults>(body);
                return(result);
            }

            return(new SearchResults());
        }
        public override string HintText(List <Item> items, BuildComponent.ComponentType type)
        {
            if (type == subType)
            {
                var containerItems = items.Where(i => i.ComponentType == containerType);
                if (containerItems.Count() == 0)
                {
                    return(null);
                }
                int containerSlots;
                if (!string.IsNullOrWhiteSpace(containerFieldName))
                {
                    containerSlots = containerItems.Sum(i => GetValue(i, containerFieldName) ?? 0);
                }
                else
                {
                    containerSlots = containerItems.Count();
                }

                return($"{containerType} has {containerSlots} available for {subType}");
            }
            if (type == containerType)
            {
                var subItems = items.Where(i => i.ComponentType == subType);
                if (subItems.Count() == 0)
                {
                    return(null);
                }

                int subItemCount;

                if (!string.IsNullOrWhiteSpace(subTypeFieldName))
                {
                    subItemCount = subItems.Sum(i => GetValue(i, subTypeFieldName) ?? 0);
                }
                else
                {
                    subItemCount = subItems.Count();
                }

                return($"{containerType} must have support for {subItemCount} {subType}");
            }

            return(null);
        }
 public override bool Applicable(BuildComponent.ComponentType type)
 {
     return(type == containerType || type == subType);
 }
 public override bool Applicable(BuildComponent.ComponentType type)
 {
     return(type == FirstType || type == SecondType);
 }
Beispiel #8
0
 public FieldQuantityDependency(BuildComponent.ComponentType first, BuildComponent.ComponentType second, string field)
 {
     FirstType       = first;
     SecondType      = second;
     SecondFieldName = field;
 }