Implements several more moves

This commit is contained in:
2025-01-10 13:45:29 +01:00
parent 0ad692a921
commit ecdc9c7654
12 changed files with 206 additions and 16 deletions

View File

@@ -8,10 +8,15 @@ namespace PkmnLib.Dynamic.Events;
/// For example, when a Pokemon gets hurt by poison, we want to show the purple poison animation and the damage at the
/// same time. This is done by batching the events together.
/// </remarks>
public readonly record struct EventBatchId()
public readonly record struct EventBatchId
{
public EventBatchId()
{
Id = Guid.NewGuid();
}
/// <summary>
/// The unique identifier for this batch of events.
/// </summary>
public Guid Id { get; init; } = Guid.NewGuid();
public Guid Id { get; init; }
}

View File

@@ -242,6 +242,8 @@ public class BattleImpl : ScriptSource, IBattle
if (!TargetResolver.IsValidTarget(moveChoice.TargetSide, moveChoice.TargetPosition,
moveChoice.ChosenMove.MoveData.Target, moveChoice.User))
return false;
var preventMove = false;
choice.RunScriptHook(script => script.PreventMoveSelection(moveChoice, ref preventMove));
}
return true;

View File

@@ -295,7 +295,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// <summary>
/// Damages the Pokemon by a certain amount of damage, from a damage source.
/// </summary>
void Damage(uint damage, DamageSource source, EventBatchId batchId);
void Damage(uint damage, DamageSource source, EventBatchId batchId = default);
/// <summary>
/// Heals the Pokemon by a specific amount. Unless allow_revive is set to true, this will not
@@ -389,6 +389,16 @@ public interface IPokemonBattleData : IDeepCloneable
/// Adds an opponent to the list of seen opponents.
/// </summary>
void MarkOpponentAsSeen(IPokemon opponent);
/// <summary>
/// A list of items the Pokémon has consumed this battle.
/// </summary>
IReadOnlyList<IItem> ConsumedItems { get; }
/// <summary>
/// Marks an item as consumed.
/// </summary>
void MarkItemAsConsumed(IItem itemName);
}
/// <inheritdoc cref="IPokemon"/>
@@ -1062,4 +1072,15 @@ public class PokemonBattleDataImpl : IPokemonBattleData
{
_seenOpponents.Add(opponent);
}
private readonly List<IItem> _consumedItems = [];
/// <inheritdoc />
public IReadOnlyList<IItem> ConsumedItems => _consumedItems;
/// <inheritdoc />
public void MarkItemAsConsumed(IItem itemName)
{
_consumedItems.Add(itemName);
}
}

View File

@@ -76,6 +76,13 @@ public abstract class Script : IDeepCloneable
public virtual void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
{
}
/// <summary>
/// Override to customize whether the move can be selected at all.
/// </summary>
public virtual void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
}
/// <summary>
/// This function is ran just before the start of the turn. Everyone has made its choices here,