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:
@@ -18,6 +18,7 @@ public partial class ExplicitAI
|
||||
private static readonly StringKey ShieldsDownName = "shields_down";
|
||||
private static readonly StringKey HarshSunlightName = "harsh_sunlight";
|
||||
private static readonly StringKey DesolateLandsName = "desolate_lands";
|
||||
private static readonly StringKey PrimordialSeaName = "primordial_sea";
|
||||
private static readonly StringKey BulletproofName = "bulletproof";
|
||||
private static readonly StringKey FlashFireName = "flash_fire";
|
||||
private static readonly StringKey LightningRodName = "lightning_rod";
|
||||
@@ -33,6 +34,8 @@ public partial class ExplicitAI
|
||||
private static readonly StringKey FireName = "fire";
|
||||
private static readonly StringKey ElectricName = "electric";
|
||||
private static readonly StringKey WaterName = "water";
|
||||
private static readonly StringKey KomalaName = "komala";
|
||||
private static readonly StringKey MiniorName = "minior";
|
||||
|
||||
private static bool CanBePoisoned(IPokemon pokemon, IBattle battle)
|
||||
{
|
||||
@@ -49,9 +52,9 @@ public partial class ExplicitAI
|
||||
if ((pokemon.ActiveAbility?.Name == LeafGuardName && battle.WeatherName == HarshSunlightName) ||
|
||||
battle.WeatherName == DesolateLandsName)
|
||||
return false;
|
||||
if (pokemon.ActiveAbility?.Name == ComatoseName && pokemon.Species.Name == "komala")
|
||||
if (pokemon.ActiveAbility?.Name == ComatoseName && pokemon.Species.Name == KomalaName)
|
||||
return false;
|
||||
if (pokemon.ActiveAbility?.Name == ShieldsDownName && pokemon.Species.Name == "minior" &&
|
||||
if (pokemon.ActiveAbility?.Name == ShieldsDownName && pokemon.Species.Name == MiniorName &&
|
||||
pokemon.Form.Name.Contains("-meteor"))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -313,9 +313,9 @@ public partial class ExplicitAI : PokemonAI, IExplicitAI
|
||||
}
|
||||
|
||||
// Primal weather
|
||||
if (battle.WeatherName == "primordial_sea" && aiMove.Move.MoveType.Name == "fire")
|
||||
if (battle.WeatherName == PrimordialSeaName && aiMove.Move.MoveType.Name == FireName)
|
||||
return true;
|
||||
if (battle.WeatherName == "desolate_lands" && aiMove.Move.MoveType.Name == "water")
|
||||
if (battle.WeatherName == DesolateLandsName && aiMove.Move.MoveType.Name == WaterName)
|
||||
return true;
|
||||
|
||||
// Check if the move will fail based on the handlers
|
||||
@@ -453,13 +453,16 @@ public partial class ExplicitAI : PokemonAI, IExplicitAI
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly StringKey TruantName = "truant";
|
||||
private static readonly StringKey TruantEffectName = "truant_effect";
|
||||
|
||||
private static bool CanAttack(IPokemon pokemon)
|
||||
{
|
||||
if (pokemon.Volatile.Contains("requires_recharge"))
|
||||
return false;
|
||||
if (pokemon.HasStatus("frozen") || pokemon.HasStatus("sleep"))
|
||||
return false;
|
||||
if (pokemon.ActiveAbility?.Name == "truant" && pokemon.Volatile.Contains("truant_effect"))
|
||||
if (pokemon.ActiveAbility?.Name == TruantName && pokemon.Volatile.Contains(TruantEffectName))
|
||||
return false;
|
||||
if (pokemon.Volatile.Contains("flinch_effect"))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user