This commit is contained in:
@@ -351,6 +351,21 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
if (switchChoice.SwitchTo == switchChoice.User)
|
||||
return false;
|
||||
}
|
||||
else if (choice is IItemChoice itemChoice)
|
||||
{
|
||||
if (!Library.ScriptResolver.TryResolveBattleItemScript(itemChoice.Item, out var itemScript))
|
||||
return false;
|
||||
if (!itemScript.IsItemUsable)
|
||||
return false;
|
||||
if (itemScript.TargetType != ItemTargetType.None)
|
||||
{
|
||||
var target = itemChoice.GetTargetPokemon(this);
|
||||
if (target is null || !itemScript.IsTargetValid(target))
|
||||
return false;
|
||||
if (!itemScript.TargetType.IsValidTarget(this, choice.User, target))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user