Begin work on outlining dynamic side
This commit is contained in:
30
PkmnLib.Dynamic/Libraries/BattleStatCalculator.cs
Normal file
30
PkmnLib.Dynamic/Libraries/BattleStatCalculator.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Dynamic.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// A battle stat calculator is used to calculate stats for a Pokemon.
|
||||
/// </summary>
|
||||
public interface IBattleStatCalculator
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculate all the flat stats of a Pokemon, disregarding stat boosts.
|
||||
/// </summary>
|
||||
void CalculateFlatStats(IPokemon pokemon, StatisticSet<uint> stats);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate a single flat stat of a Pokemon, disregarding stat boosts.
|
||||
/// </summary>
|
||||
uint CalculateFlatStat(IPokemon pokemon, Statistic stat);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate all the boosted stats of a Pokemon, including stat boosts.
|
||||
/// </summary>
|
||||
void CalculateBoostedStats(IPokemon pokemon, StatisticSet<uint> stats);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate a single boosted stat of a Pokemon, including stat boosts.
|
||||
/// </summary>
|
||||
uint CalculateBoostedStat(IPokemon pokemon, Statistic stat);
|
||||
}
|
||||
24
PkmnLib.Dynamic/Libraries/DamageCalculator.cs
Normal file
24
PkmnLib.Dynamic/Libraries/DamageCalculator.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
|
||||
namespace PkmnLib.Dynamic.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// A damage library holds the functions related to the calculation of damage.
|
||||
/// </summary>
|
||||
public interface IDamageCalculator
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculate the damage for a given hit on a Pokemon.
|
||||
/// </summary>
|
||||
uint GetDamage(IExecutingMove executingMove, IPokemon target, byte hitNumber, HitData hitData);
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the base power for a given hit on a Pokemon.
|
||||
/// </summary>
|
||||
byte GetBasePower(IExecutingMove executingMove, IPokemon target, byte hitNumber, HitData hitData);
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether a specified hit should be critical or not.
|
||||
/// </summary>
|
||||
bool IsCritical(IBattle battle, IExecutingMove executingMove, IPokemon target, byte hitNumber);
|
||||
}
|
||||
55
PkmnLib.Dynamic/Libraries/DynamicLibrary.cs
Normal file
55
PkmnLib.Dynamic/Libraries/DynamicLibrary.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using PkmnLib.Static.Libraries;
|
||||
|
||||
namespace PkmnLib.Dynamic.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// The dynamic library stores a static data library, as well as holding different libraries and
|
||||
/// calculators that might be customized between different generations and implementations.
|
||||
/// </summary>
|
||||
public interface IDynamicLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// The static data is the immutable storage data for this library.
|
||||
/// </summary>
|
||||
IStaticLibrary StaticLibrary { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The stat calculator deals with the calculation of flat and boosted stats, based on the
|
||||
/// Pokémon's attributes.
|
||||
/// </summary>
|
||||
IBattleStatCalculator StatCalculator { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The damage calculator deals with the calculation of things relating to damage.
|
||||
/// </summary>
|
||||
IDamageCalculator DamageCalculator { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Misc Library holds minor functions that do not fall in any of the other libraries and
|
||||
/// calculators.
|
||||
/// </summary>
|
||||
IMiscLibrary MiscLibrary { get; }
|
||||
}
|
||||
|
||||
public class DynamicLibraryImpl : IDynamicLibrary
|
||||
{
|
||||
public DynamicLibraryImpl(IStaticLibrary staticLibrary, IBattleStatCalculator statCalculator,
|
||||
IDamageCalculator damageCalculator, IMiscLibrary miscLibrary)
|
||||
{
|
||||
StaticLibrary = staticLibrary;
|
||||
StatCalculator = statCalculator;
|
||||
DamageCalculator = damageCalculator;
|
||||
MiscLibrary = miscLibrary;
|
||||
}
|
||||
|
||||
public IStaticLibrary StaticLibrary { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IBattleStatCalculator StatCalculator { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IDamageCalculator DamageCalculator { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IMiscLibrary MiscLibrary { get; }
|
||||
}
|
||||
19
PkmnLib.Dynamic/Libraries/MiscLibrary.cs
Normal file
19
PkmnLib.Dynamic/Libraries/MiscLibrary.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Dynamic.Libraries;
|
||||
|
||||
public interface IMiscLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the choice that's used when a Pokemon is unable to make the move choice it wants to, or when it has no
|
||||
/// moves left, yet wants to make a move.
|
||||
/// </summary>
|
||||
ITurnChoice ReplacementChoice(IPokemon user, byte targetSide, byte targetPosition);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current time of day for the battle.
|
||||
/// </summary>
|
||||
TimeOfDay GetTimeOfDay();
|
||||
}
|
||||
Reference in New Issue
Block a user