mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 14:30:56 +00:00
Reduce static constructor requirements
Gen1: all are Trade1 objects, and all get the values set; just set the value in the object initializer Gen2: all are Trade2 objects, set the same version Gen2 all static encounters already have a version marked. Only thing remaining is to set the language.
This commit is contained in:
parent
81e98b5549
commit
8a3804e4b3
4 changed files with 14 additions and 23 deletions
|
@ -15,13 +15,6 @@ namespace PKHeX.Core
|
||||||
private static EncounterArea1[] Get(string name, string ident, GameVersion game) =>
|
private static EncounterArea1[] Get(string name, string ident, GameVersion game) =>
|
||||||
EncounterArea1.GetAreas(BinLinker.Unpack(Util.GetBinaryResource($"encounter_{name}.pkl"), ident), game);
|
EncounterArea1.GetAreas(BinLinker.Unpack(Util.GetBinaryResource($"encounter_{name}.pkl"), ident), game);
|
||||||
|
|
||||||
static Encounters1()
|
|
||||||
{
|
|
||||||
var trades = ArrayUtil.ConcatAll(TradeGift_RBY_NoTradeback, TradeGift_RBY_Tradeback);
|
|
||||||
foreach (var t in trades)
|
|
||||||
t.TrainerNames = StringConverter12.G1TradeOTName;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static readonly EncounterStatic1[] StaticRBY =
|
internal static readonly EncounterStatic1[] StaticRBY =
|
||||||
{
|
{
|
||||||
// GameVersion is RBY for Pokemon with the same catch rate and initial moves in all games
|
// GameVersion is RBY for Pokemon with the same catch rate and initial moves in all games
|
||||||
|
|
|
@ -19,15 +19,7 @@ namespace PKHeX.Core
|
||||||
private static EncounterArea2[] Get(string name, string ident, GameVersion game) =>
|
private static EncounterArea2[] Get(string name, string ident, GameVersion game) =>
|
||||||
EncounterArea2.GetAreas(BinLinker.Unpack(Util.GetBinaryResource($"encounter_{name}.pkl"), ident), game);
|
EncounterArea2.GetAreas(BinLinker.Unpack(Util.GetBinaryResource($"encounter_{name}.pkl"), ident), game);
|
||||||
|
|
||||||
static Encounters2()
|
static Encounters2() => MarkEncounterTradeStrings(TradeGift_GSC, TradeGift_GSC_OTs);
|
||||||
{
|
|
||||||
MarkEncounterTradeStrings(TradeGift_GSC, TradeGift_GSC_OTs);
|
|
||||||
|
|
||||||
StaticGSC.SetVersion(GameVersion.GSC);
|
|
||||||
StaticGS.SetVersion(GameVersion.GS);
|
|
||||||
StaticC.SetVersion(GameVersion.C);
|
|
||||||
TradeGift_GSC.SetVersion(GameVersion.GSC);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly EncounterStatic2[] Encounter_GSC_Common =
|
private static readonly EncounterStatic2[] Encounter_GSC_Common =
|
||||||
{
|
{
|
||||||
|
@ -143,7 +135,7 @@ namespace PKHeX.Core
|
||||||
private static readonly EncounterStatic2[] Encounter_C = Encounter_GSC_Common.Concat(Encounter_C_Exclusive).Concat(Encounter_GSC_Roam.Slice(0, 2)).ToArray();
|
private static readonly EncounterStatic2[] Encounter_C = Encounter_GSC_Common.Concat(Encounter_C_Exclusive).Concat(Encounter_GSC_Roam.Slice(0, 2)).ToArray();
|
||||||
private static readonly EncounterStatic2[] Encounter_GSC = Encounter_GSC_Common.Concat(Encounter_GS_Exclusive).Concat(Encounter_C_Exclusive).Concat(Encounter_GSC_Roam).ToArray();
|
private static readonly EncounterStatic2[] Encounter_GSC = Encounter_GSC_Common.Concat(Encounter_GS_Exclusive).Concat(Encounter_C_Exclusive).Concat(Encounter_GSC_Roam).ToArray();
|
||||||
|
|
||||||
internal static readonly EncounterTradeGB[] TradeGift_GSC =
|
internal static readonly EncounterTrade2[] TradeGift_GSC =
|
||||||
{
|
{
|
||||||
new EncounterTrade2(095, 03, 48926) { Gender = 0, IVs = new[] {08, 09, 06, 06, 06, 06} }, // Onix @ Violet City for Bellsprout [wild]
|
new EncounterTrade2(095, 03, 48926) { Gender = 0, IVs = new[] {08, 09, 06, 06, 06, 06} }, // Onix @ Violet City for Bellsprout [wild]
|
||||||
new EncounterTrade2(066, 05, 37460) { Gender = 1, IVs = new[] {12, 03, 07, 06, 06, 06} }, // Machop @ Goldenrod City for Drowzee [wild 9, hatched egg 5]
|
new EncounterTrade2(066, 05, 37460) { Gender = 1, IVs = new[] {12, 03, 07, 06, 06, 06} }, // Machop @ Goldenrod City for Drowzee [wild 9, hatched egg 5]
|
||||||
|
@ -163,14 +155,14 @@ namespace PKHeX.Core
|
||||||
private const string tradeGSC = "tradegsc";
|
private const string tradeGSC = "tradegsc";
|
||||||
private static readonly string[][] TradeGift_GSC_OTs = Util.GetLanguageStrings8(tradeGSC);
|
private static readonly string[][] TradeGift_GSC_OTs = Util.GetLanguageStrings8(tradeGSC);
|
||||||
|
|
||||||
internal static TreeEncounterAvailable GetGSCHeadbuttAvailability(EncounterSlot encounter, int TID)
|
internal static TreeEncounterAvailable GetGSCHeadbuttAvailability(EncounterSlot encounter, int trainerID)
|
||||||
{
|
{
|
||||||
var Area = Array.Find(HeadbuttTreesC, a => a.Location == encounter.Location);
|
var area = Array.Find(HeadbuttTreesC, a => a.Location == encounter.Location);
|
||||||
if (Area == null) // Failsafe, every area with headbutt encounters has a tree area
|
if (area == null) // Failsafe, every area with headbutt encounters has a tree area
|
||||||
return TreeEncounterAvailable.Impossible;
|
return TreeEncounterAvailable.Impossible;
|
||||||
|
|
||||||
var table = Area.GetTrees(encounter.Area.Type);
|
var table = area.GetTrees(encounter.Area.Type);
|
||||||
var trainerpivot = TID % 10;
|
var trainerpivot = trainerID % 10;
|
||||||
return table[trainerpivot];
|
return table[trainerpivot];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@
|
||||||
private bool HasOddCatchRate => Catch_Rate != 0;
|
private bool HasOddCatchRate => Catch_Rate != 0;
|
||||||
|
|
||||||
public EncounterTrade1(int species, int level, GameVersion game, byte rate) : this(species, level, game) => Catch_Rate = rate;
|
public EncounterTrade1(int species, int level, GameVersion game, byte rate) : this(species, level, game) => Catch_Rate = rate;
|
||||||
public EncounterTrade1(int species, int level, GameVersion game) : base(species, level) => Version = game;
|
|
||||||
|
public EncounterTrade1(int species, int level, GameVersion game) : base(species, level)
|
||||||
|
{
|
||||||
|
Version = game;
|
||||||
|
TrainerNames = StringConverter12.G1TradeOTName;
|
||||||
|
}
|
||||||
|
|
||||||
public byte GetInitialCatchRate()
|
public byte GetInitialCatchRate()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace PKHeX.Core
|
||||||
public EncounterTrade2(int species, int level, int tid) : base(species, level)
|
public EncounterTrade2(int species, int level, int tid) : base(species, level)
|
||||||
{
|
{
|
||||||
TID = tid;
|
TID = tid;
|
||||||
|
Version = GameVersion.GSC; // All share the same details
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsMatch(PKM pkm)
|
public override bool IsMatch(PKM pkm)
|
||||||
|
|
Loading…
Reference in a new issue