コード例 #1
0
        private void CheckFullArmorSets(
            List <SolverDataEquipmentModel> source,
            List <SolverDataEquipmentModel> heads,
            List <SolverDataEquipmentModel> chests,
            List <SolverDataEquipmentModel> gloves,
            List <SolverDataEquipmentModel> waists,
            List <SolverDataEquipmentModel> legs
            )
        {
            for (int i = 0; i < source.Count; i++)
            {
                IFullArmorSet fullArmorSet = ((IArmorPiece)source[i].Equipment).FullArmorSet;

                if (fullArmorSet == null)
                {
                    continue;
                }

                IArmorPiece[] setPieces = fullArmorSet.ArmorPieces;

                IArmorPiece head  = setPieces.First(x => x.Type == EquipmentType.Head);
                IArmorPiece chest = setPieces.First(x => x.Type == EquipmentType.Chest);
                IArmorPiece glove = setPieces.First(x => x.Type == EquipmentType.Gloves);
                IArmorPiece waist = setPieces.First(x => x.Type == EquipmentType.Waist);
                IArmorPiece leg   = setPieces.First(x => x.Type == EquipmentType.Legs);

                if (heads.Where(x => x.ToBeRemoved == false).Any(x => x.Equipment.Id == head.Id) == false ||
                    chests.Where(x => x.ToBeRemoved == false).Any(x => x.Equipment.Id == chest.Id) == false ||
                    gloves.Where(x => x.ToBeRemoved == false).Any(x => x.Equipment.Id == glove.Id) == false ||
                    waists.Where(x => x.ToBeRemoved == false).Any(x => x.Equipment.Id == waist.Id) == false ||
                    legs.Where(x => x.ToBeRemoved == false).Any(x => x.Equipment.Id == leg.Id) == false)
                {
                    // if one piece is marked as to be removed, remove them all

                    heads.Where(x => x.Equipment.Id == head.Id).MarkAsToBeRemoved();
                    chests.Where(x => x.Equipment.Id == chest.Id).MarkAsToBeRemoved();
                    gloves.Where(x => x.Equipment.Id == glove.Id).MarkAsToBeRemoved();
                    waists.Where(x => x.Equipment.Id == waist.Id).MarkAsToBeRemoved();
                    legs.Where(x => x.Equipment.Id == leg.Id).MarkAsToBeRemoved();
                }
                else
                {
                    // otherwise, ensure they are all selected and not marked as to be removed

                    heads.Where(x => x.Equipment.Id == head.Id).MarkAsSelected();
                    chests.Where(x => x.Equipment.Id == chest.Id).MarkAsSelected();
                    gloves.Where(x => x.Equipment.Id == glove.Id).MarkAsSelected();
                    waists.Where(x => x.Equipment.Id == waist.Id).MarkAsSelected();
                    legs.Where(x => x.Equipment.Id == leg.Id).MarkAsSelected();
                }
            }
        }
コード例 #2
0
        private bool IsGenderMatching(IArmorPiece armorPiece, Gender selectedGender)
        {
            // If UI says both, then all armor pieces are a match, no matter the gender of the armor piece.
            if (selectedGender == Gender.Both)
            {
                return(true);
            }

            // If amor piece gender is both, it is a match no matter the UI selection.
            if (armorPiece.Attributes.RequiredGender == Gender.Both)
            {
                return(true);
            }

            // Returns only armor piece with gender matching UI selected gender.
            return(armorPiece.Attributes.RequiredGender == selectedGender);
        }
コード例 #3
0
 private ArmorPiecePrimitive ConvertArmorPiece(IArmorPiece armorPiece)
 {
     return(new ArmorPiecePrimitive
     {
         Abilities = armorPiece.Abilities.Select(ConvertArmorAbility).ToList(),
         Assets = null,
         Attributes = new ArmorPieceAttributesPrimitive
         {
             RequiredGender = DataStructures.ArmorPieceAttributes.GenderToString(armorPiece.Attributes.RequiredGender)
         },
         Defense = ConvertDefense(armorPiece.Defense),
         Id = armorPiece.Id,
         Name = armorPiece.Name,
         Rarity = armorPiece.Rarity,
         Resistances = ConvertResistances(armorPiece.Resistances),
         Slots = ConvertSlots(armorPiece.Slots),
         Type = armorPiece.Type
     });
 }
