Even more moves
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Deukhoofd 2025-05-05 16:58:03 +02:00
parent 292c303fc0
commit 7727f92f4e
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
132 changed files with 624 additions and 171 deletions

View File

@ -15,7 +15,7 @@ public interface IDamageCalculator
/// <summary>
/// Calculate the base power for a given hit on a Pokemon.
/// </summary>
byte GetBasePower(IExecutingMove executingMove, IPokemon target, byte hitNumber, IHitData hitData);
ushort GetBasePower(IExecutingMove executingMove, IPokemon target, byte hitNumber, IHitData hitData);
/// <summary>
/// Returns whether a specified hit should be critical or not.

View File

@ -76,9 +76,16 @@ public static class MoveTurnExecutor
if (failed)
{
// TODO: fail handling
executingMove.MoveChoice.Fail();
return;
}
ExecuteMove(executingMove);
if (executingMove.Hits.All(x => x.HasFailed) || (executingMove.UseMove.Category != MoveCategory.Status &&
executingMove.Hits.All(x => x.Damage == 0)))
{
executingMove.MoveChoice.Fail();
}
}
public static void ExecuteMove(IExecutingMove executingMove)

View File

@ -20,7 +20,7 @@ public interface IHitData
/// <summary>
/// The base power of the hit.
/// </summary>
byte BasePower { get; }
ushort BasePower { get; }
/// <summary>
/// The effectiveness of the hit.
@ -55,7 +55,7 @@ public record HitData : IHitData
public bool IsCritical { get; internal set; }
/// <inheritdoc />
public byte BasePower { get; internal set; }
public ushort BasePower { get; internal set; }
/// <inheritdoc />
public float Effectiveness { get; internal set; }

View File

@ -76,6 +76,11 @@ public interface ILearnedMove : IDeepCloneable
/// </summary>
bool TryUse(byte amount = 1);
/// <summary>
/// Reduce the remaining PP by a certain amount. If the number of PP is already 0, return false.
/// </summary>
bool ReduceUses(byte amount = 1);
/// <summary>
/// Set the remaining PP to the max amount of PP.
/// </summary>
@ -139,6 +144,20 @@ public class LearnedMoveImpl : ILearnedMove
return true;
}
/// <inheritdoc />
public bool ReduceUses(byte amount = 1)
{
if (CurrentPp == 0)
return false;
if (CurrentPp >= amount)
CurrentPp -= amount;
else
CurrentPp = 0;
return true;
}
/// <summary>
/// Restore the PP to the maximum amount of PP.
/// </summary>

View File

@ -403,6 +403,12 @@ public interface IPokemon : IScriptSource, IDeepCloneable
/// </summary>
void ChangeAbility(IAbility ability);
/// <summary>
/// Whether the Pokémon is levitating. This is used for moves like Magnet Rise, and abilities such as
/// Levitate.
/// </summary>
bool IsFloating { get; }
/// <summary>
/// Converts the data structure to a serializable format.
/// </summary>
@ -1206,6 +1212,17 @@ public class PokemonImpl : ScriptSource, IPokemon
}
}
/// <inheritdoc />
public bool IsFloating
{
get
{
var isFloating = Types.Any(x => x.Name == "flying");
this.RunScriptHook(x => x.IsFloating(this, ref isFloating));
return isFloating;
}
}
/// <inheritdoc />
public SerializedPokemon Serialize() => new(this);

View File

@ -307,7 +307,7 @@ public abstract class Script : IDeepCloneable
/// <summary>
/// This function allows a script to change the effective base power of a move hit.
/// </summary>
public virtual void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public virtual void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
}
@ -697,4 +697,8 @@ public abstract class Script : IDeepCloneable
public virtual void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
{
}
public virtual void IsFloating(IPokemon pokemon, ref bool isFloating)
{
}
}

View File

@ -41,6 +41,15 @@ public static class NumericHelpers
return result > ushort.MaxValue ? ushort.MaxValue : (ushort)result;
}
/// <summary>
/// Multiplies two values. If this overflows, returns <see cref="ushort.MaxValue"/>.
/// </summary>
public static ushort MultiplyOrMax(this ushort value, float multiplier)
{
var result = value * multiplier;
return result > ushort.MaxValue ? ushort.MaxValue : (ushort)result;
}
/// <summary>
/// Multiplies two values. If this overflows, returns <see cref="short.MaxValue"/>.
/// </summary>

View File

@ -10608,7 +10608,10 @@
"flags": [
"reflectable",
"nonskybattle"
]
],
"effect": {
"name": "spikes"
}
},
{
"name": "spiky_shield",
@ -10619,7 +10622,10 @@
"priority": 4,
"target": "Self",
"category": "status",
"flags": []
"flags": [],
"effect": {
"name": "spiky_shield"
}
},
{
"name": "spirit_shackle",
@ -10633,7 +10639,10 @@
"flags": [
"protect",
"mirror"
]
],
"effect": {
"name": "prevent_foes_exit"
}
},
{
"name": "spit_up",
@ -10646,7 +10655,10 @@
"category": "special",
"flags": [
"protect"
]
],
"effect": {
"name": "spit_up"
}
},
{
"name": "spite",
@ -10662,7 +10674,10 @@
"reflectable",
"mirror",
"ignore-substitute"
]
],
"effect": {
"name": "spite"
}
},
{
"name": "splash",
@ -10676,6 +10691,7 @@
"flags": [
"gravity"
]
// No secondary effect
},
{
"name": "spore",
@ -10691,7 +10707,13 @@
"reflectable",
"mirror",
"powder"
]
],
"effect": {
"name": "set_status",
"parameters": {
"status": "sleep"
}
}
},
{
"name": "spotlight",
@ -10705,7 +10727,10 @@
"flags": [
"protect",
"reflectable"
]
],
"effect": {
"name": "spotlight"
}
},
{
"name": "stealth_rock",
@ -10718,7 +10743,10 @@
"category": "status",
"flags": [
"reflectable"
]
],
"effect": {
"name": "stealth_rock"
}
},
{
"name": "steam_eruption",
@ -10733,7 +10761,14 @@
"protect",
"mirror",
"defrost"
]
],
"effect": {
"name": "set_status",
"chance": 30,
"parameters": {
"status": "burned"
}
}
},
{
"name": "steamroller",
@ -10748,7 +10783,11 @@
"contact",
"protect",
"mirror"
]
],
"effect": {
"name": "flinch",
"chance": 30
}
},
{
"name": "steel_wing",
@ -10763,7 +10802,13 @@
"contact",
"protect",
"mirror"
]
],
"effect": {
"name": "change_user_defense",
"parameters": {
"amount": 1
}
}
},
{
"name": "sticky_web",
@ -10776,7 +10821,10 @@
"category": "status",
"flags": [
"reflectable"
]
],
"effect": {
"name": "sticky_web"
}
},
{
"name": "stockpile",
@ -10789,7 +10837,10 @@
"category": "status",
"flags": [
"snatch"
]
],
"effect": {
"name": "stockpile"
}
},
{
"name": "stoked_sparksurfer",
@ -10800,7 +10851,13 @@
"priority": 0,
"target": "Any",
"category": "special",
"flags": []
"flags": [],
"effect": {
"name": "set_status",
"parameters": {
"status": "paralyzed"
}
}
},
{
"name": "stomp",
@ -10816,7 +10873,11 @@
"protect",
"mirror",
"nonskybattle"
]
],
"effect": {
"name": "flinch",
"chance": 30
}
},
{
"name": "stomping_tantrum",
@ -10831,7 +10892,10 @@
"contact",
"protect",
"mirror"
]
],
"effect": {
"name": "stomping_tantrum"
}
},
{
"name": "stone_edge",
@ -10845,7 +10909,10 @@
"flags": [
"protect",
"mirror"
]
],
"effect": {
"name": "increased_critical_stage"
}
},
{
"name": "stored_power",
@ -10859,7 +10926,10 @@
"flags": [
"protect",
"mirror"
]
],
"effect": {
"name": "power_trip"
}
},
{
"name": "storm_throw",
@ -10874,7 +10944,10 @@
"contact",
"protect",
"mirror"
]
],
"effect": {
"name": "storm_throw"
}
},
{
"name": "strength",
@ -10890,6 +10963,7 @@
"protect",
"mirror"
]
// No secondary effect
},
{
"name": "strength_sap",
@ -10905,7 +10979,10 @@
"reflectable",
"mirror",
"heal"
]
],
"effect": {
"name": "strength_sap"
}
},
{
"name": "string_shot",
@ -10920,7 +10997,13 @@
"protect",
"reflectable",
"mirror"
]
],
"effect": {
"name": "change_target_speed",
"parameters": {
"amount": -2
}
}
},
{
"name": "struggle_bug",
@ -10934,7 +11017,13 @@
"flags": [
"protect",
"mirror"
]
],
"effect": {
"name": "change_target_special_attack",
"parameters": {
"amount": -1
}
}
},
{
"name": "stun_spore",
@ -10950,7 +11039,13 @@
"reflectable",
"mirror",
"powder"
]
],
"effect": {
"name": "set_status",
"parameters": {
"status": "paralyzed"
}
}
},
{
"name": "submission",
@ -10965,7 +11060,13 @@
"contact",
"protect",
"mirror"
]
],
"effect": {
"name": "recoil",
"parameters": {
"recoilPercent": 0.25
}
}
},
{
"name": "substitute",

View File

@ -56,4 +56,35 @@ public class MoveDataTests
e);
}
}
public record SetStatusTestCaseData(IDynamicLibrary Library, IMoveData Move)
{
/// <inheritdoc />
public override string ToString() => Move.Name + " has valid status: " +
Move.SecondaryEffect?.Parameters.GetValueOrDefault("status");
}
public static IEnumerable<Func<SetStatusTestCaseData>> SetStatusMovesHaveValidStatusData()
{
var library = LibraryHelpers.LoadLibrary();
var moveLibrary = library.StaticLibrary.Moves;
foreach (var move in moveLibrary)
{
if (move.SecondaryEffect?.Name != "set_status")
continue;
yield return () => new SetStatusTestCaseData(library, move);
}
}
[Test, MethodDataSource(nameof(SetStatusMovesHaveValidStatusData))]
public async Task SetStatusMovesHaveValidStatus(SetStatusTestCaseData test)
{
if (test.Move.SecondaryEffect == null)
return;
var status = test.Move.SecondaryEffect.Parameters["status"]?.ToString();
if (status == null)
throw new Exception("Missing required parameter 'status'");
await Assert.That(test.Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out _)).IsTrue();
}
}

View File

@ -12,7 +12,7 @@ public class AcrobaticsTests
// Arrange
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
byte basePower = 10;
ushort basePower = 10;
var user = Substitute.For<IPokemon>();
user.HeldItem.Returns((IItem?)null);
move.User.Returns(user);
@ -31,7 +31,7 @@ public class AcrobaticsTests
// Arrange
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
byte basePower = 10;
ushort basePower = 10;
var user = Substitute.For<IPokemon>();
user.HeldItem.Returns(Substitute.For<IItem>());
move.User.Returns(user);
@ -50,7 +50,7 @@ public class AcrobaticsTests
// Arrange
var move = Substitute.For<IExecutingMove>();
var target = Substitute.For<IPokemon>();
byte basePower = 200;
ushort basePower = ushort.MaxValue - 100;
var user = Substitute.For<IPokemon>();
move.User.Returns(user);
user.HeldItem.Returns((IItem?)null);
@ -60,6 +60,6 @@ public class AcrobaticsTests
acrobatics.ChangeBasePower(move, target, 0, ref basePower);
// Assert
await Assert.That(basePower).IsEqualTo(byte.MaxValue);
await Assert.That(basePower).IsEqualTo(ushort.MaxValue);
}
}

View File

@ -82,7 +82,7 @@ public class HiddenPowerTests
dynamicLibrary.StaticLibrary.Returns(staticLibrary);
var hiddenPower = new HiddenPower();
byte power = 0;
ushort power = 0;
hiddenPower.ChangeBasePower(executingMove, target, 0, ref power);
await Assert.That(power).IsEqualTo(test.ExpectedPower);

View File

@ -3,3 +3,4 @@ global using PkmnLib.Dynamic.ScriptHandling.Registry;
global using PkmnLib.Dynamic.Events;
global using PkmnLib.Dynamic.Models;
global using PkmnLib.Dynamic.Models.Choices;
global using PkmnLib.Static;

View File

@ -1,6 +1,5 @@
using System;
using PkmnLib.Dynamic.Libraries;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Libraries;

View File

@ -1,6 +1,5 @@
using System;
using PkmnLib.Dynamic.Libraries;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Libraries;

View File

