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

Commit

Permalink
fix: fixed loading and translation bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 5, 2024
1 parent 008550d commit 8e0db8f
Show file tree
Hide file tree
Showing 26 changed files with 291 additions and 900 deletions.
2 changes: 1 addition & 1 deletion DefaultRotations/Duty/BozjaDefault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace DefaultRotations.Duty;

[Rotation("Bozja Default")]
[Rotation("Bozja Default", CombatType.PvE)]
internal class BozjaDefault : BozjaRotation
{
public override bool ProvokeAbility(out IAction? act)
Expand Down
2 changes: 1 addition & 1 deletion DefaultRotations/Healer/AST_Default.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace DefaultRotations.Healer;

[Rotation(Name = "Default", GameVersion ="6.28")]
[Rotation("Default", CombatType.PvE, GameVersion = "6.28")]
[RotationDesc(ActionID.DivinationPvE)]
[SourceCode(Path = "main/DefaultRotations/Healer/AST_Default.cs")]
public sealed class AST_Default : AstrologianRotation
Expand Down
1 change: 1 addition & 0 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"3": 0.6,
"5": 2.1,
"9": 0.6,
"15": 0.6,
"16": 0.6,
Expand Down
2 changes: 1 addition & 1 deletion Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ClickingCount": 60431,
"ClickingCount": 60443,
"SayingHelloCount": 13,
"SaidUsers": []
}
5 changes: 1 addition & 4 deletions Resources/downloadList.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[
"ArchiDog1998|FFXIVRotations|DefaultRotations",
"IncognitoWater|IncognitoWaterRotations|IcWaRotations",
"thunderebolt|BoltsRotations|BoltsRotations",
"BrakusTapus|KirboRotations|KirboRotations"
"ArchiDog1998|FFXIVRotations|DefaultRotations"
]
5 changes: 4 additions & 1 deletion RotationSolver.Basic/Actions/ActionSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public class ActionSetting()
{
public bool TargetStatusFromSelf { get; set; } = true;
public bool StatusFromSelf { get; set; } = true;
public StatusID[]? TargetStatusProvide { get; set; } = null;
public StatusID[]? TargetStatusNeed { get; set; } = null;
public Func<BattleChara, bool> CanTarget { get; set; } = t => true;
Expand All @@ -24,6 +24,9 @@ public class ActionSetting()

public Func<bool>? ActionCheck { get; set; } = null;

public Func<ActionConfig>? CreateConfig { get; set; } = null;


public bool IsFriendly { get; set; }

private TargetType _type = TargetType.Big;
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ private readonly bool CheckStatus(GameObject gameObject)
if (_action.Setting.TargetStatusProvide != null)
{
if (!gameObject.WillStatusEndGCD(_action.Config.StatusGcdCount, 0,
_action.Setting.TargetStatusFromSelf, _action.Setting.TargetStatusProvide)) return false;
_action.Setting.StatusFromSelf, _action.Setting.TargetStatusProvide)) return false;
}

if (_action.Setting.TargetStatusNeed != null)
{
if (gameObject.WillStatusEndGCD(_action.Config.StatusGcdCount, 0,
_action.Setting.TargetStatusFromSelf, _action.Setting.TargetStatusNeed)) return false;
_action.Setting.StatusFromSelf, _action.Setting.TargetStatusNeed)) return false;
}

