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 System.Linq;
|
||||||
using AutoRetainerAPI;
|
using AutoRetainerAPI;
|
||||||
using AutoRetainerAPI.Configuration;
|
using AutoRetainerAPI.Configuration;
|
||||||
@ -6,6 +7,7 @@ using Dalamud.Game.Command;
|
|||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using ECommons;
|
using ECommons;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Mariner;
|
namespace Mariner;
|
||||||
|
|
||||||
@ -18,14 +20,24 @@ public sealed class MarinerPlugin : IDalamudPlugin
|
|||||||
private readonly IPluginLog _pluginLog;
|
private readonly IPluginLog _pluginLog;
|
||||||
private readonly AutoRetainerApi _autoRetainerApi;
|
private readonly AutoRetainerApi _autoRetainerApi;
|
||||||
|
|
||||||
|
private readonly int _maxRank;
|
||||||
|
|
||||||
public MarinerPlugin(DalamudPluginInterface pluginInterface, IClientState clientState, IFramework framework,
|
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;
|
_clientState = clientState;
|
||||||
_framework = framework;
|
_framework = framework;
|
||||||
_commandManager = commandManager;
|
_commandManager = commandManager;
|
||||||
_pluginLog = pluginLog;
|
_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);
|
ECommonsMain.Init(pluginInterface, this);
|
||||||
_autoRetainerApi = new AutoRetainerApi();
|
_autoRetainerApi = new AutoRetainerApi();
|
||||||
|
|
||||||
@ -66,8 +78,8 @@ public sealed class MarinerPlugin : IDalamudPlugin
|
|||||||
return "Not updating subs, not all subs are enabled";
|
return "Not updating subs, not all subs are enabled";
|
||||||
|
|
||||||
if (offlineCharacterData.AdditionalSubmarineData.All(x =>
|
if (offlineCharacterData.AdditionalSubmarineData.All(x =>
|
||||||
x.Value.Level >= 115 && x.Value.VesselBehavior == VesselBehavior.Use_plan))
|
x.Value.Level >= _maxRank && x.Value.VesselBehavior == VesselBehavior.Use_plan))
|
||||||
return "Not updating subs, all subs are level 115+ and use plans";
|
return $"Not updating subs, all subs are level {_maxRank}+ and use plans";
|
||||||
|
|
||||||
var subs = offlineCharacterData.AdditionalSubmarineData.Values
|
var subs = offlineCharacterData.AdditionalSubmarineData.Values
|
||||||
.OrderBy(x => x.Level)
|
.OrderBy(x => x.Level)
|
||||||
@ -76,13 +88,17 @@ public sealed class MarinerPlugin : IDalamudPlugin
|
|||||||
for (int i = 0; i < subs.Count; ++i)
|
for (int i = 0; i < subs.Count; ++i)
|
||||||
{
|
{
|
||||||
var sub = subs[i];
|
var sub = subs[i];
|
||||||
sub.VesselBehavior = sub.Level switch
|
if (sub.Level >= _maxRank)
|
||||||
|
sub.VesselBehavior = VesselBehavior.Use_plan;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
< 101 => VesselBehavior.Unlock,
|
sub.VesselBehavior = sub.Level switch
|
||||||
>= 115 => VesselBehavior.Use_plan,
|
{
|
||||||
_ when i == 0 => VesselBehavior.Unlock,
|
< 101 => VesselBehavior.Unlock,
|
||||||
_ => VesselBehavior.Use_plan
|
_ when i == 0 => VesselBehavior.Unlock,
|
||||||
};
|
_ => VesselBehavior.Use_plan
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_autoRetainerApi.WriteOfflineCharacterData(offlineCharacterData);
|
_autoRetainerApi.WriteOfflineCharacterData(offlineCharacterData);
|
||||||
|
Loading…
Reference in New Issue
Block a user