Getting started with implementing an explicit AI, based on the Essentials one.
All checks were successful
Build / Build (push) Successful in 1m2s
All checks were successful
Build / Build (push) Successful in 1m2s
This commit is contained in:
59
PkmnLib.Dynamic/AI/AIHelpers.cs
Normal file
59
PkmnLib.Dynamic/AI/AIHelpers.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Moves;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.AI;
|
||||
|
||||
public static class AIHelpers
|
||||
{
|
||||
public static uint CalculateDamageEstimation(IMoveData move, IPokemon user, IPokemon target,
|
||||
IDynamicLibrary library)
|
||||
{
|
||||
var hitData = new CustomHitData
|
||||
{
|
||||
BasePower = move.BasePower,
|
||||
Effectiveness = library.StaticLibrary.Types.GetEffectiveness(move.MoveType, target.Types),
|
||||
Type = move.MoveType,
|
||||
};
|
||||
return library.DamageCalculator.GetDamage(null, move.Category, user, target, 1, 0, hitData);
|
||||
}
|
||||
|
||||
private class CustomHitData : IHitData
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool IsCritical => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ushort BasePower { get; init; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public float Effectiveness { get; init; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public uint Damage => 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public TypeIdentifier? Type { get; init; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsContact => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasFailed => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Fail()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetFlag(StringKey flag)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasFlag(StringKey flag) => false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user