Fixes several moves
This commit is contained in:
parent
00fe08dcd4
commit
0669f15a98
|
@ -58,7 +58,7 @@ public class ScriptRegistry
|
|||
var constructor = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
|
||||
null, Type.EmptyTypes, null);
|
||||
if (constructor == null)
|
||||
throw new ArgumentException($"Type {type} does not have a parameterless constructor.");
|
||||
return;
|
||||
|
||||
// We create a lambda that creates a new instance of the script type.
|
||||
// This is more performant than using Activator.CreateInstance.
|
||||
|
|
|
@ -307,7 +307,7 @@
|
|||
"category": "status",
|
||||
"flags": [],
|
||||
"effect": {
|
||||
"name": "SwapWithTarget"
|
||||
"name": "ally_switch"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -644,7 +644,7 @@
|
|||
"mirror"
|
||||
],
|
||||
"effect": {
|
||||
"name": "double_power_user_damaged_by_target_in_turn"
|
||||
"name": "double_power_if_target_damaged_in_turn"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2371,7 +2371,7 @@
|
|||
"mirror"
|
||||
],
|
||||
"effect": {
|
||||
"name": "raise_user_defense",
|
||||
"name": "change_user_defense",
|
||||
"chance": 50,
|
||||
"parameters": {
|
||||
"amount": 2
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Tests.Integration;
|
||||
|
||||
namespace PkmnLib.Tests.DataTests;
|
||||
|
||||
public class MoveDataTests
|
||||
{
|
||||
[Test]
|
||||
public async Task AllMoveEffectsHaveValidScripts()
|
||||
{
|
||||
var library = LibraryHelpers.LoadLibrary();
|
||||
var moveLibrary = library.StaticLibrary.Moves;
|
||||
foreach (var move in moveLibrary)
|
||||
{
|
||||
if (move.SecondaryEffect == null)
|
||||
continue;
|
||||
var scriptName = move.SecondaryEffect.Name;
|
||||
|
||||
try
|
||||
{
|
||||
await Assert.That(library.ScriptResolver.TryResolve(ScriptCategory.Move, scriptName,
|
||||
move.SecondaryEffect.Parameters, out var script)).IsTrue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new AggregateException($"Failed to resolve script for move {move.Name} with effect {scriptName}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "ally_switch")]
|
||||
public class AllySwitch : Script
|
||||
{
|
||||
// TODO: Implement the AllySwitch script.
|
||||
}
|
|
@ -3,6 +3,7 @@ using PkmnLib.Static;
|
|||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "belch")]
|
||||
public class Belch : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ChangeAllTargetStats : Script
|
|||
{
|
||||
throw new ArgumentException("Parameter 'amount' is required.");
|
||||
}
|
||||
_amount = (sbyte)amount;
|
||||
_amount = (sbyte)(int)amount;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class ChangeTargetStats : Script
|
|||
throw new ArgumentException("Parameter 'amount' is required.");
|
||||
}
|
||||
|
||||
_amount = (sbyte)amount;
|
||||
_amount = (sbyte)(int)amount;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class ChangeUserStats : Script
|
|||
throw new ArgumentException("Parameter 'amount' is required.");
|
||||
}
|
||||
|
||||
_amount = (sbyte)amount;
|
||||
_amount = (sbyte)(int)amount;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -7,10 +7,6 @@ public class BindEffect : Script
|
|||
private int _turns;
|
||||
private readonly float _percentOfMaxHealth;
|
||||
|
||||
private BindEffect(float percentOfMaxHealth)
|
||||
{
|
||||
_percentOfMaxHealth = percentOfMaxHealth;
|
||||
}
|
||||
|
||||
public BindEffect(IPokemon owner, int turns, float percentOfMaxHealth)
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ public class DoomDesireEffect : Script
|
|||
}
|
||||
}
|
||||
|
||||
private readonly IBattleSide _side;
|
||||
private readonly IBattleSide? _side;
|
||||
private List<Target> _targets = new();
|
||||
|
||||
public DoomDesireEffect(IBattleSide side)
|
||||
|
@ -40,6 +40,9 @@ public class DoomDesireEffect : Script
|
|||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_side == null)
|
||||
return;
|
||||
|
||||
var toRemove = new List<Target>();
|
||||
foreach (var v in _targets)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue