// // SkillParser.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using NosSmooth.Data.Abstractions.Enums; using NosSmooth.Data.Abstractions.Infos; using NosSmooth.Data.Abstractions.Language; using NosSmooth.Data.NOSFiles.Parsers.Dat; using Remora.Results; namespace NosSmooth.Data.NOSFiles.Parsers; /// /// Parses Skill.dat. /// public class SkillParser : IInfoParser { /// public Result> Parse(NostaleFiles files) { var skillDatResult = files.DatFiles.FindFile("Skill.dat"); if (!skillDatResult.IsSuccess) { return Result>.FromError(skillDatResult); } var reader = new DatReader(skillDatResult.Entity); var result = new Dictionary(); while (reader.ReadItem(out var itemNullable)) { var item = itemNullable.Value; var typeEntry = item.GetEntry("TYPE"); var targetEntry = item.GetEntry("TARGET"); var dataEntry = item.GetEntry("DATA"); var vnum = item.GetEntry("VNUM").Read(1); var nameKey = item.GetEntry("NAME").Read(1); result.Add ( vnum, new SkillInfo ( vnum, new TranslatableString(TranslationRoot.Skill, nameKey), targetEntry.Read(3), targetEntry.Read(4), dataEntry.Read(5), dataEntry.Read(6), (SkillType)typeEntry.Read(1), dataEntry.Read(7), typeEntry.Read(2), (TargetType)targetEntry.Read(1), (HitType)targetEntry.Read(2) ) ); } return result; } private record SkillInfo ( int VNum, TranslatableString Name, short Range, short ZoneRange, int CastTime, int Cooldown, SkillType SkillType, int MpCost, short CastId, TargetType TargetType, HitType HitType ) : ISkillInfo; }