コード例 #1
0
        public async Task InsertSkillsAsync(string folder)
        {
            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(SkillDto.SkillVNum), chunk => Convert.ToInt16(chunk["VNUM"][0][2]) },
                { nameof(SkillDto.NameI18NKey), chunk => chunk["NAME"][0][2] },
                { nameof(SkillDto.SkillType), chunk => Convert.ToByte(chunk["TYPE"][0][2]) },
                { nameof(SkillDto.CastId), chunk => Convert.ToInt16(chunk["TYPE"][0][3]) },
                { nameof(SkillDto.Class), chunk => Convert.ToByte(chunk["TYPE"][0][4]) },
                { nameof(SkillDto.Type), chunk => Convert.ToByte(chunk["TYPE"][0][5]) },
                { nameof(SkillDto.Element), chunk => Convert.ToByte(chunk["TYPE"][0][7]) },
                { nameof(SkillDto.Combo), AddCombos },
                { nameof(SkillDto.CpCost), chunk => chunk["COST"][0][2] == "-1" ? (byte)0 : byte.Parse(chunk["COST"][0][2]) },
                { nameof(SkillDto.Price), chunk => Convert.ToInt32(chunk["COST"][0][3]) },
                { nameof(SkillDto.CastEffect), chunk => Convert.ToInt16(chunk["EFFECT"][0][3]) },
                { nameof(SkillDto.CastAnimation), chunk => Convert.ToInt16(chunk["EFFECT"][0][4]) },
                { nameof(SkillDto.Effect), chunk => Convert.ToInt16(chunk["EFFECT"][0][5]) },
                { nameof(SkillDto.AttackAnimation), chunk => Convert.ToInt16(chunk["EFFECT"][0][6]) },
                { nameof(SkillDto.TargetType), chunk => Convert.ToByte(chunk["TARGET"][0][2]) },
                { nameof(SkillDto.HitType), chunk => Convert.ToByte(chunk["TARGET"][0][3]) },
                { nameof(SkillDto.Range), chunk => Convert.ToByte(chunk["TARGET"][0][4]) },
                { nameof(SkillDto.TargetRange), chunk => Convert.ToByte(chunk["TARGET"][0][5]) },
                { nameof(SkillDto.UpgradeSkill), chunk => Convert.ToInt16(chunk["DATA"][0][2]) },
                { nameof(SkillDto.UpgradeType), chunk => Convert.ToInt16(chunk["DATA"][0][3]) },
                { nameof(SkillDto.CastTime), chunk => Convert.ToInt16(chunk["DATA"][0][6]) },
                { nameof(SkillDto.Cooldown), chunk => Convert.ToInt16(chunk["DATA"][0][7]) },
                { nameof(SkillDto.MpCost), chunk => Convert.ToInt16(chunk["DATA"][0][10]) },
                { nameof(SkillDto.ItemVNum), chunk => Convert.ToInt16(chunk["DATA"][0][12]) },
                { nameof(SkillDto.BCards), AddBCards },
                { nameof(SkillDto.MinimumAdventurerLevel), chunk => chunk["LEVEL"][0][3] != "-1" ? byte.Parse(chunk["LEVEL"][0][3]) : (byte)0 },
                { nameof(SkillDto.MinimumSwordmanLevel), chunk => chunk["LEVEL"][0][4] != "-1" ? byte.Parse(chunk["LEVEL"][0][4]) : (byte)0 },
                { nameof(SkillDto.MinimumArcherLevel), chunk => chunk["LEVEL"][0][5] != "-1" ? byte.Parse(chunk["LEVEL"][0][5]) : (byte)0 },
                { nameof(SkillDto.MinimumMagicianLevel), chunk => chunk["LEVEL"][0][6] != "-1" ? byte.Parse(chunk["LEVEL"][0][6]) : (byte)0 },
                { nameof(SkillDto.LevelMinimum), chunk => chunk["LEVEL"][0][2] != "-1" ? byte.Parse(chunk["LEVEL"][0][2]) : (byte)0 },
            };
            var genericParser = new GenericParser <SkillDto>(folder + _fileCardDat,
                                                             "#=========================================================", 1, actionList, _logger);
            var skills = await genericParser.GetDtosAsync().ConfigureAwait(false);

            foreach (var skill in skills.Where(s => s.Class > 31))
            {
                var firstskill  = skills.Find(s => s.Class == skill.Class);
                var skillscount = skills.Count(s => s.Class == skill.Class);
                if ((firstskill == null) || (skill.SkillVNum <= firstskill.SkillVNum + 10))
                {
                    skill.LevelMinimum = skill.Class switch
                    {
                        8 => (byte)(skillscount - 1 * 10),
                        9 => (byte)(skillscount - 4 * 4),
                        16 => (byte)skillscount switch
                        {
                            6 => 20,
                            5 => 15,
                            4 => 10,
                            3 => 5,
                            2 => 3,
                            _ => 0
                        },
コード例 #2
0
ファイル: MapParser.cs プロジェクト: serodyx/NosCore
        public Task <List <MapDto> > ParseDatAsync(string folder)
        {
            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(MapDto.MapId), chunk => Convert.ToInt16(chunk.First(s => char.IsDigit(s.Key.FirstOrDefault())).Value[0][0]) },
                { nameof(MapDto.NameI18NKey), chunk => chunk.First(s => char.IsDigit(s.Key.FirstOrDefault())).Value[0][4] }
            };
            var genericParser = new GenericParser <MapDto>(folder + _fileMapIdDat, "DATA 0", 0, actionList, _logger);

            return(genericParser.GetDtosAsync(" "));
        }
コード例 #3
0
        public async Task ImportQuestPrizesAsync(string folder)
        {
            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(QuestRewardDto.QuestRewardId), chunk => Convert.ToInt16(chunk["VNUM"][0][1]) },
                { nameof(QuestRewardDto.RewardType), chunk => Convert.ToByte(chunk["VNUM"][0][2]) },
                { nameof(QuestRewardDto.Data), chunk => ImportData(chunk) },
                { nameof(QuestRewardDto.Amount), chunk => ImportAmount(chunk) },
            };
            var genericParser   = new GenericParser <QuestRewardDto>(folder + _fileQuestPrizeDat, "END", 0, actionList, _logger);
            var questRewardDtos = await genericParser.GetDtosAsync().ConfigureAwait(false);

            await _questRewardDtoDao.TryInsertOrUpdateAsync(questRewardDtos).ConfigureAwait(false);

            _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.QUEST_PRIZES_PARSED), questRewardDtos.Count);
        }
