store encountertrade nick/ot within object

allows for ot/nick fetch for a given language
This commit is contained in:
Kurt 2018-03-26 22:23:11 -07:00
parent 6abd2a22a4
commit 1ca69965bf
9 changed files with 40 additions and 0 deletions

View file

@ -249,5 +249,17 @@ namespace PKHeX.Core
result.Ball = 25; // Dream Ball
return result;
}
internal static void MarkEncounterTradeStrings(EncounterTrade[] table, string[][] strings)
{
int half = strings[1].Length / 2;
for (var i = 0; i < half; i++)
{
var t = table[i];
t.Nicknames = getNames(i, strings);
t.TrainerNames = getNames(i + half, strings);
}
string[] getNames(int i, IEnumerable<string[]> names) => names?.Select(z => z?.Length > i ? z[i] : null).ToArray();
}
}
}

View file

@ -18,6 +18,11 @@ namespace PKHeX.Core
SlotsRBY = GetAreas();
MarkEncountersGeneration(1, SlotsRBY);
MarkEncountersGeneration(1, StaticRBY, TradeGift_RBY_NoTradeback, TradeGift_RBY_Tradeback);
var trades = TradeGift_RBY_Common.Concat(TradeGift_RBY_NoTradeback).Concat(TradeGift_RBY_Tradeback);
var names = new[] {null, "トレーナー", "TRAINER", "TRAINER", "TRAINER", "TRAINER", null, "TRAINER", null};
foreach (var t in trades)
t.TrainerNames = names;
}
private static EncounterArea[] GetAreas()

View file

@ -26,6 +26,8 @@ namespace PKHeX.Core
ReduceAreasSize(ref SlotsGSC);
MarkEncountersGeneration(2, SlotsGS, SlotsC, SlotsGSC);
MarkEncountersGeneration(2, StaticGS, StaticC, StaticGSC, TradeGift_GSC);
MarkEncounterTradeStrings(TradeGift_GSC, TradeGift_GSC_OTs);
}
private static EncounterArea[] GetTables2(GameVersion Version)

View file

@ -58,6 +58,9 @@ namespace PKHeX.Core
MarkEncountersGeneration(3, SlotsR, SlotsS, SlotsE, SlotsFR, SlotsLG, SlotsXD);
MarkEncountersGeneration(3, StaticR, StaticS, StaticE, StaticFR, StaticLG, Encounter_CXD, TradeGift_RSE, TradeGift_FRLG);
MarkEncounterTradeStrings(TradeGift_RSE, TradeRSE);
MarkEncounterTradeStrings(TradeGift_FRLG, TradeFRLG);
}
private static void MarkG3Slots_FRLG(ref EncounterArea[] Areas)

View file

@ -76,6 +76,9 @@ namespace PKHeX.Core
MarkEncountersGeneration(4, SlotsD, SlotsP, SlotsPt, SlotsHG, SlotsSS);
MarkEncountersGeneration(4, StaticD, StaticP, StaticPt, StaticHG, StaticSS, TradeGift_DPPt, TradeGift_HGSS);
MarkEncounterTradeStrings(TradeGift_DPPt, TradeDPPt);
MarkEncounterTradeStrings(TradeGift_HGSS, TradeHGSS);
}
private static EncounterArea[] GetFeebasArea(EncounterArea template)

View file

@ -46,6 +46,11 @@ namespace PKHeX.Core
MarkEncountersGeneration(5, SlotsB, SlotsW, SlotsB2, SlotsW2);
MarkEncountersGeneration(5, StaticB, StaticW, StaticB2, StaticW2, TradeGift_BW, TradeGift_B2W2);
MarkEncounterTradeStrings(TradeGift_BW, TradeBW);
MarkEncounterTradeStrings(TradeGift_B2W2_Regular, TradeB2W2);
foreach (var t in TradeGift_B2W2_YancyCurtis)
t.TrainerNames = t.OTGender == 0 ? TradeOT_B2W2_M : TradeOT_B2W2_F;
}
private static void MarkBWSwarmSlots(EncounterArea[] Areas)

View file

@ -36,6 +36,8 @@ namespace PKHeX.Core
MarkEncountersGeneration(6, StaticX, StaticY, StaticA, StaticO, TradeGift_XY, TradeGift_AO);
FriendSafari = GetFriendSafariArea();
MarkEncounterTradeStrings(TradeGift_XY, TradeXY);
MarkEncounterTradeStrings(TradeGift_AO, TradeAO);
}
private static ILookup<int, EncounterSlot> GetFriendSafariArea()

View file

@ -47,6 +47,9 @@ namespace PKHeX.Core
MarkEncountersGeneration(7, SlotsSN, SlotsMN, SlotsUS, SlotsUM);
MarkEncountersGeneration(7, StaticSN, StaticMN, StaticUS, StaticUM, TradeGift_SM, TradeGift_USUM);
MarkEncounterTradeStrings(TradeGift_SM, TradeSM);
MarkEncounterTradeStrings(TradeGift_USUM, TradeUSUM);
}
private static void MarkG7REGSlots(ref EncounterArea[] Areas)
{

View file

@ -44,6 +44,11 @@
public bool Fateful { get; set; }
public bool IsNicknamed { get; set; } = true;
public string[] Nicknames { get; internal set; }
public string[] TrainerNames { get; internal set; }
public string GetNickname(int language) => Nicknames?.Length < language ? Nicknames[language] : null;
public string GetOT(int language) => TrainerNames?.Length < language ? TrainerNames[language] : null;
public static readonly int[] DefaultMetLocation =
{
0, 126, 254, 2001, 30002, 30001, 30001,