More moves, allow for typeless moves
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using PkmnLib.Dynamic.Events;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models;
|
||||
@@ -130,6 +131,21 @@ public interface IBattleSide : IScriptSource, IDeepCloneable
|
||||
/// Gets a random Pokémon on the given side.
|
||||
/// </summary>
|
||||
byte GetRandomPosition();
|
||||
|
||||
/// <summary>
|
||||
/// Marks an item as consumed for a position. Can be used by moves such as Recycle to get the item back.
|
||||
/// </summary>
|
||||
void SetConsumedItem(byte battleDataPosition, IItem heldItem);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the last consumed item for a position. Can be used by moves such as Recycle to get the item back.
|
||||
/// </summary>
|
||||
IItem? GetLastConsumedItem(byte battleDataPosition);
|
||||
|
||||
void MarkFaint(byte position);
|
||||
|
||||
uint? GetLastFaintTurn(byte position);
|
||||
uint? GetLastFaintTurn();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IBattleSide"/>
|
||||
@@ -302,6 +318,42 @@ public class BattleSideImpl : ScriptSource, IBattleSide
|
||||
/// <inheritdoc />
|
||||
public byte GetRandomPosition() => (byte)Battle.Random.GetInt(0, NumberOfPositions);
|
||||
|
||||
private Dictionary<byte, IItem>? _lastConsumedItems;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetConsumedItem(byte battleDataPosition, IItem heldItem)
|
||||
{
|
||||
_lastConsumedItems ??= new Dictionary<byte, IItem>();
|
||||
_lastConsumedItems[battleDataPosition] = heldItem;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IItem? GetLastConsumedItem(byte battleDataPosition) =>
|
||||
_lastConsumedItems?.GetValueOrDefault(battleDataPosition);
|
||||
|
||||
private Dictionary<byte, uint>? _lastFaintTurn;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void MarkFaint(byte position)
|
||||
{
|
||||
_lastFaintTurn ??= new Dictionary<byte, uint>();
|
||||
_lastFaintTurn[position] = Battle.CurrentTurnNumber;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public uint? GetLastFaintTurn(byte position)
|
||||
{
|
||||
if (_lastFaintTurn is null)
|
||||
return null;
|
||||
if (_lastFaintTurn.TryGetValue(position, out var turn))
|
||||
return turn;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public uint? GetLastFaintTurn() =>
|
||||
_lastFaintTurn?.Values.Max() ?? null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int ScriptCount => 1 + Battle.ScriptCount;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user