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

Commit

Permalink
fix: add combat type for rotation and its config.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Nov 7, 2023
1 parent 031a1aa commit 43955fc
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public interface IRotationConfig
/// </summary>
string DefaultValue { get; }

/// <summary>
/// Type of this config, pvp, pve, or both.
/// </summary>
CombatType Type { get; }

/// <summary>
/// Get the value of this.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,62 @@ public interface IRotationConfigSet : IEnumerable<IRotationConfig>
/// <param name="max"></param>
/// <param name="speed"></param>
/// <returns></returns>
[Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetFloat(string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f);

/// <summary>
/// Set the float.
/// </summary>
/// <param name="unit">tye unit type</param>
/// <param name="type">the combat type</param>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="speed"></param>
IRotationConfigSet SetFloat(ConfigUnitType unit, CombatType type, string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f);

/// <summary>
/// Set the string.
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <returns></returns>
[Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetString(string name, string value, string displayName);

/// <summary>
/// Set the string.
/// </summary>
/// <param name="type">the combat type</param>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <returns></returns>
IRotationConfigSet SetString(CombatType type, string name, string value, string displayName);

/// <summary>
/// Set the bool.
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <returns></returns>
[Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetBool(string name, bool value, string displayName);

/// <summary>
///
/// </summary>
/// <param name="type">the combat type</param>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <returns></returns>
IRotationConfigSet SetBool(CombatType type, string name, bool value, string displayName);

/// <summary>
/// Set the combo.
/// </summary>
Expand All @@ -48,8 +84,20 @@ public interface IRotationConfigSet : IEnumerable<IRotationConfig>
/// <param name="displayName"></param>
/// <param name="items"></param>
/// <returns></returns>
[Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetCombo(string name, int value, string displayName, params string[] items);

/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <param name="items"></param>
/// <returns></returns>
IRotationConfigSet SetCombo(CombatType type, string name, int value, string displayName, params string[] items);

/// <summary>
/// Set the int.
/// </summary>
Expand All @@ -60,8 +108,22 @@ public interface IRotationConfigSet : IEnumerable<IRotationConfig>
/// <param name="max"></param>
/// <param name="speed"></param>
/// <returns></returns>
[Obsolete("Please use the one with types!", true)]
IRotationConfigSet SetInt(string name, int value, string displayName, int min = 0, int max = 10, int speed = 1);

/// <summary>
///
/// </summary>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="displayName"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="speed"></param>
/// <returns></returns>
IRotationConfigSet SetInt(CombatType type, string name, int value, string displayName, int min = 0, int max = 10, int speed = 1);

/// <summary>
/// Set the value.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ internal abstract class RotationConfigBase : IRotationConfig
public string Name { get; }
public string DefaultValue { get; }
public string DisplayName { get; }
public CombatType Type { get; }

public RotationConfigBase(string name, string value, string displayName)
public RotationConfigBase(string name, string value, string displayName, CombatType type)
{
Name = name;
DefaultValue = value;
DisplayName = displayName;
Type = type;
}

public string GetValue(Job job, string rotationName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

internal class RotationConfigBoolean : RotationConfigBase
{
public RotationConfigBoolean(string name, bool value, string displayName) : base(name, value.ToString(), displayName)

public RotationConfigBoolean(string name, bool value, string displayName, CombatType type)
: base(name, value.ToString(), displayName, type)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace RotationSolver.Basic.Configuration.RotationConfig;
internal class RotationConfigCombo : RotationConfigBase
{
public string[] Items { get; set; }
public RotationConfigCombo(string name, int value, string displayName, string[] items) : base(name, value.ToString(), displayName)
public RotationConfigCombo(string name, int value, string displayName, string[] items, CombatType type) : base(name, value.ToString(), displayName, type)
{
Items = items;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ internal class RotationConfigFloat : RotationConfigBase
public ConfigUnitType UnitType { get; set; }


[Obsolete("Please use the one with unit type!", true)]
public RotationConfigFloat(string name, float value, string displayName, float min, float max, float speed)
:this(name, value, displayName, min, max, speed, ConfigUnitType.None)
{

}

public RotationConfigFloat(string name, float value, string displayName, float min, float max, float speed, ConfigUnitType unitType) : base(name, value.ToString(), displayName)
public RotationConfigFloat(string name, float value, string displayName, float min, float max, float speed, ConfigUnitType unitType, CombatType type) : base(name, value.ToString(), displayName, type)
{
Min = min;
Max = max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ internal class RotationConfigInt : RotationConfigBase
{
public int Min, Max, Speed;

public RotationConfigInt(string name, int value, string displayName, int min, int max, int speed) : base(name, value.ToString(), displayName)
public RotationConfigInt(string name, int value, string displayName, int min, int max, int speed, CombatType type)
: base(name, value.ToString(), displayName, type)
{
Min = min;
Max = max;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,63 @@ public RotationConfigSet(Job job, string rotationName)
}

#region Set
[Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetFloat(string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f)
{
Configs.Add(new RotationConfigFloat(name, value, displayName, min, max, speed));
return SetFloat(ConfigUnitType.None, CombatType.Both, name, value, displayName, min, max, speed);
}

public IRotationConfigSet SetFloat(ConfigUnitType unit, CombatType type, string name, float value, string displayName, float min = 0, float max = 1, float speed = 0.002f)
{
Configs.Add(new RotationConfigFloat(name, value, displayName, min, max, speed, unit, type));
return this;
}

[Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetString(string name, string value, string displayName)
{
Configs.Add(new RotationConfigString(name, value, displayName));
return SetString(CombatType.Both, name, value, displayName);
}

public IRotationConfigSet SetString(CombatType type, string name, string value, string displayName)
{
Configs.Add(new RotationConfigString(name, value, displayName, type));
return this;
}

[Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetBool(string name, bool value, string displayName)
{
Configs.Add(new RotationConfigBoolean(name, value, displayName));
return SetBool(CombatType.Both, name, value, displayName);
}

public IRotationConfigSet SetBool(CombatType type, string name, bool value, string displayName)
{
Configs.Add(new RotationConfigBoolean(name, value, displayName, type));
return this;
}

[Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetCombo(string name, int value, string displayName, params string[] items)
{
Configs.Add(new RotationConfigCombo(name, value, displayName, items));
return SetCombo(CombatType.Both, name, value, displayName, items);
}

public IRotationConfigSet SetCombo(CombatType type, string name, int value, string displayName, params string[] items)
{
Configs.Add(new RotationConfigCombo(name, value, displayName, items, type));
return this;
}

[Obsolete("Please use the one with types!", true)]
public IRotationConfigSet SetInt(string name, int value, string displayName, int min = 0, int max = 10, int speed = 1)
{
Configs.Add(new RotationConfigInt(name, value, displayName, min, max, speed));
return SetInt(CombatType.Both, name, value, displayName, min, max, speed);
}

public IRotationConfigSet SetInt(CombatType type, string name, int value, string displayName, int min = 0, int max = 10, int speed = 1)
{
Configs.Add(new RotationConfigInt(name, value, displayName, min, max, speed, type));
return this;
}

Expand Down Expand Up @@ -101,7 +131,6 @@ public string GetDisplayString(string name)

public IEnumerator<IRotationConfig> GetEnumerator() => Configs.GetEnumerator();


IEnumerator IEnumerable.GetEnumerator() => Configs.GetEnumerator();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

internal class RotationConfigString : RotationConfigBase
{
public RotationConfigString(string name, string value, string displayName) : base(name, value, displayName)
public RotationConfigString(string name, string value, string displayName, CombatType type)
: base(name, value, displayName, type)
{
}

Expand Down
28 changes: 28 additions & 0 deletions RotationSolver.Basic/Data/CombatType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace RotationSolver.Basic.Data;

/// <summary>
/// The type of the combat
/// </summary>
[Flags]
public enum CombatType : byte
{
/// <summary>
/// None of them! (Invalid)
/// </summary>
None = 0,

/// <summary>
/// Only for PvP.
/// </summary>
PvP = 1 << 0,

/// <summary>
/// Only for PvE.
/// </summary>
PvE = 1 << 1,

/// <summary>
/// PvP and PvE.
/// </summary>
Both = PvP | PvE,
}
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Helpers/TargetFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private static T FindMoveTargetScreenCenter<T>(IEnumerable<T> charas) where T :
/// Find the one being attacked.
/// </summary>
/// <param name="charas"></param>
/// <param name="mustUse"></param>
/// <param name="_"></param>
/// <returns></returns>
public static BattleChara FindAttackedTarget(IEnumerable<BattleChara> charas, bool _)
{
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Rotations/Basic/BLU_Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,8 @@ protected override bool EmergencyGCD(out IAction act)
protected override IRotationConfigSet CreateConfiguration()
{
return base.CreateConfiguration()
.SetCombo("BlueId", 2, "Role", "Tank", "Healer", "DPS")
.SetCombo("AttackType", 2, "Type", "Both", "Magic", "Physic");
.SetCombo(CombatType.PvE, "BlueId", 2, "Role", "Tank", "Healer", "DPS")
.SetCombo(CombatType.PvE, "AttackType", 2, "Type", "Both", "Magic", "Physic");
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/Rotations/CustomRotation_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace RotationSolver.Basic.Rotations;
public abstract partial class CustomRotation : ICustomRotation
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public virtual CombatType Type => CombatType.None;

public abstract Job[] Jobs { get; }

Expand Down
5 changes: 5 additions & 0 deletions RotationSolver.Basic/Rotations/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace RotationSolver.Basic.Rotations;
/// </summary>
public interface ICustomRotation : ITexture
{
/// <summary>
/// The type of this rotation, pvp, pve, or both.
/// </summary>
CombatType Type { get; }

/// <summary>
/// The average count of not recommend members using.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@
"ActionConditionType_MaxCharges": "Max Charges",
"TargetConditionType_HasStatus": "Has Status",
"TargetConditionType_IsDying": "Is Dying",
"TargetConditionType_IsBoss": "Is Boss",
"TargetConditionType_IsBossFromTTK": "Is Boss From TTK",
"TargetConditionType_IsBossFromIcon": "Is Boss From Icon",
"TargetConditionType_InCombat": "In Combat",
"TargetConditionType_Distance": "Distance",
"TargetConditionType_StatusEnd": "Status End",
Expand Down
Loading

0 comments on commit 43955fc

Please sign in to comment.