return true;
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver.Basic/Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public ActionConfig Config
{
get
{
if(!Service.Config.RotationActionConfig.TryGetValue(ID, out var value))
if (!Service.Config.RotationActionConfig.TryGetValue(ID, out var value))
{
Service.Config.RotationActionConfig[ID] = value = new();
Service.Config.RotationActionConfig[ID] = value
= Setting.CreateConfig?.Invoke() ?? new();
}
return value;
}
Expand Down
13 changes: 4 additions & 9 deletions RotationSolver.Basic/Attributes/RotationAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.Basic.Attributes;
namespace RotationSolver.Basic.Attributes;

[AttributeUsage(AttributeTargets.Class)]
public class RotationAttribute(string name) : Attribute
public class RotationAttribute(string name, CombatType type) : Attribute
{
public string Name => name;
public CombatType Type => type;

public string? Description { get; set; }
public CombatType Type { get; set; } = CombatType.None;

public string? GameVersion { get; set; }
}
6 changes: 4 additions & 2 deletions RotationSolver.Basic/Configuration/ConditionBoolean.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace RotationSolver.Basic.Configuration;

internal class ConditionBoolean(bool defaultValue, string key)
{
public bool Value { get; set; }
private readonly bool _defaultValue = defaultValue;
public bool Value { get; set; } = defaultValue;
public bool Enable { get; set; }
public bool Disable { get; set; }

Expand All @@ -10,7 +12,7 @@ internal class ConditionBoolean(bool defaultValue, string key)

public void ResetValue()
{
Value = defaultValue;
Value = _defaultValue;
}

public static implicit operator bool(ConditionBoolean condition)
Expand Down
132 changes: 66 additions & 66 deletions RotationSolver.Basic/Configuration/Conditions/IConditionConverter.cs
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
//using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq;

//namespace RotationSolver.Basic.Configuration.Conditions;
namespace RotationSolver.Basic.Configuration.Conditions;

//internal class IConditionConverter : JsonCreationConverter<ICondition>
//{
// protected override ICondition Create(JObject jObject)
// {
// if (FieldExists(nameof(ConditionSet.Conditions), jObject))
// {
// return new ConditionSet();
// }
// else if (FieldExists(nameof(ActionCondition.ActionConditionType), jObject))
// {
// return new ActionCondition();
// }
// else if (FieldExists(nameof(TargetCondition.TargetConditionType), jObject))
// {
// return new TargetCondition();
// }
// else if (FieldExists(nameof(RotationCondition.ComboConditionType), jObject))
// {
// return new RotationCondition();
// }
// else if (FieldExists(nameof(TraitCondition.TraitID), jObject))
// {
// return new TraitCondition();
// }
// else if (FieldExists(nameof(NamedCondition.ConditionName), jObject))
// {
// return new NamedCondition();
// }
// else if (FieldExists(nameof(TerritoryCondition.TerritoryConditionType), jObject))
// {
// return new TerritoryCondition();
// }
// else
// {
// return null;
// }
// }
internal class IConditionConverter : JsonCreationConverter<ICondition>
{
protected override ICondition Create(JObject jObject)
{
if (FieldExists(nameof(ConditionSet.Conditions), jObject))
{
return new ConditionSet();
}
else if (FieldExists(nameof(ActionCondition.ActionConditionType), jObject))
{
return new ActionCondition();
}
else if (FieldExists(nameof(TargetCondition.TargetConditionType), jObject))
{
return new TargetCondition();
}
else if (FieldExists(nameof(RotationCondition.ComboConditionType), jObject))
{
return new RotationCondition();
}
else if (FieldExists(nameof(TraitCondition.TraitID), jObject))
{
return new TraitCondition();
}
else if (FieldExists(nameof(NamedCondition.ConditionName), jObject))
{
return new NamedCondition();
}
else if (FieldExists(nameof(TerritoryCondition.TerritoryConditionType), jObject))
{
return new TerritoryCondition();
}
else
{
return null;
}
}

// private static bool FieldExists(string fieldName, JObject jObject)
// {
// return jObject[fieldName] != null;
// }
//}
private static bool FieldExists(string fieldName, JObject jObject)
{
return jObject[fieldName] != null;
}
}

//internal abstract class JsonCreationConverter<T> : JsonConverter
//{
// protected abstract T Create(JObject jObject);
internal abstract class JsonCreationConverter<T> : JsonConverter
{
protected abstract T Create(JObject jObject);

// public override bool CanConvert(Type objectType)
// {
// return typeof(T).IsAssignableFrom(objectType);
// }
public override bool CanConvert(Type objectType)
{
return typeof(T).IsAssignableFrom(objectType);
}

// public override bool CanWrite => false;
public override bool CanWrite => false;

// public sealed override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
// {
// }
public sealed override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
}

// public sealed override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
// {
// // Load JObject from stream
// JObject jObject = JObject.Load(reader);
public sealed override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
// Load JObject from stream
JObject jObject = JObject.Load(reader);

// // Create target object based on JObject
// T target = Create(jObject);
// Create target object based on JObject
T target = Create(jObject);

// // Populate the object properties
// serializer.Populate(jObject.CreateReader(), target);
// Populate the object properties
serializer.Populate(jObject.CreateReader(), target);

// return target;
// }
//}
return target;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ public static MajorConditionSet[] Read(string folder)

try
{
return JsonConvert.DeserializeObject<MajorConditionSet>(str, new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Objects,
});
return JsonConvert.DeserializeObject<MajorConditionSet>(str, new IConditionConverter());
}
catch (Exception ex)
{
Expand Down
5 changes: 1 addition & 4 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,6 @@ public void Save()
Svc.Log.Information("Saved configurations.");
#endif
File.WriteAllText(Svc.PluginInterface.ConfigFile.FullName,
JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Objects,
}));
JsonConvert.SerializeObject(this, Formatting.Indented));
}
}
11 changes: 11 additions & 0 deletions RotationSolver.Basic/Helpers/StatusHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ namespace RotationSolver.Basic.Helpers;
/// </summary>
public static class StatusHelper
{
/// <summary>
///
/// </summary>
public static StatusID[] RangePhysicalDefense { get; } =
[
StatusID.Troubadour,
StatusID.Tactician_1951,
StatusID.Tactician_2177,
StatusID.ShieldSamba,
];

/// <summary>
///
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions RotationSolver.Basic/Rotations/Basic/AstrologianRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,47 +85,47 @@ static partial void ModifyMinorArcanaPvE(ref ActionSetting setting)
static partial void ModifyTheArrowPvE(ref ActionSetting setting)
{
setting.TargetStatusProvide = StatusHelper.AstCardStatus;
setting.TargetStatusFromSelf = false;
setting.StatusFromSelf = false;
setting.TargetType = TargetType.Melee;
setting.ActionCheck = () => DrawnCard == CardType.ARROW;
}

static partial void ModifyTheBalancePvE(ref ActionSetting setting)
{
setting.TargetStatusProvide = StatusHelper.AstCardStatus;
setting.TargetStatusFromSelf = false;
setting.StatusFromSelf = false;
setting.TargetType = TargetType.Melee;
setting.ActionCheck = () => DrawnCard == CardType.BALANCE;
}

static partial void ModifyTheBolePvE(ref ActionSetting setting)
{
setting.TargetStatusProvide = StatusHelper.AstCardStatus;
setting.TargetStatusFromSelf = false;
setting.StatusFromSelf = false;
setting.TargetType = TargetType.Range;
setting.ActionCheck = () => DrawnCard == CardType.BOLE;
}

static partial void ModifyTheEwerPvE(ref ActionSetting setting)
{
setting.TargetStatusProvide = StatusHelper.AstCardStatus;
setting.TargetStatusFromSelf = false;
setting.StatusFromSelf = false;
setting.TargetType = TargetType.Range;
setting.ActionCheck = () => DrawnCard == CardType.EWER;
}

static partial void ModifyTheSpearPvE(ref ActionSetting setting)
{
setting.TargetStatusProvide = StatusHelper.AstCardStatus;
setting.TargetStatusFromSelf = false;
setting.StatusFromSelf = false;
setting.TargetType = TargetType.Melee;
setting.ActionCheck = () => DrawnCard == CardType.SPEAR;
}

static partial void ModifyTheSpirePvE(ref ActionSetting setting)
{
setting.TargetStatusProvide = StatusHelper.AstCardStatus;
setting.TargetStatusFromSelf = false;
setting.StatusFromSelf = false;
setting.TargetType = TargetType.Range;
setting.ActionCheck = () => DrawnCard == CardType.SPIRE;
}
Expand Down
Loading

0 comments on commit 8e0db8f

Please sign in to comment.