Adds a lot more move effects

This commit is contained in:
2025-01-26 11:55:13 +01:00
parent 802481c1f5
commit 549b92048a
75 changed files with 563 additions and 230 deletions

View File

@@ -163,30 +163,13 @@ public static class TurnRunner
var battleData = user.BattleData;
if (battleData == null)
return;
if (!battle.Library.ScriptResolver.TryResolveBattleItemScript(itemChoice.Item, out var itemScript))
{
return;
}
if (!itemScript.IsItemUsable)
return;
itemScript.OnInitialize(itemChoice.Item.BattleEffect!.Parameters);
IPokemon? target = null;
if (itemChoice is { TargetSide: not null, TargetPosition: not null })
{
var side = battle.Sides[itemChoice.TargetSide.Value];
target = side.Pokemon[itemChoice.TargetPosition.Value];
}
var requiresTarget = itemScript.RequiresTarget;
if (requiresTarget)
{
target ??= user;
itemScript.OnUseWithTarget(target);
}
else
{
itemScript.OnUse();
}
itemChoice.Item.RunItemScript(battle.Library.ScriptResolver, target ?? user);
}
}

View File

@@ -313,6 +313,10 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// </summary>
void LearnMove(StringKey moveName, MoveLearnMethod method, byte index);
/// <summary>
/// Checks whether the Pokémon has a specific non-volatile status.
/// </summary>
bool HasStatus(StringKey status);
/// <summary>
/// Adds a non-volatile status to the Pokemon.
/// </summary>
@@ -347,6 +351,17 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// Marks a Pokemon as seen in the battle.
/// </summary>
void MarkOpponentAsSeen(IPokemon pokemon);
/// <summary>
/// Removes a type from the Pokémon. Returns whether the type was removed.
/// </summary>
bool RemoveType(TypeIdentifier type);
/// <summary>
/// Adds a type to the Pokémon. Returns whether the type was added. It will not add the type if
/// the Pokémon already has it.
/// </summary>
bool AddType(TypeIdentifier type);
/// <summary>
/// Converts the data structure to a serializable format.
@@ -639,8 +654,10 @@ public class PokemonImpl : ScriptSource, IPokemon
/// <inheritdoc />
public bool AllowedExperience { get; set; }
private List<TypeIdentifier> _types = new();
/// <inheritdoc />
public IReadOnlyList<TypeIdentifier> Types { get; private set; }
public IReadOnlyList<TypeIdentifier> Types { get => _types; private set => _types = value.ToList(); }
/// <inheritdoc />
public bool IsEgg { get; private set; }
@@ -940,6 +957,9 @@ public class PokemonImpl : ScriptSource, IPokemon
_learnedMoves[index] = new LearnedMoveImpl(move, method);
}
/// <inheritdoc />
public bool HasStatus(StringKey status) => StatusScript.Script?.Name == status;
/// <inheritdoc />
public void SetStatus(StringKey status)
{
@@ -1000,6 +1020,18 @@ public class PokemonImpl : ScriptSource, IPokemon
/// <inheritdoc />
public void MarkOpponentAsSeen(IPokemon pokemon) => BattleData?.MarkOpponentAsSeen(pokemon);
/// <inheritdoc />
public bool RemoveType(TypeIdentifier type) => _types.Remove(type);
/// <inheritdoc />
public bool AddType(TypeIdentifier type)
{
if (_types.Contains(type))
return false;
_types.Add(type);
return true;
}
/// <inheritdoc />
public SerializedPokemon Serialize() => new(this);