コード例 #4
0
ファイル: DataUtility.cs プロジェクト: patriciomg/MHArmory
        public static bool IsLessPoweredEquivalentArmorPiece(IArmorPiece baseArmorPiece, IArmorPiece checkedArmorPiece)
        {
            if (IsLessPoweredEquivalentEquipment(baseArmorPiece, checkedArmorPiece) == false)
            {
                return(false);
            }

            IAbility[] checkedAbilities = checkedArmorPiece.Abilities;
            IAbility[] baseAbilities    = baseArmorPiece.Abilities;

            // From here, checkedAbilities has less or equal amount of abilities compared to baseAbilities.

            if (checkedAbilities.Length == baseAbilities.Length)
            {
                // When there is an equal amount of abilities, they match their skills.

                for (int i = 0; i < checkedAbilities.Length; i++)
                {
                    for (int j = 0; j < baseAbilities.Length; j++)
                    {
                        if (checkedAbilities[i].Skill.Id == baseAbilities[j].Skill.Id)
                        {
                            // The double loop with skill equality check is to avoid ordering issues.
                            // Ability checkedAbilities[i] is not necessarily the same as baseAbilities[i].

                            if (checkedAbilities[i].Level < baseAbilities[j].Level)
                            {
                                return(true);
                            }
                        }
                    }
                }

                // Here all skills have equal level of ability, let's consider as less powered
                // if the checkedArmorPiece has less augmented defense.

                return(checkedArmorPiece.Defense.Augmented <= baseArmorPiece.Defense.Augmented);
            }

            return(true);
        }
コード例 #5
0
 private bool ArmorPieceMatchInParameters(IArmorPiece armorPiece)
 {
     return(EquipmentMatchInParameters(armorPiece) && IsGenderMatching(armorPiece, InParameters.Gender));
 }
コード例 #6
0
 public ArmorPieceViewModel(RootViewModel rootViewModel, IArmorPiece armorPiece)
     : base(rootViewModel, armorPiece)
 {
 }
