// // InfoService.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; using NosSmooth.Data.Abstractions.Infos; using NosSmooth.Data.Abstractions.Language; using NosSmooth.Data.NOSFiles.Parsers; using Remora.Results; namespace NosSmooth.Data.NOSFiles; /// internal class InfoService : IInfoService { private readonly NostaleData _nostaleData; /// /// Initializes a new instance of the class. /// /// The parsed data. public InfoService(NostaleData nostaleData) { _nostaleData = nostaleData; } /// public Result GetItemInfo(int vnum) { if (!_nostaleData.Items.ContainsKey(vnum)) { return new NotFoundError($"Couldn't find item {vnum}"); } return Result.FromSuccess(_nostaleData.Items[vnum]); } /// public Result GetMapInfo(int id) { if (!_nostaleData.Maps.ContainsKey(id)) { return new NotFoundError($"Couldn't find item {id}"); } return Result.FromSuccess(_nostaleData.Maps[id]); } /// public Result GetMonsterInfo(int vnum) { if (!_nostaleData.Monsters.ContainsKey(vnum)) { return new NotFoundError($"Couldn't find item {vnum}"); } return Result.FromSuccess(_nostaleData.Monsters[vnum]); } /// public Result GetSkillInfo(int vnum) { if (!_nostaleData.Skills.ContainsKey(vnum)) { return new NotFoundError($"Couldn't find item {vnum}"); } return Result.FromSuccess(_nostaleData.Skills[vnum]); } }