This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Static.Moves;
|
||||
|
||||
@@ -132,7 +132,7 @@ public static class MoveTurnExecutor
|
||||
target.RunScriptHook(x => x.IsInvulnerableToMove(executingMove, target, ref isInvulnerable));
|
||||
if (isInvulnerable)
|
||||
{
|
||||
// TODO: event?
|
||||
battle.EventHook.Invoke(new MoveInvulnerableEvent(executingMove, target));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace PkmnLib.Dynamic.Events;
|
||||
|
||||
/// <summary>
|
||||
|
||||
18
PkmnLib.Dynamic/Events/MoveInvulnerableEvent.cs
Normal file
18
PkmnLib.Dynamic/Events/MoveInvulnerableEvent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
|
||||
namespace PkmnLib.Dynamic.Events;
|
||||
|
||||
public class MoveInvulnerableEvent : IEventData
|
||||
{
|
||||
public IExecutingMove ExecutingMove { get; }
|
||||
public IPokemon Target { get; }
|
||||
|
||||
public MoveInvulnerableEvent(IExecutingMove executingMove, IPokemon target)
|
||||
{
|
||||
ExecutingMove = executingMove;
|
||||
Target = target;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public EventBatchId BatchId { get; init; }
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
global using LevelInt = byte;
|
||||
global using JetBrains.Annotations;
|
||||
|
||||
namespace PkmnLib.Dynamic;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Libraries;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Libraries;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.Libraries.DataLoaders.Models;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Libraries;
|
||||
|
||||
@@ -40,6 +40,13 @@ public interface IBattle : IScriptSource, IDeepCloneable, IDisposable
|
||||
/// </summary>
|
||||
byte PositionsPerSide { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the environment the battle is taking place in, such as "grass", "cave", etc.
|
||||
/// This is sometimes referred to as the "terrain" in the games, but is not the same as the
|
||||
/// <see cref="TerrainName"/> which is a battle condition that can be set by scripts.
|
||||
/// </summary>
|
||||
StringKey EnvironmentName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this battle is a wild battle. In a wild battle, the player can catch the opposing Pokemon,
|
||||
/// and moves like roar will end the battle instead of switching out the Pokemon.
|
||||
@@ -173,9 +180,12 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
/// <param name="canFlee">Whether Pokémon are allowed to flee from the battle.</param>
|
||||
/// <param name="numberOfSides">The number of sides in the battle. Generally 2.</param>
|
||||
/// <param name="positionsPerSide">The number of spots there are on each side for Pokémon. 1 for singles, 2 for doubles, etc.</param>
|
||||
/// <param name="isWildBattle">Whether this battle is a wild battle. In a wild battle, the player can catch the opposing Pokémon,
|
||||
/// and moves like roar will end the battle instead of switching out the Pokémon.</param>
|
||||
/// <param name="environmentName">The name of the environment the battle is taking place in, such as "grass", "cave", etc.</param>
|
||||
/// <param name="randomSeed">The seed for the RNG. If null, this uses a time-dependent seed.</param>
|
||||
public BattleImpl(IDynamicLibrary library, IReadOnlyList<IBattleParty> parties, bool canFlee, byte numberOfSides,
|
||||
byte positionsPerSide, bool isWildBattle, int? randomSeed = null)
|
||||
byte positionsPerSide, bool isWildBattle, StringKey environmentName, int? randomSeed = null)
|
||||
{
|
||||
Library = library;
|
||||
Parties = parties;
|
||||
@@ -183,6 +193,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
NumberOfSides = numberOfSides;
|
||||
PositionsPerSide = positionsPerSide;
|
||||
IsWildBattle = isWildBattle;
|
||||
EnvironmentName = environmentName;
|
||||
Volatile = new ScriptSet(this);
|
||||
var sides = new IBattleSide[numberOfSides];
|
||||
for (byte i = 0; i < numberOfSides; i++)
|
||||
@@ -207,6 +218,9 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
/// <inheritdoc />
|
||||
public byte PositionsPerSide { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public StringKey EnvironmentName { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsWildBattle { get; }
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.Events;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models.Serialized;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using JetBrains.Annotations;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
@@ -5,11 +5,17 @@ namespace PkmnLib.Dynamic;
|
||||
/// </summary>
|
||||
public static class StaticHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// A delegate that provides the current date and time.
|
||||
/// </summary>
|
||||
public delegate DateTimeOffset DateTimeProviderDelegate();
|
||||
|
||||
/// <summary>
|
||||
/// A function to get the current date and time. This can be replaced in cases where the date and time
|
||||
/// may not be the same as the system time.
|
||||
/// </summary>
|
||||
public static Func<DateTimeOffset> DateTimeProvider { get; set; } = () => DateTimeOffset.Now;
|
||||
[PublicAPI]
|
||||
public static DateTimeProviderDelegate DateTimeProvider { get; set; } = () => DateTimeOffset.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Get the current date and time.
|
||||
|
||||
Reference in New Issue
Block a user