Dynamically determine max sub rank
This commit is contained in:
parent
6032215d6b
commit
033566a3a0
@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using AutoRetainerAPI;
|
||||
using AutoRetainerAPI.Configuration;
|
||||
@ -6,6 +7,7 @@ using Dalamud.Game.Command;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using ECommons;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
|
||||
namespace Mariner;
|
||||
|
||||
@ -18,14 +20,24 @@ public sealed class MarinerPlugin : IDalamudPlugin
|
||||
private readonly IPluginLog _pluginLog;
|
||||
private readonly AutoRetainerApi _autoRetainerApi;
|
||||
|
||||
private readonly int _maxRank;
|
||||
|
||||
public MarinerPlugin(DalamudPluginInterface pluginInterface, IClientState clientState, IFramework framework,
|
||||
ICommandManager commandManager, IChatGui chatGui, IPluginLog pluginLog)
|
||||
ICommandManager commandManager, IChatGui chatGui, IPluginLog pluginLog, IDataManager dataManager)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dataManager);
|
||||
|
||||
_clientState = clientState;
|
||||
_framework = framework;
|
||||
_commandManager = commandManager;
|
||||
_pluginLog = pluginLog;
|
||||
|
||||
_maxRank = dataManager.GetExcelSheet<SubmarineRank>()!
|
||||
.Where(x => x.RowId > 0 && x.Capacity > 0)
|
||||
.Select(x => (int)x.RowId)
|
||||
.Max();
|
||||
_pluginLog.Information($"Max submersible rank: {_maxRank}");
|
||||
|
||||
ECommonsMain.Init(pluginInterface, this);
|
||||
_autoRetainerApi = new AutoRetainerApi();
|
||||
|
||||
@ -66,8 +78,8 @@ public sealed class MarinerPlugin : IDalamudPlugin
|
||||
return "Not updating subs, not all subs are enabled";
|
||||
|
||||
if (offlineCharacterData.AdditionalSubmarineData.All(x =>
|
||||
x.Value.Level >= 115 && x.Value.VesselBehavior == VesselBehavior.Use_plan))
|
||||
return "Not updating subs, all subs are level 115+ and use plans";
|
||||
x.Value.Level >= _maxRank && x.Value.VesselBehavior == VesselBehavior.Use_plan))
|
||||
return $"Not updating subs, all subs are level {_maxRank}+ and use plans";
|
||||
|
||||
var subs = offlineCharacterData.AdditionalSubmarineData.Values
|
||||
.OrderBy(x => x.Level)
|
||||
@ -76,14 +88,18 @@ public sealed class MarinerPlugin : IDalamudPlugin
|
||||
for (int i = 0; i < subs.Count; ++i)
|
||||
{
|
||||
var sub = subs[i];
|
||||
if (sub.Level >= _maxRank)
|
||||
sub.VesselBehavior = VesselBehavior.Use_plan;
|
||||
else
|
||||
{
|
||||
sub.VesselBehavior = sub.Level switch
|
||||
{
|
||||
< 101 => VesselBehavior.Unlock,
|
||||
>= 115 => VesselBehavior.Use_plan,
|
||||
_ when i == 0 => VesselBehavior.Unlock,
|
||||
_ => VesselBehavior.Use_plan
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
_autoRetainerApi.WriteOfflineCharacterData(offlineCharacterData);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user