Replace all raw string comparisons with StringKey, source generator that creates cache keys for all names for Gen7 plugin
All checks were successful
Build / Build (push) Successful in 2m21s
All checks were successful
Build / Build (push) Successful in 2m21s
This commit is contained in:
@@ -17,7 +17,7 @@ public static class AIHelperFunctions
|
||||
if (move.User.BattleData?.SideIndex != target.BattleData?.SideIndex)
|
||||
desireMult = -1;
|
||||
|
||||
if (!ignoreContrary && !fixedChange && target.ActiveAbility?.Name == "contrary")
|
||||
if (!ignoreContrary && !fixedChange && target.ActiveAbility?.Name == AbilityNames.Contrary)
|
||||
{
|
||||
if (desireMult > 0 && wholeEffect)
|
||||
{
|
||||
@@ -39,10 +39,10 @@ public static class AIHelperFunctions
|
||||
if (expectedEndOfTurnDamage >= target.CurrentHealth)
|
||||
return wholeEffect ? ExplicitAI.MoveUselessScore : score;
|
||||
|
||||
if (!move.User.HasMoveWithEffect("power_trip"))
|
||||
if (!move.User.HasMoveWithEffect(MoveEffectNames.PowerTrip))
|
||||
{
|
||||
var foeIsAware = target.BattleData?.BattleSide.Pokemon.Any(x => x?.ActiveAbility?.Name == "unaware") !=
|
||||
true;
|
||||
var foeIsAware =
|
||||
target.BattleData?.BattleSide.Pokemon.Any(x => x?.ActiveAbility?.Name == AbilityNames.Unaware) != true;
|
||||
if (!foeIsAware)
|
||||
{
|
||||
return wholeEffect ? ExplicitAI.MoveUselessScore : score;
|
||||
@@ -56,7 +56,7 @@ public static class AIHelperFunctions
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!fixedChange && target.ActiveAbility?.Name == "simple")
|
||||
if (!fixedChange && target.ActiveAbility?.Name == AbilityNames.Simple)
|
||||
{
|
||||
increment *= 2;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public static class AIHelperFunctions
|
||||
var desireMult = -1;
|
||||
if (move.User.BattleData?.SideIndex == target.BattleData?.SideIndex)
|
||||
desireMult = 1;
|
||||
if (!ignoreContrary && !fixedChange && target.ActiveAbility?.Name == "contrary")
|
||||
if (!ignoreContrary && !fixedChange && target.ActiveAbility?.Name == AbilityNames.Contrary)
|
||||
{
|
||||
if (desireMult > 0 && wholeEffect)
|
||||
{
|
||||
@@ -109,7 +109,7 @@ public static class AIHelperFunctions
|
||||
return wholeEffect ? ExplicitAI.MoveUselessScore : score;
|
||||
|
||||
var foeIsAware = false;
|
||||
if (target.BattleData?.BattleSide.Pokemon.All(x => x?.ActiveAbility?.Name != "unaware") == true)
|
||||
if (target.BattleData?.BattleSide.Pokemon.All(x => x?.ActiveAbility?.Name != AbilityNames.Unaware) == true)
|
||||
{
|
||||
foeIsAware = true;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public static class AIHelperFunctions
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!fixedChange && target.ActiveAbility?.Name == "simple")
|
||||
if (!fixedChange && target.ActiveAbility?.Name == AbilityNames.Simple)
|
||||
{
|
||||
decrement *= 2;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public static class AIHelperFunctions
|
||||
{
|
||||
if (!fixedChange && pokemon.StatBoost.GetStatistic(stat) == StatBoostStatisticSet.MaxStatBoost)
|
||||
return false;
|
||||
if (!pokemon.HasMoveWithEffect("power_trip", "baton_pass"))
|
||||
if (!pokemon.HasMoveWithEffect(MoveEffectNames.PowerTrip, MoveEffectNames.BatonPass))
|
||||
return true;
|
||||
|
||||
switch (stat)
|
||||
@@ -160,7 +160,8 @@ public static class AIHelperFunctions
|
||||
case Statistic.Attack:
|
||||
{
|
||||
if (!pokemon.Moves.WhereNotNull().Any(x => x.MoveData.Category == MoveCategory.Physical &&
|
||||
x.MoveData.SecondaryEffect?.Name != "foul_play"))
|
||||
x.MoveData.SecondaryEffect?.Name !=
|
||||
MoveEffectNames.FoulPlay))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -170,7 +171,8 @@ public static class AIHelperFunctions
|
||||
{
|
||||
var opponentSide = pokemon.BattleData!.Battle.Sides.First(x => x != pokemon.BattleData.BattleSide);
|
||||
return opponentSide.Pokemon.WhereNotNull().Any(x => x.Moves.WhereNotNull().Any(y =>
|
||||
y.MoveData.Category == MoveCategory.Physical || y.MoveData.SecondaryEffect?.Name == "psyshock"));
|
||||
y.MoveData.Category == MoveCategory.Physical ||
|
||||
y.MoveData.SecondaryEffect?.Name == MoveEffectNames.Psyshock));
|
||||
}
|
||||
case Statistic.SpecialAttack:
|
||||
{
|
||||
@@ -184,11 +186,12 @@ public static class AIHelperFunctions
|
||||
{
|
||||
var opponentSide = pokemon.BattleData!.Battle.Sides.First(x => x != pokemon.BattleData.BattleSide);
|
||||
return opponentSide.Pokemon.WhereNotNull().Any(x => x.Moves.WhereNotNull().Any(y =>
|
||||
y.MoveData.Category == MoveCategory.Special && y.MoveData.SecondaryEffect?.Name != "psyshock"));
|
||||
y.MoveData.Category == MoveCategory.Special &&
|
||||
y.MoveData.SecondaryEffect?.Name != MoveEffectNames.Psyshock));
|
||||
}
|
||||
case Statistic.Speed:
|
||||
{
|
||||
if (!pokemon.HasMoveWithEffect("electro_ball", "power_trip"))
|
||||
if (!pokemon.HasMoveWithEffect(MoveEffectNames.ElectroBall, MoveEffectNames.PowerTrip))
|
||||
{
|
||||
var targetSpeed = pokemon.BoostedStats.Speed;
|
||||
var opponentSide = pokemon.BattleData!.Battle.Sides.First(x => x != pokemon.BattleData.BattleSide);
|
||||
@@ -228,13 +231,15 @@ public static class AIHelperFunctions
|
||||
case Statistic.Attack:
|
||||
{
|
||||
return pokemon.Moves.WhereNotNull().Any(x => x.MoveData.Category == MoveCategory.Physical &&
|
||||
x.MoveData.SecondaryEffect?.Name != FoulPlayAbilityName);
|
||||
x.MoveData.SecondaryEffect?.Name !=
|
||||
MoveEffectNames.FoulPlay);
|
||||
}
|
||||
case Statistic.Defense:
|
||||
{
|
||||
var opponentSide = pokemon.BattleData!.Battle.Sides.First(x => x != pokemon.BattleData.BattleSide);
|
||||
return opponentSide.Pokemon.WhereNotNull().Any(x => x.Moves.WhereNotNull().Any(y =>
|
||||
y.MoveData.Category == MoveCategory.Physical || y.MoveData.SecondaryEffect?.Name == "psyshock"));
|
||||
y.MoveData.Category == MoveCategory.Physical ||
|
||||
y.MoveData.SecondaryEffect?.Name == MoveEffectNames.Psyshock));
|
||||
}
|
||||
case Statistic.SpecialAttack:
|
||||
{
|
||||
@@ -244,11 +249,12 @@ public static class AIHelperFunctions
|
||||
{
|
||||
var opponentSide = pokemon.BattleData!.Battle.Sides.First(x => x != pokemon.BattleData.BattleSide);
|
||||
return opponentSide.Pokemon.WhereNotNull().Any(x => x.Moves.WhereNotNull().Any(y =>
|
||||
y.MoveData.Category == MoveCategory.Special && y.MoveData.SecondaryEffect?.Name != "psyshock"));
|
||||
y.MoveData.Category == MoveCategory.Special &&
|
||||
y.MoveData.SecondaryEffect?.Name != MoveEffectNames.Psyshock));
|
||||
}
|
||||
case Statistic.Speed:
|
||||
{
|
||||
if (!pokemon.HasMoveWithEffect("electro_ball"))
|
||||
if (!pokemon.HasMoveWithEffect(MoveEffectNames.ElectroBall))
|
||||
{
|
||||
var targetSpeed = pokemon.BoostedStats.Speed;
|
||||
var opponentSide = pokemon.BattleData!.Battle.Sides.First(x => x != pokemon.BattleData.BattleSide);
|
||||
@@ -266,8 +272,6 @@ public static class AIHelperFunctions
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly StringKey FoulPlayAbilityName = "foul_play";
|
||||
|
||||
private static void GetTargetStatRaiseScoreOne(ref int score, IPokemon target, Statistic stat, sbyte increment,
|
||||
AIMoveState move, float desireMult = 1)
|
||||
{
|
||||
@@ -311,7 +315,7 @@ public static class AIHelperFunctions
|
||||
{
|
||||
var hasPhysicalMoves = target.Moves.WhereNotNull().Any(x =>
|
||||
x.MoveData.Category == MoveCategory.Physical &&
|
||||
x.MoveData.SecondaryEffect?.Name != FoulPlayAbilityName);
|
||||
x.MoveData.SecondaryEffect?.Name != MoveEffectNames.FoulPlay);
|
||||
var inc = hasPhysicalMoves ? 8 : 12;
|
||||
score += (int)(inc * incMult);
|
||||
}
|
||||
@@ -340,15 +344,15 @@ public static class AIHelperFunctions
|
||||
else
|
||||
score += (int)(8 * incMult);
|
||||
}
|
||||
if (target.HasMoveWithEffect("electro_ball", "power_trip"))
|
||||
if (target.HasMoveWithEffect(MoveEffectNames.ElectroBall, MoveEffectNames.PowerTrip))
|
||||
{
|
||||
score += (int)(5 * incMult);
|
||||
}
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect("gyro_ball")))
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect(MoveEffectNames.GyroBall)))
|
||||
{
|
||||
score -= (int)(5 * incMult);
|
||||
}
|
||||
if (target.ActiveAbility?.Name == "speed_boost")
|
||||
if (target.ActiveAbility?.Name == AbilityNames.SpeedBoost)
|
||||
{
|
||||
score -= (int)(15 * (target.Opposes(move.User) ? 1 : desireMult));
|
||||
}
|
||||
@@ -393,11 +397,11 @@ public static class AIHelperFunctions
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (target.HasMoveWithEffect("power_trip"))
|
||||
if (target.HasMoveWithEffect(MoveEffectNames.PowerTrip))
|
||||
{
|
||||
score += (int)(5 * increment * desireMult);
|
||||
}
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect("punishment")))
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect(MoveEffectNames.Punishment)))
|
||||
{
|
||||
score -= (int)(5 * increment * desireMult);
|
||||
}
|
||||
@@ -445,7 +449,7 @@ public static class AIHelperFunctions
|
||||
{
|
||||
var hasPhysicalMoves = target.Moves.WhereNotNull().Any(x =>
|
||||
x.MoveData.Category == MoveCategory.Physical &&
|
||||
x.MoveData.SecondaryEffect?.Name != FoulPlayAbilityName);
|
||||
x.MoveData.SecondaryEffect?.Name != MoveEffectNames.FoulPlay);
|
||||
var dec = hasPhysicalMoves ? 8 : 12;
|
||||
score += (int)(dec * decMult);
|
||||
}
|
||||
@@ -475,11 +479,11 @@ public static class AIHelperFunctions
|
||||
score += (int)(8 * decMult);
|
||||
break;
|
||||
}
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect("electro_ball")))
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect(MoveEffectNames.ElectroBall)))
|
||||
{
|
||||
score += (int)(5 * decMult);
|
||||
}
|
||||
if (target.ActiveAbility?.Name == "speed_boost")
|
||||
if (target.ActiveAbility?.Name == AbilityNames.SpeedBoost)
|
||||
{
|
||||
score -= (int)(15 * (target.Opposes(move.User) ? 1 : desireMult));
|
||||
}
|
||||
@@ -502,11 +506,11 @@ public static class AIHelperFunctions
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (target.HasMoveWithEffect("power_trip"))
|
||||
if (target.HasMoveWithEffect(MoveEffectNames.PowerTrip))
|
||||
{
|
||||
score += (int)(5 * decrement * desireMult);
|
||||
}
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect("punishment")))
|
||||
if (opponentSide.Pokemon.WhereNotNull().Any(x => x.HasMoveWithEffect(MoveEffectNames.Punishment)))
|
||||
{
|
||||
score -= (int)(5 * decrement * desireMult);
|
||||
}
|
||||
@@ -545,13 +549,13 @@ public static class AIHelperFunctions
|
||||
{
|
||||
if (move.Move.SecondaryEffect is null)
|
||||
return 0;
|
||||
if (move.User.ActiveAbility?.Name == "sheer_force")
|
||||
if (move.User.ActiveAbility?.Name == AbilityNames.SheerForce)
|
||||
return -999;
|
||||
if (target is not null && target.BattleData?.Position != move.User.BattleData?.Position &&
|
||||
target.ActiveAbility?.Name == "shield_dust")
|
||||
target.ActiveAbility?.Name == AbilityNames.ShieldDust)
|
||||
return -999;
|
||||
|
||||
if ((move.Move.SecondaryEffect.Chance < 100 && move.User.ActiveAbility?.Name == "serene_grace") ||
|
||||
if ((move.Move.SecondaryEffect.Chance < 100 && move.User.ActiveAbility?.Name == AbilityNames.SereneGrace) ||
|
||||
move.User.BattleData?.BattleSide.VolatileScripts.Contains<RainbowEffect>() == true)
|
||||
{
|
||||
return 5;
|
||||
@@ -574,38 +578,38 @@ public static class AIHelperFunctions
|
||||
return true;
|
||||
if (pokemon.ActiveAbility != null)
|
||||
{
|
||||
if (pokemon.ActiveAbility.Name == "guts" && status != ScriptUtils.ResolveName<Sleep>() &&
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.Guts && status != ScriptUtils.ResolveName<Sleep>() &&
|
||||
status != ScriptUtils.ResolveName<Frozen>() &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.Attack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "marvel_scale" &&
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.MarvelScale &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.Defense, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "quick_feet" && status != ScriptUtils.ResolveName<Sleep>() &&
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.QuickFeet && status != ScriptUtils.ResolveName<Sleep>() &&
|
||||
status != ScriptUtils.ResolveName<Frozen>() && IsStatRaiseWorthwhile(pokemon, Statistic.Speed, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "flare_boost" && status == ScriptUtils.ResolveName<Burned>() &&
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.FlareBoost && status == ScriptUtils.ResolveName<Burned>() &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.SpecialAttack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "toxic_boost" &&
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.ToxicBoost &&
|
||||
(status == ScriptUtils.ResolveName<Poisoned>() || status == ScriptUtils.ResolveName<BadlyPoisoned>()) &&
|
||||
IsStatRaiseWorthwhile(pokemon, Statistic.Attack, 1, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "poison_heal" && status == ScriptUtils.ResolveName<Poisoned>())
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.PoisonHeal && status == ScriptUtils.ResolveName<Poisoned>())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (pokemon.ActiveAbility.Name == "magic_guard")
|
||||
if (pokemon.ActiveAbility.Name == AbilityNames.MagicGuard)
|
||||
{
|
||||
if (status != ScriptUtils.ResolveName<Poisoned>() &&
|
||||
status != ScriptUtils.ResolveName<BadlyPoisoned>() && status != ScriptUtils.ResolveName<Burned>())
|
||||
|
||||
Reference in New Issue
Block a user