コード例 #4
0
        public async Task ParseAsync(string folder)
        {
            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(NpcTalkDto.DialogId), chunk => Convert.ToInt16(chunk["%"][0][1]) },
                { nameof(NpcTalkDto.NameI18NKey), chunk => chunk["t"][0][1] },
            };

            var genericParser = new GenericParser <NpcTalkDto>(folder + _fileNpcTalkDat,
                                                               "%", 0, actionList, _logger);
            var npcTalks = (await genericParser.GetDtosAsync(" ").ConfigureAwait(false)).ToList();

            npcTalks.Add(new NpcTalkDto {
                DialogId = 99, NameI18NKey = ""
            });
            await _npcTalkDao.TryInsertOrUpdateAsync(npcTalks).ConfigureAwait(false);

            _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.NPCTALKS_PARSED), npcTalks.Count);
        }
コード例 #5
0
        public async Task ImportQuestsAsync(string folder)
        {
            _questRewards = _questRewardDao.LoadAll().ToDictionary(x => x.QuestRewardId, x => x);

            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(QuestDto.QuestId), chunk => Convert.ToInt16(chunk["VNUM"][0][1]) },
                { nameof(QuestDto.QuestType), chunk => (QuestType)Enum.Parse(typeof(QuestType), chunk["VNUM"][0][2]) },
                { nameof(QuestDto.AutoFinish), chunk => chunk["VNUM"][0][3] == "1" },
                { nameof(QuestDto.IsDaily), chunk => chunk["VNUM"][0][4] == "-1" },
                { nameof(QuestDto.RequiredQuestId), chunk => chunk["VNUM"][0][5] != "-1" ? short.Parse(chunk["VNUM"][0][5]) : (short?)null },
                { nameof(QuestDto.IsSecondary), chunk => chunk["VNUM"][0][6] != "-1" },
                { nameof(QuestDto.LevelMin), chunk => Convert.ToByte(chunk["LEVEL"][0][1]) },
                { nameof(QuestDto.LevelMax), chunk => Convert.ToByte(chunk["LEVEL"][0][2]) },
                { nameof(QuestDto.TitleI18NKey), chunk => chunk["TITLE"][0][1] },
                { nameof(QuestDto.DescI18NKey), chunk => chunk["DESC"][0][1] },
                { nameof(QuestDto.TargetX), chunk => chunk["TARGET"][0][1] == "-1" ? (short?)null : Convert.ToInt16(chunk["TARGET"][0][1]) },
                { nameof(QuestDto.TargetY), chunk => chunk["TARGET"][0][2] == "-1"  ? (short?)null : Convert.ToInt16(chunk["TARGET"][0][2]) },
                { nameof(QuestDto.TargetMap), chunk => chunk["TARGET"][0][3] == "-1"  ? (short?)null : Convert.ToInt16(chunk["TARGET"][0][3]) },
                { nameof(QuestDto.StartDialogId), chunk => chunk["TARGET"][0][1] == "-1" ? (int?)null :  Convert.ToInt32(chunk["TALK"][0][1]) },
                { nameof(QuestDto.EndDialogId), chunk => chunk["TARGET"][0][2] == "-1" ? (int?)null :  Convert.ToInt32(chunk["TALK"][0][2]) },
                { nameof(QuestDto.NextQuestId), chunk => chunk["LINK"][0][1] == "-1" ? (short?)null :  Convert.ToInt16(chunk["LINK"][0][1]) },
                { nameof(QuestDto.QuestQuestReward), ImportQuestQuestRewards },
                { nameof(QuestDto.QuestObjective), ImportQuestObjectives },
            };
            var genericParser = new GenericParser <QuestDto>(folder + _fileQuestDat, "END", 0, actionList, _logger);
            var quests        = await genericParser.GetDtosAsync().ConfigureAwait(false);

            await _questDao.TryInsertOrUpdateAsync(quests).ConfigureAwait(false);

            await _questQuestRewardDao.TryInsertOrUpdateAsync(quests.Where(s => s.QuestQuestReward != null).SelectMany(s => s.QuestQuestReward)).ConfigureAwait(false);

            await _questObjectiveDao.TryInsertOrUpdateAsync(quests.Where(s => s.QuestObjective != null).SelectMany(s => s.QuestObjective)).ConfigureAwait(false);

            _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.QUESTS_PARSED), quests.Count);
        }