@ -1,7 +1,6 @@
using System;
using System.Linq;
using PkmnLib.Dynamic.Libraries;
using PkmnLib.Static;
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Libraries;
@ -69,11 +68,11 @@ public class Gen7DamageCalculator(bool hasRandomness) : IDamageCalculator
}
/// <inheritdoc />
public byte GetBasePower(IExecutingMove executingMove, IPokemon target, byte hitNumber, IHitData hitData)
public ushort GetBasePower(IExecutingMove executingMove, IPokemon target, byte hitNumber, IHitData hitData)
{
if (executingMove.UseMove.Category == MoveCategory.Status)
return 0;
var basePower = executingMove.UseMove.BasePower;
var basePower = (ushort)executingMove.UseMove.BasePower;
executingMove.RunScriptHook(script => script.ChangeBasePower(executingMove, target, hitNumber, ref basePower));
return basePower;
}

View File

@ -2,7 +2,6 @@ using System.Collections.Generic;
using System.Linq;
using PkmnLib.Dynamic;
using PkmnLib.Dynamic.Libraries;
using PkmnLib.Static;
using PkmnLib.Static.Moves;
using PkmnLib.Static.Utils;

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
@ -7,6 +6,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
[Script(ScriptCategory.Battle, "gravity")]
public class Gravity : Script
{
private int _turns = 5;
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
@ -25,4 +26,21 @@ public class Gravity : Script
if (move.UseMove.HasFlag("gravity"))
fail = true;
}
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
{
// Gravity makes all Pokémon susceptible to Ground-type moves
isFloating = false;
}
/// <inheritdoc />
public override void OnEndTurn(IBattle battle)
{
_turns--;
if (_turns > 0)
return;
RemoveSelf();
}
}

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
[Script(ScriptCategory.Move, "ion_deluge")]

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;

View File

@ -8,7 +8,7 @@ public class MudSportEffect : Script
private int _turnsLeft = 5;
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.UseMove.MoveType.Name == "electric")
{

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Items;

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Items;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
[Script(ScriptCategory.MoveVolatile, "electrify")]

View File

@ -6,6 +6,6 @@ namespace PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
public class MeFirstPowerBoost : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower) =>
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) =>
basePower = basePower.MultiplyOrMax(1.5f);
}

View File

@ -6,6 +6,6 @@ namespace PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
public class RoundPowerBoost : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower) =>
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) =>
basePower = basePower.MultiplyOrMax(2f);
}

View File

@ -12,7 +12,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Acrobatics : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.User.HeldItem == null)
basePower = basePower.MultiplyOrMax(2);

View File

@ -1,5 +1,4 @@
using System.Linq;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,6 +1,5 @@
using System;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -30,7 +30,7 @@ public class BeatUp : Script
}
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var relevantPartyMembers = _relevantPartyMembers ??= GetRelevantPartyMembers(move.User).ToArray();
var hittingPokemon = relevantPartyMembers.ElementAtOrDefault(hit);

View File

@ -1,5 +1,4 @@
using System.Linq;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "belly_drum")]

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Brine : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (target.CurrentHealth <= target.BoostedStats.Hp / 2)
{

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "bug_bite")]

View File

@ -1,4 +1,3 @@
using PkmnLib.Static;
using PkmnLib.Static.Species;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class CrushGrip : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
basePower = Math.Max((byte)(120 * target.CurrentHealth / target.BoostedStats.Hp), (byte)1);
}

View File

@ -1,6 +1,5 @@
using System.Linq;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -14,7 +14,8 @@ public class Defog : Script
ScriptUtils.ResolveName<LightScreenEffect>(),
ScriptUtils.ResolveName<ReflectEffect>(),
ScriptUtils.ResolveName<SafeguardEffect>(),
"spikes",
ScriptUtils.ResolveName<StickyWebEffect>(),
ScriptUtils.ResolveName<SpikesEffect>(),
"toxic_spikes",
"stealth_rock",
];

View File

@ -19,7 +19,7 @@ public class DoublePowerIfTargetDamagedInTurn : Script
}
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var battle = move.User.BattleData?.Battle;
if (battle == null)

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "dragon_ascent")]

View File

@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class ElectroBall : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var user = move.User;
var targetSpeed = target.BoostedStats.Speed;

View File

@ -5,7 +5,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "eruption")]
public class Eruption : Script
{
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
basePower = Math.Max((byte)(150 * move.User.CurrentHealth / move.User.BoostedStats.Hp), (byte)1);
}

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Facade : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var status = move.User.StatusScript.Script?.Name;
if (status == "paralyzed" || status == "burned" || status == "poisoned")

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "fell_stinger")]

View File

