More moves implemented
This commit is contained in:
41
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Counter.cs
Normal file
41
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Counter.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "counter")]
|
||||
public class Counter : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnBeforeTurnStart(ITurnChoice choice)
|
||||
{
|
||||
choice.User.Volatile.Add(new CounterHelperEffect());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
{
|
||||
var counterHelper = moveChoice.User.Volatile.Get<CounterHelperEffect>();
|
||||
var lastHitBy = counterHelper?.LastHitBy;
|
||||
if (lastHitBy == null)
|
||||
{
|
||||
moveChoice.Fail();
|
||||
return;
|
||||
}
|
||||
targets = [lastHitBy];
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
var counterHelper = move.User.Volatile.Get<CounterHelperEffect>();
|
||||
if (counterHelper == null || counterHelper.LastHitBy == null || counterHelper.LastHitBy != target)
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
var lastDamage = counterHelper.LastDamage;
|
||||
damage = lastDamage.MultiplyOrMax(2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user