More moves implemented
This commit is contained in:
@@ -383,13 +383,14 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Weather, weatherName.Value, null, out var script))
|
||||
throw new InvalidOperationException($"Weather script {weatherName} not found.");
|
||||
|
||||
if (script is IWeatherScript weatherScript)
|
||||
if (script is ILimitedTurnsScript weatherScript)
|
||||
{
|
||||
this.RunScriptHook(x => x.ChangeWeatherDuration(weatherName.Value, ref duration));
|
||||
weatherScript.SetTurns(duration);
|
||||
}
|
||||
|
||||
_weatherScript.Set(script);
|
||||
script.OnAddedToParent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -415,6 +416,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Terrain, terrainName.Value, null, out var script))
|
||||
throw new InvalidOperationException($"Terrain script {terrainName} not found.");
|
||||
_terrainScript.Set(script);
|
||||
script.OnAddedToParent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.Models.BattleFlow;
|
||||
|
||||
internal static class MoveTurnExecutor
|
||||
public static class MoveTurnExecutor
|
||||
{
|
||||
internal static void ExecuteMoveChoice(IBattle battle, IMoveChoice moveChoice)
|
||||
{
|
||||
@@ -30,6 +30,7 @@ internal static class MoveTurnExecutor
|
||||
secondaryEffect.Parameters, out var script))
|
||||
{
|
||||
moveChoice.Script.Set(script);
|
||||
script.OnAddedToParent(moveChoice);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -77,16 +78,20 @@ internal static class MoveTurnExecutor
|
||||
// TODO: fail handling
|
||||
return;
|
||||
}
|
||||
ExecuteMove(executingMove);
|
||||
}
|
||||
|
||||
public static void ExecuteMove(IExecutingMove executingMove)
|
||||
{
|
||||
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())
|
||||
foreach (var target in executingMove.Targets.WhereNotNull())
|
||||
{
|
||||
ExecuteMoveChoiceForTarget(battle, executingMove, target);
|
||||
ExecuteMoveChoiceForTarget(executingMove.Battle, executingMove, target);
|
||||
}
|
||||
executingMove.RunScriptHook(x => x.OnAfterMove(executingMove));
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class MoveChoice : TurnChoice, IMoveChoice
|
||||
secondaryEffect.Parameters, out var script))
|
||||
{
|
||||
Script.Set(script);
|
||||
script.OnAddedToParent(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,6 +553,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
out var statusScript))
|
||||
throw new KeyNotFoundException($"Status script {serializedPokemon.Status} not found");
|
||||
StatusScript.Set(statusScript);
|
||||
statusScript.OnAddedToParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,6 +927,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
out var abilityScript))
|
||||
{
|
||||
AbilityScript.Set(abilityScript);
|
||||
abilityScript.OnAddedToParent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1099,12 +1101,17 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
{
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
|
||||
throw new KeyNotFoundException($"Status script {status} not found");
|
||||
|
||||
if (!StatusScript.IsEmpty)
|
||||
return false;
|
||||
|
||||
var preventStatus = false;
|
||||
this.RunScriptHook(script => script.PreventStatusChange(this, status, ref preventStatus));
|
||||
if (preventStatus)
|
||||
return false;
|
||||
|
||||
StatusScript.Set(statusScript);
|
||||
statusScript.OnAddedToParent(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1191,6 +1198,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
out var abilityScript))
|
||||
{
|
||||
AbilityScript.Set(abilityScript);
|
||||
abilityScript.OnAddedToParent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user