44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using PkmnLibSharp.Utilities;
|
|
|
|
namespace PkmnLibSharp.Battling.ChoiceTurn
|
|
{
|
|
public abstract class BaseTurnChoice : PointerWrapper
|
|
{
|
|
protected BaseTurnChoice(IntPtr ptr) : base(ptr){}
|
|
|
|
public static BaseTurnChoice GetFromPointer(IntPtr ptr)
|
|
{
|
|
var kind = (TurnChoiceKind) Creaturelib.Generated.BaseTurnChoice.GetKind(ptr);
|
|
switch (kind)
|
|
{
|
|
case TurnChoiceKind.Attack:
|
|
return new MoveTurnChoice(ptr);
|
|
case TurnChoiceKind.Switch:
|
|
return new SwitchTurnChoice(ptr);
|
|
case TurnChoiceKind.Flee:
|
|
return new FleeTurnChoice(ptr);
|
|
default:
|
|
throw new ArgumentOutOfRangeException();
|
|
}
|
|
}
|
|
|
|
public TurnChoiceKind Kind => (TurnChoiceKind) Creaturelib.Generated.BaseTurnChoice.GetKind(Ptr);
|
|
|
|
|
|
public Pokemon User
|
|
{
|
|
get
|
|
{
|
|
if (_user != null) return _user;
|
|
var ptr = Creaturelib.Generated.BaseTurnChoice.GetUser(Ptr);
|
|
if (TryResolvePointer(ptr, out _user))
|
|
return _user!;
|
|
_user = Constructor.Active.ConstructPokemon(ptr)!;
|
|
return _user;
|
|
}
|
|
}
|
|
|
|
private Pokemon? _user;
|
|
}
|
|
} |