コード例 #6
0
ファイル: CardParser.cs プロジェクト: erencino55/NosCore
        public async Task InsertCardsAsync(string folder)
        {
            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(CardDto.CardId), chunk => Convert.ToInt16(chunk["VNUM"][0][2]) },
                { nameof(CardDto.NameI18NKey), chunk => chunk["NAME"][0][2] },
                { nameof(CardDto.Level), chunk => Convert.ToByte(chunk["GROUP"][0][3]) },
                { nameof(CardDto.EffectId), chunk => Convert.ToInt32(chunk["EFFECT"][0][2]) },
                { nameof(CardDto.BuffType), chunk => (BCardType.CardType)Convert.ToByte(chunk["STYLE"][0][3]) },
                { nameof(CardDto.Duration), chunk => Convert.ToInt32(chunk["TIME"][0][2]) },
                { nameof(CardDto.Delay), chunk => Convert.ToInt32(chunk["TIME"][0][3]) },
                { nameof(CardDto.BCards), AddBCards },
                { nameof(CardDto.TimeoutBuff), chunk => Convert.ToInt16(chunk["LAST"][0][2]) },
                { nameof(CardDto.TimeoutBuffChance), chunk => Convert.ToByte(chunk["LAST"][0][3]) }
            };
            var genericParser = new GenericParser <CardDto>(folder + _fileCardDat,
                                                            "END", 1, actionList, _logger);
            var cards = (await genericParser.GetDtosAsync().ConfigureAwait(false)).GroupBy(p => p.CardId).Select(g => g.First()).ToList();
            await _cardDao.TryInsertOrUpdateAsync(cards).ConfigureAwait(false);

            await _bcardDao.TryInsertOrUpdateAsync(cards.Where(s => s.BCards != null).SelectMany(s => s.BCards)).ConfigureAwait(false);

            _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.CARDS_PARSED), cards.Count);
        }
