Esempio n. 1
0
        private List <MingwenInfo> SuggestedMingwens(MingwenColor color, AttributeDependency attributeDependency)
        {
            var mingwens             = new List <MingwenInfo>();
            var currentColorMingwens = Elements.Values.Where(m => color == m.Color).ToList();

            foreach (var mingwen in currentColorMingwens)
            {
                mingwen.UpdateScore(attributeDependency);
            }

            var         orderedMingwens = currentColorMingwens.OrderByDescending(m => m.Score).ToList();
            MingwenInfo first           = null;

            foreach (var mingwen in orderedMingwens)
            {
                if (mingwens.Count < MaxMingwenPerUnit &&
                    (null == first && mingwen.Score > ScoreMin ||
                     null != first && (mingwen.Score > ScoreAdvanced ||
                                       mingwen.Score > ScoreMin && first.Score - mingwen.Score < ScoreDiffLess ||
                                       mingwen.Score > ScoreMid && first.Score - mingwen.Score < ScoreDiffMore)))
                {
                    var current = mingwen.Clone();
                    mingwens.Add(current);
                    if (null == first)
                    {
                        first = current;
                    }
                }
            }

            return(mingwens);
        }
Esempio n. 2
0
        public bool HasSameAttribute(MingwenInfo other)
        {
            var hasSameAttribute = null != other &&
                                   (other.Attributes.Any(o => Attributes.Contains(o)) ||
                                    Attributes.Any(a => other.Attributes.Contains(a)));

            return(hasSameAttribute);
        }
Esempio n. 3
0
        public MingwenInfo Clone()
        {
            var cloned = new MingwenInfo
            {
                Name       = Name,
                Level      = Level,
                Color      = Color,
                Attributes = Attributes,
                Score      = Score,
            };

            return(cloned);
        }
Esempio n. 4
0
        private void Add(
            int mingwenLevel,
            IReadOnlyList <string> titles,
            IReadOnlyList <string> values)
        {
            var mingwenInfo = new MingwenInfo {
                Level = mingwenLevel
            };

            for (var i = 0; i < values.Count && i < titles.Count; i++)
            {
                var title = titles[i];
                if (string.IsNullOrEmpty(title))
                {
                    continue;
                }
                var color       = GetMingwenColor(title);
                var valueString = values[i];
                if (string.IsNullOrEmpty(valueString))
                {
                    continue;
                }
                if (color == MingwenColor.Unknown)
                {
                    var attribute = Attributes.Add(title, valueString);
                    mingwenInfo.AddAttribute(attribute);
                }
                else
                {
                    mingwenInfo.Name  = valueString;
                    mingwenInfo.Color = color;
                }
            }

            Elements[mingwenInfo.Name] = mingwenInfo;
        }