This commit is contained in:
@@ -2,7 +2,7 @@ namespace PkmnLib.Dynamic.AI;
|
||||
|
||||
public static class AILogging
|
||||
{
|
||||
public static Action<string> LogHandler { get; set; } = message => { };
|
||||
public static Action<string> LogHandler { get; set; } = _ => { };
|
||||
|
||||
public static void LogInformation(string message) => LogHandler(message);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.AI;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using PkmnLib.Dynamic.Events;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static.Species;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models;
|
||||
namespace PkmnLib.Dynamic.Events;
|
||||
|
||||
public class DisplaySpeciesChangeEvent : IEventData
|
||||
{
|
||||
|
||||
@@ -226,20 +226,20 @@ public class SerializedMoves
|
||||
/// <summary>
|
||||
/// The moves the Pokémon can learn by leveling up.
|
||||
/// </summary>
|
||||
public SerializedLevelMove[]? LevelMoves { get; set; } = null!;
|
||||
public SerializedLevelMove[]? LevelMoves { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The moves the Pokémon can learn by breeding.
|
||||
/// </summary>
|
||||
public string[]? EggMoves { get; set; } = null!;
|
||||
public string[]? EggMoves { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The moves the Pokémon can learn by tutoring.
|
||||
/// </summary>
|
||||
public string[]? TutorMoves { get; set; } = null!;
|
||||
public string[]? TutorMoves { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The moves the Pokémon can learn by TM.
|
||||
/// </summary>
|
||||
public string[]? Machine { get; set; } = null!;
|
||||
public string[]? Machine { get; set; }
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using PkmnLib.Dynamic.AI.Explicit;
|
||||
using PkmnLib.Dynamic.Plugins;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Static.Libraries;
|
||||
|
||||
namespace PkmnLib.Dynamic.Libraries;
|
||||
|
||||
@@ -136,7 +136,7 @@ public interface IBattle : IScriptSource, IDeepCloneable, IDisposable
|
||||
/// <summary>
|
||||
/// Sets the current weather for the battle. If null is passed, this clears the weather.
|
||||
/// A duration can be passed to set the duration of the weather in turns. This duration can be modified by
|
||||
/// other scripts before the weather is set through the <see cref="Script.ChangeWeatherDuration"/> script hook.
|
||||
/// other scripts before the weather is set through the <see cref="IScriptChangeWeatherDuration"/> script hook.
|
||||
/// </summary>
|
||||
bool SetWeather(StringKey? weatherName, int duration, EventBatchId batchId = default);
|
||||
|
||||
@@ -369,18 +369,18 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
|
||||
return true;
|
||||
|
||||
bool IsValidForForcedTurn(ITurnChoice forcedChoice, ITurnChoice choiceToCheck)
|
||||
bool IsValidForForcedTurn(ITurnChoice forcedChoiceInner, ITurnChoice choiceToCheck)
|
||||
{
|
||||
// If the forced choice is a move choice, we can only use it if the move is the same
|
||||
if (forcedChoice is IMoveChoice forcedMove && choiceToCheck is IMoveChoice moveChoice)
|
||||
if (forcedChoiceInner is IMoveChoice forcedMove && choiceToCheck is IMoveChoice moveChoiceInner)
|
||||
{
|
||||
return forcedMove.ChosenMove.MoveData.Name == moveChoice.ChosenMove.MoveData.Name;
|
||||
return forcedMove.ChosenMove.MoveData.Name == moveChoiceInner.ChosenMove.MoveData.Name;
|
||||
}
|
||||
if (forcedChoice is IPassChoice && choiceToCheck is IPassChoice)
|
||||
if (forcedChoiceInner is IPassChoice && choiceToCheck is IPassChoice)
|
||||
{
|
||||
return true; // Both are pass choices, so they are valid
|
||||
}
|
||||
return forcedChoice.Equals(choiceToCheck);
|
||||
return forcedChoiceInner.Equals(choiceToCheck);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
/// <inheritdoc cref="BattleChoiceQueue"/>
|
||||
public BattleChoiceQueue(ITurnChoice[] choices)
|
||||
{
|
||||
Array.Sort(choices, TurnChoiceComparer.Instance!);
|
||||
Array.Sort(choices, TurnChoiceComparer.Instance);
|
||||
_choices = choices;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
/// </summary>
|
||||
public void Remove(ITurnChoice choice)
|
||||
{
|
||||
var index = Array.FindIndex(_choices, _currentIndex, x => x == choice);
|
||||
var index = Array.FindIndex(_choices, _currentIndex, x => Equals(x, choice));
|
||||
if (index == -1)
|
||||
return;
|
||||
_choices[index] = null;
|
||||
|
||||
@@ -47,5 +47,6 @@ public class FleeTurnChoice : TurnChoice, IFleeChoice
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() =>
|
||||
// ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
||||
User?.GetHashCode() ?? 0;
|
||||
}
|
||||
@@ -51,5 +51,6 @@ public class PassChoice : TurnChoice, IPassChoice
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() =>
|
||||
// ReSharper disable once ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
||||
User?.GetHashCode() ?? 0;
|
||||
}
|
||||
@@ -60,5 +60,6 @@ public class SwitchChoice : TurnChoice, ISwitchChoice
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() =>
|
||||
// ReSharper disable twice ConditionalAccessQualifierIsNonNullableAccordingToAPIContract
|
||||
User?.GetHashCode() ?? 0 ^ SwitchTo?.GetHashCode() ?? 0;
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Moves;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace PkmnLib.Dynamic.ScriptHandling;
|
||||
public class ScriptIterator : IEnumerable<ScriptContainer>
|
||||
{
|
||||
private readonly IReadOnlyList<IEnumerable<ScriptContainer>> _scripts;
|
||||
private int _currentIndex = 0;
|
||||
private int _currentIndex;
|
||||
|
||||
/// <inheritdoc cref="ScriptIterator"/>
|
||||
public ScriptIterator(IReadOnlyList<IEnumerable<ScriptContainer>> scripts)
|
||||
|
||||
Reference in New Issue
Block a user