2024-07-11 02:56:42 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Dalamud.Plugin.Services;
|
2024-08-04 16:03:23 +02:00
|
|
|
|
using Lumina.Excel.GeneratedSheets;
|
2024-07-11 02:56:42 +02:00
|
|
|
|
using Questionable.Model;
|
2024-08-03 20:30:18 +02:00
|
|
|
|
using Questionable.Model.Questing;
|
2024-07-11 02:56:42 +02:00
|
|
|
|
using Quest = Lumina.Excel.GeneratedSheets.Quest;
|
|
|
|
|
|
|
|
|
|
namespace Questionable.Data;
|
|
|
|
|
|
|
|
|
|
internal sealed class QuestData
|
|
|
|
|
{
|
2024-08-04 16:03:23 +02:00
|
|
|
|
private readonly Dictionary<ElementId, IQuestInfo> _quests;
|
2024-07-11 02:56:42 +02:00
|
|
|
|
|
2024-07-14 21:31:07 +02:00
|
|
|
|
public QuestData(IDataManager dataManager)
|
2024-07-11 02:56:42 +02:00
|
|
|
|
{
|
2024-08-04 16:03:23 +02:00
|
|
|
|
List<IQuestInfo> quests =
|
|
|
|
|
[
|
|
|
|
|
..dataManager.GetExcelSheet<Quest>()!
|
|
|
|
|
.Where(x => x.RowId > 0)
|
|
|
|
|
.Where(x => x.IssuerLocation.Row > 0)
|
|
|
|
|
.Select(x => new QuestInfo(x)),
|
|
|
|
|
..dataManager.GetExcelSheet<SatisfactionNpc>()!
|
|
|
|
|
.Where(x => x.RowId > 0)
|
2024-08-08 01:49:14 +02:00
|
|
|
|
.Select(x => new SatisfactionSupplyInfo(x)),
|
|
|
|
|
..dataManager.GetExcelSheet<Leve>()!
|
|
|
|
|
.Where(x => x.RowId > 0)
|
|
|
|
|
.Where(x => x.LevelLevemete.Row != 0)
|
|
|
|
|
.Select(x => new LeveInfo(x)),
|
2024-08-04 16:03:23 +02:00
|
|
|
|
];
|
|
|
|
|
_quests = quests.ToDictionary(x => x.QuestId, x => x);
|
2024-07-11 02:56:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-04 16:03:23 +02:00
|
|
|
|
public IQuestInfo GetQuestInfo(ElementId elementId)
|
2024-08-03 20:30:18 +02:00
|
|
|
|
{
|
2024-08-04 16:03:23 +02:00
|
|
|
|
return _quests[elementId] ?? throw new ArgumentOutOfRangeException(nameof(elementId));
|
2024-07-11 02:56:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-04 16:03:23 +02:00
|
|
|
|
public List<IQuestInfo> GetAllByIssuerDataId(uint targetId)
|
2024-07-11 02:56:42 +02:00
|
|
|
|
{
|
|
|
|
|
return _quests.Values
|
|
|
|
|
.Where(x => x.IssuerDataId == targetId)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 02:42:37 +02:00
|
|
|
|
public bool IsIssuerOfAnyQuest(uint targetId) => _quests.Values.Any(x => x.IssuerDataId == targetId);
|
2024-07-29 16:54:18 +02:00
|
|
|
|
|
|
|
|
|
public List<QuestInfo> GetAllByJournalGenre(uint journalGenre)
|
|
|
|
|
{
|
|
|
|
|
return _quests.Values
|
2024-08-09 00:53:05 +02:00
|
|
|
|
.Where(x => x is QuestInfo { IsSeasonalEvent: false })
|
2024-08-04 16:03:23 +02:00
|
|
|
|
.Cast<QuestInfo>()
|
2024-07-29 16:54:18 +02:00
|
|
|
|
.Where(x => x.JournalGenre == journalGenre)
|
|
|
|
|
.OrderBy(x => x.SortKey)
|
|
|
|
|
.ThenBy(x => x.QuestId)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
2024-07-11 02:56:42 +02:00
|
|
|
|
}
|