mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-25 08:10:48 -05:00
Misc tweaks
This commit is contained in:
parent
13154d70f8
commit
47092a2df0
|
|
@ -12,7 +12,7 @@ public sealed record BattleTemplateLocalization(GameStrings Strings, BattleTempl
|
|||
{
|
||||
public const string DefaultLanguage = GameLanguage.DefaultLanguage; // English
|
||||
|
||||
private static readonly Dictionary<string, BattleTemplateLocalization> Cache = new();
|
||||
private static readonly Dictionary<string, BattleTemplateLocalization> Cache = new(1);
|
||||
private static readonly BattleTemplateConfigContext Context = new(LocalizationStorage<BattleTemplateConfig>.Options);
|
||||
public static readonly LocalizationStorage<BattleTemplateConfig> ConfigCache = new("battle", Context.BattleTemplateConfig);
|
||||
public static readonly BattleTemplateLocalization Default = GetLocalization(DefaultLanguage);
|
||||
|
|
|
|||
|
|
@ -144,8 +144,6 @@ public bool MoveNext()
|
|||
if (Deferred is not null)
|
||||
return SetCurrent(Deferred, Rating);
|
||||
break;
|
||||
case YieldState.End:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public static IReadOnlyList<string> GetTextLines(this IEncounterInfo enc, Encoun
|
|||
}
|
||||
}
|
||||
|
||||
public record struct EncounterDisplayContext
|
||||
public readonly record struct EncounterDisplayContext
|
||||
{
|
||||
public required EncounterDisplayLocalization Localization { get; init; }
|
||||
public required GameStrings Strings { get; init; }
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public string Summary(in LegalityLocalizationContext ctx)
|
|||
Info.Summarize(sb, ctx.Settings.Moves);
|
||||
if (Info.Method.HasExpectedMove())
|
||||
{
|
||||
var name = ParseSettings.MoveStrings[Expect];
|
||||
var name = ctx.GetMoveName(Expect);
|
||||
var str = ctx.Settings.Lines.MoveFExpectSingle_0;
|
||||
sb.Append(' ').AppendFormat(str, name);
|
||||
return sb.ToString();
|
||||
|
|
@ -40,7 +40,7 @@ public string Summary(in LegalityLocalizationContext ctx)
|
|||
if (detail.Species == current.Species && detail.Form == current.Form)
|
||||
return sb.ToString();
|
||||
|
||||
sb.Append(' ').Append(ParseSettings.SpeciesStrings[detail.Species]);
|
||||
sb.Append(' ').Append(ctx.GetSpeciesName(detail.Species));
|
||||
if (detail.Form != current.Form)
|
||||
sb.Append('-').Append(detail.Form);
|
||||
return sb.ToString();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace PKHeX.Core;
|
|||
/// </summary>
|
||||
public sealed class LegalityLocalizationSet
|
||||
{
|
||||
private static readonly Dictionary<string, LegalityLocalizationSet> Cache = new();
|
||||
private static readonly Dictionary<string, LegalityLocalizationSet> Cache = new(1);
|
||||
|
||||
public required LegalityCheckLocalization Lines { get; init; }
|
||||
public required GameStrings Strings { get; init; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using static PKHeX.Core.LearnMethod;
|
||||
using static PKHeX.Core.LegalityCheckLocalization;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,9 @@ private static bool IsValidTrainerCombination(in EncounterCriteria criteria, uin
|
|||
// Check if request constraints satisfied
|
||||
if (criteria.IsSpecifiedNature() && !criteria.IsSatisfiedNature((Nature)(espeonPID % 25)))
|
||||
return false;
|
||||
return false;
|
||||
// gender and shiny locked.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Call structure for XD Starter:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -45,15 +43,6 @@ public static void Initialize(LegalitySettings settings)
|
|||
Settings = settings;
|
||||
}
|
||||
|
||||
public static IReadOnlyList<string> MoveStrings { get; private set; } = Util.GetMovesList(GameLanguage.DefaultLanguage);
|
||||
public static IReadOnlyList<string> SpeciesStrings { get; private set; } = Util.GetSpeciesList(GameLanguage.DefaultLanguage);
|
||||
|
||||
public static void ChangeLocalizationStrings(IReadOnlyList<string> moves, IReadOnlyList<string> species)
|
||||
{
|
||||
SpeciesStrings = species;
|
||||
MoveStrings = moves;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if Crystal is available to visit/originate from.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public static byte GetSuggestedFriendshipOT(PKM pk, IEncounterTemplate enc)
|
|||
// 3+
|
||||
bool neverOT = !GetCanOTHandle(enc, pk, enc.Generation);
|
||||
if (neverOT)
|
||||
return (byte)GetBaseFriendship(enc);
|
||||
return GetBaseFriendship(enc);
|
||||
return GetSuggestedFriendshipByMove(pk);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ private static void VerifyEncounterTrade5(LegalityAnalysis data, EncounterTrade5
|
|||
var pk = data.Entity;
|
||||
var lang = pk.Language;
|
||||
if (pk.Format == 5 && lang == (int)Japanese)
|
||||
data.AddLine(GetInvalid(CheckIdentifier.Language, OTLanguageShouldBe_0, (byte)0));
|
||||
data.AddLine(GetInvalid(CheckIdentifier.Language, OTLanguageShouldBe_0, 0));
|
||||
|
||||
lang = Math.Max(lang, 1);
|
||||
VerifyTrade(data, t, lang);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ internal static GeoValid GetValidity(this IGeoTrack g)
|
|||
if ((result = UpdateCheck(g.Geo5_Country, g.Geo5_Region, ref end)) != GeoValid.Valid)
|
||||
return result;
|
||||
|
||||
return result;
|
||||
return GeoValid.Valid;
|
||||
|
||||
static GeoValid UpdateCheck(byte country, byte region, ref bool end)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,8 +65,7 @@ private void Initialize(GameVersion versionOverride)
|
|||
// see if RBY can be differentiated
|
||||
if (versionOverride is not (GameVersion.RB or GameVersion.YW))
|
||||
{
|
||||
if (Starter != 0)
|
||||
// Pikachu
|
||||
if (Starter != 0) // Pikachu
|
||||
Version = Starter == 0x54 ? GameVersion.YW : GameVersion.RB;
|
||||
else
|
||||
Version = Data[Offsets.PikaFriendship] != 0 ? GameVersion.YW : GameVersion.RB;
|
||||
|
|
|
|||
|
|
@ -64,25 +64,25 @@ public override bool NationalDex
|
|||
|
||||
public uint BerryPowder
|
||||
{
|
||||
get => ReadUInt32LittleEndian(Small.Slice(0xAF8)) ^ SecurityKey;
|
||||
set => WriteUInt32LittleEndian(Small.Slice(0xAF8), value ^ SecurityKey);
|
||||
get => ReadUInt32LittleEndian(Small[0xAF8..]) ^ SecurityKey;
|
||||
set => WriteUInt32LittleEndian(Small[0xAF8..], value ^ SecurityKey);
|
||||
}
|
||||
|
||||
public ushort JoyfulJumpInRow { get => ReadUInt16LittleEndian(Small.Slice(0xB00)); set => WriteUInt16LittleEndian(Small.Slice(0xB00), Math.Min((ushort)9999, value)); }
|
||||
public ushort JoyfulJumpInRow { get => ReadUInt16LittleEndian(Small[0xB00..]); set => WriteUInt16LittleEndian(Small[0xB00..], Math.Min((ushort)9999, value)); }
|
||||
// u16 field2;
|
||||
public ushort JoyfulJump5InRow { get => ReadUInt16LittleEndian(Small.Slice(0xB04)); set => WriteUInt16LittleEndian(Small.Slice(0xB04), Math.Min((ushort)9999, value)); }
|
||||
public ushort JoyfulJumpGamesMaxPlayers { get => ReadUInt16LittleEndian(Small.Slice(0xB06)); set => WriteUInt16LittleEndian(Small.Slice(0xB06), Math.Min((ushort)9999, value)); }
|
||||
public ushort JoyfulJump5InRow { get => ReadUInt16LittleEndian(Small[0xB04..]); set => WriteUInt16LittleEndian(Small[0xB04..], Math.Min((ushort)9999, value)); }
|
||||
public ushort JoyfulJumpGamesMaxPlayers { get => ReadUInt16LittleEndian(Small[0xB06..]); set => WriteUInt16LittleEndian(Small[0xB06..], Math.Min((ushort)9999, value)); }
|
||||
// u32 field8;
|
||||
public uint JoyfulJumpScore { get => ReadUInt16LittleEndian(Small.Slice(0xB0C)); set => WriteUInt32LittleEndian(Small.Slice(0xB0C), Math.Min(99990, value)); }
|
||||
public uint JoyfulJumpScore { get => ReadUInt16LittleEndian(Small[0xB0C..]); set => WriteUInt32LittleEndian(Small[0xB0C..], Math.Min(99990, value)); }
|
||||
|
||||
public uint JoyfulBerriesScore { get => ReadUInt16LittleEndian(Small.Slice(0xB10)); set => WriteUInt32LittleEndian(Small.Slice(0xB10), Math.Min(99990, value)); }
|
||||
public ushort JoyfulBerriesInRow { get => ReadUInt16LittleEndian(Small.Slice(0xB14)); set => WriteUInt16LittleEndian(Small.Slice(0xB14), Math.Min((ushort)9999, value)); }
|
||||
public ushort JoyfulBerries5InRow { get => ReadUInt16LittleEndian(Small.Slice(0xB16)); set => WriteUInt16LittleEndian(Small.Slice(0xB16), Math.Min((ushort)9999, value)); }
|
||||
public uint JoyfulBerriesScore { get => ReadUInt16LittleEndian(Small[0xB10..]); set => WriteUInt32LittleEndian(Small[0xB10..], Math.Min(99990, value)); }
|
||||
public ushort JoyfulBerriesInRow { get => ReadUInt16LittleEndian(Small[0xB14..]); set => WriteUInt16LittleEndian(Small[0xB14..], Math.Min((ushort)9999, value)); }
|
||||
public ushort JoyfulBerries5InRow { get => ReadUInt16LittleEndian(Small[0xB16..]); set => WriteUInt16LittleEndian(Small[0xB16..], Math.Min((ushort)9999, value)); }
|
||||
|
||||
public override uint SecurityKey
|
||||
{
|
||||
get => ReadUInt32LittleEndian(Small.Slice(0xF20));
|
||||
set => WriteUInt32LittleEndian(Small.Slice(0xF20), value);
|
||||
get => ReadUInt32LittleEndian(Small[0xF20..]);
|
||||
set => WriteUInt32LittleEndian(Small[0xF20..], value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -92,14 +92,14 @@ public override uint SecurityKey
|
|||
|
||||
public override uint Money
|
||||
{
|
||||
get => ReadUInt32LittleEndian(Large.Slice(0x0290)) ^ SecurityKey;
|
||||
set => WriteUInt32LittleEndian(Large.Slice(0x0290), value ^ SecurityKey);
|
||||
get => ReadUInt32LittleEndian(Large[0x0290..]) ^ SecurityKey;
|
||||
set => WriteUInt32LittleEndian(Large[0x0290..], value ^ SecurityKey);
|
||||
}
|
||||
|
||||
public override uint Coin
|
||||
{
|
||||
get => (ushort)(ReadUInt16LittleEndian(Large.Slice(0x0294)) ^ SecurityKey);
|
||||
set => WriteUInt16LittleEndian(Large.Slice(0x0294), (ushort)(value ^ SecurityKey));
|
||||
get => (ushort)(ReadUInt16LittleEndian(Large[0x0294..]) ^ SecurityKey);
|
||||
set => WriteUInt16LittleEndian(Large[0x0294..], (ushort)(value ^ SecurityKey));
|
||||
}
|
||||
|
||||
private const int OFS_PCItem = 0x0298;
|
||||
|
|
@ -130,8 +130,8 @@ protected override InventoryPouch3[] GetItems()
|
|||
protected override int GetDaycareEXPOffset(int slot) => GetDaycareSlotOffset(slot + 1) - 4; // @ end of each pk slot
|
||||
ushort IDaycareRandomState<ushort>.Seed
|
||||
{
|
||||
get => ReadUInt16LittleEndian(Large.Slice(GetDaycareEXPOffset(2)));
|
||||
set => WriteUInt16LittleEndian(Large.Slice(GetDaycareEXPOffset(2)), value);
|
||||
get => ReadUInt16LittleEndian(Large[GetDaycareEXPOffset(2)..]);
|
||||
set => WriteUInt16LittleEndian(Large[GetDaycareEXPOffset(2)..], value);
|
||||
}
|
||||
|
||||
protected override int ExternalEventData => 0x30A7;
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ private int GetActiveExtraBlock(BlockInfo4 block)
|
|||
private int OFS_Backdrop => FashionCase + 0x28;
|
||||
|
||||
protected int OFS_Chatter = int.MinValue;
|
||||
public Chatter4 Chatter => new(this, Buffer.Slice(OFS_Chatter));
|
||||
public Chatter4 Chatter => new(this, Buffer[OFS_Chatter..]);
|
||||
|
||||
protected int OFS_Record = int.MinValue;
|
||||
public Record4 Records => new(this, Buffer.Slice(OFS_Record, Record4.GetSize(this)));
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public string Rival
|
|||
public Span<byte> RivalTrash
|
||||
{
|
||||
get => Data.Slice(0x23BA4, MaxStringLengthTrainer * 2);
|
||||
set { if (value.Length == MaxStringLengthTrainer * 2) value.CopyTo(Data.Slice(0x23BA4)); }
|
||||
set { if (value.Length == MaxStringLengthTrainer * 2) value.CopyTo(Data[0x23BA4..]); }
|
||||
}
|
||||
|
||||
protected override int ExtBattleVideoNativeOffset => 0x4C000; // 0x1A00
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using static System.Buffers.Binary.BinaryPrimitives;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ private void ResetData()
|
|||
MailType = 0;
|
||||
}
|
||||
|
||||
public override ushort GetMessage(int index1, int index2) => ReadUInt16LittleEndian(Data.Slice(((index1 * 3) + index2) * 2));
|
||||
public override void SetMessage(int index1, int index2, ushort value) => WriteUInt16LittleEndian(Data.Slice(((index1 * 3) + index2) * 2), value);
|
||||
public override void CopyTo(SaveFile sav) => sav.SetData(((SAV3)sav).Large[_dataOffset..], Data);
|
||||
public override ushort GetMessage(int index1, int index2) => ReadUInt16LittleEndian(Data[(((index1 * 3) + index2) * 2)..]);
|
||||
public override void SetMessage(int index1, int index2, ushort value) => WriteUInt16LittleEndian(Data[(((index1 * 3) + index2) * 2)..], value);
|
||||
public override void CopyTo(SaveFile sav) => sav.SetData(((SAV3)sav).Large[DataOffset..], Data);
|
||||
|
||||
public override string AuthorName
|
||||
{
|
||||
|
|
@ -57,10 +57,10 @@ public override byte AuthorLanguage
|
|||
set => JP = value == (byte)LanguageID.Japanese;
|
||||
}
|
||||
|
||||
public override ushort AuthorTID { get => ReadUInt16LittleEndian(Data.Slice(0x1A)); set => WriteUInt16LittleEndian(Data.Slice(0x1A), value); }
|
||||
public override ushort AuthorSID { get => ReadUInt16LittleEndian(Data.Slice(0x1C)); set => WriteUInt16LittleEndian(Data.Slice(0x1C), value); }
|
||||
public override ushort AppearPKM { get => ReadUInt16LittleEndian(Data.Slice(0x1E)); set => WriteUInt16LittleEndian(Data.Slice(0x1E), (ushort)(value == 0 ? 1 : value)); }
|
||||
public override int MailType { get => ReadUInt16LittleEndian(Data.Slice(0x20)); set => WriteUInt16LittleEndian(Data.Slice(0x20), (ushort)value); }
|
||||
public override ushort AuthorTID { get => ReadUInt16LittleEndian(Data[0x1A..]); set => WriteUInt16LittleEndian(Data[0x1A..], value); }
|
||||
public override ushort AuthorSID { get => ReadUInt16LittleEndian(Data[0x1C..]); set => WriteUInt16LittleEndian(Data[0x1C..], value); }
|
||||
public override ushort AppearPKM { get => ReadUInt16LittleEndian(Data[0x1E..]); set => WriteUInt16LittleEndian(Data[0x1E..], (ushort)(value == 0 ? 1 : value)); }
|
||||
public override int MailType { get => ReadUInt16LittleEndian(Data[0x20..]); set => WriteUInt16LittleEndian(Data[0x20..], (ushort)value); }
|
||||
|
||||
public override bool? IsEmpty => MailType switch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public Mail4(byte? lang, byte? version) : base(new byte[SIZE])
|
|||
ResetData();
|
||||
}
|
||||
|
||||
public override void CopyTo(SaveFile sav) => sav.SetData(((SAV4)sav).General[_dataOffset..], Data);
|
||||
public override void CopyTo(SaveFile sav) => sav.SetData(((SAV4)sav).General[DataOffset..], Data);
|
||||
|
||||
private void ResetData()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
public abstract class MailDetail(Memory<byte> Raw, int DataOffset = 0)
|
||||
public abstract class MailDetail(Memory<byte> Raw, int dataOffset = 0)
|
||||
{
|
||||
protected readonly int _dataOffset = DataOffset;
|
||||
protected Span<byte> Data => Raw.Span.Slice(_dataOffset);
|
||||
protected Span<byte> Data => Raw.Span;
|
||||
protected readonly int DataOffset = dataOffset;
|
||||
|
||||
public virtual void CopyTo(SaveFile sav) => sav.SetData(Raw.Span, _dataOffset);
|
||||
public virtual void CopyTo(SaveFile sav) => sav.SetData(Raw.Span, DataOffset);
|
||||
public virtual void CopyTo(PK4 pk4) { }
|
||||
public virtual void CopyTo(PK5 pk5) { }
|
||||
public virtual string GetMessage(bool isLastLine) => string.Empty;
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ public string TeamName
|
|||
|
||||
public uint EntityCount
|
||||
{
|
||||
get => ReadUInt32LittleEndian(Data.Slice(OFS_END));
|
||||
set => WriteUInt32LittleEndian(Data.Slice(OFS_END), value);
|
||||
get => ReadUInt32LittleEndian(Data[OFS_END..]);
|
||||
set => WriteUInt32LittleEndian(Data[OFS_END..], value);
|
||||
}
|
||||
|
||||
public PK9 GetSlot(int slot)
|
||||
|
|
@ -80,7 +80,7 @@ public void SetSlot(int slot, PK9 pk)
|
|||
var data = pk.EncryptedPartyData;
|
||||
// Wipe Party Stats
|
||||
Array.Clear(data, LEN_STORED, LEN_PARTYSTAT);
|
||||
data.CopyTo(Data.Slice(ofs));
|
||||
data.CopyTo(Data[ofs..]);
|
||||
}
|
||||
|
||||
public PK9[] GetTeam()
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@ public static void InitializeStrings(string lang, SaveFile? sav = null, bool hax
|
|||
if (sav is not null)
|
||||
GameInfo.FilteredSources = new FilteredGameDataSource(sav, GameInfo.Sources, hax);
|
||||
|
||||
// Update Legality Analysis strings
|
||||
ParseSettings.ChangeLocalizationStrings(str.movelist, str.specieslist);
|
||||
|
||||
// Update Legality Strings
|
||||
Task.Run(() =>
|
||||
{
|
||||
LocalizationUtil.SetLocalization(typeof(MessageStrings), lang);
|
||||
});
|
||||
Task.Run(() => LocalizationUtil.SetLocalization(typeof(MessageStrings), lang));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ private static void VerifyAll(string folder, string subFolder, bool isValid, boo
|
|||
exists.Should().BeTrue($"the specified test directory at '{path}' should exist");
|
||||
else if (!exists)
|
||||
return;
|
||||
|
||||
|
||||
var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
|
||||
var ctr = 0;
|
||||
foreach (var file in files)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user