コード例 #1
0
        private static Dictionary<ItemSlot, Stats[]> removeRedundantItems(IEnumerable<Item> items, Hero hero, Monster monster, StatsFilter statsMask)
        {
            var itemGroups = items.Select(x => new Stats(x, hero, monster)).GroupBy(x => x.OriginalItem.Slot);
            var filteredItems = new Dictionary<ItemSlot, Stats[]>();

            foreach (var itemGroup in itemGroups)
            {
                var filteredList = new List<Stats>();
                foreach (var item in itemGroup)
                {
                    bool redundant = false;
                    var superiorTo = new HashSet<Stats>();
                    foreach (var filteredItem in filteredList)
                    {
                        if (item.isSuperiorTo(filteredItem, statsMask))
                            superiorTo.Add(filteredItem);
                        redundant |= item.isInferiorTo(filteredItem, statsMask);
                    }
                    foreach (var toRemove in superiorTo)
                        filteredList.Remove(toRemove);
                    if (!redundant)
                        filteredList.Add(item);
                }

                if (filteredList.Count == 0)
                {
                    var maxDamage = itemGroup.Max(x => x.Damage);
                    filteredList.Add(itemGroup.First(x => Math.Abs(x.Damage - maxDamage) < 1e-3));
                }

                filteredItems.Add(itemGroup.Key, filteredList.ToArray());
            }

            return filteredItems;
        }
コード例 #2
0
        public Stats(Item item, Hero forHero, Monster vsMonster)
        {
            this.OriginalItem = item;

            this.Damage =
                (item.Attack + item.Strength * forHero.Strength) / (1 + vsMonster.Defense / 100.0) +
                (item.MagicAttack + item.Intelligence * forHero.Intelligence) / (1 + vsMonster.MagicDefense / 100.0);

            this.Accuracy = (item.Accuracy + item.Dexterity * forHero.Dexterity) / 100.0;
            this.CriticalRate = item.CriticalRate / 100.0;
            this.Defense = item.Defense / 100.0;
            this.MagicDefense = item.MagicDefense / 100.0;
            this.Hp = item.HP;
        }
コード例 #3
0
        public Stats(Hero hero, int heroLevel, Monster vsMonster)
        {
            this.OriginalItem = null;
            heroLevel--; //Heros start at level 1 and gain per level stats afterwards

            this.Damage =
                (hero.StartAttack + hero.LevelAttack * heroLevel) / (1 + vsMonster.Defense / 100.0) +
                (hero.StartMagicAttack + hero.LevelMagicAttack * heroLevel) / (1 + vsMonster.MagicDefense / 100.0);

            this.Accuracy = (hero.StartAccuracy + hero.LevelAccuracy * heroLevel) / 100.0;
            this.CriticalRate = (hero.StartCriticalRate + hero.LevelCriticalRate * heroLevel) / 100.0;
            this.Defense = (hero.StartDefense + hero.LevelDefense * heroLevel) / 100.0;
            this.MagicDefense = (hero.StartMagicDefense + hero.LevelMagicDefense * heroLevel) / 100.0;
            this.Hp = hero.StartHP + hero.LevelHP * heroLevel;
        }
コード例 #4
0
 public Item ItemData(Hero hero, int slot, int index)
 {
     return AllItems[hero][slot][index].OriginalItem;
 }
コード例 #5
0
 public int ItemChoices(Hero hero, int slot)
 {
     return AllItems[hero][slot] == null ?
         0 :
         AllItems[hero][slot].Length;
 }
コード例 #6
0
 public static Dictionary<ItemSlot, Stats[]> RelevantFor(Hero hero, int maxItemLevel, Monster monster, StatsFilter statsMask)
 {
     return removeRedundantItems(
         MakeItems(maxItemLevel),
         hero, monster, statsMask);
 }