Style cleanup
This commit is contained in:
@@ -12,7 +12,7 @@ internal static class MoveTurnExecutor
|
||||
{
|
||||
var chosenMove = moveChoice.ChosenMove;
|
||||
var moveData = chosenMove.MoveData;
|
||||
|
||||
|
||||
var moveDataName = moveData.Name;
|
||||
moveChoice.RunScriptHook(x => x.ChangeMove(moveChoice, ref moveDataName));
|
||||
if (moveData.Name != moveDataName)
|
||||
@@ -31,11 +31,11 @@ internal static class MoveTurnExecutor
|
||||
moveChoice.Script.Set(script);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var targetType = moveData.Target;
|
||||
var targets = TargetResolver.ResolveTargets(battle, moveChoice.TargetSide, moveChoice.TargetPosition, targetType);
|
||||
var targets =
|
||||
TargetResolver.ResolveTargets(battle, moveChoice.TargetSide, moveChoice.TargetPosition, targetType);
|
||||
moveChoice.RunScriptHook(x => x.ChangeTargets(moveChoice, ref targets));
|
||||
|
||||
byte numberOfHits = 1;
|
||||
@@ -46,7 +46,7 @@ internal static class MoveTurnExecutor
|
||||
}
|
||||
|
||||
var executingMove = new ExecutingMoveImpl(targets, numberOfHits, chosenMove, moveData, moveChoice);
|
||||
|
||||
|
||||
var prevented = false;
|
||||
executingMove.RunScriptHook(x => x.PreventMove(executingMove, ref prevented));
|
||||
if (prevented)
|
||||
@@ -56,9 +56,9 @@ internal static class MoveTurnExecutor
|
||||
// TODO: Modify the PP used by the move.
|
||||
if (!executingMove.ChosenMove.TryUse(ppUsed))
|
||||
return;
|
||||
|
||||
|
||||
battle.EventHook.Invoke(new MoveUseEvent(executingMove));
|
||||
|
||||
|
||||
var failed = false;
|
||||
executingMove.RunScriptHook(x => x.FailMove(executingMove, ref failed));
|
||||
if (failed)
|
||||
@@ -66,12 +66,12 @@ internal static class MoveTurnExecutor
|
||||
// TODO: fail handling
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var stopped = false;
|
||||
executingMove.RunScriptHook(x => x.StopBeforeMove(executingMove, ref stopped));
|
||||
if (stopped)
|
||||
return;
|
||||
|
||||
|
||||
executingMove.RunScriptHook(x => x.OnBeforeMove(executingMove));
|
||||
foreach (var target in targets.WhereNotNull())
|
||||
{
|
||||
@@ -88,7 +88,7 @@ internal static class MoveTurnExecutor
|
||||
// TODO: fail handling
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var isInvulnerable = false;
|
||||
target.RunScriptHook(x => x.IsInvulnerableToMove(executingMove, target, ref isInvulnerable));
|
||||
if (isInvulnerable)
|
||||
@@ -96,7 +96,7 @@ internal static class MoveTurnExecutor
|
||||
// TODO: event?
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var numberOfHits = executingMove.NumberOfHits;
|
||||
var targetHitStat = executingMove.GetTargetIndex(target) * numberOfHits;
|
||||
|
||||
@@ -120,7 +120,7 @@ internal static class MoveTurnExecutor
|
||||
var effectiveness = battle.Library.StaticLibrary.Types.GetEffectiveness(hitType, target.Types);
|
||||
executingMove.RunScriptHook(x => x.ChangeEffectiveness(executingMove, target, hitIndex, ref effectiveness));
|
||||
hitData.Effectiveness = effectiveness;
|
||||
|
||||
|
||||
var blockCritical = false;
|
||||
executingMove.RunScriptHook(x => x.BlockCriticalHit(executingMove, target, hitIndex, ref blockCritical));
|
||||
target.RunScriptHook(x => x.BlockIncomingCriticalHit(executingMove, target, hitIndex, ref blockCritical));
|
||||
@@ -129,10 +129,10 @@ internal static class MoveTurnExecutor
|
||||
var critical = battle.Library.DamageCalculator.IsCritical(battle, executingMove, target, hitIndex);
|
||||
hitData.IsCritical = critical;
|
||||
}
|
||||
|
||||
|
||||
var basePower = battle.Library.DamageCalculator.GetBasePower(executingMove, target, hitIndex, hitData);
|
||||
hitData.BasePower = basePower;
|
||||
|
||||
|
||||
hitData.Damage = battle.Library.DamageCalculator.GetDamage(executingMove, target, hitIndex, hitData);
|
||||
|
||||
var accuracy = useMove.Accuracy;
|
||||
@@ -140,17 +140,17 @@ internal static class MoveTurnExecutor
|
||||
// modifying it.
|
||||
if (accuracy != 255)
|
||||
{
|
||||
accuracy = battle.Library.StatCalculator.CalculateModifiedAccuracy(executingMove, target,
|
||||
hitIndex, accuracy);
|
||||
accuracy = battle.Library.StatCalculator.CalculateModifiedAccuracy(executingMove, target, hitIndex,
|
||||
accuracy);
|
||||
}
|
||||
|
||||
|
||||
if (accuracy < 100 && battle.Random.GetInt(100) >= accuracy)
|
||||
{
|
||||
executingMove.RunScriptHook(x => x.OnMoveMiss(executingMove, target));
|
||||
battle.EventHook.Invoke(new MoveMissEvent(executingMove));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
var blockIncomingHit = false;
|
||||
target.RunScriptHook(x => x.BlockIncomingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||
executingMove.RunScriptHook(x => x.BlockOutgoingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||
@@ -187,7 +187,7 @@ internal static class MoveTurnExecutor
|
||||
BatchId = hitEventBatch,
|
||||
});
|
||||
target.Damage(damage, DamageSource.MoveDamage, hitEventBatch);
|
||||
if (!target.IsFainted)
|
||||
if (!target.IsFainted)
|
||||
target.RunScriptHook(x => x.OnIncomingHit(executingMove, target, hitIndex));
|
||||
else
|
||||
executingMove.RunScriptHook(x => x.OnOpponentFaints(executingMove, target, hitIndex));
|
||||
@@ -198,14 +198,16 @@ internal static class MoveTurnExecutor
|
||||
if (secondaryEffect != null)
|
||||
{
|
||||
var preventSecondary = false;
|
||||
target.RunScriptHook(x => x.PreventSecondaryEffect(executingMove, target, hitIndex, ref preventSecondary));
|
||||
target.RunScriptHook(x =>
|
||||
x.PreventSecondaryEffect(executingMove, target, hitIndex, ref preventSecondary));
|
||||
|
||||
if (!preventSecondary)
|
||||
{
|
||||
var chance = secondaryEffect.Chance;
|
||||
if (chance < 0 || battle.Random.EffectChance(chance, executingMove, target, hitIndex))
|
||||
{
|
||||
executingMove.RunScriptHook(x => x.OnSecondaryEffect(executingMove, target, hitIndex));
|
||||
executingMove.RunScriptHook(x =>
|
||||
x.OnSecondaryEffect(executingMove, target, hitIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +215,7 @@ internal static class MoveTurnExecutor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (numberOfHits == 0)
|
||||
{
|
||||
target.RunScriptHook(x => x.OnMoveMiss(executingMove, target));
|
||||
@@ -224,6 +226,5 @@ internal static class MoveTurnExecutor
|
||||
{
|
||||
executingMove.RunScriptHook(x => x.OnAfterHits(executingMove, target));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,8 @@ public static class TargetResolver
|
||||
return target switch
|
||||
{
|
||||
MoveTarget.Adjacent or MoveTarget.AdjacentAlly or MoveTarget.AdjacentAllySelf or MoveTarget.AdjacentOpponent
|
||||
or MoveTarget.Any or MoveTarget.RandomOpponent
|
||||
or MoveTarget.SelfUse => [battle.GetPokemon(side, position)],
|
||||
or MoveTarget.Any or MoveTarget.RandomOpponent or MoveTarget.SelfUse =>
|
||||
[battle.GetPokemon(side, position)],
|
||||
MoveTarget.All => GetAllTargets(battle),
|
||||
MoveTarget.AllAdjacentOpponent => GetAllAdjacentAndOpponent(battle, side, position),
|
||||
MoveTarget.AllAdjacent => GetAllAdjacent(battle, side, position),
|
||||
@@ -144,7 +144,8 @@ public static class TargetResolver
|
||||
|
||||
return
|
||||
[
|
||||
battle.GetPokemon(side, position), battle.GetPokemon(side, (byte)left), battle.GetPokemon(side, (byte)right),
|
||||
battle.GetPokemon(side, position), battle.GetPokemon(side, (byte)left),
|
||||
battle.GetPokemon(side, (byte)right),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,11 @@ public static class TurnRunner
|
||||
{
|
||||
var queue = battle.ChoiceQueue;
|
||||
if (queue == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(battle.ChoiceQueue),
|
||||
"The battle's choice queue must be set before running a turn.");
|
||||
|
||||
}
|
||||
|
||||
// We are now at the very beginning of a turn. We have assigned speeds and priorities to all
|
||||
// choices, and put them in the correct order.
|
||||
|
||||
@@ -30,7 +32,7 @@ public static class TurnRunner
|
||||
{
|
||||
choice.RunScriptHook(script => script.OnBeforeTurnStart(choice));
|
||||
}
|
||||
|
||||
|
||||
// Now we can properly begin executing choices.
|
||||
// One by one dequeue the turns, and run them. If the battle has ended we do not want to
|
||||
// continue running.
|
||||
@@ -41,7 +43,7 @@ public static class TurnRunner
|
||||
continue;
|
||||
ExecuteChoice(battle, next);
|
||||
}
|
||||
|
||||
|
||||
// If the battle is not ended, we have arrived at the normal end of a turn. and thus want
|
||||
// to run the end turn scripts.
|
||||
|
||||
@@ -122,7 +124,6 @@ public static class TurnRunner
|
||||
userSide.SwapPokemon(battleData.Position, fleeChoice.SwitchTo);
|
||||
}
|
||||
|
||||
|
||||
private static void ExecuteFleeChoice(IBattle battle, IFleeChoice fleeChoice)
|
||||
{
|
||||
var user = fleeChoice.User;
|
||||
@@ -131,7 +132,7 @@ public static class TurnRunner
|
||||
return;
|
||||
if (!battle.CanFlee)
|
||||
return;
|
||||
|
||||
|
||||
var preventFlee = false;
|
||||
fleeChoice.RunScriptHook(script => script.PreventSelfRunAway(fleeChoice, ref preventFlee));
|
||||
if (preventFlee)
|
||||
@@ -148,10 +149,10 @@ public static class TurnRunner
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!battle.Library.MiscLibrary.CanFlee(battle, fleeChoice))
|
||||
return;
|
||||
|
||||
|
||||
var userSide = battle.Sides[battleData.SideIndex];
|
||||
userSide.MarkAsFled();
|
||||
battle.ValidateBattleState();
|
||||
@@ -171,5 +172,4 @@ public static class TurnRunner
|
||||
}
|
||||
itemChoice.Item.RunItemScript(battle.Library.ScriptResolver, target ?? user);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user