forked from aly/qstbak
qstcompanion v1.0.1
This commit is contained in:
parent
3e10cbbbf2
commit
44c67ab71b
79 changed files with 21148 additions and 0 deletions
|
|
@ -0,0 +1,87 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dalamud.Plugin.Services;
|
||||
using QuestionableCompanion.Models;
|
||||
|
||||
namespace QuestionableCompanion.Services;
|
||||
|
||||
public class AlliedSocietyQuestSelector
|
||||
{
|
||||
private readonly QuestionableIPC questionableIpc;
|
||||
|
||||
private readonly IPluginLog log;
|
||||
|
||||
public AlliedSocietyQuestSelector(QuestionableIPC questionableIpc, IPluginLog log)
|
||||
{
|
||||
this.questionableIpc = questionableIpc;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
public List<string> SelectQuestsForCharacter(string characterId, int remainingAllowances, List<AlliedSocietyPriority> priorities, AlliedSocietyQuestMode mode)
|
||||
{
|
||||
List<string> selectedQuests = new List<string>();
|
||||
int currentAllowances = remainingAllowances;
|
||||
List<AlliedSocietyPriority> list = (from p in priorities
|
||||
where p.Enabled
|
||||
orderby p.Order
|
||||
select p).ToList();
|
||||
log.Debug($"[AlliedSociety] Selecting quests for {characterId}. Allowances: {remainingAllowances}, Mode: {mode}");
|
||||
foreach (AlliedSocietyPriority priority in list)
|
||||
{
|
||||
if (currentAllowances <= 0)
|
||||
{
|
||||
log.Debug("[AlliedSociety] No allowances left, stopping selection");
|
||||
break;
|
||||
}
|
||||
byte societyId = priority.SocietyId;
|
||||
List<string> optimalQuests = questionableIpc.GetAlliedSocietyOptimalQuests(societyId);
|
||||
if (optimalQuests.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<string> readyQuests = new List<string>();
|
||||
foreach (string questId in optimalQuests)
|
||||
{
|
||||
if (questionableIpc.IsReadyToAcceptQuest(questId))
|
||||
{
|
||||
readyQuests.Add(questId);
|
||||
}
|
||||
}
|
||||
if (readyQuests.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (mode == AlliedSocietyQuestMode.OnlyThreePerSociety)
|
||||
{
|
||||
List<string> questsToTake = readyQuests;
|
||||
if (questsToTake.Count > 3)
|
||||
{
|
||||
questsToTake = questsToTake.Skip(questsToTake.Count - 3).Take(3).ToList();
|
||||
}
|
||||
foreach (string questId2 in questsToTake)
|
||||
{
|
||||
if (currentAllowances > 0)
|
||||
{
|
||||
selectedQuests.Add(questId2);
|
||||
currentAllowances--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
foreach (string questId3 in readyQuests)
|
||||
{
|
||||
if (currentAllowances > 0)
|
||||
{
|
||||
selectedQuests.Add(questId3);
|
||||
currentAllowances--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
log.Information($"[AlliedSociety] Selected {selectedQuests.Count} quests for {characterId}");
|
||||
return selectedQuests;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue