More moves implemented
This commit is contained in:
@@ -110,6 +110,8 @@ public interface IBattle : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
void SetWeather(StringKey? weatherName);
|
||||
|
||||
public IScriptSet Volatile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current weather of the battle. If no weather is present, this returns null.
|
||||
/// </summary>
|
||||
@@ -359,7 +361,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
// TODO: Trigger weather change script hooks
|
||||
}
|
||||
|
||||
private IScriptSet Volatile { get; } = new ScriptSet();
|
||||
public IScriptSet Volatile { get; } = new ScriptSet();
|
||||
|
||||
/// <inheritdoc />
|
||||
public StringKey? WeatherName => _weatherScript.Script?.Name;
|
||||
|
||||
@@ -102,5 +102,5 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
|
||||
internal IReadOnlyList<ITurnChoice?> GetChoices() => _choices;
|
||||
|
||||
public ITurnChoice? Where(Func<ITurnChoice, bool> predicate) => _choices.WhereNotNull().FirstOrDefault(predicate);
|
||||
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) => _choices.WhereNotNull().FirstOrDefault(predicate);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Dynamic.Models;
|
||||
public interface IBattleRandom : IRandom, IDeepCloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets whether or not a move triggers its secondary effect. This takes its chance, and
|
||||
/// Gets whether or not a move triggers its secondary effect. This takes its chance as percent, and
|
||||
/// rolls whether it triggers. As a side effect this run scripts to allow modifying this random
|
||||
/// chance.
|
||||
/// </summary>
|
||||
|
||||
@@ -373,6 +373,8 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// Replace the types of the Pokémon with the provided types.
|
||||
/// </summary>
|
||||
void SetTypes(IReadOnlyList<TypeIdentifier> types);
|
||||
|
||||
void ChangeAbility(IAbility ability);
|
||||
|
||||
/// <summary>
|
||||
/// Converts the data structure to a serializable format.
|
||||
@@ -409,7 +411,7 @@ public interface IPokemonBattleData : IDeepCloneable
|
||||
/// <summary>
|
||||
/// Whether the Pokémon is on the battlefield.
|
||||
/// </summary>
|
||||
bool IsOnBattlefield { get; set; }
|
||||
bool IsOnBattlefield { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds an opponent to the list of seen opponents.
|
||||
@@ -425,6 +427,8 @@ public interface IPokemonBattleData : IDeepCloneable
|
||||
/// Marks an item as consumed.
|
||||
/// </summary>
|
||||
void MarkItemAsConsumed(IItem itemName);
|
||||
|
||||
uint SwitchInTurn { get; internal set; }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IPokemon"/>
|
||||
@@ -720,6 +724,15 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
return false;
|
||||
if (!Library.ScriptResolver.TryResolveBattleItemScript(HeldItem, out _))
|
||||
return false;
|
||||
|
||||
if (BattleData != null)
|
||||
{
|
||||
var prevented = false;
|
||||
this.RunScriptHook(script => script.PreventHeldItemConsume(this, HeldItem, ref prevented));
|
||||
if (prevented)
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: actually consume the item
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -885,6 +898,13 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
// If the Pokémon is already fainted, we don't need to do anything.
|
||||
if (IsFainted)
|
||||
return;
|
||||
if (BattleData is not null)
|
||||
{
|
||||
var dmg = damage;
|
||||
this.RunScriptHook(script => script.ChangeIncomingDamage(this, source, ref dmg));
|
||||
damage = dmg;
|
||||
}
|
||||
|
||||
// If the damage is more than the current health, we cap it at the current health, to prevent
|
||||
// underflow.
|
||||
if (damage >= CurrentHealth)
|
||||
@@ -1013,10 +1033,11 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
{
|
||||
BattleData.Battle = battle;
|
||||
BattleData.SideIndex = sideIndex;
|
||||
BattleData.SwitchInTurn = battle.CurrentTurnNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
BattleData = new PokemonBattleDataImpl(battle, sideIndex);
|
||||
BattleData = new PokemonBattleDataImpl(battle, sideIndex, battle.CurrentTurnNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1068,6 +1089,12 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
_types = types.ToList();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeAbility(IAbility ability)
|
||||
{
|
||||
OverrideAbility = ability;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public SerializedPokemon Serialize() => new(this);
|
||||
|
||||
@@ -1112,10 +1139,11 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
public class PokemonBattleDataImpl : IPokemonBattleData
|
||||
{
|
||||
/// <inheritdoc cref="PokemonBattleDataImpl"/>
|
||||
public PokemonBattleDataImpl(IBattle battle, byte sideIndex)
|
||||
public PokemonBattleDataImpl(IBattle battle, byte sideIndex, uint switchInTurn)
|
||||
{
|
||||
Battle = battle;
|
||||
SideIndex = sideIndex;
|
||||
SwitchInTurn = switchInTurn;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1151,4 +1179,7 @@ public class PokemonBattleDataImpl : IPokemonBattleData
|
||||
{
|
||||
_consumedItems.Add(itemName);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public uint SwitchInTurn { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user