Gigantamax Swap per SpeciesSettings

Accounts for when only specific Generations are allowed
If no criteria matches (e.g. only Gen 2 species allowed), make it any regular Dynamax
This commit is contained in:
sora10pls 2020-06-08 16:14:06 -04:00
parent 1f6970dbd9
commit eb38d5cb83
2 changed files with 12 additions and 3 deletions

View File

@ -26,6 +26,7 @@ public class TrainerRandomizer : Randomizer
public EvolutionSet[] Evos { get; set; }
private TrainerRandSettings Settings;
private SpeciesSettings SpecSettings;
public TrainerRandomizer(GameInfo info, PersonalTable t, VsTrainer[] trainers, EvolutionSet[] evos)
{
@ -42,9 +43,10 @@ public TrainerRandomizer(GameInfo info, PersonalTable t, VsTrainer[] trainers, E
CrashClasses = GetCrashClasses(Info.Game);
}
public void Initialize(TrainerRandSettings settings)
public void Initialize(TrainerRandSettings settings, SpeciesSettings spec)
{
Settings = settings;
SpecSettings = spec;
IEnumerable<int> classes = Enumerable.Range(0, ClassCount).Except(CrashClasses);
if (Settings.SkipSpecialClasses)
@ -244,7 +246,14 @@ private void UpdatePKMFromSettings(TrainerPoke pk)
{
if (Settings.GigantamaxSwap && c.CanGigantamax)
{
c.Species = GigantamaxForms[Util.Random.Next(GigantamaxForms.Length)];
// only allow Gigantamax Forms per the user's species settings
var species = SpecSettings.GetSpecies(Info.MaxSpeciesID, Info.Generation);
var AllowedGigantamaxes = species.Intersect(GigantamaxForms).ToArray();
if (AllowedGigantamaxes.Length == 0) // return if the user's settings make it to where no gmax fits the criteria
return;
c.Species = AllowedGigantamaxes[Util.Random.Next(AllowedGigantamaxes.Length)];
c.Form = c.Species == (int)Species.Pikachu || c.Species == (int)Species.Meowth ? 0 : Legal.GetRandomForme(c.Species, false, false, false, Personal); // Pikachu & Meowth altforms can't gmax
}
if (Settings.MaxDynamaxLevel && c.CanDynamax)

View File

@ -592,7 +592,7 @@ private TrainerRandomizer GetRandomizer()
RandSpec = rspec,
GetBlank = () => (Game.Info.SWSH ? (TrainerPoke)new TrainerPoke8() : new TrainerPoke7b()), // this should probably be less specific
};
trand.Initialize((TrainerRandSettings)PG_RTrainer.SelectedObject);
trand.Initialize((TrainerRandSettings)PG_RTrainer.SelectedObject, (SpeciesSettings)PG_Species.SelectedObject);
return trand;
}