More warning fixes

This commit is contained in:
2025-05-02 16:04:54 +02:00
parent dabb26e4f2
commit b69ba6eaff
56 changed files with 56 additions and 80 deletions

View File

@@ -1,5 +1,5 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Moves;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;

View File

@@ -11,7 +11,7 @@ public class Gen7Plugin : Dynamic.ScriptHandling.Registry.Plugin
{
private readonly Gen7PluginConfiguration _configuration;
public Gen7Plugin() : base()
public Gen7Plugin()
{
_configuration = new Gen7PluginConfiguration();
}

View File

@@ -57,6 +57,7 @@ public class Gen7BattleStatCalculator : IBattleStatCalculator
executingMove.RunScriptHook(
x => x.ChangeAccuracyModifier(executingMove, target, hitIndex, ref accuracyModifier));
var modifiedAccuracy = (int)(moveAccuracy * accuracyModifier);
// ReSharper disable once AccessToModifiedClosure
executingMove.RunScriptHook(x => x.ChangeAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
if (modifiedAccuracy == 255)
return 255;

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;

View File

@@ -1,6 +1,6 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// The user nimbly strikes the target. If the user is not holding an item, this attack inflicts massive damage.

View File

@@ -1,7 +1,7 @@
using System.Linq;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// The user applies pressure to stress points, sharply boosting one of its or its allies' stats.

View File

@@ -1,4 +1,4 @@
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// The user helps the target and makes it use its move right after the user.

View File

@@ -4,7 +4,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
using PkmnLib.Static.Moves;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// The user hurriedly and randomly uses a move among those known by ally Pokémon.

View File

@@ -1,7 +1,7 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Species;
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// If it is the opposite gender of the user, the target becomes infatuated and less likely to attack.

View File

@@ -1,10 +1,9 @@
using System.Collections.Generic;
using PkmnLib.Plugin.Gen7.Scripts;
using PkmnLib.Plugin.Gen7.Scripts.Side;
using PkmnLib.Plugin.Gen7.Scripts.Weather;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// This move reduces damage from physical and special moves for five turns. This can be used only in a hailstorm.
@@ -43,7 +42,7 @@ public class AuroraVeil : Script
var side = battle.Sides[move.User.BattleData!.SideIndex];
var numberOfTurns = 5;
var dict = new Dictionary<StringKey, object?>()
var dict = new Dictionary<StringKey, object?>
{
{ "duration", numberOfTurns },
};

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// The user sheds part of its body to make itself lighter and sharply raise its Speed stat.
@@ -27,7 +27,7 @@ public class Autotomize : Script
if (user.ChangeStatBoost(Statistic.Speed, 2, true) && user.ChangeWeightInKgBy(-100.0f))
{
var battle = user.BattleData?.Battle;
battle?.EventHook.Invoke(new DialogEvent("pokemon_became_nimble", new Dictionary<string, object>()
battle?.EventHook.Invoke(new DialogEvent("pokemon_became_nimble", new Dictionary<string, object>
{
{ "pokemon", user },
}));

View File

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

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Dynamic.Events;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "change_all_target_stats")]
public class ChangeAllTargetStats : Script

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
@@ -34,7 +33,7 @@ public class ChangeMultipleTargetStatBoosts : Script
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
EventBatchId batchId = new();
foreach (var stat in _statBoosts!)
foreach (var stat in _statBoosts)
{
target.ChangeStatBoost(stat.Key, stat.Value, true, batchId);
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
@@ -34,7 +33,7 @@ public class ChangeMultipleUserStatBoosts : Script
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
EventBatchId batchId = new();
foreach (var stat in _statBoosts!)
foreach (var stat in _statBoosts)
{
move.User.ChangeStatBoost(stat.Key, stat.Value, true, batchId);
}

View File

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

View File

@@ -30,7 +30,7 @@ public class DoublePowerIfTargetDamagedInTurn : Script
var data = side.VolatileScripts.Get<DoublePowerIfTargetDamagedInTurnData>();
if (data == null)
return;
if (data._hitPokemon.Contains(target))
if (data.HitPokemon.Contains(target))
basePower *= 2;
}
}

View File

@@ -25,6 +25,6 @@ public class Drain : Script
var healed = (uint)(damage * DrainModifier);
if (move.User.HasHeldItem("big_root"))
healed = (uint)(healed * 1.3f);
user.Heal(healed, false);
user.Heal(healed);
}
}

