mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-24 15:47:15 -05:00
Refactoring
more discards & simplifications
This commit is contained in:
parent
e2f11edc43
commit
99005d8fc0
|
|
@ -209,7 +209,7 @@ private void SanitizeMetLocations()
|
|||
metBW2_00000[134] += "(B2/W2)"; // Victory Road in B2W2
|
||||
// BW2 Entries from 76 to 105 are for Entralink in BW
|
||||
for (int i = 76; i < 106; i++)
|
||||
metBW2_00000[i] = metBW2_00000[i] + "●";
|
||||
metBW2_00000[i] += "●";
|
||||
|
||||
// Collision between 40002 (legal) and 00002 (illegal) "Faraway place"
|
||||
if (metBW2_00000[2] == metBW2_40000[2 - 1])
|
||||
|
|
@ -670,7 +670,7 @@ public static string GetLocationName(bool eggmet, int locval, int format, int ge
|
|||
|
||||
locval %= size;
|
||||
if (bankID >= 3)
|
||||
locval -= 1;
|
||||
locval--;
|
||||
}
|
||||
|
||||
var bank = GetLocationNames(gen, bankID);
|
||||
|
|
|
|||
50
PKHeX.Core/Game/LanguageGC.cs
Normal file
50
PKHeX.Core/Game/LanguageGC.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="GameVersion.CXD"/> Game Language IDs
|
||||
/// </summary>
|
||||
public enum LanguageGC : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Undefined Language ID, usually indicative of a value not being set.
|
||||
/// </summary>
|
||||
/// <remarks>Gen5 Japanese In-game Trades happen to not have their Language value set, and express Language=0.</remarks>
|
||||
Hacked = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Japanese (日本語)
|
||||
/// </summary>
|
||||
Japanese = 1,
|
||||
|
||||
/// <summary>
|
||||
/// English (US/UK/AU)
|
||||
/// </summary>
|
||||
English = 2,
|
||||
|
||||
/// <summary>
|
||||
/// German (Deutsch)
|
||||
/// </summary>
|
||||
German = 3,
|
||||
|
||||
/// <summary>
|
||||
/// French (Français)
|
||||
/// </summary>
|
||||
French = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Italian (Italiano)
|
||||
/// </summary>
|
||||
Italian = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Spanish (Español)
|
||||
/// </summary>
|
||||
Spanish = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Unused Language ID
|
||||
/// </summary>
|
||||
/// <remarks>Was reserved for Korean in Gen3 but never utilized.</remarks>
|
||||
UNUSED_6 = 7,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Contiguous series Game Language IDs
|
||||
/// </summary>
|
||||
public enum LanguageID : byte
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -59,48 +62,4 @@ public enum LanguageID : byte
|
|||
/// </summary>
|
||||
ChineseT = 10,
|
||||
}
|
||||
public enum LanguageGC : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// Undefined Language ID, usually indicative of a value not being set.
|
||||
/// </summary>
|
||||
/// <remarks>Gen5 Japanese In-game Trades happen to not have their Language value set, and express Language=0.</remarks>
|
||||
Hacked = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Japanese (日本語)
|
||||
/// </summary>
|
||||
Japanese = 1,
|
||||
|
||||
/// <summary>
|
||||
/// English (US/UK/AU)
|
||||
/// </summary>
|
||||
English = 2,
|
||||
|
||||
/// <summary>
|
||||
/// German (Deutsch)
|
||||
/// </summary>
|
||||
German = 3,
|
||||
|
||||
/// <summary>
|
||||
/// French (Français)
|
||||
/// </summary>
|
||||
French = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Italian (Italiano)
|
||||
/// </summary>
|
||||
Italian = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Spanish (Español)
|
||||
/// </summary>
|
||||
Spanish = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Unused Language ID
|
||||
/// </summary>
|
||||
/// <remarks>Was reserved for Korean in Gen3 but never utilized.</remarks>
|
||||
UNUSED_6 = 7,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ private string GetVerboseLegalityReport()
|
|||
if (rl != lines.Count) // move info added, break for next section
|
||||
lines.Add(br[1]);
|
||||
|
||||
var outputLines = Parse.Where(chk => chk != null && chk.Valid && chk.Comment != V).OrderBy(chk => chk.Judgement); // Fishy sorted to top
|
||||
var outputLines = Parse.Where(chk => chk?.Valid == true && chk.Comment != V).OrderBy(chk => chk.Judgement); // Fishy sorted to top
|
||||
lines.AddRange(outputLines.Select(chk => string.Format(V196, chk.Rating, chk.Comment)));
|
||||
|
||||
lines.AddRange(br);
|
||||
|
|
@ -378,7 +378,7 @@ public int[] GetSuggestedRelearn()
|
|||
return Info.RelearnBase;
|
||||
|
||||
List<int> window = new List<int>(Info.RelearnBase.Where(z => z != 0));
|
||||
window.AddRange(pkm.Moves.Where((v, i) => !Info.Moves[i].Valid || Info.Moves[i].Flag));
|
||||
window.AddRange(pkm.Moves.Where((_, i) => !Info.Moves[i].Valid || Info.Moves[i].Flag));
|
||||
window = window.Distinct().ToList();
|
||||
int[] moves = new int[4];
|
||||
int start = Math.Max(0, window.Count - 4);
|
||||
|
|
|
|||
|
|
@ -110,9 +110,10 @@ private static List<EncounterSlot1> GetSlots2_F(byte[] data, ref int ofs, SlotTy
|
|||
// slot set ends in 0xFF 0x** 0x**
|
||||
var slots = new List<EncounterSlot1>();
|
||||
int ctr = 0;
|
||||
while (true)
|
||||
int rate;
|
||||
do
|
||||
{
|
||||
int rate = data[ofs++];
|
||||
rate = data[ofs++];
|
||||
int species = data[ofs++];
|
||||
int level = data[ofs++];
|
||||
|
||||
|
|
@ -125,10 +126,8 @@ private static List<EncounterSlot1> GetSlots2_F(byte[] data, ref int ofs, SlotTy
|
|||
SlotNumber = ctr++,
|
||||
Type = species == 0 ? SlotType.Special : t // day/night specific
|
||||
});
|
||||
|
||||
if (rate == 0xFF)
|
||||
break;
|
||||
}
|
||||
while (rate != 0xFF);
|
||||
return slots;
|
||||
}
|
||||
private static EncounterSlot1[] GetSlots2_H(byte[] data, ref int ofs, SlotType t)
|
||||
|
|
@ -703,8 +702,8 @@ private static EncounterArea GetArea4HGSS_Headbutt(byte[] data)
|
|||
//4 bytes padding
|
||||
var Slots = new List<EncounterSlot>();
|
||||
|
||||
// 00-11 Normal trees
|
||||
// 12-17 Special trees
|
||||
// 00-11 Normal trees
|
||||
// 12-17 Special trees
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
int Species = BitConverter.ToInt16(data, 6 + i*4);
|
||||
|
|
@ -1032,7 +1031,7 @@ public static EncounterArea[] GetArray(byte[][] entries)
|
|||
}
|
||||
}
|
||||
|
||||
public partial class Extensions
|
||||
public static partial class Extensions
|
||||
{
|
||||
public static IEnumerable<IEnumerable<T>> CartesianProduct<T>(this IEnumerable<IEnumerable<T>> sequences)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ private void ReadAreaRawData(byte[] entry)
|
|||
|
||||
// Invalid tress are trees that the player can not reach without cheating devices, like a tree beyond other trees
|
||||
InvalidTrees = new TreeCoordinates[entry[ofs]];
|
||||
ofs += 1;
|
||||
ofs++;
|
||||
for (int i = 0; i < InvalidTrees.Length; i++, ofs += 2)
|
||||
InvalidTrees[i] = new TreeCoordinates(entry[ofs], entry[ofs + 1]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1362,7 +1362,7 @@ private void VerifyBall()
|
|||
// For gen3/4 Safari Zones and BCC getValidWildEncounters already filter to not return
|
||||
// mixed possible encounters between safari, BCC and other encounters
|
||||
// That means is the first encounter is not safari then there is no safari encounter in the array
|
||||
else if (3 <= Info.Generation && Info.Generation <= 4 && EncounterSlotGenerator.IsSafariSlot(w.Type))
|
||||
else if (3 <= Info.Generation && Info.Generation <= 4 && w.Type.IsSafariType())
|
||||
VerifyBallEquals(5); // Safari Ball
|
||||
else if (Info.Generation == 4 && w.Type == SlotType.BugContest)
|
||||
VerifyBallEquals(0x18); // Sport Ball
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ private static void MarkG3SlotsSafariZones(ref EncounterArea[] Areas, int locati
|
|||
private static readonly int[] Roaming_MetLocation_RSE =
|
||||
{
|
||||
//Roaming encounter is possible in tall grass and on water
|
||||
//Route 101-138
|
||||
//Route 101-138
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
||||
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
||||
36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
|
||||
|
|
@ -122,7 +122,7 @@ private static void MarkG3SlotsSafariZones(ref EncounterArea[] Areas, int locati
|
|||
};
|
||||
private static readonly EncounterStatic[] Encounter_RSE_Regular =
|
||||
{
|
||||
// Starters
|
||||
// Starters
|
||||
new EncounterStatic { Gift = true, Species = 152, Level = 05, Location = 000, Version = GameVersion.E, }, // Chikorita @ Littleroot Town
|
||||
new EncounterStatic { Gift = true, Species = 155, Level = 05, Location = 000, Version = GameVersion.E, }, // Cyndaquil
|
||||
new EncounterStatic { Gift = true, Species = 158, Level = 05, Location = 000, Version = GameVersion.E, }, // Totodile
|
||||
|
|
@ -176,7 +176,7 @@ private static void MarkG3SlotsSafariZones(ref EncounterArea[] Areas, int locati
|
|||
private static readonly EncounterStatic[] Encounter_FRLG_Stationary =
|
||||
{
|
||||
// Starters @ Pallet Town
|
||||
new EncounterStatic { Gift = true, Species = 1, Level = 05, Location = 088, }, // Bulbasaur
|
||||
new EncounterStatic { Gift = true, Species = 1, Level = 05, Location = 088, }, // Bulbasaur
|
||||
new EncounterStatic { Gift = true, Species = 4, Level = 05, Location = 088, }, // Charmander
|
||||
new EncounterStatic { Gift = true, Species = 7, Level = 05, Location = 088, }, // Squirtle
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ private static void MarkG3SlotsSafariZones(ref EncounterArea[] Areas, int locati
|
|||
// Stationary Legendary
|
||||
new EncounterStatic { Species = 144, Level = 50, Location = 139, }, // Articuno @ Seafoam Islands
|
||||
new EncounterStatic { Species = 145, Level = 50, Location = 142, }, // Zapdos @ Power Plant
|
||||
new EncounterStatic { Species = 146, Level = 50, Location = 175, }, // Moltres @ Mt. Ember.
|
||||
new EncounterStatic { Species = 146, Level = 50, Location = 175, }, // Moltres @ Mt. Ember.
|
||||
new EncounterStatic { Species = 150, Level = 70, Location = 141, }, // Mewtwo @ Cerulean Cave
|
||||
|
||||
// Event
|
||||
|
|
@ -251,7 +251,7 @@ private static void MarkG3SlotsSafariZones(ref EncounterArea[] Areas, int locati
|
|||
new EncounterTradePID { Species = 032, Ability = 1, TID = 63184, SID = 00000, OTGender = 1, Gender = 0, IVs = new[] {19,25,18,22,22,15}, PID = 0x4C970B9E, Contest = TradeContest_Cool, Version = GameVersion.LG, }, // Nidoran♂ *
|
||||
new EncounterTradePID { Species = 030, Ability = 1, TID = 13637, SID = 00000, OTGender = 0, Gender = 1, IVs = new[] {22,25,18,19,22,15}, PID = 0x00EECA15, Contest = TradeContest_Cute, Version = GameVersion.FR,}, // Nidorina *
|
||||
new EncounterTradePID { Species = 033, Ability = 1, TID = 13637, SID = 00000, OTGender = 0, Gender = 0, IVs = new[] {19,18,25,22,15,22}, PID = 0x00EECA19, Contest = TradeContest_Tough, Version = GameVersion.LG,}, // Nidorino *
|
||||
new EncounterTradePID { Species = 108, Ability = 1, TID = 01239, SID = 00000, OTGender = 0, Gender = 0, IVs = new[] {24,19,21,15,23,21}, PID = 0x451308AB, Contest = TradeContest_Tough, }, // Lickitung *
|
||||
new EncounterTradePID { Species = 108, Ability = 1, TID = 01239, SID = 00000, OTGender = 0, Gender = 0, IVs = new[] {24,19,21,15,23,21}, PID = 0x451308AB, Contest = TradeContest_Tough, }, // Lickitung *
|
||||
new EncounterTradePID { Species = 124, Ability = 1, TID = 36728, SID = 00000, OTGender = 0, Gender = 1, IVs = new[] {18,17,18,22,25,21}, PID = 0x498A2E1D, Contest = TradeContest_Beauty, }, // Jynx
|
||||
new EncounterTradePID { Species = 083, Ability = 1, TID = 08810, SID = 00000, OTGender = 0, Gender = 0, IVs = new[] {20,25,21,24,15,20}, PID = 0x151943D7, Contest = TradeContest_Cool, }, // Farfetch'd
|
||||
new EncounterTradePID { Species = 101, Ability = 2, TID = 50298, SID = 00000, OTGender = 0, Gender = 2, IVs = new[] {19,16,18,25,25,19}, PID = 0x06341016, Contest = TradeContest_Cool, }, // Electrode
|
||||
|
|
@ -346,7 +346,7 @@ private static EncounterArea GetUnownArea(int location, IReadOnlyList<int> SlotF
|
|||
return new EncounterArea
|
||||
{
|
||||
Location = location,
|
||||
Slots = SlotForms.Select((z, i) => new EncounterSlot
|
||||
Slots = SlotForms.Select((_, i) => new EncounterSlot
|
||||
{
|
||||
Species = 201, LevelMin = 25, LevelMax = 25, Type = SlotType.Grass,
|
||||
SlotNumber = i,
|
||||
|
|
|
|||
|
|
@ -1009,7 +1009,7 @@ private static void MarkHGSSEncounterTypeSlots(ref EncounterArea[] Areas)
|
|||
{
|
||||
new EncounterArea {
|
||||
Location = 53, // Solaceon Ruins
|
||||
Slots = new int[25].Select((s, i) => new EncounterSlot { Species = 201, LevelMin = 14, LevelMax = 30, Type = SlotType.Grass, Form = i+1 }).ToArray() // B->?, Unown A is loaded from encounters raw file
|
||||
Slots = new int[25].Select((_, i) => new EncounterSlot { Species = 201, LevelMin = 14, LevelMax = 30, Type = SlotType.Grass, Form = i+1 }).ToArray() // B->?, Unown A is loaded from encounters raw file
|
||||
},
|
||||
};
|
||||
private static readonly EncounterArea SlotsHGSS_BCC =
|
||||
|
|
@ -1420,7 +1420,7 @@ private static void MarkHGSSEncounterTypeSlots(ref EncounterArea[] Areas)
|
|||
SlotsHGSS_BCC,
|
||||
new EncounterArea {
|
||||
Location = 209, // Ruins of Alph
|
||||
Slots = new int[25].Select((s, i) => new EncounterSlot { Species = 201, LevelMin = 5, LevelMax = 5, Type = SlotType.Grass, Form = i+1 }).ToArray() // B->?, Unown A is loaded from encounters raw file
|
||||
Slots = new int[25].Select((_, i) => new EncounterSlot { Species = 201, LevelMin = 5, LevelMax = 5, Type = SlotType.Grass, Form = i+1 }).ToArray() // B->?, Unown A is loaded from encounters raw file
|
||||
},
|
||||
SlotsHGSS_SafariZone,
|
||||
//Some edge cases
|
||||
|
|
|
|||
|
|
@ -453,7 +453,7 @@ private static EncounterArea[] GetPelagoArea(int[][] species, int[] min)
|
|||
var area = new EncounterArea
|
||||
{
|
||||
Location = 30016,
|
||||
Slots = species.SelectMany((t, i) =>
|
||||
Slots = species.SelectMany((_, i) =>
|
||||
species.Take(1 + i).SelectMany(z => // grab current row & above
|
||||
z.Select(s => new EncounterSlot // get slot data for each species
|
||||
{
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ private int GetBall()
|
|||
{
|
||||
if (Type == SlotType.BugContest)
|
||||
return 24; // Sport
|
||||
if (Type.HasFlag(SlotType.Safari))
|
||||
if (Type.IsSafariType())
|
||||
return 5; // Safari
|
||||
return 4; // Poké Ball
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
internal class EncounterSlot1 : EncounterSlot
|
||||
{
|
||||
public int Rate;
|
||||
internal EncounterTime Time = EncounterTime.Any;
|
||||
internal EncounterTime Time;
|
||||
}
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ private static IEnumerable<IEncounterable> GenerateRawEncounters4(PKM pkm, Legal
|
|||
foreach (var z in GetValidWildEncounters34(pkm))
|
||||
{
|
||||
bool defer = z.IsDeferred4(species, pkm, safari, sport);
|
||||
var frame = slots.FirstOrDefault(s => s.IsSlotCompatibile(z, pkm));
|
||||
var frame = slots.Find(s => s.IsSlotCompatibile(z, pkm));
|
||||
if (defer)
|
||||
{
|
||||
if (frame != null)
|
||||
|
|
@ -358,7 +358,7 @@ private static IEnumerable<IEncounterable> GenerateRawEncounters3(PKM pkm, Legal
|
|||
foreach (var z in GetValidWildEncounters34(pkm))
|
||||
{
|
||||
bool defer = z.IsDeferred3(species, pkm, safari);
|
||||
var frame = slots.FirstOrDefault(s => s.IsSlotCompatibile(z, pkm));
|
||||
var frame = slots.Find(s => s.IsSlotCompatibile(z, pkm));
|
||||
if (defer)
|
||||
{
|
||||
if (frame != null)
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ private static bool IsDeferred(this EncounterSlot slot, int currentSpecies, PKM
|
|||
|| slot.IsDeferredSport(IsSportBall);
|
||||
}
|
||||
private static bool IsDeferredWurmple(this IEncounterable slot, int currentSpecies, PKM pkm) => slot.Species == 265 && currentSpecies != 265 && !IsWurmpleEvoValid(pkm);
|
||||
private static bool IsDeferredSafari(this EncounterSlot slot, bool IsSafariBall) => IsSafariBall != slot.Type.HasFlag(SlotType.Safari);
|
||||
private static bool IsDeferredSport(this EncounterSlot slot, bool IsSportBall) => IsSportBall != slot.Type.HasFlag(SlotType.BugContest);
|
||||
private static bool IsDeferredSafari(this EncounterSlot slot, bool IsSafariBall) => IsSafariBall != ((slot.Type & SlotType.Safari) != 0);
|
||||
private static bool IsDeferredSport(this EncounterSlot slot, bool IsSportBall) => IsSportBall != ((slot.Type & SlotType.BugContest) != 0);
|
||||
private static bool IsDeferredHiddenAbility(this EncounterSlot slot, bool IsHidden) => IsHidden != slot.IsHiddenAbilitySlot();
|
||||
|
||||
public static IEnumerable<EncounterSlot> GetValidFriendSafari(PKM pkm)
|
||||
|
|
@ -369,11 +369,6 @@ private static bool IsHiddenAbilitySlot(this EncounterSlot slot)
|
|||
return slot.Permissions.DexNav || slot.Type == SlotType.FriendSafari || slot.Type == SlotType.Horde || slot.Type == SlotType.SOS;
|
||||
}
|
||||
|
||||
internal static bool IsSafariSlot(SlotType t)
|
||||
{
|
||||
return t.HasFlag(SlotType.Safari);
|
||||
}
|
||||
|
||||
internal static bool IsDexNavValid(PKM pkm)
|
||||
{
|
||||
if (!pkm.AO || !pkm.InhabitedGeneration(6))
|
||||
|
|
|
|||
|
|
@ -170,9 +170,8 @@ private static bool GetIsMatchStatic(PKM pkm, EncounterStatic e, int lvl)
|
|||
// if (e.Gift && pkm.Ball != 4) // PokéBall
|
||||
// continue;
|
||||
|
||||
if (pkm is PK1 pk1 && pk1.Gen1_NotTradeback)
|
||||
if (!IsValidCatchRatePK1(e, pk1))
|
||||
return false;
|
||||
if (pkm is PK1 pk1 && pk1.Gen1_NotTradeback && !IsValidCatchRatePK1(e, pk1))
|
||||
return false;
|
||||
|
||||
if (!AllowGBCartEra && GameVersion.GBCartEraOnly.Contains(e.Version))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -112,24 +112,18 @@ private static bool GetIsValidTradeVC2(PKM pkm, EncounterTrade z)
|
|||
return false;
|
||||
if (z.Gender >= 0 && z.Gender != pkm.Gender && pkm.Format <= 2)
|
||||
return false;
|
||||
if (z.IVs != null && !z.IVs.SequenceEqual(pkm.IVs) && pkm.Format <= 2)
|
||||
if (z.IVs?.SequenceEqual(pkm.IVs) == false && pkm.Format <= 2)
|
||||
return false;
|
||||
if (pkm.Met_Location != 0 && pkm.Format == 2 && pkm.Met_Location != 126)
|
||||
return false;
|
||||
|
||||
int index = Array.IndexOf(Encounters2.TradeGift_GSC, z);
|
||||
int otIndex = Encounters2.TradeGift_GSC.Length + index;
|
||||
bool valid;
|
||||
if (pkm.Japanese)
|
||||
valid = Encounters2.TradeGift_GSC_OTs[(int)LanguageID.Japanese][otIndex] == pkm.OT_Name;
|
||||
else if (pkm.Korean)
|
||||
valid = Encounters2.TradeGift_GSC_OTs[(int)LanguageID.Korean][otIndex] == pkm.OT_Name;
|
||||
else
|
||||
valid = Array.FindIndex(Encounters2.TradeGift_GSC_OTs, 2, 6, arr => arr.Length > index && arr[otIndex] == pkm.OT_Name) >= 0;
|
||||
if (!valid)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return Encounters2.TradeGift_GSC_OTs[(int)LanguageID.Japanese][otIndex] == pkm.OT_Name;
|
||||
if (pkm.Korean)
|
||||
return Encounters2.TradeGift_GSC_OTs[(int)LanguageID.Korean][otIndex] == pkm.OT_Name;
|
||||
return Array.FindIndex(Encounters2.TradeGift_GSC_OTs, 2, 6, arr => arr.Length > index && arr[otIndex] == pkm.OT_Name) >= 0;
|
||||
}
|
||||
|
||||
private static bool GetIsFromGB(PKM pkm) => pkm.VC || pkm.Format <= 2;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/// Encounter lock values restricting certain properties to a fixed value.
|
||||
/// </summary>
|
||||
/// <remarks>Used in Colosseum/XD to ensure that non-shadow <see cref="PKM"/> are of a certain Nature/etc.</remarks>
|
||||
public class EncounterLock
|
||||
public sealed class EncounterLock
|
||||
{
|
||||
public int Species { get; set; }
|
||||
public int Nature { get; set; } = -1;
|
||||
|
|
|
|||
|
|
@ -83,9 +83,10 @@ private static EncounterStatic GetSuggestedEncounterStatic(EncounterStatic s, in
|
|||
return encounter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Gets a valid Egg hatch location for the origin game.
|
||||
/// </summary>
|
||||
/// <param name="pkm">Pokémon data to suggest for</param>
|
||||
public static int GetSuggestedEggMetLocation(PKM pkm)
|
||||
{
|
||||
// Return one of legal hatch locations for game
|
||||
|
|
@ -142,9 +143,10 @@ public static int GetSuggestedEggMetLocation(PKM pkm)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Gets the correct Transfer Met location for the origin game.
|
||||
/// </summary>
|
||||
/// <param name="pkm">Pokémon data to suggest for</param>
|
||||
/// <remarks>
|
||||
/// Returns -1 if the met location is not overriden with a transfer location
|
||||
/// </remarks>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class ValidEncounterMoves
|
|||
public int MinimumLevelGen2 { get; }
|
||||
|
||||
private const int EmptyCount = 7;
|
||||
private static readonly List<int>[] Empty = new int[EmptyCount].Select(z => new List<int>()).ToArray();
|
||||
private static readonly List<int>[] Empty = new int[EmptyCount].Select(_ => new List<int>()).ToArray();
|
||||
|
||||
public ValidEncounterMoves(PKM pkm, LegalInfo info)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,9 +74,7 @@ public LegalInfo(PKM pk)
|
|||
public List<EncounterRejected> InvalidMatches;
|
||||
internal void Reject(CheckResult c)
|
||||
{
|
||||
if (InvalidMatches == null)
|
||||
InvalidMatches = new List<EncounterRejected>();
|
||||
InvalidMatches.Add(new EncounterRejected(EncounterMatch, c));
|
||||
(InvalidMatches ?? (InvalidMatches = new List<EncounterRejected>())).Add(new EncounterRejected(EncounterMatch, c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ internal enum EncounterTime
|
|||
|
||||
internal static class EncounterTimeExtension
|
||||
{
|
||||
internal static bool Contains(this EncounterTime t1, int t2) => t1 == EncounterTime.Any || t1.HasFlag((EncounterTime)(1 << t2));
|
||||
internal static bool Contains(this EncounterTime t1, int t2) => t1 == EncounterTime.Any || (t1 & (EncounterTime)(1 << t2)) != 0;
|
||||
internal static int RandomValidTime(this EncounterTime t1)
|
||||
{
|
||||
int val = Util.Rand.Next(1, 4);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace PKHeX.Core
|
|||
[Flags]
|
||||
public enum EncounterType
|
||||
{
|
||||
Undefined = 0,
|
||||
None = 1 << 00,
|
||||
RockSmash = 1 << 01,
|
||||
TallGrass = 1 << 02,
|
||||
|
|
@ -27,7 +28,7 @@ public enum EncounterType
|
|||
|
||||
public static class EncounterTypeExtension
|
||||
{
|
||||
public static bool Contains(this EncounterType g1, int g2) => g1.HasFlag((EncounterType)(1 << g2));
|
||||
public static bool Contains(this EncounterType g1, int g2) => (g1 & (EncounterType)(1 << g2)) != 0;
|
||||
|
||||
public static int GetIndex(this EncounterType g)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ public enum Severity
|
|||
|
||||
public static partial class Extensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Check result Severity determination (Valid/Invalid/etc) to the localized string.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public enum SlotType
|
|||
/// Default (un-assigned) encounter slot type.
|
||||
/// </summary>
|
||||
Any = 0,
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Slot is encountered via Grass.
|
||||
/// </summary>
|
||||
Grass = 1 << 00,
|
||||
|
|
@ -42,7 +42,7 @@ public enum SlotType
|
|||
/// Slot is encountered via a Horde.
|
||||
/// </summary>
|
||||
Horde = 1 << 06,
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Slot is encountered via the Friend Safari.
|
||||
/// </summary>
|
||||
FriendSafari = 1 << 07,
|
||||
|
|
@ -102,13 +102,14 @@ public enum SlotType
|
|||
|
||||
public static partial class Extensions
|
||||
{
|
||||
internal static bool IsSafariType(this SlotType t) => (t & SlotType.Safari) != 0;
|
||||
internal static bool IsFishingRodType(this SlotType t)
|
||||
{
|
||||
return t.HasFlag(SlotType.Old_Rod) || t.HasFlag(SlotType.Good_Rod) || t.HasFlag(SlotType.Super_Rod);
|
||||
return (t & SlotType.Old_Rod) != 0 || (t & SlotType.Good_Rod) != 0 || (t & SlotType.Super_Rod) != 0;
|
||||
}
|
||||
internal static bool IsSweetScentType(this SlotType t)
|
||||
{
|
||||
return !(t.IsFishingRodType() || t.HasFlag(SlotType.Rock_Smash));
|
||||
return !(t.IsFishingRodType() || (t & SlotType.Rock_Smash) != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class Frame
|
|||
/// </summary>
|
||||
public uint RandESV { get; set; }
|
||||
|
||||
public bool LevelSlotModified => Lead.IsLevelOrSlotModified() || Lead.HasFlag(LeadRequired.UsesLevelCall);
|
||||
public bool LevelSlotModified => Lead.IsLevelOrSlotModified() || (Lead & LeadRequired.UsesLevelCall) != 0;
|
||||
|
||||
public Frame(uint seed, FrameType type, RNG rng, LeadRequired lead)
|
||||
{
|
||||
|
|
@ -44,11 +44,8 @@ public Frame(uint seed, FrameType type, RNG rng, LeadRequired lead)
|
|||
public bool IsSlotCompatibile(EncounterSlot slot, PKM pkm)
|
||||
{
|
||||
bool usesLevel = !slot.FixedLevel;
|
||||
if (FrameType != FrameType.MethodH)
|
||||
{
|
||||
if (Lead.HasFlag(LeadRequired.UsesLevelCall) != usesLevel)
|
||||
return false;
|
||||
}
|
||||
if (FrameType != FrameType.MethodH && (Lead & LeadRequired.UsesLevelCall) != 0 != usesLevel)
|
||||
return false;
|
||||
|
||||
// Level is before Nature, but usually isn't varied. Check ESV calc first.
|
||||
int s = GetSlot(slot);
|
||||
|
|
|
|||
|
|
@ -155,27 +155,27 @@ public static bool GetIsEncounterable(EncounterSlot slot, FrameType frameType, i
|
|||
private static bool GetCanEncounter(EncounterSlot slot, FrameType frameType, int rand, LeadRequired lead)
|
||||
{
|
||||
int proc = frameType == FrameType.MethodJ ? rand / 656 : rand % 100;
|
||||
if (slot.Type.HasFlag(SlotType.Rock_Smash))
|
||||
if ((slot.Type & SlotType.Rock_Smash) != 0)
|
||||
return proc < 60;
|
||||
if (frameType == FrameType.MethodH)
|
||||
return true; // fishing encounters are disjointed by the hooked message.
|
||||
|
||||
// fishing
|
||||
if (slot.Type.HasFlag(SlotType.Old_Rod))
|
||||
if ((slot.Type & SlotType.Old_Rod) != 0)
|
||||
{
|
||||
if (proc < 25)
|
||||
return true;
|
||||
if (proc < 50)
|
||||
return lead == LeadRequired.None;
|
||||
}
|
||||
else if (slot.Type.HasFlag(SlotType.Good_Rod))
|
||||
else if ((slot.Type & SlotType.Good_Rod) != 0)
|
||||
{
|
||||
if (proc < 50)
|
||||
return true;
|
||||
if (proc < 75 && lead == LeadRequired.None)
|
||||
return lead == LeadRequired.None;
|
||||
}
|
||||
else if (slot.Type.HasFlag(SlotType.Super_Rod))
|
||||
else if ((slot.Type & SlotType.Super_Rod) != 0)
|
||||
{
|
||||
if (proc < 75)
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ public static PIDIV Analyze(PKM pk)
|
|||
for (int i = 0; i < 6; i++)
|
||||
IVs[i] = (uint)iIVs[i];
|
||||
|
||||
PIDIV pidiv;
|
||||
if (GetLCRNGMatch(top, bot, IVs, out pidiv))
|
||||
if (GetLCRNGMatch(top, bot, IVs, out PIDIV pidiv))
|
||||
return pidiv;
|
||||
if (pk.Species == 201 && GetLCRNGUnownMatch(top, bot, IVs, out pidiv)) // frlg only
|
||||
return pidiv;
|
||||
|
|
@ -330,15 +329,14 @@ private static bool GetChainShinyMatch(PKM pk, uint pid, uint[] IVs, out PIDIV p
|
|||
// check the individual bits
|
||||
var s = seed;
|
||||
int i = 15;
|
||||
while (true)
|
||||
do
|
||||
{
|
||||
var bit = s >> 16 & 1;
|
||||
if (bit != (pid >> i & 1))
|
||||
break;
|
||||
s = RNG.LCRNG.Prev(s);
|
||||
if (--i == 2)
|
||||
break;
|
||||
}
|
||||
while (--i != 2);
|
||||
if (i != 2) // bit failed
|
||||
continue;
|
||||
// Shiny Bits of PID validated
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ private static void SetValuesFromSeedBACD(PKM pk, PIDType type, uint seed)
|
|||
|
||||
if (shiny)
|
||||
{
|
||||
uint PID;
|
||||
PID = X & 0xFFFF0000 | (uint)pk.SID ^ (uint)pk.TID ^ X >> 16;
|
||||
uint PID = X & 0xFFFF0000 | (uint)pk.SID ^ (uint)pk.TID ^ X >> 16;
|
||||
PID &= 0xFFFFFFF8;
|
||||
PID |= B >> 16 & 0x7; // lowest 3 bits
|
||||
|
||||
|
|
@ -103,7 +102,7 @@ private static void SetValuesFromSeedChannel(PKM pk, uint seed)
|
|||
var D = rng.Next(C); // Version
|
||||
var E = rng.Next(D); // OT Gender
|
||||
|
||||
var TID = 40122;
|
||||
const int TID = 40122;
|
||||
var SID = (int)(O >> 16);
|
||||
var pid1 = A >> 16;
|
||||
var pid2 = B >> 16;
|
||||
|
|
@ -168,7 +167,7 @@ public static void SetValuesFromSeed(PKM pk, PIDType type, uint seed)
|
|||
case PIDType.G4MGAntiShiny:
|
||||
break;
|
||||
}
|
||||
return (pk, seed) => { };
|
||||
return (pk, _) => { };
|
||||
}
|
||||
|
||||
public static void SetRandomChainShinyPID(PKM pk, uint seed)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,8 @@ private static IEnumerable<RibbonResult> GetInvalidRibbons6Any(PKM pkm, IRibbonS
|
|||
// Each contest victory requires a contest participation; each participation gives 20 OT affection (not current trainer).
|
||||
var affect = pkm.OT_Affection;
|
||||
var contMemory = s6.RibbonNamesContest();
|
||||
var present = contMemory.Where((z, i) => contest[i]).Where((z, i) => affect < 20 * (i+1));
|
||||
int contCount = 0;
|
||||
var present = contMemory.Where((_, i) => contest[i] && affect < 20 * ++contCount);
|
||||
foreach (var rib in present)
|
||||
yield return new RibbonResult(rib);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
/// </summary>
|
||||
internal interface IMoveset
|
||||
{
|
||||
int[] Moves { get; set; }
|
||||
int[] Moves { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ private static MoveType GetMoveTypeFromG12(this MoveType type)
|
|||
{
|
||||
if (type <= MoveType.Rock)
|
||||
return type;
|
||||
type -= 1; // Bird
|
||||
type--; // Skip unused Bird type
|
||||
if (type <= MoveType.Steel)
|
||||
return type;
|
||||
type -= 10; // 10 Normal duplicates
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
|
@ -254,7 +255,7 @@ public static bool CheckVivillonPattern(int form, int country, int region)
|
|||
if (!VivillonCountryTable[form].Contains(country))
|
||||
return false; // Country mismatch
|
||||
|
||||
CountryTable ct = RegionFormTable.Where(t => t.countryID == country).FirstOrDefault();
|
||||
CountryTable ct = Array.Find(RegionFormTable, t => t.countryID == country);
|
||||
if (ct.otherforms == null) // empty struct = no forms referenced
|
||||
return true; // No subregion table
|
||||
|
||||
|
|
@ -271,7 +272,7 @@ public static bool CheckVivillonPattern(int form, int country, int region)
|
|||
/// <param name="region">Console Region ID</param>
|
||||
public static int GetVivillonPattern(int country, int region)
|
||||
{
|
||||
CountryTable ct = RegionFormTable.Where(t => t.countryID == country).FirstOrDefault();
|
||||
CountryTable ct = Array.Find(RegionFormTable, t => t.countryID == country);
|
||||
if (ct.otherforms == null) // empty struct = no forms referenced
|
||||
return ct.mainform; // No subregion table
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public static MysteryGift GetMysteryGift(byte[] data)
|
|||
public string Extension => GetType().Name.ToLower();
|
||||
public string FileName => $"{CardHeader}.{Extension}";
|
||||
public byte[] Data { get; set; }
|
||||
public abstract PKM ConvertToPKM(ITrainerInfo sav);
|
||||
public abstract PKM ConvertToPKM(ITrainerInfo SAV);
|
||||
public abstract int Format { get; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@ public override string CardTitle
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public override int CardID
|
||||
{
|
||||
get => BitConverter.ToUInt16(Data, 0xB0);
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV)
|
|||
}
|
||||
else
|
||||
{
|
||||
pk4.Egg_Location = pk4.Egg_Location + 3000;
|
||||
pk4.Egg_Location += 3000;
|
||||
if (SAV.Generation == 4)
|
||||
{
|
||||
pk4.IsEgg = true;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public PL6(byte[] data = null)
|
|||
Data = data ?? new byte[Size];
|
||||
}
|
||||
/// <summary>
|
||||
/// Pokémon Link Flag
|
||||
/// Pokémon Link Flag
|
||||
/// </summary>
|
||||
public byte PL_Flag {
|
||||
get => Data[0x00]; set => Data[0x00] = value;
|
||||
|
|
@ -171,7 +171,6 @@ public int[] Quantities
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//Battle Points
|
||||
public int BattlePoints {
|
||||
get => BitConverter.ToUInt16(Data, 0x4A1);
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV)
|
|||
pk.Nickname = IsNicknamed ? Nickname : PKX.GetSpeciesNameGeneration(Species, pk.Language, Format);
|
||||
|
||||
int[] finalIVs = new int[6];
|
||||
var ivflag = IVs.FirstOrDefault(iv => (byte)(iv - 0xFC) < 3);
|
||||
var ivflag = Array.Find(IVs, iv => (byte)(iv - 0xFC) < 3);
|
||||
if (ivflag == 0) // Random IVs
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ public override PKM ConvertToPKM(ITrainerInfo SAV)
|
|||
pk.Nickname = IsNicknamed ? Nickname : PKX.GetSpeciesNameGeneration(Species, pk.Language, Format);
|
||||
|
||||
int[] finalIVs = new int[6];
|
||||
var ivflag = IVs.FirstOrDefault(iv => (byte)(iv - 0xFC) < 3);
|
||||
var ivflag = Array.Find(IVs, iv => (byte)(iv - 0xFC) < 3);
|
||||
if (ivflag == 0) // Random IVs
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
|
|
|
|||
|
|
@ -413,8 +413,8 @@ public static void SetMarkings(this PKM pk, int[] IVs = null)
|
|||
return GetSimpleMarking;
|
||||
return GetComplexMarking;
|
||||
|
||||
int GetSimpleMarking(int val, int index) => val == 31 ? 1 : 0;
|
||||
int GetComplexMarking(int val, int index)
|
||||
int GetSimpleMarking(int val, int _) => val == 31 ? 1 : 0;
|
||||
int GetComplexMarking(int val, int _)
|
||||
{
|
||||
if (val == 31 || val == 1)
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -887,6 +887,7 @@ public void SetShinySID()
|
|||
/// <summary>
|
||||
/// Applies a <see cref="PID"/> to the <see cref="PKM"/> according to the specified <see cref="Gender"/>.
|
||||
/// </summary>
|
||||
/// <param name="gender"><see cref="Gender"/> to apply</param>
|
||||
/// <remarks>
|
||||
/// If a <see cref="PKM"/> originated in a generation prior to Generation 6, the <see cref="EncryptionConstant"/> is updated.
|
||||
/// </remarks>
|
||||
|
|
@ -899,6 +900,7 @@ public void SetPIDGender(int gender)
|
|||
/// <summary>
|
||||
/// Applies a <see cref="PID"/> to the <see cref="PKM"/> according to the specified <see cref="Gender"/>.
|
||||
/// </summary>
|
||||
/// <param name="nature"><see cref="Nature"/> to apply</param>
|
||||
/// <remarks>
|
||||
/// If a <see cref="PKM"/> originated in a generation prior to Generation 6, the <see cref="EncryptionConstant"/> is updated.
|
||||
/// </remarks>
|
||||
|
|
@ -911,6 +913,7 @@ public void SetPIDNature(int nature)
|
|||
/// <summary>
|
||||
/// Applies a <see cref="PID"/> to the <see cref="PKM"/> according to the specified <see cref="AltForm"/>.
|
||||
/// </summary>
|
||||
/// <param name="form"><see cref="AltForm"/> to apply</param>
|
||||
/// <remarks>
|
||||
/// This method should only be used for Unown originating in Generation 3 games.
|
||||
/// If a <see cref="PKM"/> originated in a generation prior to Generation 6, the <see cref="EncryptionConstant"/> is updated.
|
||||
|
|
@ -925,6 +928,7 @@ public void SetPIDUnown3(int form)
|
|||
/// <summary>
|
||||
/// Randomizes the IVs within game constraints.
|
||||
/// </summary>
|
||||
/// <param name="flawless">Count of flawless IVs to set. If none provided, a count will be detected.</param>
|
||||
/// <returns>Randomized IVs if desired.</returns>
|
||||
public int[] SetRandomIVs(int? flawless = null)
|
||||
{
|
||||
|
|
@ -947,6 +951,8 @@ public int[] SetRandomIVs(int? flawless = null)
|
|||
/// <summary>
|
||||
/// Randomizes the IVs within game constraints.
|
||||
/// </summary>
|
||||
/// <param name="template">IV template to generate from</param>
|
||||
/// <param name="flawless">Count of flawless IVs to set. If none provided, a count will be detected.</param>
|
||||
/// <returns>Randomized IVs if desired.</returns>
|
||||
public int[] SetRandomIVs(int[] template, int? flawless = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ public static bool IsConvertibleToFormat(PKM pk, int format)
|
|||
/// </summary>
|
||||
/// <param name="pk">PKM to convert</param>
|
||||
/// <param name="PKMType">Format/Type to convert to</param>
|
||||
/// <param name="comment">Comments regarding the transfer's success/failure</param>
|
||||
/// <param name="comment">Comments regarding the transfer's success/failure</param>
|
||||
/// <returns>Converted PKM</returns>
|
||||
public static PKM ConvertToType(PKM pk, Type PKMType, out string comment)
|
||||
{
|
||||
|
|
@ -250,7 +250,6 @@ private static PKM ConvertPKM(PKM pk, Type PKMType, Type fromType, out string co
|
|||
return pkm;
|
||||
}
|
||||
|
||||
|
||||
private static PKM ConvertPKM(PKM pk, Type PKMType, Type fromType, int toFormat, ref string comment)
|
||||
{
|
||||
PKM pkm = pk.Clone();
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public static IEnumerable<PKM> ReverseSort(this IEnumerable<PKM> list)
|
|||
{
|
||||
int i = 0;
|
||||
return list.InitialSortBy()
|
||||
.ThenByDescending(z => i++)
|
||||
.ThenByDescending(_ => i++)
|
||||
; // can't sort further
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -398,7 +398,6 @@ public static void ModifyStatsForNature(ushort[] Stats, int nature)
|
|||
0, 1, 2, 4, 3, 5, 6, 7, 12, 18, 13, 19, 8, 10, 14, 20, 16, 22, 9, 11, 15, 21, 17, 23
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Shuffles a 232 byte array containing <see cref="PKM"/> data.
|
||||
/// </summary>
|
||||
|
|
@ -811,12 +810,13 @@ public static byte GetGCLangIDfromMain(byte value)
|
|||
/// <summary>
|
||||
/// Gets an array of valid <see cref="PKM"/> file extensions.
|
||||
/// </summary>
|
||||
/// <param name="maxGeneration">Maximum Generation to permit</param>
|
||||
/// <returns>Valid <see cref="PKM"/> file extensions.</returns>
|
||||
public static string[] GetPKMExtensions(int MaxGeneration = Generation)
|
||||
public static string[] GetPKMExtensions(int maxGeneration = Generation)
|
||||
{
|
||||
var result = new List<string>();
|
||||
result.AddRange(new [] {"ck3", "xk3", "bk4"}); // Special Cases
|
||||
for (int i = 1; i <= MaxGeneration; i++)
|
||||
for (int i = 1; i <= maxGeneration; i++)
|
||||
result.Add("pk"+i);
|
||||
return result.ToArray();
|
||||
}
|
||||
|
|
@ -865,6 +865,7 @@ public static string GetLocationString(this PKM pk, bool eggmet)
|
|||
/// <summary>
|
||||
/// Copies an <see cref="Enumerable"/> list to the destination list, with an option to copy to a starting point.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Typed object to copy</typeparam>
|
||||
/// <param name="list">Source list to copy from</param>
|
||||
/// <param name="dest">Destination list/array</param>
|
||||
/// <param name="start">Starting point to copy to</param>
|
||||
|
|
|
|||
|
|
@ -49,6 +49,5 @@ public QRPK7(byte[] d)
|
|||
|
||||
Data = (byte[]) d.Clone();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ private static IEnumerable<string> GetHeader(PKM pkm, GameInfo.GameStrings s)
|
|||
}
|
||||
|
||||
if (pkm.Format >= 3)
|
||||
yield return $"{s.natures[pkm.Nature]}";
|
||||
yield return s.natures[pkm.Nature];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ private string GetStringFirstLine(string form)
|
|||
if (!string.IsNullOrWhiteSpace(form))
|
||||
specForm += $"-{form.Replace("Mega ", "Mega-")}";
|
||||
|
||||
string result = Nickname != null && PKX.GetSpeciesNameGeneration(Species, LanguageID, Format) != Nickname ? $"{Nickname} ({specForm})" : $"{specForm}";
|
||||
string result = Nickname != null && PKX.GetSpeciesNameGeneration(Species, LanguageID, Format) != Nickname ? $"{Nickname} ({specForm})" : specForm;
|
||||
if (!string.IsNullOrEmpty(Gender))
|
||||
result += $" ({Gender})";
|
||||
if (HeldItem > 0)
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ public static byte[] SetString5(string value, int maxLength, int padTo = 0, usho
|
|||
/// <param name="data">Encoded data</param>
|
||||
/// <param name="offset">Offset to read from</param>
|
||||
/// <param name="count">Length of data to read.</param>
|
||||
/// <returns>Decoded string.</returns>
|
||||
/// <returns>Decoded string.</returns>
|
||||
public static string GetString6(byte[] data, int offset, int count)
|
||||
{
|
||||
return SanitizeString(Util.TrimFromZero(Encoding.Unicode.GetString(data, offset, count)));
|
||||
|
|
@ -427,7 +427,7 @@ public static string GetString6(byte[] data, int offset, int count)
|
|||
/// <param name="maxLength">Maximum length</param>
|
||||
/// <param name="padTo">Pad to given length</param>
|
||||
/// <param name="padWith">Pad with value</param>
|
||||
/// <returns>Encoded data.</returns>
|
||||
/// <returns>Encoded data.</returns>
|
||||
public static byte[] SetString6(string value, int maxLength, int padTo = 0, ushort padWith = 0)
|
||||
{
|
||||
if (value.Length > maxLength)
|
||||
|
|
@ -548,7 +548,7 @@ private static ushort ConvertValue2CharG4(ushort val)
|
|||
/// <returns>Encoded value.</returns>
|
||||
private static ushort ConvertChar2ValueG4(ushort chr)
|
||||
{
|
||||
if (chr == 0x27) // apostrophe, used by Farfetch'd
|
||||
if (chr == 0x27) // apostrophe, used by Farfetch'd
|
||||
return 0x1B3; // here rather than in static constructor to prevent byte[]->str outputting ’ instead of '
|
||||
return G4CharId.TryGetValue(chr, out int index)
|
||||
? G4Values[index] : ushort.MaxValue;
|
||||
|
|
@ -1925,16 +1925,16 @@ private static byte SetG3Char(ushort chr, bool jp)
|
|||
private const ushort SM_ZHCharTable_Size = 0x30F;
|
||||
private const ushort USUM_CHS_Size = 0x4;
|
||||
private const ushort USUM_CHT_Size = 0x5;
|
||||
private static bool getisG7CHSChar(int idx) => idx < SM_ZHCharTable_Size || SM_ZHCharTable_Size * 2 <= idx && idx < SM_ZHCharTable_Size * 2 + USUM_CHS_Size;
|
||||
private static bool GetisG7CHSChar(int idx) => idx < SM_ZHCharTable_Size || SM_ZHCharTable_Size * 2 <= idx && idx < SM_ZHCharTable_Size * 2 + USUM_CHS_Size;
|
||||
|
||||
private static readonly Dictionary<char, int> G7_CHS = Gen7_ZH
|
||||
.Select((value, index) => new { value, index })
|
||||
.Where(pair => getisG7CHSChar(pair.index))
|
||||
.Where(pair => GetisG7CHSChar(pair.index))
|
||||
.ToDictionary(pair => pair.value, pair => pair.index);
|
||||
|
||||
private static readonly Dictionary<char, int> G7_CHT = Gen7_ZH
|
||||
.Select((value, index) => new { value, index })
|
||||
.Where(pair => !getisG7CHSChar(pair.index))
|
||||
.Where(pair => !GetisG7CHSChar(pair.index))
|
||||
.ToDictionary(pair => pair.value, pair => pair.index);
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -98,10 +98,16 @@ protected static byte[] SetBits(bool[] bits)
|
|||
/// <summary>
|
||||
/// Injects supplementary TM/HM compatibility which is not present in the generation specific <see cref="PersonalInfo"/> format.
|
||||
/// </summary>
|
||||
/// <param name="data">Data to read from</param>
|
||||
/// <param name="start">Starting offset to read at</param>
|
||||
/// <param name="length">Amount of bytes to decompose into bits</param>
|
||||
internal void AddTMHM(byte[] data, int start = 0, int length = -1) => TMHM = GetBits(data, start, length);
|
||||
/// <summary>
|
||||
/// Injects supplementary Type Tutor compatibility which is not present in the generation specific <see cref="PersonalInfo"/> format.
|
||||
/// </summary>
|
||||
/// <param name="data">Data to read from</param>
|
||||
/// <param name="start">Starting offset to read at</param>
|
||||
/// <param name="length">Amount of bytes to decompose into bits</param>
|
||||
internal void AddTypeTutors(byte[] data, int start = 0, int length = -1) => TypeTutors = GetBits(data, start, length);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ public int[] Moves
|
|||
Move2 = value[1];
|
||||
Move3 = value[2];
|
||||
Move4 = value[3];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ internal static bool[] RibbonBits(this IRibbonSetCommon3 set)
|
|||
set.RibbonEffort,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNames(this IRibbonSetCommon3 set) => RibbonSetNamesCommon3;
|
||||
internal static string[] RibbonNames(this IRibbonSetCommon3 _) => RibbonSetNamesCommon3;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ internal static bool[] RibbonBitsCosmetic(this IRibbonSetCommon4 set)
|
|||
set.RibbonGorgeousRoyal,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNamesCosmetic(this IRibbonSetCommon4 set) => RibbonSetNamesCommon4;
|
||||
internal static string[] RibbonNamesCosmetic(this IRibbonSetCommon4 _) => RibbonSetNamesCommon4;
|
||||
private static readonly string[] RibbonSetNamesCommon4Only =
|
||||
{
|
||||
nameof(IRibbonSetCommon4.RibbonRecord), nameof(IRibbonSetCommon4.RibbonChampionSinnoh), nameof(IRibbonSetCommon4.RibbonLegend),
|
||||
|
|
@ -52,7 +52,7 @@ internal static bool[] RibbonBitsOnly(this IRibbonSetCommon4 set)
|
|||
set.RibbonLegend,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNamesOnly(this IRibbonSetCommon4 set) => RibbonSetNamesCommon4Only;
|
||||
internal static string[] RibbonNamesOnly(this IRibbonSetCommon4 _) => RibbonSetNamesCommon4Only;
|
||||
|
||||
private static readonly string[] RibbonSetNamesCommon4Daily =
|
||||
{
|
||||
|
|
@ -76,6 +76,6 @@ internal static bool[] RibbonBitsDaily(this IRibbonSetCommon4 set)
|
|||
set.RibbonSmile,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNamesDaily(this IRibbonSetCommon4 set) => RibbonSetNamesCommon4Daily;
|
||||
internal static string[] RibbonNamesDaily(this IRibbonSetCommon4 _) => RibbonSetNamesCommon4Daily;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ internal static bool[] RibbonBitsContest(this IRibbonSetCommon6 set)
|
|||
set.RibbonMasterToughness,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNamesBool(this IRibbonSetCommon6 set) => RibbonSetNamesCommon6Bool;
|
||||
internal static string[] RibbonNamesContest(this IRibbonSetCommon6 set) => RibbonSetNamesCommon6Contest;
|
||||
internal static string[] RibbonNamesBool(this IRibbonSetCommon6 _) => RibbonSetNamesCommon6Bool;
|
||||
internal static string[] RibbonNamesContest(this IRibbonSetCommon6 _) => RibbonSetNamesCommon6Contest;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,6 @@ internal static bool[] RibbonBits(this IRibbonSetCommon7 set)
|
|||
set.RibbonBattleTreeMaster,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNames(this IRibbonSetCommon7 set) => RibbonSetNamesCommon7;
|
||||
internal static string[] RibbonNames(this IRibbonSetCommon7 _) => RibbonSetNamesCommon7;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,6 @@ internal static bool[] RibbonBits(this IRibbonSetEvent3 set)
|
|||
set.RibbonChampionNational,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNames(this IRibbonSetEvent3 set) => RibbonSetNamesEvent3;
|
||||
internal static string[] RibbonNames(this IRibbonSetEvent3 _) => RibbonSetNamesEvent3;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,6 @@ internal static int[] RibbonCounts(this IRibbonSetOnly3 set)
|
|||
set.RibbonCountG3Tough,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNames(this IRibbonSetOnly3 set) => RibbonSetNamesOnly3;
|
||||
internal static string[] RibbonNames(this IRibbonSetOnly3 _) => RibbonSetNamesOnly3;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ internal static bool[] RibbonBits(this IRibbonSetUnique3 set)
|
|||
set.RibbonVictory,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNames(this IRibbonSetUnique3 set) => RibbonSetNamesUnique3;
|
||||
internal static string[] RibbonNames(this IRibbonSetUnique3 _) => RibbonSetNamesUnique3;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ internal static bool[] RibbonBitsAbility(this IRibbonSetUnique4 set)
|
|||
}
|
||||
internal static bool[] RibbonBitsContest3(this IRibbonSetUnique4 set)
|
||||
{
|
||||
|
||||
if (set == null)
|
||||
return new bool[20];
|
||||
|
||||
|
|
@ -192,8 +191,8 @@ internal static bool[] RibbonBitsContest4(this IRibbonSetUnique4 set)
|
|||
set.RibbonG4ToughMaster,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNamesAbility(this IRibbonSetUnique4 set) => RibbonSetNamesUnique4Ability;
|
||||
internal static string[] RibbonNamesContest3(this IRibbonSetUnique4 set) => RibbonSetNamesUnique4Contest3;
|
||||
internal static string[] RibbonNamesContest4(this IRibbonSetUnique4 set) => RibbonSetNamesUnique4Contest4;
|
||||
internal static string[] RibbonNamesAbility(this IRibbonSetUnique4 _) => RibbonSetNamesUnique4Ability;
|
||||
internal static string[] RibbonNamesContest3(this IRibbonSetUnique4 _) => RibbonSetNamesUnique4Contest3;
|
||||
internal static string[] RibbonNamesContest4(this IRibbonSetUnique4 _) => RibbonSetNamesUnique4Contest4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ internal static bool[] RibbonBits(this IRibbonSetEvent4 set)
|
|||
set.RibbonSouvenir,
|
||||
};
|
||||
}
|
||||
internal static string[] RibbonNames(this IRibbonSetEvent4 set) => RibbonSetNamesEvent4;
|
||||
internal static string[] RibbonNames(this IRibbonSetEvent4 _) => RibbonSetNamesEvent4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ public static bool VerifyMemeData(byte[] input, out byte[] output, MemeKeyIndex
|
|||
Array.Copy(input, input.Length - 0x60, sigBuffer, 0, 0x60);
|
||||
sigBuffer = memekey.RsaPublic(sigBuffer);
|
||||
using (var sha1 = SHA1.Create())
|
||||
{
|
||||
foreach (var orVal in new byte[] { 0, 0x80 })
|
||||
{
|
||||
sigBuffer[0x0] |= orVal;
|
||||
|
|
@ -76,6 +77,8 @@ public static bool VerifyMemeData(byte[] input, out byte[] output, MemeKeyIndex
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output = null;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -140,6 +143,7 @@ public static byte[] SignMemeData(byte[] input, MemeKeyIndex keyIndex = MemeKeyI
|
|||
/// <summary>
|
||||
/// Resigns save data.
|
||||
/// </summary>
|
||||
/// <param name="sav7">Save file data to resign</param>
|
||||
/// <returns>The resigned save data. Invalid input returns null.</returns>
|
||||
public static byte[] Resign7(byte[] sav7)
|
||||
{
|
||||
|
|
@ -173,6 +177,5 @@ public static byte[] Resign7(byte[] sav7)
|
|||
}
|
||||
return outSav;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,9 +211,6 @@ internal byte[] RsaPublic(byte[] data)
|
|||
return Exponentiate(M, E);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region MemeKey Helper Methods
|
||||
/// <summary> Indicator value for a bad Exponent </summary>
|
||||
private static readonly BigInteger INVALID = BigInteger.MinusOne;
|
||||
|
|
@ -231,7 +228,6 @@ private byte[] Exponentiate(BigInteger M, BigInteger Power)
|
|||
else
|
||||
Array.Copy(rawSig, outSig, 0x60);
|
||||
return outSig;
|
||||
|
||||
}
|
||||
// Helper Method to retrieve data for loading
|
||||
private static void GetMemeData(MemeKeyIndex key, out byte[] d, out byte[] der)
|
||||
|
|
|
|||
|
|
@ -170,7 +170,6 @@ protected override byte[] Write(bool DSV)
|
|||
return outData;
|
||||
}
|
||||
|
||||
|
||||
// Configuration
|
||||
public override SaveFile Clone() { return new SAV1(Write(DSV: false)); }
|
||||
|
||||
|
|
@ -527,7 +526,7 @@ public bool[] EventSpawnFlags
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString1(Data, Offset, Count, Japanese);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetString1(Data, Offset, Length, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -595,11 +595,11 @@ public void UnlockAllDecorations()
|
|||
SetEventFlag(i, true);
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count)
|
||||
public override string GetString(int Offset, int Length)
|
||||
{
|
||||
if (Korean)
|
||||
return StringConverter.GetString2KOR(Data, Offset, Count);
|
||||
return StringConverter.GetString1(Data, Offset, Count, Japanese);
|
||||
return StringConverter.GetString2KOR(Data, Offset, Length);
|
||||
return StringConverter.GetString1(Data, Offset, Length, Japanese);
|
||||
}
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -299,8 +299,7 @@ public override byte[] DecryptPKM(byte[] data)
|
|||
|
||||
protected override void SetPKM(PKM pkm)
|
||||
{
|
||||
var pk = pkm as CK3;
|
||||
if (pk == null)
|
||||
if (!(pkm is CK3 pk))
|
||||
return;
|
||||
|
||||
if (pk.CurrentRegion == 0)
|
||||
|
|
@ -394,7 +393,7 @@ public override InventoryPouch[] Inventory
|
|||
public override void SetDaycareEXP(int loc, int slot, uint EXP) { }
|
||||
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetBEString3(Data, Offset, Length);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ public override void SetStoredSlot(PKM pkm, int offset, bool? trade = null, bool
|
|||
Edited = true;
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString3(Data, Offset, Count, Japanese);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetString3(Data, Offset, Length, Japanese);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -286,8 +286,7 @@ public override PKM GetStoredSlot(int offset)
|
|||
}
|
||||
protected override void SetPKM(PKM pkm)
|
||||
{
|
||||
XK3 pk = pkm as XK3;
|
||||
if (pk == null)
|
||||
if (!(pkm is XK3 pk))
|
||||
return; // shouldn't ever hit
|
||||
|
||||
if (pk.CurrentRegion == 0)
|
||||
|
|
@ -361,7 +360,7 @@ public override InventoryPouch[] Inventory
|
|||
public override void SetDaycareEXP(int loc, int slot, uint EXP) { }
|
||||
public override void SetDaycareOccupied(int loc, int slot, bool occupied) { }
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString3(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetBEString3(Data, Offset, Length);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -901,7 +901,7 @@ protected override void SetDex(PKM pkm)
|
|||
}
|
||||
private static int GetGen4LanguageBitIndex(int lang)
|
||||
{
|
||||
lang -= 1;
|
||||
lang--;
|
||||
switch (lang) // invert ITA/GER
|
||||
{
|
||||
case 3: return 4;
|
||||
|
|
@ -1215,7 +1215,7 @@ public bool[] PokewalkerCoursesUnlocked
|
|||
public int GetApricornCount(int i) => !HGSS ? -1 : Data[0xE558 + GBO + i];
|
||||
public void SetApricornCount(int i, int count) => Data[0xE558 + GBO + i] = (byte)count;
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString4(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetString4(Data, Offset, Length);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ private static void SetChecksum(byte[] input, int offset, int len, int checksum_
|
|||
}
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetBEString4(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetBEString4(Data, Offset, Length);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@ public override bool GetSeen(int species)
|
|||
return false;
|
||||
}
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString5(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetString5(Data, Offset, Length);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
@ -507,7 +507,6 @@ public override byte[] SetString(string value, int maxLength, int PadToSize = 0,
|
|||
return StringConverter.SetString5(value, maxLength, PadToSize, PadWith);
|
||||
}
|
||||
|
||||
|
||||
// DLC
|
||||
private int CGearSkinInfoOffset => CGearInfoOffset + (B2W2 ? 0x10 : 0) + 0x24;
|
||||
private bool CGearSkinPresent
|
||||
|
|
|
|||
|
|
@ -1003,7 +1003,7 @@ public override string MiscSaveChecks()
|
|||
}
|
||||
public override string MiscSaveInfo() => string.Join(Environment.NewLine, Blocks.Select(b => b.Summary));
|
||||
|
||||
public override string GetString(int Offset, int Count) => StringConverter.GetString6(Data, Offset, Count);
|
||||
public override string GetString(int Offset, int Length) => StringConverter.GetString6(Data, Offset, Length);
|
||||
public override byte[] SetString(string value, int maxLength, int PadToSize = 0, ushort PadWith = 0)
|
||||
{
|
||||
if (PadToSize == 0)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,6 @@ private void GetSAVOffsets()
|
|||
LastViewedBox = PCLayout + 0x5E3;
|
||||
PCFlags = PCLayout + 0x5E0;
|
||||
|
||||
|
||||
FashionLength = 0x1A08;
|
||||
|
||||
TeamCount = 6;
|
||||
|
|
@ -221,7 +220,6 @@ private void GetSAVOffsets()
|
|||
private int LastViewedBox { get; set; } = int.MinValue;
|
||||
private int WondercardFlags { get; set; } = int.MinValue;
|
||||
private int PlayTime { get; set; } = int.MinValue;
|
||||
private int ItemInfo { get; set; } = int.MinValue;
|
||||
private int Overworld { get; set; } = int.MinValue;
|
||||
public int JoinFestaData { get; set; } = int.MinValue;
|
||||
private int PokeFinderSave { get; set; } = int.MinValue;
|
||||
|
|
@ -1427,7 +1425,7 @@ public override string MiscSaveChecks()
|
|||
{
|
||||
if (Data.Skip(i * 0x200).Take(0x200).Any(z => z != 0xFF))
|
||||
continue;
|
||||
r.AppendLine($"0x200 chunk @ 0x{i*0x200:X5} is FF'd.");
|
||||
r.Append("0x200 chunk @ 0x").AppendFormat("{0:X5}", i * 0x200).AppendLine(" is FF'd.");
|
||||
r.AppendLine("Cyber will screw up (as of August 31st 2014).");
|
||||
r.AppendLine();
|
||||
|
||||
|
|
|
|||
|
|
@ -1050,7 +1050,7 @@ public static ushort[] AdvanceGCKeys(ushort[] oldKeys)
|
|||
{
|
||||
uint s7 = 4294;
|
||||
if (val > 967295)
|
||||
s7 -= 1;
|
||||
s7--;
|
||||
s7 = (uint)Util.Rand.Next(0, (int)s7);
|
||||
val += s7 * 1000000;
|
||||
}
|
||||
|
|
@ -1158,7 +1158,7 @@ public static byte[] GetMainFromSaveContainer(byte[] input)
|
|||
/// <summary>
|
||||
/// Checks if the <see cref="PKM"/> is compatible with the input <see cref="SaveFile"/>, and makes any necessary modifications to force compatibility.
|
||||
/// </summary>
|
||||
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
|
||||
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
|
||||
/// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
|
||||
/// <param name="SAV">Save File target that the PKM will be injected.</param>
|
||||
/// <param name="pk">PKM input that is to be injected into the Save File.</param>
|
||||
|
|
@ -1186,7 +1186,7 @@ public static bool IsPKMCompatibleWithModifications(SaveFile SAV, PKM pk)
|
|||
/// <summary>
|
||||
/// Checks if the <see cref="PKM"/> is compatible with the input <see cref="PKM"/>, and makes any necessary modifications to force compatibility.
|
||||
/// </summary>
|
||||
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
|
||||
/// <remarks>Should only be used when forcing a backwards conversion to sanitize the PKM fields to the target format.
|
||||
/// If the PKM is compatible, some properties may be forced to sanitized values.</remarks>
|
||||
/// <param name="pk">PKM input that is to be sanity checked.</param>
|
||||
/// <returns>Indication whether or not the PKM is compatible.</returns>
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ public BV6(byte[] data)
|
|||
private readonly byte[] Data;
|
||||
|
||||
private int Mode { get => Data[0x00]; set => Data[0x00] = (byte)value; }
|
||||
private string[] BVmode =
|
||||
private static readonly string[] BVmode =
|
||||
{
|
||||
"Link", "Maison", "Super Maison", "Battle Spot - Free", "Battle Spot - Rating",
|
||||
"Battle Spot - Special", "UNUSED", "JP-1", "JP-2", "BROKEN",
|
||||
};
|
||||
private int Style { get => Data[0x01]; set => Data[0x01] = (byte)value; }
|
||||
private string[] BVstyle = { "Single", "Double", "Triple", "Rotation", "Multi", };
|
||||
private static readonly string[] BVstyle = { "Single", "Double", "Triple", "Rotation", "Multi", };
|
||||
private string Debug1
|
||||
{
|
||||
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x6, 24));
|
||||
|
|
@ -49,7 +49,6 @@ private string Debug2
|
|||
private int IntroID { get => BitConverter.ToUInt16(Data, 0x1E4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E4); }
|
||||
private int MusicID { get => BitConverter.ToUInt16(Data, 0x1F0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1F0); }
|
||||
|
||||
|
||||
public override PKM[] BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
|
||||
public override int Generation => 6;
|
||||
|
||||
|
|
@ -139,12 +138,12 @@ public DateTime UploadStamp
|
|||
}
|
||||
|
||||
// Battle Instruction Parsing
|
||||
private string[] Action = { "0", "Fight", "2", "Switch", "Run", "5", "Rotate", "7", "MegaEvolve" };
|
||||
private string[] Target =
|
||||
private static readonly string[] Action = { "0", "Fight", "2", "Switch", "Run", "5", "Rotate", "7", "MegaEvolve" };
|
||||
private static readonly string[] Target =
|
||||
{
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Opposite Enemy", "B", "C", "D",
|
||||
"All except User", "Everyone"
|
||||
};
|
||||
private string[] Rotate = { "0", "Right", "Left", "3" };
|
||||
private static readonly string[] Rotate = { "0", "Right", "Left", "3" };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class CGearBackground
|
|||
* 32 * 24 = 0x300
|
||||
* The tiles are chosen based on the 16bit index of the tile.
|
||||
* 0x300 * 2 = 0x600!
|
||||
*
|
||||
*
|
||||
* CGearBackgrounds tilemap (when stored on BW) employs some obfuscation.
|
||||
* BW obfuscates by adding 0xA0A0.
|
||||
* The obfuscated number is then tweaked by adding 15*(i/17)
|
||||
|
|
@ -314,7 +314,7 @@ internal byte[] Write()
|
|||
private static int ValToIndex(int val)
|
||||
{
|
||||
if ((val & 0x3FF) < 0xA0 || (val & 0x3FF) > 0x280)
|
||||
return ((val & 0x5C00) | 0xFF);
|
||||
return (val & 0x5C00) | 0xFF;
|
||||
return ((val % 0x20) + 0x11 * (((val & 0x3FF) - 0xA0) / 0x20)) | (val & 0x5C00);
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,6 @@ private static void GetTileList(IReadOnlyList<Tile> tiles, out List<Tile> tileli
|
|||
// start at 1 as the 0th tile is always non-duplicate
|
||||
for (int i = 1; i < tm.TileChoices.Length; i++)
|
||||
FindPossibleRotatedTile(tiles[i], tilelist, tm, i);
|
||||
|
||||
}
|
||||
private static void FindPossibleRotatedTile(Tile t, IList<Tile> tilelist, TileMap tm, int tileIndex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
public class G1OverworldSpawner
|
||||
{
|
||||
|
||||
private readonly SAV1 SAV;
|
||||
private readonly bool[] EventFlags;
|
||||
private readonly bool[] SpawnFlags;
|
||||
|
|
@ -86,7 +85,6 @@ public class FlagPair
|
|||
public void Reset() => SetState(false);
|
||||
public void SetState(bool despawned)
|
||||
{
|
||||
|
||||
if (EventFlag != 0)
|
||||
Event[EventFlag] = despawned;
|
||||
if (SpawnFlag != 0)
|
||||
|
|
@ -119,8 +117,7 @@ public IEnumerable<FlagPair> GetFlagPairs()
|
|||
|
||||
foreach (var pair in pz)
|
||||
{
|
||||
var p = ReflectUtil.GetValue(this, pair) as FlagPair;
|
||||
if (p == null)
|
||||
if (!(ReflectUtil.GetValue(this, pair) is FlagPair p))
|
||||
continue;
|
||||
p.Name = pair;
|
||||
p.Event = EventFlags;
|
||||
|
|
|
|||
|
|
@ -204,7 +204,6 @@ public void GetPouchG1(byte[] Data)
|
|||
}
|
||||
}
|
||||
Items = items;
|
||||
|
||||
}
|
||||
public void SetPouchG1(byte[] Data)
|
||||
{
|
||||
|
|
@ -269,7 +268,7 @@ public void SortByName(string[] names, bool reverse = false)
|
|||
public void Sanitize(bool HaX, int MaxItemID)
|
||||
{
|
||||
var x = Items.Where(item => item.Valid(LegalItems, HaX, MaxItemID)).ToArray();
|
||||
Items = x.Concat(new byte[PouchDataSize - x.Length].Select(i => new InventoryItem())).ToArray();
|
||||
Items = x.Concat(new byte[PouchDataSize - x.Length].Select(_ => new InventoryItem())).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public SAV2Offsets(SAV2 sav)
|
|||
if (sav.Japanese)
|
||||
LoadOffsetsJapanese(sav.Version);
|
||||
else if (sav.Korean)
|
||||
LoadOffsetsKorean(sav.Version);
|
||||
LoadOffsetsKorean();
|
||||
else
|
||||
LoadOffsetsInternational(sav.Version);
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ private void LoadOffsetsJapanese(GameVersion Version)
|
|||
|
||||
public int OverallChecksumPosition2 { get; set; }
|
||||
|
||||
private void LoadOffsetsKorean(GameVersion Version)
|
||||
private void LoadOffsetsKorean()
|
||||
{
|
||||
// No Crystal Version
|
||||
DaylightSavings = 0x2042;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public ShadowInfoTableXD(byte[] data)
|
|||
public byte[] FinalData => Entries.SelectMany(entry => entry.Data).Take(MaxLength).ToArray();
|
||||
public ShadowInfoEntryXD GetEntry(int Species, uint PID)
|
||||
{
|
||||
return Entries.FirstOrDefault(entry => entry.PID == PID && entry.Species == Species) ?? new ShadowInfoEntryXD();
|
||||
return Entries.Find(entry => entry.PID == PID && entry.Species == Species) ?? new ShadowInfoEntryXD();
|
||||
}
|
||||
public void SetEntry(ShadowInfoEntryXD Entry)
|
||||
{
|
||||
|
|
@ -47,7 +47,7 @@ public void SetEntry(ShadowInfoEntryXD Entry)
|
|||
|
||||
public class ShadowInfoEntryXD
|
||||
{
|
||||
public byte[] Data { get; private set; }
|
||||
public byte[] Data { get; }
|
||||
internal const int SIZE_ENTRY = 72;
|
||||
public ShadowInfoEntryXD(byte[] data = null)
|
||||
{
|
||||
|
|
@ -66,7 +66,7 @@ public ShadowInfoEntryXD(byte[] data = null)
|
|||
|
||||
public class ShadowInfoEntryColo
|
||||
{
|
||||
public byte[] Data { get; private set; }
|
||||
public byte[] Data { get; }
|
||||
internal const int SIZE_ENTRY = 12;
|
||||
public ShadowInfoEntryColo(byte[] data = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class StrategyMemo
|
|||
private readonly bool XD;
|
||||
private const int SIZE_ENTRY = 12;
|
||||
private readonly List<StrategyMemoEntry> Entries = new List<StrategyMemoEntry>();
|
||||
private StrategyMemoEntry this[int Species] => Entries.FirstOrDefault(e => e.Species == Species);
|
||||
private StrategyMemoEntry this[int Species] => Entries.Find(e => e.Species == Species);
|
||||
private readonly byte[] _unk;
|
||||
|
||||
public StrategyMemo(byte[] input, int offset, bool xd)
|
||||
|
|
@ -92,7 +92,7 @@ public bool Owned
|
|||
get
|
||||
{
|
||||
if (XD) return false;
|
||||
return Flag0 | Flag1 == false;
|
||||
return Flag0 | !Flag1;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public partial class Util
|
||||
public static partial class Util
|
||||
{
|
||||
private const string TranslationSplitter = " = ";
|
||||
private static readonly Assembly thisAssembly = typeof(Util).GetTypeInfo().Assembly;
|
||||
|
|
@ -15,7 +15,7 @@ public partial class Util
|
|||
private static readonly Dictionary<string, string> resourceNameMap = new Dictionary<string, string>();
|
||||
private static readonly Dictionary<string, string[]> stringListCache = new Dictionary<string, string[]>();
|
||||
|
||||
#region String Lists
|
||||
#region String Lists
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all Pokémon species names.
|
||||
|
|
@ -119,9 +119,11 @@ public static byte[] GetBinaryResource(string name)
|
|||
public static string GetStringResource(string name)
|
||||
{
|
||||
if (!resourceNameMap.ContainsKey(name))
|
||||
resourceNameMap.Add(name, manifestResourceNames.FirstOrDefault(x =>
|
||||
x.StartsWith("PKHeX.Core.Resources.text.") &&
|
||||
x.EndsWith($"{name}.txt", StringComparison.OrdinalIgnoreCase)));
|
||||
{
|
||||
bool Match(string x) => x.StartsWith("PKHeX.Core.Resources.text.") && x.EndsWith($"{name}.txt", StringComparison.OrdinalIgnoreCase);
|
||||
var resname = Array.Find(manifestResourceNames, Match);
|
||||
resourceNameMap.Add(name, resname);
|
||||
}
|
||||
|
||||
if (resourceNameMap[name] == null)
|
||||
return null;
|
||||
|
|
@ -145,12 +147,14 @@ private static string[] GetProperties(IEnumerable<string> input)
|
|||
private static IEnumerable<string> DumpStrings(Type t)
|
||||
{
|
||||
var props = ReflectUtil.GetPropertiesStartWithPrefix(t, "");
|
||||
return props.Select(p => $"{p}{TranslationSplitter}{ReflectUtil.GetValue(t, p).ToString()}");
|
||||
return props.Select(p => $"{p}{TranslationSplitter}{ReflectUtil.GetValue(t, p)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current localization in a static class containing language-specific strings
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <param name="existingLines">Existing localization lines (if provided)</param>
|
||||
public static string[] GetLocalization(Type t, string[] existingLines = null)
|
||||
{
|
||||
existingLines = existingLines ?? new string[0];
|
||||
|
|
@ -259,7 +263,7 @@ public static List<ComboItem> GetOffsetCBList(List<ComboItem> cbList, string[] i
|
|||
allowed = Enumerable.Range(0, inStrings.Length).ToArray();
|
||||
|
||||
var list = allowed
|
||||
.Select((z, i) => new ComboItem {Text = inStrings[z - offset], Value = z})
|
||||
.Select(z => new ComboItem {Text = inStrings[z - offset], Value = z})
|
||||
.OrderBy(z => z.Text);
|
||||
|
||||
cbList.AddRange(list);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public partial class Util
|
||||
public static partial class Util
|
||||
{
|
||||
public static string CleanFileName(string fileName)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public partial class Util
|
||||
public static partial class Util
|
||||
{
|
||||
public static readonly Random Rand = new Random();
|
||||
public static uint Rand32()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public partial class Util
|
||||
public static partial class Util
|
||||
{
|
||||
public static int ToInt32(string value)
|
||||
{
|
||||
|
|
@ -36,7 +36,6 @@ private void PopulateFieldsPK4()
|
|||
UpdateStats();
|
||||
}
|
||||
|
||||
|
||||
private PKM PreparePK4()
|
||||
{
|
||||
var pk4 = pkm;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ private void SavePartyStats(PKM pk)
|
|||
private readonly PictureBox[] movePB, relearnPB;
|
||||
private readonly ToolTip Tip3 = new ToolTip(), NatureTip = new ToolTip();
|
||||
private SaveFile RequestSaveFile => SaveFileRequested?.Invoke(this, EventArgs.Empty);
|
||||
public bool PKMIsUnsaved => FieldsInitialized && FieldsLoaded && LastData != null && LastData.Any(b => b != 0) && !LastData.SequenceEqual(CurrentPKM.Data);
|
||||
public bool PKMIsUnsaved => FieldsInitialized && FieldsLoaded && LastData?.Any(b => b != 0) == true && !LastData.SequenceEqual(CurrentPKM.Data);
|
||||
public bool IsEmptyOrEgg => CHK_IsEgg.Checked || CB_Species.SelectedIndex == 0;
|
||||
|
||||
private readonly ComboBox[] Moves, Relearn, ValidationRequired, PPUps;
|
||||
|
|
@ -109,7 +109,7 @@ public bool VerifiedPKM()
|
|||
return true; // Override
|
||||
// Make sure the PKX Fields are filled out properly (color check)
|
||||
|
||||
var cb = ValidationRequired.FirstOrDefault(c => c.BackColor == Color.DarkSalmon && c.Items.Count != 0);
|
||||
var cb = Array.Find(ValidationRequired, c => c.BackColor == Color.DarkSalmon && c.Items.Count != 0);
|
||||
if (cb != null)
|
||||
{
|
||||
Control c = cb.Parent; while (!(c is TabPage)) c = c.Parent;
|
||||
|
|
@ -537,10 +537,11 @@ private void ClickGender(object sender, EventArgs e)
|
|||
}
|
||||
private void ClickPPUps(object sender, EventArgs e)
|
||||
{
|
||||
CB_PPu1.SelectedIndex = !ModifierKeys.HasFlag(Keys.Control) && WinFormsUtil.GetIndex(CB_Move1) > 0 ? 3 : 0;
|
||||
CB_PPu2.SelectedIndex = !ModifierKeys.HasFlag(Keys.Control) && WinFormsUtil.GetIndex(CB_Move2) > 0 ? 3 : 0;
|
||||
CB_PPu3.SelectedIndex = !ModifierKeys.HasFlag(Keys.Control) && WinFormsUtil.GetIndex(CB_Move3) > 0 ? 3 : 0;
|
||||
CB_PPu4.SelectedIndex = !ModifierKeys.HasFlag(Keys.Control) && WinFormsUtil.GetIndex(CB_Move4) > 0 ? 3 : 0;
|
||||
bool min = ModifierKeys.HasFlag(Keys.Control);
|
||||
CB_PPu1.SelectedIndex = !min && WinFormsUtil.GetIndex(CB_Move1) > 0 ? 3 : 0;
|
||||
CB_PPu2.SelectedIndex = !min && WinFormsUtil.GetIndex(CB_Move2) > 0 ? 3 : 0;
|
||||
CB_PPu3.SelectedIndex = !min && WinFormsUtil.GetIndex(CB_Move3) > 0 ? 3 : 0;
|
||||
CB_PPu4.SelectedIndex = !min && WinFormsUtil.GetIndex(CB_Move4) > 0 ? 3 : 0;
|
||||
}
|
||||
private void ClickMarking(object sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -1382,11 +1383,10 @@ private void ValidateComboBox(object sender)
|
|||
{
|
||||
if (!FieldsInitialized)
|
||||
return;
|
||||
ComboBox cb = sender as ComboBox;
|
||||
if (cb == null)
|
||||
if (!(sender is ComboBox cb))
|
||||
return;
|
||||
|
||||
if (cb.Text == "" && cb.Items.Count > 0)
|
||||
if (cb.Text?.Length == 0 && cb.Items.Count > 0)
|
||||
{ cb.SelectedIndex = 0; return; }
|
||||
if (cb.SelectedValue == null)
|
||||
cb.BackColor = Color.DarkSalmon;
|
||||
|
|
@ -1445,7 +1445,7 @@ private void ValidateMovePaint(object sender, DrawItemEventArgs e)
|
|||
|
||||
var i = (ComboItem)((ComboBox)sender).Items[e.Index];
|
||||
var moves = Legality.AllSuggestedMovesAndRelearn;
|
||||
bool vm = moves != null && moves.Contains(i.Value) && !HaX;
|
||||
bool vm = moves?.Contains(i.Value) == true && !HaX;
|
||||
|
||||
bool current = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
|
||||
Brush tBrush = current ? SystemBrushes.HighlightText : new SolidBrush(e.ForeColor);
|
||||
|
|
@ -1492,6 +1492,8 @@ private void OpenHistory(object sender, EventArgs e)
|
|||
/// <summary>
|
||||
/// Refreshes the interface for the current PKM format.
|
||||
/// </summary>
|
||||
/// <param name="sav">Save File context the editor is editing for</param>
|
||||
/// <param name="pk">Pokémon data to edit</param>
|
||||
public bool ToggleInterface(SaveFile sav, PKM pk)
|
||||
{
|
||||
if (pk.GetType() != sav.PKMType || pkm.Format < 3)
|
||||
|
|
@ -1714,7 +1716,7 @@ private static List<string> GetSuggestionMessage(PKM pkm, int level, int locatio
|
|||
if (pkm.Format >= 3)
|
||||
{
|
||||
var met_list = GameInfo.GetLocationList((GameVersion)pkm.Version, pkm.Format, egg: false);
|
||||
var locstr = met_list.FirstOrDefault(loc => loc.Value == location).Text;
|
||||
var locstr = met_list.Find(loc => loc.Value == location).Text;
|
||||
suggestion.Add($"{MsgPKMSuggestionMetLocation} {locstr}");
|
||||
suggestion.Add($"{MsgPKMSuggestionMetLevel} {level}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,7 +408,6 @@ public void ToggleInterface(int gen)
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
void SetMaskSize(Size s, string Mask)
|
||||
{
|
||||
foreach (var ctrl in MT_EVs)
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ public void SetParty()
|
|||
}
|
||||
public void ClickUndo()
|
||||
{
|
||||
if (!UndoStack.Any())
|
||||
if (UndoStack.Count == 0)
|
||||
return;
|
||||
|
||||
SlotChange change = UndoStack.Pop();
|
||||
|
|
@ -279,7 +279,7 @@ public void ClickUndo()
|
|||
}
|
||||
public void ClickRedo()
|
||||
{
|
||||
if (!RedoStack.Any())
|
||||
if (RedoStack.Count == 0)
|
||||
return;
|
||||
|
||||
SlotChange change = RedoStack.Pop();
|
||||
|
|
@ -341,9 +341,9 @@ private void UndoSlotChange(SlotChange change)
|
|||
M?.SetColor(box, slot, Resources.slotSet);
|
||||
|
||||
if (Menu_Undo != null)
|
||||
Menu_Undo.Enabled = UndoStack.Any();
|
||||
Menu_Undo.Enabled = UndoStack.Count > 0;
|
||||
if (Menu_Redo != null)
|
||||
Menu_Redo.Enabled = RedoStack.Any();
|
||||
Menu_Redo.Enabled = RedoStack.Count > 0;
|
||||
|
||||
SystemSounds.Asterisk.Play();
|
||||
}
|
||||
|
|
@ -490,8 +490,7 @@ private void UpdateStringSeed(object sender, EventArgs e)
|
|||
if (!FieldsLoaded)
|
||||
return;
|
||||
|
||||
TextBox tb = sender as TextBox;
|
||||
if (tb == null)
|
||||
if (!(sender is TextBox tb))
|
||||
return;
|
||||
|
||||
if (tb.Text.Length == 0)
|
||||
|
|
@ -787,7 +786,7 @@ public bool GetBulkImportSettings(out bool clearAll, out bool? noSetb)
|
|||
MsgSaveBoxImportModifyYes + Environment.NewLine +
|
||||
MsgSaveBoxImportModifyNo + Environment.NewLine +
|
||||
string.Format(MsgSaveBoxImportModifyCurrent, yn));
|
||||
return noSet == DialogResult.Yes ? true : (noSet == DialogResult.No ? (bool?)false : null);
|
||||
return noSet == DialogResult.Yes || noSet == DialogResult.No ? (bool?)false : null;
|
||||
}
|
||||
private static bool IsFolderPath(out string path)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ private set
|
|||
public static string MGDatabasePath => Path.Combine(WorkingDirectory, "mgdb");
|
||||
public static string BackupPath => Path.Combine(WorkingDirectory, "bak");
|
||||
private static string TemplatePath => Path.Combine(WorkingDirectory, "template");
|
||||
private const string ThreadPath = @"https://projectpokemon.org/pkhex/";
|
||||
private const string VersionPath = @"https://raw.githubusercontent.com/kwsch/PKHeX/master/PKHeX.WinForms/Resources/text/version.txt";
|
||||
private const string ThreadPath = "https://projectpokemon.org/pkhex/";
|
||||
private const string VersionPath = "https://raw.githubusercontent.com/kwsch/PKHeX/master/PKHeX.WinForms/Resources/text/version.txt";
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -386,7 +386,7 @@ private void ClickShowdownImportPKM(object sender, EventArgs e)
|
|||
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgSimulatorLoad, Set.Text))
|
||||
return;
|
||||
|
||||
if (Set.InvalidLines.Any())
|
||||
if (Set.InvalidLines.Count > 0)
|
||||
WinFormsUtil.Alert(MsgSimulatorInvalid, string.Join(Environment.NewLine, Set.InvalidLines));
|
||||
|
||||
// Set Species & Nickname
|
||||
|
|
@ -763,7 +763,7 @@ private static string GetProgramTitle(SaveFile sav)
|
|||
string title = GetProgramTitle() + $" - {sav.GetType().Name}: ";
|
||||
if (!sav.Exportable) // Blank save file
|
||||
return title + $"{sav.FileName} [{sav.OT} ({sav.Version})]";
|
||||
return title + $"{Path.GetFileNameWithoutExtension(Util.CleanFileName(sav.BAKName))}"; // more descriptive
|
||||
return title + Path.GetFileNameWithoutExtension(Util.CleanFileName(sav.BAKName)); // more descriptive
|
||||
}
|
||||
private static bool TryBackupExportCheck(SaveFile sav, string path)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ private static void Main()
|
|||
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
|
||||
// Add the event handler for handling non-UI thread exceptions to the event.
|
||||
// Add the event handler for handling non-UI thread exceptions to the event.
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
#endif
|
||||
if (!CheckNETFramework())
|
||||
|
|
@ -39,13 +39,13 @@ private static bool CheckNETFramework()
|
|||
{
|
||||
if (IsOnWindows())
|
||||
{
|
||||
#if MONO
|
||||
#if MONO
|
||||
Error("Mono version should not be used on a Windows system.");
|
||||
#endif
|
||||
if (GetFrameworkVersion() >= 393295)
|
||||
return true;
|
||||
Error(".NET Framework 4.6 needs to be installed for this version of PKHeX to run.");
|
||||
Process.Start(@"https://www.microsoft.com/download/details.aspx?id=48130");
|
||||
Process.Start("https://www.microsoft.com/download/details.aspx?id=48130");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +95,8 @@ private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
|
|||
|
||||
// Handle the UI exceptions by showing a dialog box, and asking the user whether
|
||||
// or not they wish to abort execution.
|
||||
// NOTE: This exception cannot be kept from terminating the application - it can only
|
||||
// log the event, and inform the user about it.
|
||||
// NOTE: This exception cannot be kept from terminating the application - it can only
|
||||
// log the event, and inform the user about it.
|
||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
var ex = e.ExceptionObject as Exception;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ private static string[][] GetPropArray()
|
|||
// Properties for any PKM
|
||||
var any = ReflectFrameworkUtil.GetPropertiesCanWritePublic(typeof(PK1)).Union(p.SelectMany(a => a)).OrderBy(a => a).ToArray();
|
||||
// Properties shared by all PKM
|
||||
var all = p.Aggregate(new HashSet<string>(p.First()), (h, e) => { h.IntersectWith(e); return h; }).OrderBy(a => a).ToArray();
|
||||
var all = p.Aggregate(new HashSet<string>(p[0]), (h, e) => { h.IntersectWith(e); return h; }).OrderBy(a => a).ToArray();
|
||||
|
||||
var p1 = new string[types.Length + 2][];
|
||||
Array.Copy(p, 0, p1, 1, p.Length);
|
||||
|
|
@ -156,11 +156,11 @@ private void RunBackgroundWorker()
|
|||
if (sets.Any(s => s.Filters.Any(z => string.IsNullOrWhiteSpace(z.PropertyValue))))
|
||||
{ WinFormsUtil.Error(MsgBEFilterEmpty); return; }
|
||||
|
||||
if (sets.Any(z => !z.Instructions.Any()))
|
||||
if (sets.Any(z => z.Instructions.Count == 0))
|
||||
{ WinFormsUtil.Error(MsgBEInstructionNone); return; }
|
||||
|
||||
var emptyVal = sets.SelectMany(s => s.Instructions.Where(z => string.IsNullOrWhiteSpace(z.PropertyValue))).ToArray();
|
||||
if (emptyVal.Any())
|
||||
if (emptyVal.Length > 0)
|
||||
{
|
||||
string props = string.Join(", ", emptyVal.Select(z => z.PropertyName));
|
||||
string invalid = MsgBEPropertyEmpty + Environment.NewLine + props;
|
||||
|
|
@ -347,16 +347,11 @@ public static IEnumerable<StringInstructionSet> GetBatchSets(string[] lines)
|
|||
int start = 0;
|
||||
while (start < lines.Length)
|
||||
{
|
||||
var list = lines.Skip(start).TakeWhile(z => !lines[start++].StartsWith(SetSeparator)).ToList();
|
||||
var list = lines.Skip(start).TakeWhile(_ => !lines[start++].StartsWith(SetSeparator)).ToList();
|
||||
yield return GetBatchSet(list);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<StringInstructionSet> GetBatchSets(IEnumerable<IEnumerable<string>> sets)
|
||||
{
|
||||
return sets.Select(set => GetBatchSet(set.ToList()));
|
||||
}
|
||||
|
||||
private static StringInstructionSet GetBatchSet(IList<string> set)
|
||||
{
|
||||
return new StringInstructionSet
|
||||
|
|
@ -416,9 +411,7 @@ public static IEnumerable<StringInstruction> GetInstructions(IEnumerable<string>
|
|||
}
|
||||
private static IEnumerable<string> GetRelevantStrings(IEnumerable<string> lines, params char[] pieces)
|
||||
{
|
||||
return lines
|
||||
.Where(line => !string.IsNullOrEmpty(line))
|
||||
.Where(line => pieces.Any(z => z == line[0]));
|
||||
return lines.Where(line => !string.IsNullOrEmpty(line) && pieces.Any(z => z == line[0]));
|
||||
}
|
||||
}
|
||||
private sealed class PKMInfo
|
||||
|
|
@ -624,7 +617,7 @@ private static void SetProperty(PKM PKM, StringInstruction cmd)
|
|||
SetRandomIVs(PKM, cmd);
|
||||
else if (cmd.Random)
|
||||
ReflectFrameworkUtil.SetValue(PKM, cmd.PropertyName, cmd.RandomValue);
|
||||
else if (cmd.PropertyName == nameof(PKM.IsNicknamed) && cmd.PropertyValue.ToLower() == "false")
|
||||
else if (cmd.PropertyName == nameof(PKM.IsNicknamed) && string.Equals(cmd.PropertyValue, "false", StringComparison.OrdinalIgnoreCase))
|
||||
{ PKM.IsNicknamed = false; PKM.Nickname = PKX.GetSpeciesNameGeneration(PKM.Species, PKM.Language, PKM.Format); }
|
||||
else
|
||||
ReflectFrameworkUtil.SetValue(PKM, cmd.PropertyName, cmd.PropertyValue);
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ private static string Hash(PKM pk)
|
|||
// Important Events
|
||||
private void ClickView(object sender, EventArgs e)
|
||||
{
|
||||
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
int index = Array.IndexOf(PKXBOXES, sender);
|
||||
if (index >= RES_MAX)
|
||||
{
|
||||
|
|
@ -146,7 +146,7 @@ private void ClickView(object sender, EventArgs e)
|
|||
}
|
||||
private void ClickDelete(object sender, EventArgs e)
|
||||
{
|
||||
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
int index = Array.IndexOf(PKXBOXES, sender);
|
||||
if (index >= RES_MAX)
|
||||
{
|
||||
|
|
@ -234,7 +234,7 @@ private void ClickSet(object sender, EventArgs e)
|
|||
slotSelected = Results.Count - 1;
|
||||
slotColor = Properties.Resources.slotSet;
|
||||
if ((SCR_Box.Maximum+1)*6 < Results.Count)
|
||||
SCR_Box.Maximum += 1;
|
||||
SCR_Box.Maximum++;
|
||||
SCR_Box.Value = Math.Max(0, SCR_Box.Maximum - PKXBOXES.Length/6 + 1);
|
||||
FillPKXBoxes(SCR_Box.Value);
|
||||
WinFormsUtil.Alert(MsgDBAddFromTabsSuccess);
|
||||
|
|
@ -554,7 +554,7 @@ private static IEnumerable<PKM> FilterByLVL(IEnumerable<PKM> res, int option, st
|
|||
case 0: break; // Any (Do nothing)
|
||||
case 3: // <=
|
||||
return res.Where(pk => pk.Stat_Level <= level);
|
||||
case 2: // ==
|
||||
case 2: // ==
|
||||
return res.Where(pk => pk.Stat_Level == level);
|
||||
case 1: // >=
|
||||
return res.Where(pk => pk.Stat_Level >= level);
|
||||
|
|
@ -606,7 +606,7 @@ private async void B_Search_Click(object sender, EventArgs e)
|
|||
bool legalSearch = Menu_SearchLegal.Checked ^ Menu_SearchIllegal.Checked;
|
||||
if (legalSearch && WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgDBSearchLegalityWordfilter) == DialogResult.No)
|
||||
Legal.CheckWordFilter = false;
|
||||
var results = await Task.Run(() => search.ToArray());
|
||||
var results = await Task.Run(() => search.ToArray()).ConfigureAwait(false);
|
||||
Legal.CheckWordFilter = true;
|
||||
|
||||
if (results.Length == 0)
|
||||
|
|
@ -630,7 +630,7 @@ private void SetResults(List<PKM> res)
|
|||
Results = new List<PKM>(res);
|
||||
|
||||
SCR_Box.Maximum = (int)Math.Ceiling((decimal)Results.Count / RES_MIN);
|
||||
if (SCR_Box.Maximum > 0) SCR_Box.Maximum -= 1;
|
||||
if (SCR_Box.Maximum > 0) SCR_Box.Maximum--;
|
||||
|
||||
SCR_Box.Value = 0;
|
||||
FillPKXBoxes(0);
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ private void ClickSaveMG(object sender, EventArgs e)
|
|||
|
||||
private int GetSenderIndex(object sender)
|
||||
{
|
||||
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
int index = Array.IndexOf(PKXBOXES, sender);
|
||||
if (index >= RES_MAX)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -491,7 +491,6 @@ private void ReadBattleFrontier()
|
|||
|
||||
editing = false;
|
||||
CB_Stats1.SelectedIndex = 0;
|
||||
|
||||
}
|
||||
private void SaveBattleFrontier()
|
||||
{
|
||||
|
|
@ -556,7 +555,7 @@ private void ChangeStat1(object sender, EventArgs e)
|
|||
private void ChangeStat(object sender, EventArgs e)
|
||||
{
|
||||
if (editing) return;
|
||||
if (sender is RadioButton && ((RadioButton)sender).Checked == false) return;
|
||||
if (sender is RadioButton radioButton && !radioButton.Checked) return;
|
||||
StatAddrControl(SetValToSav: -2, SetSavToVal: true);
|
||||
if (GB_Hall.Visible)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public SAV_Pokedex4(SaveFile sav)
|
|||
LB_Species.SelectedIndex = 0;
|
||||
|
||||
string[] dexMode = { "not given", "simple mode", "detect forms", "national dex", "other languages" };
|
||||
if (SAV.HGSS) dexMode = dexMode.Where((t, i) => i != 2).ToArray();
|
||||
if (SAV.HGSS) dexMode = dexMode.Where((_, i) => i != 2).ToArray();
|
||||
foreach (string mode in dexMode)
|
||||
CB_DexUpgraded.Items.Add(mode);
|
||||
if (SAV.DexUpgraded < CB_DexUpgraded.Items.Count)
|
||||
|
|
@ -139,7 +139,7 @@ private void GetEntry()
|
|||
|
||||
string[] formNames = GetFormNames4Dex(species);
|
||||
|
||||
var seen = forms.Where(z => z >= 0 && z < forms.Length).Select((v, i) => formNames[forms[i]]).ToArray();
|
||||
var seen = forms.Where(z => z >= 0 && z < forms.Length).Select((_, i) => formNames[forms[i]]).ToArray();
|
||||
var not = formNames.Where(z => !seen.Contains(z)).ToArray();
|
||||
|
||||
LB_Form.Items.AddRange(seen);
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ public SAV_FestivalPlaza(SaveFile sav)
|
|||
};
|
||||
break;
|
||||
default:
|
||||
string musical8note = "♪";
|
||||
string linedP = "₽"; //currency Ruble
|
||||
const string musical8note = "♪";
|
||||
const string linedP = "₽"; //currency Ruble
|
||||
res = new[] { //source:UltraMoon
|
||||
/* (SM)Pokémon House */"There's nothing funny about Nuggets.","The Power of science is awesome.","1, 2, and... Ta-da!","How's the future Champ today?","Why, you!","There! All happy and healthy!","Your Pokémon seems to be very happy!","No thanks!","Would you like to use Cut?","Saving...",
|
||||
/* (SM)Kanto Tent */"Well, I better get going!","Bonjour!","Smell ya later!","Sorry! Bad call!","You better have Burn Heal!","Hoo hah!","Pokémon are for battling!","Slowbro took a snooze...","Shades of your journey await!","You're 10,000 light-years from facing Brock!","Hey! Wait! Don't go out!","Hiya! I'm a Pokémon...","What do you want?","WHAT! This can't be!","Mew!","Be gone... Intruders...",
|
||||
|
|
@ -604,7 +604,8 @@ private void B_ImportParty_Click(object sender, EventArgs e)
|
|||
|
||||
private void mnuSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
int i = Array.IndexOf(PBs, ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox);
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
int i = Array.IndexOf(PBs, sender);
|
||||
if (i < 0) return;
|
||||
WinFormsUtil.SavePKMDialog(p[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ private static int GetLastUnfilledByType(MysteryGift Gift, MysteryGiftAlbum Albu
|
|||
// Mystery Gift RW (window<->sav)
|
||||
private void ClickView(object sender, EventArgs e)
|
||||
{
|
||||
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
int index = Array.IndexOf(pba, sender);
|
||||
|
||||
SetBackground(index, Properties.Resources.slotView);
|
||||
|
|
@ -185,7 +185,7 @@ private void ClickSet(object sender, EventArgs e)
|
|||
}
|
||||
private void ClickDelete(object sender, EventArgs e)
|
||||
{
|
||||
sender = ((sender as ToolStripItem)?.Owner as ContextMenuStrip)?.SourceControl ?? sender as PictureBox;
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
int index = Array.IndexOf(pba, sender);
|
||||
|
||||
mga.Gifts[index].Data = new byte[mga.Gifts[index].Data.Length];
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ private static void UpdateTranslations()
|
|||
nameof(SettingsEditor),
|
||||
};
|
||||
|
||||
|
||||
private static void DumpStringsMessage() => DumpStrings(typeof(MessageStrings));
|
||||
private static void DumpStringsLegality() => DumpStrings(typeof(LegalityCheckStrings));
|
||||
private static void DumpStrings(Type t, bool sort = false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user