using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "ice_fang")]
public class IceFang : Script, IScriptOnSecondaryEffect
{
///
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target;
if (battleData == null)
return;
var random = battleData.Battle.Random;
if (random.EffectChance(10, move, target, hit))
{
target.SetStatus(ScriptUtils.ResolveName(), move.User);
}
// It also has an independent 10% chance of causing the target to flinch, if the user attacks before the target.
var choiceQueue = battleData.Battle.ChoiceQueue;
if (choiceQueue?.FirstOrDefault(x => x.User == target) != null)
{
if (random.EffectChance(10, move, target, hit))
{
target.Volatile.Add(new FlinchEffect());
}
}
}
}