Example #1
0
        public core.ArmorSeries[] Build()
        {
            var result = new List <core.ArmorSeries>();

            foreach (KeyValuePair <uint, LanguageItem> x in armorSeriesLanguages.Table[LanguageIdPrimitive.English])
            {
                LanguageItem item = x.Value;

                if (LanguageUtils.IsValidText(armorSeriesLanguages.Table, x.Key) == false)
                {
                    continue;
                }

                result.Add(new core.ArmorSeries
                {
                    Id   = (int)x.Key,
                    Name = LanguageUtils.CreateLocalizations(armorSeriesLanguages.Table, x.Key, translationValueProcessors)
                });
            }

            return(result.ToArray());
        }
        protected virtual bool IsValidEquipment(EquipmentPrimitive equipment)
        {
            if (equipment.Gender == core.Gender.None)
            {
                return(false);
            }

            string englishWeaponName = equipmentLanguages.Table[LanguageIdPrimitive.English][equipment.GmdNameIndex].Value;

            if (LanguageUtils.IsValidText(englishWeaponName) == false)
            {
                return(false);
            }

            string japaneseWeaponName = equipmentLanguages.Table[LanguageIdPrimitive.Japanese][equipment.GmdNameIndex].Value;

            if (LanguageUtils.IsValidText(japaneseWeaponName) == false)
            {
                return(false);
            }

            string englishWeaponDescription = equipmentLanguages.Table[LanguageIdPrimitive.English][equipment.GmdDescriptionIndex].Value;

            if (LanguageUtils.IsValidText(englishWeaponDescription) == false)
            {
                return(false);
            }

            string japaneseWeaponDescription = equipmentLanguages.Table[LanguageIdPrimitive.Japanese][equipment.GmdDescriptionIndex].Value;

            if (LanguageUtils.IsValidText(japaneseWeaponDescription) == false)
            {
                return(false);
            }

            return(true);
        }
        public core.Skill[] Build()
        {
            var result = new List <core.Skill>();

            foreach (KeyValuePair <ushort, Dictionary <byte, SkillAbilityPrimitive> > skillGroup in skillAbilities.Table)
            {
                if (skillGroup.Key == 0)
                {
                    continue;
                }

                SkillPrimitive skill = skills.List[skillGroup.Key];

                uint skillNameIndex        = (uint)(skillGroup.Key * 3);
                uint skillReadingIndex     = skillNameIndex + 1;
                uint skillDescriptionIndex = skillNameIndex + 2;

                if (LanguageUtils.IsValidText(skillsLanguages.Table, skillNameIndex) == false)
                {
                    continue;
                }

                bool isSetBonus = skill.IsSetBonus != 0;

                Dictionary <string, string> skillName        = LanguageUtils.CreateLocalizations(skillsLanguages.Table, skillNameIndex);
                Dictionary <string, string> skillReading     = LanguageUtils.CreateLocalizations(skillsLanguages.Table, skillReadingIndex);
                Dictionary <string, string> skillDescription = LanguageUtils.CreateLocalizations(skillsLanguages.Table, skillDescriptionIndex, languageValueProcessors);

                var abilities = new List <core.Ability>();

                foreach (SkillAbilityPrimitive skillAbility in skillGroup.Value.Values)
                {
                    if (skillAbility.SkillId == 0)
                    {
                        continue;
                    }

                    uint skillAbilityNameIndex        = skillAbility.Index * 2;
                    uint skillAbilityDescriptionIndex = skillAbilityNameIndex + 1;

                    Dictionary <string, string> skillAbilityName        = LanguageUtils.CreateLocalizations(skillAttributesLanguages.Table, skillAbilityNameIndex);
                    Dictionary <string, string> skillAbilityDescription = LanguageUtils.CreateLocalizations(skillAttributesLanguages.Table, skillAbilityDescriptionIndex, languageValueProcessors);

                    if (isSetBonus)
                    {
                        abilities.Add(core.Ability.CreateSetSkill(
                                          skillAbility.Index,
                                          skillAbility.Level,
                                          skillAbilityName,
                                          skillAbilityDescription,
                                          skillAbility.Params
                                          ));
                    }
                    else
                    {
                        abilities.Add(core.Ability.CreateRegularSkill(
                                          skillAbility.Index,
                                          skillAbility.Level,
                                          skillAbilityDescription,
                                          skillAbility.Params
                                          ));
                    }
                }

                result.Add(new core.Skill
                {
                    Id          = skillGroup.Key,
                    Category    = skill.Unknown,
                    IsSetBonus  = isSetBonus,
                    Name        = skillName,
                    Reading     = LanguageUtils.IsValidText(skillReading) ? skillReading : null,
                    Description = isSetBonus ? null : skillDescription,
                    Abilities   = abilities.ToArray()
                });
            }

            foreach (core.Skill skill in result)
            {
                if (skill.IsSetBonus)
                {
                    foreach (core.Ability ability in skill.Abilities)
                    {
                        ability.SkillId = FindSkillIdByName(ability.Name, result);
                    }
                }
            }

            return(result.OrderBy(x => x.Id).ToArray());
        }
        public core.WeaponTreeName[] Build()
        {
            var treeNames = new Dictionary <byte, core.WeaponTreeName>();

            foreach (core.WeaponType weaponClass in Enum.GetValues(typeof(core.WeaponType)))
            {
                if (weaponClass == core.WeaponType.None)
                {
                    continue;
                }

                foreach (KeyValuePair <uint, WeaponPrimitiveBase> weapon in weapons.Table[weaponClass])
                {
                    byte treeId         = weapon.Value.TreeId;
                    bool isDisabledTree = false;
                    var  name           = new Dictionary <string, string>();

                    if (treeNames.ContainsKey(treeId))
                    {
                        continue;
                    }

                    foreach (LanguageIdPrimitive language in LanguageUtils.Languages)
                    {
                        Dictionary <uint, LanguageItem> languageEntries;
#if DEBUG
                        // Allow to work with degraded data in debug mode.
                        if (weaponSeriesLanguages.Table.TryGetValue(language, out languageEntries) == false)
                        {
                            continue;
                        }
#else
                        languageEntries = weaponSeriesLanguages.Table[language];
#endif
                        if (languageEntries.TryGetValue(treeId, out LanguageItem treeSeriesLanguageItem) == false)
                        {
                            continue;
                        }

                        string treeName = treeSeriesLanguageItem.Value;

                        if (LanguageUtils.IsValidText(treeName) == false)
                        {
                            isDisabledTree = true;
                            break;
                        }

                        if (treeName == "無効" || treeName.Length == 0)
                        {
                            isDisabledTree = true;
                            break;
                        }

                        name.Add(LanguageUtils.LanguageIdToLanguageCode(language), treeName);
                    }

                    if (isDisabledTree)
                    {
                        continue;
                    }

                    treeNames.Add(treeId, new core.WeaponTreeName {
                        TreeId = treeId, Name = name
                    });
                }
            }

            return(treeNames.Values.OrderBy(x => x.TreeId).ToArray());
        }