Add all missing docs
This commit is contained in:
@@ -93,6 +93,10 @@ public interface IBattle : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
void ValidateBattleState();
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether a Pokemon has a forced turn choice. If it does, this returns true and the choice
|
||||
/// is set in the out parameter. If it does not, this returns false and the out parameter is null.
|
||||
/// </summary>
|
||||
bool HasForcedTurn(IPokemon pokemon, [NotNullWhen(true)] out ITurnChoice? choice);
|
||||
|
||||
/// <summary>
|
||||
@@ -117,6 +121,9 @@ public interface IBattle : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
bool SetWeather(StringKey? weatherName, int duration);
|
||||
|
||||
/// <summary>
|
||||
/// Volatile scripts are scripts that are not permanent and can be removed by other scripts.
|
||||
/// </summary>
|
||||
public IScriptSet Volatile { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -124,8 +131,15 @@ public interface IBattle : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
StringKey? WeatherName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current terrain for the battle. If null is passed, this clears the terrain.
|
||||
/// </summary>
|
||||
/// <param name="terrainName"></param>
|
||||
void SetTerrain(StringKey? terrainName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current terrain of the battle. If no terrain is present, this returns null.
|
||||
/// </summary>
|
||||
StringKey? TerrainName { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -134,6 +148,9 @@ public interface IBattle : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
IReadOnlyList<IReadOnlyList<ITurnChoice>> PreviousTurnChoices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to capture a Pokemon. This will use the current RNG to determine whether the capture is successful.
|
||||
/// </summary>
|
||||
CaptureResult AttempCapture(byte sideIndex, byte position, IItem item);
|
||||
}
|
||||
|
||||
@@ -350,7 +367,11 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
EventHook.Invoke(new EndTurnEvent());
|
||||
}
|
||||
|
||||
private ScriptContainer _weatherScript = new();
|
||||
private readonly ScriptContainer _weatherScript = new();
|
||||
|
||||
/// <summary>
|
||||
/// The script that handles the current weather of the battle.
|
||||
/// </summary>
|
||||
public IReadOnlyScriptContainer WeatherScript => _weatherScript;
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -377,6 +398,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
// TODO: Trigger weather change script hooks
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IScriptSet Volatile { get; } = new ScriptSet();
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -16,6 +16,10 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
{
|
||||
private readonly ITurnChoice?[] _choices;
|
||||
private int _currentIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last choice that was executed.
|
||||
/// </summary>
|
||||
public ITurnChoice? LastRanChoice { get; private set; }
|
||||
|
||||
/// <inheritdoc cref="BattleChoiceQueue"/>
|
||||
@@ -122,9 +126,15 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
|
||||
internal IReadOnlyList<ITurnChoice?> GetChoices() => _choices;
|
||||
|
||||
/// <summary>
|
||||
/// This returns the first choice that matches the predicate, or null if none was found.
|
||||
/// </summary>
|
||||
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) =>
|
||||
_choices.Skip(_currentIndex).WhereNotNull().FirstOrDefault(predicate);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a choice from the queue.
|
||||
/// </summary>
|
||||
public void Remove(ITurnChoice choice)
|
||||
{
|
||||
var index = Array.FindIndex(_choices, _currentIndex, x => x == choice);
|
||||
|
||||
@@ -19,10 +19,18 @@ public interface IBattleRandom : IRandom, IDeepCloneable
|
||||
/// <inheritdoc cref="IBattleRandom"/>
|
||||
public class BattleRandomImpl : RandomImpl, IBattleRandom
|
||||
{
|
||||
/// <inheritdoc cref="BattleRandomImpl"/>
|
||||
/// <remarks>
|
||||
/// This constructor is used to instantiate the class when no seed is provided. It uses a time-dependent default seed value.
|
||||
/// </remarks>
|
||||
public BattleRandomImpl()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BattleRandomImpl"/>
|
||||
/// <remarks>
|
||||
/// This constructor is used to instantiate the class with a specific seed value.
|
||||
/// </remarks>
|
||||
public BattleRandomImpl(int seed) : base(seed)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -142,9 +142,19 @@ public interface IBattleSide : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
IItem? GetLastConsumedItem(byte battleDataPosition);
|
||||
|
||||
/// <summary>
|
||||
/// Marks a Pokémon as fainted. This is used to track the last turn a Pokémon in a position fainted.
|
||||
/// </summary>
|
||||
void MarkFaint(byte position);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last turn a Pokémon in a specific position fainted.
|
||||
/// </summary>
|
||||
uint? GetLastFaintTurn(byte position);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last turn a Pokémon in any position fainted.
|
||||
/// </summary>
|
||||
uint? GetLastFaintTurn();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface IItemChoice : ITurnChoice
|
||||
/// <inheritdoc cref="IItemChoice"/>
|
||||
public class ItemChoice : TurnChoice, IItemChoice
|
||||
{
|
||||
/// <inheritdoc cref="ItemChoice"/>
|
||||
public ItemChoice(IPokemon user, IItem item, byte? targetSide, byte? targetPosition) : base(user)
|
||||
{
|
||||
Item = item;
|
||||
@@ -34,6 +35,9 @@ public class ItemChoice : TurnChoice, IItemChoice
|
||||
TargetPosition = targetPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The item that is used.
|
||||
/// </summary>
|
||||
public IItem Item { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -9,8 +9,10 @@ public interface IPassChoice : ITurnChoice
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IPassChoice"/>
|
||||
public class PassChoice : TurnChoice, IPassChoice
|
||||
{
|
||||
/// <inheritdoc cref="PassChoice"/>
|
||||
public PassChoice(IPokemon user) : base(user)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public interface ISwitchChoice : ITurnChoice
|
||||
/// <inheritdoc cref="ISwitchChoice"/>
|
||||
public class SwitchChoice : TurnChoice, ISwitchChoice
|
||||
{
|
||||
/// <inheritdoc cref="SwitchChoice"/>
|
||||
public SwitchChoice(IPokemon user, IPokemon switchTo) : base(user)
|
||||
{
|
||||
SwitchTo = switchTo;
|
||||
|
||||
@@ -140,8 +140,14 @@ public interface IExecutingMove : IScriptSource
|
||||
/// </summary>
|
||||
IMoveChoice MoveChoice { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns all the hits of this move.
|
||||
/// </summary>
|
||||
IReadOnlyList<IHitData> Hits { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The battle this move is being executed in.
|
||||
/// </summary>
|
||||
IBattle Battle { get; }
|
||||
}
|
||||
|
||||
@@ -189,6 +195,9 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
|
||||
/// <inheritdoc />
|
||||
public ScriptContainer Script => MoveChoice.Script;
|
||||
|
||||
/// <summary>
|
||||
/// The volatile scripts that are applicable to this move.
|
||||
/// </summary>
|
||||
public IScriptSet Volatile => MoveChoice.Volatile;
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -101,6 +101,7 @@ public class LearnedMoveImpl : ILearnedMove
|
||||
CurrentPp = MaxPp;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="LearnedMoveImpl" />
|
||||
public LearnedMoveImpl(IMoveData moveData, MoveLearnMethod learnMethod, byte pp) : this(moveData, learnMethod)
|
||||
{
|
||||
CurrentPp = pp;
|
||||
|
||||
@@ -202,6 +202,9 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
bool IsCaught { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Marks the Pokemon as caught. This makes it so that the Pokemon is not considered valid in battle anymore.
|
||||
/// </summary>
|
||||
public void MarkAsCaught();
|
||||
|
||||
/// <summary>
|
||||
@@ -395,6 +398,9 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
void SetTypes(IReadOnlyList<TypeIdentifier> types);
|
||||
|
||||
/// <summary>
|
||||
/// Changes the ability of the Pokémon.
|
||||
/// </summary>
|
||||
void ChangeAbility(IAbility ability);
|
||||
|
||||
/// <summary>
|
||||
@@ -449,8 +455,14 @@ public interface IPokemonBattleData : IDeepCloneable
|
||||
/// </summary>
|
||||
void MarkItemAsConsumed(IItem item);
|
||||
|
||||
/// <summary>
|
||||
/// The turn the Pokémon switched in.
|
||||
/// </summary>
|
||||
uint SwitchInTurn { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The side the Pokémon is on.
|
||||
/// </summary>
|
||||
IBattleSide BattleSide { get; }
|
||||
}
|
||||
|
||||
@@ -483,6 +495,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
CurrentHealth = BoostedStats.Hp;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="PokemonImpl"/>
|
||||
public PokemonImpl(IDynamicLibrary library, SerializedPokemon serializedPokemon)
|
||||
{
|
||||
Library = library;
|
||||
|
||||
@@ -8,7 +8,14 @@ namespace PkmnLib.Dynamic.Models;
|
||||
/// </summary>
|
||||
public interface IPokemonParty : IReadOnlyList<IPokemon?>, IDeepCloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event that is triggered when a Pokemon is swapped into the party.
|
||||
/// </summary>
|
||||
event EventHandler<(IPokemon?, int index)>? OnSwapInto;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is triggered when two Pokemon are swapped in the party.
|
||||
/// </summary>
|
||||
event EventHandler<(int index1, int index2)>? OnSwap;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -129,22 +129,23 @@ public record SerializedLearnedMove
|
||||
public required byte CurrentPp { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A serialized stats is a representation of a Pokémon's stats that can be easily serialized and deserialized.
|
||||
/// </summary>
|
||||
public record SerializedStats
|
||||
{
|
||||
/// <inheritdoc cref="SerializedStats"/>
|
||||
public SerializedStats()
|
||||
{
|
||||
}
|
||||
|
||||
public SerializedStats(ImmutableStatisticSet<byte> stats)
|
||||
/// <inheritdoc cref="SerializedStats"/>
|
||||
public SerializedStats(ImmutableStatisticSet<byte> stats) : this(stats.Hp, stats.Attack, stats.Defense,
|
||||
stats.SpecialAttack, stats.SpecialDefense, stats.Speed)
|
||||
{
|
||||
Hp = stats.Hp;
|
||||
Attack = stats.Attack;
|
||||
Defense = stats.Defense;
|
||||
SpecialAttack = stats.SpecialAttack;
|
||||
SpecialDefense = stats.SpecialDefense;
|
||||
Speed = stats.Speed;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="SerializedStats"/>
|
||||
public SerializedStats(long hp, long attack, long defense, long specialAttack, long specialDefense, long speed)
|
||||
{
|
||||
Hp = hp;
|
||||
@@ -155,13 +156,39 @@ public record SerializedStats
|
||||
Speed = speed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The health points stat value.
|
||||
/// </summary>
|
||||
public long Hp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The physical attack stat value.
|
||||
/// </summary>
|
||||
public long Attack { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The physical defense stat value.
|
||||
/// </summary>
|
||||
public long Defense { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The special attack stat value.
|
||||
/// </summary>
|
||||
public long SpecialAttack { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The special defense stat value.
|
||||
/// </summary>
|
||||
public long SpecialDefense { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The speed stat value.
|
||||
/// </summary>
|
||||
public long Speed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts the serialized stats to an <see cref="IndividualValueStatisticSet"/>.
|
||||
/// </summary>
|
||||
public IndividualValueStatisticSet ToIndividualValueStatisticSet()
|
||||
{
|
||||
if (Hp < 0 || Attack < 0 || Defense < 0 || SpecialAttack < 0 || SpecialDefense < 0 || Speed < 0)
|
||||
@@ -174,6 +201,10 @@ public record SerializedStats
|
||||
(byte)SpecialDefense, (byte)Speed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the serialized stats to an <see cref="EffortValueStatisticSet"/>.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public EffortValueStatisticSet ToEffortValueStatisticSet()
|
||||
{
|
||||
if (Hp < 0 || Attack < 0 || Defense < 0 || SpecialAttack < 0 || SpecialDefense < 0 || Speed < 0)
|
||||
|
||||
Reference in New Issue
Block a user