More moves implemented
This commit is contained in:
63
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/DoomDesireEffect.cs
Normal file
63
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/DoomDesireEffect.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "doom_desire_effect")]
|
||||
public class DoomDesireEffect : Script
|
||||
{
|
||||
private class Target
|
||||
{
|
||||
public byte Position { get; }
|
||||
public uint Damage { get; }
|
||||
public int Turns { get; set; }
|
||||
|
||||
public Target(byte position, uint damage)
|
||||
{
|
||||
Position = position;
|
||||
Damage = damage;
|
||||
Turns = 3;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IBattleSide _side;
|
||||
private List<Target> _targets = new();
|
||||
|
||||
public DoomDesireEffect(IBattleSide side)
|
||||
{
|
||||
_side = side;
|
||||
}
|
||||
|
||||
public void AddTarget(byte position, uint damage)
|
||||
{
|
||||
_targets.Add(new Target(position, damage));
|
||||
}
|
||||
|
||||
public bool HasTarget(byte position)
|
||||
{
|
||||
return _targets.Exists(x => x.Position == position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
var toRemove = new List<Target>();
|
||||
foreach (var v in _targets)
|
||||
{
|
||||
v.Turns--;
|
||||
if (v.Turns == 0)
|
||||
{
|
||||
var pokemon = _side.Pokemon[v.Position];
|
||||
pokemon?.Damage(v.Damage, DamageSource.Misc);
|
||||
toRemove.Add(v);
|
||||
}
|
||||
}
|
||||
foreach (var v in toRemove)
|
||||
{
|
||||
_targets.Remove(v);
|
||||
}
|
||||
if (_targets.Count == 0)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user