@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Flail : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var remainingHealth = move.User.CurrentHealth / move.User.BoostedStats.Hp;
var fraction = remainingHealth * 48;

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,12 +1,10 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "fling")]
public class Fling : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var item = move.User.HeldItem;
if (item == null)

View File

@ -1,5 +1,4 @@
using System.Linq;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,4 +1,3 @@
using PkmnLib.Static;
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Frustration : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var friendship = move.User.Happiness;
basePower = Math.Max((byte)1, (byte)((255 - friendship) * 2 / 5));

View File

@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FuryCutter : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var userEffect = move.User.Volatile.Get<FuryCutterEffect>();
if (userEffect == null)

View File

@ -1,4 +1,3 @@
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class GrassKnot : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var targetWeight = target.WeightInKg;
basePower = targetWeight switch

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "guard_split")]

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "guard_swap")]

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class GyroBall : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
basePower = Math.Min((byte)150, (byte)(25 * target.BoostedStats.Speed / move.User.BoostedStats.Speed + 1));
}

View File

@ -1,5 +1,4 @@
using System;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class HeatCrash : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var weightMultiplier = move.User.WeightInKg / target.WeightInKg;
basePower = weightMultiplier switch

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Hex : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (!target.StatusScript.IsEmpty)
{

View File

@ -1,5 +1,4 @@
using System;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
@ -18,7 +17,7 @@ public class HiddenPower : Script
}
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var ivs = move.User.IndividualValues;

View File

@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class IceBall : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var userEffect = move.User.Volatile.Get<IceBallEffect>();
if (userEffect == null)

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "incinerate")]

View File

@ -15,7 +15,7 @@ public class Instruct : Script
if (battleData == null)
return;
var lastMoveChoiceByTarget = battleData.Battle.PreviousTurnChoices.SelectMany(x => x)
var lastMoveChoiceByTarget = battleData.Battle.PreviousTurnChoices.SelectMany(x => x).Reverse()
.SkipWhile(x => x != move.MoveChoice).OfType<MoveChoice>().FirstOrDefault(x => x.User == target);
if (lastMoveChoiceByTarget == null || !battleData.Battle.CanUse(lastMoveChoiceByTarget))

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "judgement")]

View File

@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class LowKick : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
basePower = target.WeightInKg switch
{

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Magnitude : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var battleData = move.User.BattleData;
if (battleData == null)

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "memento")]

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "multi_attack")]

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
@ -8,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class NaturalGift : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var naturalGiftData = GetNaturalGiftData(move.User.HeldItem);
if (naturalGiftData == null)

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>

View File

@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Payback : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var battleData = move.User.BattleData;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "power_split")]

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "power_swap")]

View File

@ -1,5 +1,4 @@
using System;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -40,7 +40,7 @@ public class Present : Script
}
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
basePower = _basePower;
}

View File

@ -1,5 +1,4 @@
using System;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "psyshock")]

View File

@ -1,5 +1,4 @@
using System.Linq;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
@ -7,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Punishment : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.User.BattleData == null)
return;

View File

@ -1,4 +1,5 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Plugin.Gen7.Scripts.Side;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
@ -12,12 +13,16 @@ public class RapidSpin : Script
move.User.Volatile.Remove<BindEffect>();
move.User.Volatile.Remove<FireSpinEffect>();
move.User.Volatile.Remove<MagmaStormEffect>();
// TODO: Sand Tomb effect removal
// TODO: Whirlpool effect removal
// TODO: Wrap effect removal
// TODO: Remove Spikes
// TODO: Remove Toxic Spikes
// TODO: Remove Stealth Rock
var battleData = move.User.BattleData;
if (battleData != null)
{
battleData.BattleSide.VolatileScripts.Remove<SpikesEffect>();
battleData.BattleSide.VolatileScripts.Remove<StickyWebEffect>();
// TODO: Remove Toxic Spikes
// TODO: Remove Stealth Rock
}
}
}

View File

@ -1,5 +1,4 @@
using System;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Retaliate : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var battleData = move.User.BattleData;
if (battleData is null)

View File

@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Return : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var friendship = move.User.Happiness;
var power = friendship * 2 / 5;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "revelation_dance")]

View File

@ -1,5 +1,4 @@
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "shell_smash")]

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,4 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,4 +1,3 @@
using System;
using System.Linq;
using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
using PkmnLib.Plugin.Gen7.Scripts.Utils;

View File

@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;

View File

@ -1,5 +1,3 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "speed_swap")]

Some files were not shown because too many files have changed in this diff Show More