Bunch more moves, changes in how additional information for items works.
This commit is contained in:
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/MirrorMove.cs
Normal file
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/MirrorMove.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "mirror_move")]
|
||||
public class MirrorMove : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMove(IMoveChoice choice, ref StringKey moveName)
|
||||
{
|
||||
var battleData = choice.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var battle = battleData.Battle;
|
||||
var currentTurn = battle.ChoiceQueue!.LastRanChoice;
|
||||
var lastMove = battle.PreviousTurnChoices.SelectMany(x => x).OfType<IMoveChoice>()
|
||||
.TakeWhile(x => x != currentTurn).LastOrDefault(x => x.TargetPosition == choice.TargetPosition &&
|
||||
x.TargetSide == choice.TargetSide &&
|
||||
x.User.BattleData?.IsOnBattlefield == true);
|
||||
if (lastMove == null || !lastMove.ChosenMove.MoveData.CanCopyMove())
|
||||
{
|
||||
choice.Fail();
|
||||
return;
|
||||
}
|
||||
moveName = lastMove.ChosenMove.MoveData.Name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user