More moves implemented
This commit is contained in:
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Encore.cs
Normal file
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Encore.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "encore")]
|
||||
public class Encore : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var battle = target.BattleData?.Battle;
|
||||
if (battle == null)
|
||||
return;
|
||||
|
||||
var currentTurn = battle.ChoiceQueue!.LastRanChoice;
|
||||
var lastMove = battle.PreviousTurnChoices
|
||||
.SelectMany(x => x)
|
||||
.OfType<IMoveChoice>()
|
||||
.TakeWhile(x => x != currentTurn)
|
||||
.LastOrDefault(x => x.User == target);
|
||||
if (lastMove == null)
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
|
||||
var effect = new EncoreEffect(target, lastMove.ChosenMove.MoveData.Name, 3);
|
||||
target.Volatile.Add(effect);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user