mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-20 22:20:55 -05:00
Minor clean
Stability intensifies
This commit is contained in:
parent
553e9ac1b3
commit
eb2cef10c9
|
|
@ -28,6 +28,8 @@ private static bool HasVisitedAnother(PA8 pk)
|
|||
{
|
||||
if (pk.IsUntraded)
|
||||
return false;
|
||||
if (pk.Tracker == 0)
|
||||
return false;
|
||||
if (PersonalTable.BDSP.IsPresentInGame(pk.Species, pk.Form))
|
||||
return true;
|
||||
if (PersonalTable.SWSH.IsPresentInGame(pk.Species, pk.Form))
|
||||
|
|
|
|||
|
|
@ -24,8 +24,21 @@ public static int GetFormFromString(string name, GameStrings strings, int specie
|
|||
if (name.Length == 0)
|
||||
return 0;
|
||||
|
||||
var formStrings = FormConverter.GetFormList(species, strings.Types, strings.forms, genderForms, context);
|
||||
return Math.Max(0, Array.FindIndex(formStrings, z => z.Contains(name)));
|
||||
var forms = FormConverter.GetFormList(species, strings.Types, strings.forms, genderForms, context);
|
||||
if (forms.Length < 1)
|
||||
return 0;
|
||||
|
||||
// Find first matching index that matches any case.
|
||||
for (int i = 0; i < forms.Length; i++)
|
||||
{
|
||||
var form = forms[i];
|
||||
var index = form.IndexOf(name, StringComparison.OrdinalIgnoreCase);
|
||||
if (index != -1)
|
||||
return i;
|
||||
}
|
||||
|
||||
// No match, assume default 0 form.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -67,7 +80,7 @@ public static string GetShowdownFormName(int species, string form)
|
|||
(int)Basculin when form is "Blue" => "Blue-Striped",
|
||||
(int)Vivillon when form is "Poké Ball" => "Pokeball",
|
||||
(int)Zygarde => form.Replace("-C", string.Empty).Replace("50%", string.Empty),
|
||||
(int)Minior when form.StartsWith("M-", StringComparison.Ordinal) => MiniorFormName,
|
||||
(int)Minior when form.StartsWith("M-", StringComparison.OrdinalIgnoreCase) => MiniorFormName,
|
||||
(int)Minior => form.Replace("C-", string.Empty),
|
||||
(int)Necrozma when form is "Dusk" => $"{form}-Mane",
|
||||
(int)Necrozma when form is "Dawn" => $"{form}-Wings",
|
||||
|
|
@ -107,7 +120,7 @@ public static string SetShowdownFormName(int species, string form, int ability)
|
|||
(int)Rockruff when ability == 020 => "Dusk", // Rockruff-1
|
||||
(int)Urshifu or (int)Pikachu or (int)Alcremie => form.Replace('-', ' '), // Strike and Cosplay
|
||||
|
||||
_ => Legal.Totem_USUM.Contains(species) && form.EndsWith("Totem", StringComparison.Ordinal) ? "Large" : form,
|
||||
_ => Legal.Totem_USUM.Contains(species) && form.EndsWith("Totem", StringComparison.OrdinalIgnoreCase) ? "Large" : form,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Flags to tweak behavior of the sprite builder for the destination display.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SpriteBuilderTweak
|
||||
{
|
||||
None = 0,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.GameVersion;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
public static class GenerationTraversal
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the generation numbers in descending order for iterating over.
|
||||
/// </summary>
|
||||
public static int[] GetVisitedGenerationOrder(PKM pk, int origin)
|
||||
{
|
||||
if (pk.Format < 3)
|
||||
return GetVisitedGenerationOrderGB(pk, pk.Format);
|
||||
if (pk.VC)
|
||||
return GetVisitedGenerationOrderVC(pk, origin);
|
||||
return GetVisitedGenerationOrder(pk.Format, origin);
|
||||
}
|
||||
|
||||
private static int[] GetVisitedGenerationOrderVC(PKM pk, int origin)
|
||||
{
|
||||
// VC case: check transfer games in reverse order (8, 7..) then past games.
|
||||
int[] xfer = GetVisitedGenerationOrder(pk.Format, 7);
|
||||
int[] past = GetVisitedGenerationOrderGB(pk, origin);
|
||||
int end = xfer.Length;
|
||||
Array.Resize(ref xfer, xfer.Length + past.Length);
|
||||
past.CopyTo(xfer, end);
|
||||
return xfer;
|
||||
}
|
||||
|
||||
private static readonly int[] G2 = { 2 };
|
||||
private static readonly int[] G12 = { 1, 2 };
|
||||
private static readonly int[] G21 = { 2, 1 };
|
||||
|
||||
private static int[] GetVisitedGenerationOrderGB(PKM pk, int originalGeneration)
|
||||
{
|
||||
if (originalGeneration == 2)
|
||||
return pk.Korean ? G2 : G21;
|
||||
return G12; // RBY
|
||||
}
|
||||
|
||||
private static int[] GetVisitedGenerationOrder(int start, int end)
|
||||
{
|
||||
if (end < 0)
|
||||
return Array.Empty<int>();
|
||||
if (start <= end)
|
||||
return new[] { start };
|
||||
var order = new int[start - end + 1];
|
||||
for (int i = 0; i < order.Length; i++)
|
||||
order[i] = start - i;
|
||||
return order;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.Move;
|
||||
using static PKHeX.Core.Species;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
// ReSharper disable RedundantExplicitPositionalPropertyDeclaration
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
|
|
@ -16,14 +15,6 @@ namespace PKHeX.Core;
|
|||
public readonly record struct IndividualValueSet(sbyte HP, sbyte ATK, sbyte DEF, sbyte SPE, sbyte SPA, sbyte SPD, byte Type = 1)
|
||||
{
|
||||
// 8 BYTES MAX STRUCTURE
|
||||
public byte Type { get; init; } = Type;
|
||||
|
||||
public sbyte HP { get; init; } = HP;
|
||||
public sbyte ATK { get; init; } = ATK;
|
||||
public sbyte DEF { get; init; } = DEF;
|
||||
public sbyte SPE { get; init; } = SPE;
|
||||
public sbyte SPA { get; init; } = SPA;
|
||||
public sbyte SPD { get; init; } = SPD;
|
||||
|
||||
// Default struct will be zero type.
|
||||
public bool IsSpecified => Type != 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.LegalityCheckStrings;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public static void Fix(this RibbonIndex4 r, RibbonVerifierArguments args, bool s
|
|||
ToughGreat => u4.RibbonG4ToughGreat = state,
|
||||
ToughUltra => u4.RibbonG4ToughUltra = state,
|
||||
ToughMaster => u4.RibbonG4ToughMaster = state,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(r), r, null)
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(r), r, null),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -119,8 +119,8 @@ public void SetData(Span<byte> dest, Span<byte> input, int offset)
|
|||
public virtual IReadOnlyList<InventoryPouch> Inventory { get => Array.Empty<InventoryPouch>(); set { } }
|
||||
|
||||
#region Mystery Gift
|
||||
protected virtual int GiftCountMax { get; } = int.MinValue;
|
||||
protected virtual int GiftFlagMax { get; } = 0x800;
|
||||
protected virtual int GiftCountMax => int.MinValue;
|
||||
protected virtual int GiftFlagMax => 0x800;
|
||||
protected int WondercardData { get; set; } = int.MinValue;
|
||||
public bool HasWondercards => WondercardData > -1;
|
||||
protected virtual bool[] MysteryGiftReceivedFlags { get => Array.Empty<bool>(); set { } }
|
||||
|
|
@ -244,8 +244,8 @@ public IList<PKM> PartyData
|
|||
#region Daycare
|
||||
public bool HasDaycare => DaycareOffset > -1;
|
||||
protected int DaycareOffset { get; set; } = int.MinValue;
|
||||
public virtual int DaycareSeedSize { get; } = 0;
|
||||
public int DaycareIndex = 0;
|
||||
public virtual int DaycareSeedSize => 0;
|
||||
public int DaycareIndex;
|
||||
public virtual bool HasTwoDaycares => false;
|
||||
public virtual int GetDaycareSlotOffset(int loc, int slot) => -1;
|
||||
public virtual uint? GetDaycareEXP(int loc, int slot) => null;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace PKHeX.Core;
|
||||
namespace PKHeX.Core;
|
||||
|
||||
internal sealed class SAV1Offsets
|
||||
{
|
||||
|
|
@ -57,7 +57,7 @@ private static SAV1Offsets GetJPN() => new()
|
|||
ChecksumOfs = 0x3594,
|
||||
};
|
||||
|
||||
public int OT { get; } = 0x2598;
|
||||
public int OT => 0x2598;
|
||||
public int DexCaught { get; private init; }
|
||||
public int DexSeen { get; private init; }
|
||||
public int Items { get; private init; }
|
||||
|
|
|
|||
|
|
@ -155,18 +155,18 @@ public void SetState(int species, ZukanState8b state)
|
|||
WriteInt32LittleEndian(SAV.Data.AsSpan(PokeDex + offset), (int)state);
|
||||
}
|
||||
|
||||
private bool GetBoolean(int index, int baseOffset, int max)
|
||||
private bool GetBoolean(int index, int baseOffset)
|
||||
{
|
||||
if ((uint)index > (uint)max)
|
||||
if ((uint)index >= COUNT_SPECIES)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
var offset = baseOffset + (ALIGN_BOOLARRAY * index);
|
||||
return ReadUInt32LittleEndian(SAV.Data.AsSpan(PokeDex + offset)) == 1;
|
||||
}
|
||||
|
||||
private void SetBoolean(int index, int baseOffset, int max, bool value)
|
||||
private void SetBoolean(int index, int baseOffset, bool value)
|
||||
{
|
||||
if ((uint)index > (uint)max)
|
||||
if ((uint)index >= COUNT_SPECIES)
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
|
||||
var offset = baseOffset + (ALIGN_BOOLARRAY * index);
|
||||
|
|
@ -175,18 +175,18 @@ private void SetBoolean(int index, int baseOffset, int max, bool value)
|
|||
|
||||
public void GetGenderFlags(int species, out bool m, out bool f, out bool ms, out bool fs)
|
||||
{
|
||||
m = GetBoolean(species - 1, OFS_MALE, COUNT_SPECIES - 1);
|
||||
f = GetBoolean(species - 1, OFS_FEMALE, COUNT_SPECIES - 1);
|
||||
ms = GetBoolean(species - 1, OFS_MALESHINY, COUNT_SPECIES - 1);
|
||||
fs = GetBoolean(species - 1, OFS_FEMALESHINY, COUNT_SPECIES - 1);
|
||||
m = GetBoolean(species - 1, OFS_MALE);
|
||||
f = GetBoolean(species - 1, OFS_FEMALE);
|
||||
ms = GetBoolean(species - 1, OFS_MALESHINY);
|
||||
fs = GetBoolean(species - 1, OFS_FEMALESHINY);
|
||||
}
|
||||
|
||||
public void SetGenderFlags(int species, bool m, bool f, bool ms, bool fs)
|
||||
{
|
||||
SetBoolean(species - 1, OFS_MALE, COUNT_SPECIES - 1, m);
|
||||
SetBoolean(species - 1, OFS_FEMALE, COUNT_SPECIES - 1, f);
|
||||
SetBoolean(species - 1, OFS_MALESHINY, COUNT_SPECIES - 1, ms);
|
||||
SetBoolean(species - 1, OFS_FEMALESHINY, COUNT_SPECIES - 1, fs);
|
||||
SetBoolean(species - 1, OFS_MALE, m);
|
||||
SetBoolean(species - 1, OFS_FEMALE, f);
|
||||
SetBoolean(species - 1, OFS_MALESHINY, ms);
|
||||
SetBoolean(species - 1, OFS_FEMALESHINY, fs);
|
||||
}
|
||||
|
||||
public bool GetLanguageFlag(int species, int language)
|
||||
|
|
@ -363,8 +363,8 @@ private void SetGenderFlag(int species, int gender, bool shiny)
|
|||
}
|
||||
}
|
||||
|
||||
private void SetGenderFlagMale(int species, bool shiny) => SetBoolean(species - 1, shiny ? OFS_MALESHINY : OFS_MALE, COUNT_SPECIES - 1, true);
|
||||
private void SetGenderFlagFemale(int species, bool shiny) => SetBoolean(species - 1, shiny ? OFS_FEMALESHINY : OFS_FEMALE, COUNT_SPECIES - 1, true);
|
||||
private void SetGenderFlagMale(int species, bool shiny) => SetBoolean(species - 1, shiny ? OFS_MALESHINY : OFS_MALE, true);
|
||||
private void SetGenderFlagFemale(int species, bool shiny) => SetBoolean(species - 1, shiny ? OFS_FEMALESHINY : OFS_FEMALE, true);
|
||||
|
||||
public override void SeenNone()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using PKHeX.Core;
|
||||
|
||||
namespace PKHeX.WinForms.Controls;
|
||||
|
|
@ -41,8 +41,15 @@ private PK5 PreparePK5()
|
|||
|
||||
pk5.GroundTile = (GroundTileType)WinFormsUtil.GetIndex(CB_GroundTile);
|
||||
pk5.NSparkle = CHK_NSparkle.Checked;
|
||||
if (!HaX) // specify via extra 0x42 instead
|
||||
if (!HaX)
|
||||
{
|
||||
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
|
||||
}
|
||||
else
|
||||
{
|
||||
var pi = (IPersonalAbility12H)pk5.PersonalInfo;
|
||||
pk5.HiddenAbility = pk5.Ability == pi.AbilityH;
|
||||
}
|
||||
|
||||
SavePartyStats(pk5);
|
||||
pk5.FixMoves();
|
||||
|
|
|
|||
|
|
@ -458,11 +458,12 @@ private void SetForms()
|
|||
return;
|
||||
}
|
||||
|
||||
var ds = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, gendersymbols, Entity.Context);
|
||||
if (ds.Length == 1 && string.IsNullOrEmpty(ds[0])) // empty (Alolan Totems)
|
||||
var str = GameInfo.Strings;
|
||||
var forms = FormConverter.GetFormList(species, str.types, str.forms, gendersymbols, Entity.Context);
|
||||
if (forms.Length <= 1) // no choices
|
||||
CB_Form.Enabled = CB_Form.Visible = Label_Form.Visible = false;
|
||||
else
|
||||
CB_Form.DataSource = ds;
|
||||
CB_Form.DataSource = forms;
|
||||
}
|
||||
|
||||
private void SetAbilityList()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
|
@ -29,8 +29,8 @@ public class LegalityData
|
|||
if (feebas.Length == 0)
|
||||
continue;
|
||||
|
||||
var t1 = (EvolutionType)feebas[0].Method;
|
||||
var t2 = (EvolutionType)feebas[1].Method;
|
||||
var t1 = feebas[0].Method;
|
||||
var t2 = feebas[1].Method;
|
||||
|
||||
t1.IsLevelUpRequired().Should().BeFalse();
|
||||
t2.IsLevelUpRequired().Should().BeTrue();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user