View File

@@ -18,6 +18,6 @@ public class DreamEater : Script
var healed = (uint)(damage * 0.5f);
if (move.User.HasHeldItem("big_root"))
healed = (uint)(healed * 1.3f);
user.Heal(healed, false);
user.Heal(healed);
}
}

View File

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

View File

@@ -16,7 +16,7 @@ public class FlareBlitz : Script
}
var hitData = move.GetHitData(target, hit);
var recoilDamage = (uint)(hitData.Damage * (1 / 3));
var recoilDamage = hitData.Damage * (1 / 3);
move.User.Damage(recoilDamage, DamageSource.Misc);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,7 +20,7 @@ public class HealEachEndOfTurn : Script
}
else
{
_healPercentage = healPercentage!;
_healPercentage = healPercentage;
}
}

View File

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

View File

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

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 System.Linq;
using PkmnLib.Static;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Utils;

View File

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

View File

@@ -1,5 +1,4 @@
using System;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;

View File

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

View File

@@ -13,7 +13,7 @@ public class Rest : Script
move.GetHitData(target, hit).Fail();
return;
}
if (!move.User.Heal(move.User.MaxHealth, false, forceHeal: false))
if (!move.User.Heal(move.User.MaxHealth))
{
move.GetHitData(target, hit).Fail();
return;

View File

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

View File

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

View File

@@ -17,7 +17,7 @@ public class SetWeather : Script
{
throw new Exception("Weather not provided.");
}
_weather = weather!.ToString();
_weather = weather.ToString();
if (parameters.TryGetValue("turns", out var turns) && turns is int turn)
{
_defaultTurns = turn;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
@@ -52,6 +50,6 @@ public class BideEffect : Script
return;
}
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", opposingSideIndex, position);
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", opposingSideIndex, position);
}
}

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Libraries;
using PkmnLib.Static.Utils;
@@ -9,14 +8,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "foresight")]
public class ForesightEffect : Script
{
private readonly IReadOnlyTypeLibrary _typeLibrary;
private readonly TypeIdentifier _normalType;
private readonly TypeIdentifier _fightingType;
private readonly TypeIdentifier _ghostType;
public ForesightEffect(IReadOnlyTypeLibrary typeLibrary)
{
_typeLibrary = typeLibrary;
typeLibrary.TryGetTypeIdentifier("normal", out _normalType);
typeLibrary.TryGetTypeIdentifier("fighting", out _fightingType);
typeLibrary.TryGetTypeIdentifier("ghost", out _ghostType);

View File

@@ -15,7 +15,7 @@ public class Infatuated : Script
/// <inheritdoc />
public override void PreventMove(IExecutingMove move, ref bool prevent)
{
if (move.User.BattleData?.Battle?.Random.GetBool() == true)
if (move.User.BattleData?.Battle.Random.GetBool() == true)
prevent = true;
}
}

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;

View File

@@ -23,7 +23,7 @@ public abstract class OutrageLikeEffect : Script
/// <inheritdoc />
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "_move", _targetSide, _targetPosition);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, _targetSide, _targetPosition);
}
/// <inheritdoc />

View File

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

View File

@@ -5,7 +5,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "double_power_if_target_damaged_in_turn_data")]
public class DoublePowerIfTargetDamagedInTurnData : Script
{
public HashSet<IPokemon> _hitPokemon = new();
public readonly HashSet<IPokemon> HitPokemon = [];
/// <param name="battle"></param>
/// <inheritdoc />
@@ -17,6 +17,6 @@ public class DoublePowerIfTargetDamagedInTurnData : Script
/// <inheritdoc />
public override void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
{
_hitPokemon.Add(pokemon);
HitPokemon.Add(pokemon);
}
}