Even more moves

This commit is contained in:
2025-04-19 13:01:10 +02:00
parent c22ad1a793
commit 807acf1947
19 changed files with 505 additions and 19 deletions

View File

@@ -99,8 +99,39 @@ public class BattleChoiceQueue : IDeepCloneable
return true;
}
/// <summary>
/// This moves the choice of a specific Pokémon to the end of the queue, making it the last choice to be executed.
/// </summary>
/// <returns>
/// Returns true if the Pokémon was found and moved, false otherwise.
/// </returns>
public bool MovePokemonChoiceLast(IPokemon pokemon)
{
var index = Array.FindIndex(_choices, _currentIndex, choice => choice?.User == pokemon);
if (index == -1)
return false;
var choice = _choices[index];
_choices[index] = null;
// Put all choices after the index of the choice forward
for (var i = index; i < _choices.Length - 1; i++)
_choices[i] = _choices[i + 1];
// And insert the choice at the end
_choices[^1] = choice;
return true;
}
internal IReadOnlyList<ITurnChoice?> GetChoices() => _choices;
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) =>
_choices.WhereNotNull().FirstOrDefault(predicate);
_choices.Skip(_currentIndex).WhereNotNull().FirstOrDefault(predicate);
public void Remove(ITurnChoice choice)
{
var index = Array.FindIndex(_choices, _currentIndex, x => x == choice);
if (index == -1)
return;
_choices[index] = null;
for (var i = index; i > _currentIndex; i--)
_choices[i] = _choices[i - 1];
}
}

View File

@@ -45,6 +45,8 @@ internal static class MoveTurnExecutor
var targets =
TargetResolver.ResolveTargets(battle, moveChoice.TargetSide, moveChoice.TargetPosition, targetType);
moveChoice.RunScriptHook(x => x.ChangeTargets(moveChoice, ref targets));
var targetSide = battle.Sides[moveChoice.TargetSide];
targetSide.RunScriptHook(x => x.ChangeIncomingTargets(moveChoice, ref targets));
byte numberOfHits = 1;
moveChoice.RunScriptHook(x => x.ChangeNumberOfHits(moveChoice, ref numberOfHits));

View File

@@ -140,6 +140,10 @@ public abstract class Script : IDeepCloneable
{
}
public virtual void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
}
/// <summary>
/// This function allows you to change a move into a multi-hit move. The number of hits set here
/// gets used as the number of hits. If set to 0, this will behave as if the move missed on its