mirror of
https://github.com/kwsch/pkNX.git
synced 2026-04-24 23:06:56 -05:00
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:
parent
1f6970dbd9
commit
eb38d5cb83
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user