Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
refactor: only one instance about the rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 4, 2024
1 parent 130e330 commit 4926315
Show file tree
Hide file tree
Showing 27 changed files with 220 additions and 219 deletions.
5 changes: 1 addition & 4 deletions DefaultRotations/Healer/AST_Default.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
namespace DefaultRotations.Healer;

[Rotation(Name = "Default", GameVersion ="6.28")]
[RotationDesc(ActionID.DivinationPvE)]
[SourceCode(Path = "main/DefaultRotations/Healer/AST_Default.cs")]
public sealed class AST_Default : AstrologianRotation
{
public override CombatType Type => CombatType.PvE;

public override string GameVersion => "6.28";

public override string RotationName => "Default";

protected override IRotationConfigSet CreateConfiguration()
=> base.CreateConfiguration()
.SetFloat(ConfigUnitType.Seconds, CombatType.PvE, "UseEarthlyStarTime", 15, "Use Earthly Star during countdown timer.", 4, 20);
Expand Down
9 changes: 9 additions & 0 deletions RotationSolver.Basic/Attributes/JobsAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using ECommons.ExcelServices;

namespace RotationSolver.Basic.Attributes;

[AttributeUsage(AttributeTargets.Class)]
internal class JobsAttribute(params Job[] jobs) : Attribute
{
public Job[] Jobs => jobs;
}
17 changes: 17 additions & 0 deletions RotationSolver.Basic/Attributes/RotationAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Basic.Attributes;

[AttributeUsage(AttributeTargets.Class)]
public class RotationAttribute : Attribute
{
public string Name { get; set; }
public string Description { get; set; }
public CombatType Type { get; set; }

public string GameVersion { get; set; }
}
49 changes: 5 additions & 44 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,12 @@ public static bool GetTexture(this ActionID actionID, out IDalamudTextureWrap te
/// <summary>
/// Get job Icon from rotation.
/// </summary>
/// <param name="rotation"></param>
/// <param name="job"></param>
/// <returns></returns>
public static uint GetJobIcon(ICustomRotation rotation)
public static uint GetJobIcon(JobRole role, Job job)
{
IconType type = IconType.Gold;
switch (rotation.ClassJob.GetJobRole())
switch (role)
{
case JobRole.Tank:
type = IconType.Blue;
Expand All @@ -315,18 +315,7 @@ public static uint GetJobIcon(ICustomRotation rotation)
type = IconType.Green;
break;
}
return GetJobIcon(rotation, type);
}

/// <summary>
/// Get Job Icon from specific type.
/// </summary>
/// <param name="combo"></param>
/// <param name="type"></param>
/// <returns></returns>
public static uint GetJobIcon(ICustomRotation combo, IconType type)
{
return _icons[type][(uint)combo.Jobs[0] - 1];
return GetJobIcon(job, type);
}

/// <summary>
Expand All @@ -336,35 +325,7 @@ public static uint GetJobIcon(ICustomRotation combo, IconType type)
/// <returns></returns>
public static uint GetJobIcon(Job job)
{
return GetJobIcon(job, Svc.Data.GetExcelSheet<ClassJob>()?.GetRow((uint)job)?.GetJobRole() ?? JobRole.None);
}

/// <summary>
///
/// </summary>
/// <param name="job"></param>
/// <param name="role"></param>
/// <returns></returns>
public static uint GetJobIcon(Job job, JobRole role)
{
IconType type = IconType.Gold;

switch (role)
{
case JobRole.Tank:
type = IconType.Blue;
break;
case JobRole.RangedPhysical:
case JobRole.RangedMagical:
case JobRole.Melee:
type = IconType.Red;
break;
case JobRole.Healer:
type = IconType.Green;
break;
}

return GetJobIcon(job, type);
return GetJobIcon(Svc.Data.GetExcelSheet<ClassJob>()?.GetRow((uint)job)?.GetJobRole() ?? JobRole.None, job);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Rotations/CustomRotation_Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private bool GeneralUsingAbility(JobRole role, out IAction? act)

case JobRole.Healer:
case JobRole.RangedMagical:
if (Jobs[0] == ECommons.ExcelServices.Job.BLM) break;
if (Job == ECommons.ExcelServices.Job.BLM) break;
if (LucidDreamingPvE.CanUse(out act)) return true;
break;

Expand All @@ -258,7 +258,7 @@ protected virtual bool EmergencyAbility(IAction nextGCD, out IAction? act)
{
if (nextGCD is BaseAction action)
{
if (ClassJob.GetJobRole() is JobRole.Healer or JobRole.RangedMagical &&
if (Role is JobRole.Healer or JobRole.RangedMagical &&
action.Info.CastTime >= 5 && SwiftcastPvE.CanUse(out act)) return true;

if (Service.Config.AutoUseTrueNorth
Expand Down
34 changes: 22 additions & 12 deletions RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
using ECommons.ExcelServices;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using Lumina.Excel.GeneratedSheets;

namespace RotationSolver.Basic.Rotations;

[Jobs()]
partial class CustomRotation : ICustomRotation
{
public abstract CombatType Type { get; }

public abstract Job[] Jobs { get; }
private Job? _job = null;
public Job Job => _job ??= this.GetType().GetCustomAttribute<JobsAttribute>()?.Jobs[0] ?? Job.ADV;

public abstract string GameVersion { get; }

public ClassJob ClassJob => Service.GetSheet<ClassJob>().GetRow((uint)Jobs[0])!;
private JobRole? _role = null;
public JobRole Role => _role ??= Svc.Data.GetExcelSheet<ClassJob>()!.GetRow((uint)Job)!.GetJobRole();
private string? _name = null;
public string Name
{
get
{
if (_name != null) return _name;

public string Name => ClassJob.Abbreviation + " - " + ClassJob.Name;
var classJob = Svc.Data.GetExcelSheet<ClassJob>()?.GetRow((uint)Job)!;

public abstract string RotationName { get; }
return _name = classJob.Abbreviation + " - " + classJob.Name;
}
}

public bool IsEnabled
{
get => !Service.Config.DisabledJobs.Contains(Jobs.FirstOrDefault());
get => !Service.Config.DisabledJobs.Contains(Job);
set
{
if (value)
{
Service.Config.DisabledJobs.Remove(Jobs.FirstOrDefault());
Service.Config.DisabledJobs.Remove(Job);
}
else
{
Service.Config.DisabledJobs.Add(Jobs.FirstOrDefault());
Service.Config.DisabledJobs.Add(Job);
}
}
}
Expand Down Expand Up @@ -84,7 +94,7 @@ public bool IsEnabled

private protected CustomRotation()
{
IconID = IconSet.GetJobIcon(this);
IconID = IconSet.GetJobIcon(this.Job);
Configs = CreateConfiguration();
}

Expand All @@ -93,7 +103,7 @@ protected virtual IRotationConfigSet CreateConfiguration()
return new RotationConfigSet();
}

public override string ToString() => RotationName;
public override string ToString() => this.GetType().GetCustomAttribute<RotationAttribute>()?.Name ?? this.GetType().Name;

/// <summary>
/// Update your customized field.
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_Invoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public bool TryInvoke(out IAction? newAction, out IAction? gcdAction)
UpdateInfo();

IBaseAction.ActionPreview = true;
UpdateActions(ClassJob.GetJobRole());
UpdateActions(Role);
IBaseAction.ActionPreview = false;

CountingOfLastUsing = CountingOfCombatTimeUsing = 0;
Expand Down
18 changes: 4 additions & 14 deletions RotationSolver.Basic/Rotations/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,14 @@ public interface ICustomRotation : ITexture
string WhyNotValid { get; }

/// <summary>
/// The class job about this rotation.
/// Job
/// </summary>
ClassJob ClassJob { get; }
Job Job { get; }

/// <summary>
/// All jobs.
///
/// </summary>
Job[] Jobs { get; }

/// <summary>
/// The game version in writing.
/// </summary>
string GameVersion { get; }

/// <summary>
/// The name of this rotation.
/// </summary>
string RotationName { get; }
JobRole Role { get; }

/// <summary>
/// Configurations about this rotation.
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.GameData/Getters/RotationGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public string GetCode()
/// <br>Number of Actions: {{rotationsGetter.Count}}</br>
/// <br>Number of Traits: {{traitsGetter.Count}}</br>
/// </summary>
[Jobs({{jobs}})]
public abstract partial class {{GetName()}} : CustomRotation
{
public sealed override Job[] Jobs => new[] { {{jobs}} };
{{jobGauge}}
#region Actions
Expand Down
Loading

0 comments on commit 4926315

Please sign in to comment.