First couple abilities implemented
All checks were successful
Build / Build (push) Successful in 48s
All checks were successful
Build / Build (push) Successful in 48s
This commit is contained in:
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/BadDreams.cs
Normal file
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/BadDreams.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
[Script(ScriptCategory.Ability, "bad_dreams")]
|
||||
public class BadDreams : Script
|
||||
{
|
||||
private IPokemon? _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
throw new InvalidOperationException("Bad Dreams ability can only be added to a Pokemon.");
|
||||
_owner = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_owner is null)
|
||||
return;
|
||||
var opponents = battle.Sides.Where(x => x != _owner?.BattleData?.BattleSide).SelectMany(x => x.Pokemon)
|
||||
.WhereNotNull();
|
||||
|
||||
foreach (var opponent in opponents)
|
||||
{
|
||||
if (!opponent.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()))
|
||||
continue;
|
||||
EventBatchId batchId = new();
|
||||
battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
opponent.Damage(opponent.MaxHealth / 8, DamageSource.Misc, batchId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user