コード例 #7
0
        public async Task InsertNpcMonstersAsync(string folder)
        {
            _skilldb = _skillDao.LoadAll().ToDictionary(x => x.SkillVNum, x => x);
            _dropdb  = _dropDao.LoadAll().Where(x => x.MonsterVNum != null).GroupBy(x => x.MonsterVNum).ToDictionary(x => x.Key ?? 0, x => x.ToList());
            var actionList = new Dictionary <string, Func <Dictionary <string, string[][]>, object?> >
            {
                { nameof(NpcMonsterDto.NpcMonsterVNum), chunk => Convert.ToInt16(chunk["VNUM"][0][2]) },
                { nameof(NpcMonsterDto.NameI18NKey), chunk => chunk["NAME"][0][2] },
                { nameof(NpcMonsterDto.Level), chunk => Level(chunk) },
                { nameof(NpcMonsterDto.HeroXp), chunk => ImportHeroXp(chunk) },
                { nameof(NpcMonsterDto.Race), chunk => Convert.ToByte(chunk["RACE"][0][2]) },
                { nameof(NpcMonsterDto.RaceType), chunk => Convert.ToByte(chunk["RACE"][0][3]) },
                { nameof(NpcMonsterDto.Element), chunk => Convert.ToByte(chunk["ATTRIB"][0][2]) },
                { nameof(NpcMonsterDto.ElementRate), chunk => Convert.ToInt16(chunk["ATTRIB"][0][3]) },
                { nameof(NpcMonsterDto.FireResistance), chunk => Convert.ToInt16(chunk["ATTRIB"][0][4]) },
                { nameof(NpcMonsterDto.WaterResistance), chunk => Convert.ToInt16(chunk["ATTRIB"][0][5]) },
                { nameof(NpcMonsterDto.LightResistance), chunk => Convert.ToInt16(chunk["ATTRIB"][0][6]) },
                { nameof(NpcMonsterDto.DarkResistance), chunk => Convert.ToInt16(chunk["ATTRIB"][0][7]) },
                { nameof(NpcMonsterDto.MaxHp), chunk => Convert.ToInt32(chunk["HP/MP"][0][2]) + _basicHp[Level(chunk)] },
                { nameof(NpcMonsterDto.MaxMp), chunk => Convert.ToInt32(chunk["HP/MP"][0][3]) + Convert.ToByte(chunk["RACE"][0][2]) == 0 ? _basicPrimaryMp[Level(chunk)] : _basicSecondaryMp[Level(chunk)] },
                { nameof(NpcMonsterDto.Xp), chunk => Math.Abs(Convert.ToInt32(chunk["EXP"][0][2]) + _basicXp[Level(chunk)]) },
                { nameof(NpcMonsterDto.JobXp), chunk => Convert.ToInt32(chunk["EXP"][0][3]) + _basicJXp[Level(chunk)] },
                { nameof(NpcMonsterDto.IsHostile), chunk => chunk["PREATT"][0][2] != "0" },
                { nameof(NpcMonsterDto.NoticeRange), chunk => Convert.ToByte(chunk["PREATT"][0][4]) },
                { nameof(NpcMonsterDto.Speed), chunk => Convert.ToByte(chunk["PREATT"][0][5]) },
                { nameof(NpcMonsterDto.RespawnTime), chunk => Convert.ToInt32(chunk["PREATT"][0][6]) },
                { nameof(NpcMonsterDto.CloseDefence), chunk => Convert.ToInt16((Convert.ToInt16(chunk["ARMOR"][0][2]) - 1) * 2 + 18) },
                { nameof(NpcMonsterDto.DistanceDefence), chunk => Convert.ToInt16((Convert.ToInt16(chunk["ARMOR"][0][2]) - 1) * 3 + 17) },
                { nameof(NpcMonsterDto.MagicDefence), chunk => Convert.ToInt16((Convert.ToInt16(chunk["ARMOR"][0][2]) - 1) * 2 + 13) },
                { nameof(NpcMonsterDto.DefenceDodge), chunk => Convert.ToInt16((Convert.ToInt16(chunk["ARMOR"][0][2]) - 1) * 5 + 31) },
                { nameof(NpcMonsterDto.DistanceDefenceDodge), chunk => Convert.ToInt16((Convert.ToInt16(chunk["ARMOR"][0][2]) - 1) * 5 + 31) },
                { nameof(NpcMonsterDto.AttackClass), chunk => Convert.ToByte(chunk["ZSKILL"][0][2]) },
                { nameof(NpcMonsterDto.BasicRange), chunk => Convert.ToByte(chunk["ZSKILL"][0][3]) },
                { nameof(NpcMonsterDto.BasicArea), chunk => Convert.ToByte(chunk["ZSKILL"][0][5]) },
                { nameof(NpcMonsterDto.BasicCooldown), chunk => Convert.ToInt16(chunk["ZSKILL"][0][6]) },
                { nameof(NpcMonsterDto.AttackUpgrade), chunk => Convert.ToByte(LoadUnknownData(chunk) == 1?chunk["WINFO"][0][2]:chunk["WINFO"][0][4]) },
                { nameof(NpcMonsterDto.DefenceUpgrade), chunk => Convert.ToByte(LoadUnknownData(chunk) == 1? chunk["WINFO"][0][2]:chunk["AINFO"][0][3]) },
                { nameof(NpcMonsterDto.BasicSkill), chunk => Convert.ToInt16(chunk["EFF"][0][2]) },
                { nameof(NpcMonsterDto.VNumRequired), chunk => Convert.ToInt16(chunk["SETTING"][0][4] != "0" && ShouldLoadPetinfo(chunk) ? chunk["PETINFO"][0][2] : chunk["SETTING"][0][4]) },
                { nameof(NpcMonsterDto.AmountRequired), chunk => Convert.ToByte(chunk["SETTING"][0][4] == "0" ? "1" : ShouldLoadPetinfo(chunk) ? chunk["PETINFO"][0][3] : "0") },
                { nameof(NpcMonsterDto.DamageMinimum), chunk => ImportDamageMinimum(chunk) },
                { nameof(NpcMonsterDto.DamageMaximum), chunk => ImportDamageMaximum(chunk) },
                { nameof(NpcMonsterDto.Concentrate), chunk => ImportConcentrate(chunk) },
                { nameof(NpcMonsterDto.CriticalChance), chunk => ImportCriticalChance(chunk) },
                { nameof(NpcMonsterDto.CriticalRate), chunk => ImportCriticalRate(chunk) },
                { nameof(NpcMonsterDto.NpcMonsterSkill), ImportNpcMonsterSkill },
                { nameof(NpcMonsterDto.BCards), ImportBCards },
                { nameof(NpcMonsterDto.Drop), ImportDrops },
                { nameof(NpcMonsterDto.MonsterType), chunk => ImportMonsterType(chunk) },
                { nameof(NpcMonsterDto.NoAggresiveIcon), chunk => {
                      var unknowndata = LoadUnknownData(chunk);
                      return((unknowndata == -2147483616 ||
                              unknowndata == -2147483647 ||
                              unknowndata == -2147483646) && ((Convert.ToByte(chunk["RACE"][0][2]) == 8) && (Convert.ToByte(chunk["RACE"][0][3]) == 0)));
                  } }
            };

            var genericParser = new GenericParser <NpcMonsterDto>(folder + _fileNpcId,
                                                                  "#========================================================", 1, actionList, _logger);
            var monsters = (await genericParser.GetDtosAsync().ConfigureAwait(false)).GroupBy(p => p.NpcMonsterVNum).Select(g => g.First()).ToList();
            await _npcMonsterDao.TryInsertOrUpdateAsync(monsters).ConfigureAwait(false);

            await _bCardDao.TryInsertOrUpdateAsync(monsters.Where(s => s.BCards != null).SelectMany(s => s.BCards)).ConfigureAwait(false);

            await _dropDao.TryInsertOrUpdateAsync(monsters.Where(s => s.Drop != null).SelectMany(s => s.Drop)).ConfigureAwait(false);

            await _npcMonsterSkillDao.TryInsertOrUpdateAsync(monsters.Where(s => s.NpcMonsterSkill != null).SelectMany(s => s.NpcMonsterSkill)).ConfigureAwait(false);

            _logger.Information(LogLanguage.Instance.GetMessageFromKey(LogLanguageKey.NPCMONSTERS_PARSED), monsters.Count);
        }