コード例 #7
0
        private static bool Equals(IArmorPiece x, IArmorPiece y)
        {
            /*
             *  int Id { get; }
             *  EquipmentType Type { get; }
             *  string Name { get; }
             *  int Rarity { get; }
             *  int[] Slots { get; }
             *  IEvent Event { get; }
             *  IAbility[] Abilities { get; }
             *  IArmorPieceDefense Defense { get; }
             *  IArmorPieceResistances Resistances { get; }
             *  IArmorPieceAttributes Attributes { get; }
             *  IArmorPieceAssets Assets { get; }
             *  IArmorSetSkill[] ArmorSetSkills { get; }
             *  IFullArmorSet FullArmorSet { get; }
             */

            if (x.Id != y.Id)
            {
                return(false);
            }

            if (x.Type != y.Type)
            {
                return(false);
            }

            if (x.Name != y.Name)
            {
                return(false);
            }

            if (x.Rarity != y.Rarity)
            {
                return(false);
            }

            if (SlotsEquals(x.Slots, y.Slots) == false)
            {
                return(false);
            }

            if (x.Abilities != null && y.Abilities != null)
            {
                if (x.Abilities.Length != y.Abilities.Length)
                {
                    return(false);
                }

                for (int i = 0; i < x.Abilities.Length; i++)
                {
                    if (Equals(x.Abilities[i], y.Abilities[i]) == false)
                    {
                        return(false);
                    }
                }
            }
            else if (x.Abilities == null ^ y.Abilities == null)
            {
                return(false);
            }

            if (Equals(x.Defense, y.Defense) == false)
            {
                return(false);
            }

            if (Equals(x.Resistances, y.Resistances) == false)
            {
                return(false);
            }

            if (Equals(x.Attributes, y.Attributes) == false)
            {
                return(false);
            }

            if (x.ArmorSetSkills != null && y.ArmorSetSkills != null)
            {
                if (x.ArmorSetSkills.Length != y.ArmorSetSkills.Length)
                {
                    return(false);
                }

                for (int i = 0; i < x.ArmorSetSkills.Length; i++)
                {
                    if (Equals(x.ArmorSetSkills[i], y.ArmorSetSkills[i]) == false)
                    {
                        return(false);
                    }
                }
            }
            else if (x.ArmorSetSkills == null ^ y.ArmorSetSkills == null)
            {
                return(false);
            }

            if (x.FullArmorSet != null && y.FullArmorSet != null)
            {
                if (Equals(x.FullArmorSet, y.FullArmorSet) == false)
                {
                    return(false);
                }
            }
            else if (x.FullArmorSet == null ^ y.FullArmorSet == null)
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
ファイル: SupersetMaker.cs プロジェクト: TanukiSharp/MHArmory
        public SupersetInfo CreateSupersetModel(IList <IEquipment> equipments, IAbility[] desiredAbilities)
        {
            EquipmentType type            = equipments.FirstOrDefault()?.Type ?? EquipmentType.Charm; // No equipment probably means charm
            var           desiredSkillIDs = new HashSet <int>(desiredAbilities.Select(x => x.Skill.Id));

            int[] slots     = new int[CutoffSearchConstants.Slots];
            int   maxSkills = 0;

            foreach (IEquipment eq in equipments)
            {
                for (int i = 0; i < eq.Slots.Length; i++)
                {
                    if (slots[i] < eq.Slots[i])
                    {
                        slots[i] = eq.Slots[i];
                    }
                }

                int skillCount = 0;
                foreach (IAbility ability in eq.Abilities)
                {
                    if (!desiredSkillIDs.Contains(ability.Skill.Id))
                    {
                        continue;
                    }
                    skillCount += ability.Level;
                }
                if (skillCount > maxSkills)
                {
                    maxSkills = skillCount;
                }
            }

            IAbility[] abilities = equipments
                                   .SelectMany(x => x.Abilities)
                                   .GroupBy(x => x.Skill.Id)
                                   .Select(x => x.OrderByDescending(y => y.Level).First())
                                   .ToArray();

            string name     = $"{type} superset";
            var    nameDict = new Dictionary <string, string>()
            {
                { "EN", name }
            };
            var        craftMaterials = new CraftMaterial[0];
            IEvent     ev             = null;
            IEquipment equipment;

            if (type == EquipmentType.Charm)
            {
                equipment = new CharmLevel(-1, 0, nameDict, 0, slots, abilities, ev, craftMaterials);
            }
            else
            {
                var armorPieces            = equipments.Cast <IArmorPiece>().ToList();
                IArmorSetSkill[] setSkills = armorPieces
                                             .Where(x => x.ArmorSetSkills != null)
                                             .SelectMany(x => x.ArmorSetSkills)
                                             .Distinct()
                                             .ToArray();
                IArmorPiece firstArmor = armorPieces.First();
                equipment = new ArmorPiece(-1, nameDict, firstArmor.Type, 0, slots, abilities, setSkills, firstArmor.Defense, firstArmor.Resistances, firstArmor.Attributes, firstArmor.Assets, firstArmor.FullArmorSet, ev, craftMaterials);
            }
            var info = new SupersetInfo(equipment, maxSkills);

            return(info);
        }
コード例 #9
0
        private async Task LoadArmorsData(ILogger logger)
        {
            Task <IList <ArmorPiecePrimitive> > armorTask = LoadBase <ArmorPiecePrimitive>("armor", logger);
            Task <IList <ArmorSetPrimitive> >   setsTask  = LoadBase <ArmorSetPrimitive>("armor/sets", logger);

            await Task.WhenAll(armorTask, setsTask);

            IList <ArmorPiecePrimitive> armorResult = armorTask.Result;
            IList <ArmorSetPrimitive>   setsResult  = setsTask.Result;

            if (armorResult == null || setsResult == null)
            {
                return;
            }

            var allArmors = new IArmorPiece[armorResult.Count];

            for (int i = 0; i < allArmors.Length; i++)
            {
                var localAbilities = new IAbility[armorResult[i].Abilities.Count];

                for (int j = 0; j < localAbilities.Length; j++)
                {
                    int skillId      = armorResult[i].Abilities[j].SkillId;
                    int abilityLevel = armorResult[i].Abilities[j].Level;

                    ISkill   skill   = skills.FirstOrDefault(s => s.Id == skillId);
                    IAbility ability = abilities.FirstOrDefault(a => a.Skill.Id == skillId && a.Level == abilityLevel);

                    localAbilities[j] = new Ability(skill, abilityLevel, ability.Description);
                }

                allArmors[i] = new DataStructures.ArmorPiece(armorResult[i], localAbilities);
            }

            foreach (ArmorSetPrimitive armorSetPrimitive in setsResult)
            {
                var setArmorPieces = new IArmorPiece[armorSetPrimitive.ArmorPieces.Length];
                for (int i = 0; i < armorSetPrimitive.ArmorPieces.Length; i++)
                {
                    setArmorPieces[i] = allArmors.FirstOrDefault(x => x.Id == armorSetPrimitive.ArmorPieces[i].ArmorPieceId);
                }

                List <IArmorSetSkill> armorSetSkills = null;

                if (armorSetPrimitive.Bonus != null)
                {
                    armorSetSkills = new List <IArmorSetSkill>();
                    foreach (ArmorSetBonusRankPrimitive bonusRank in armorSetPrimitive.Bonus.Ranks)
                    {
                        IAbility[] setAbilities = abilities.Where(a => a.Skill.Id == bonusRank.Skill.SkillId && a.Level == bonusRank.Skill.Level).ToArray();
                        armorSetSkills.Add(new ArmorSetSkill(bonusRank.PieceCount, setAbilities));
                    }
                }

                var armorSet = new ArmorSet(armorSetPrimitive.Id, false, setArmorPieces, armorSetSkills?.ToArray());

                foreach (DataStructures.ArmorPiece armorPiece in setArmorPieces)
                {
                    armorPiece.UpdateArmorSet(armorSet);
                }
            }

            armors = allArmors;
        }