mirror of
https://github.com/kwsch/pkNX.git
synced 2026-04-25 07:16:51 -05:00
Minor clean
This commit is contained in:
parent
2578ba073c
commit
33a2ab24f1
|
|
@ -20,7 +20,7 @@ public static IFileContainer GetContainer(string path, ContainerType t)
|
|||
ContainerType.Folder => new FolderContainer(path),
|
||||
ContainerType.SingleFile => new SingleFileContainer(path),
|
||||
ContainerType.GFPack => new GFPack(path),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(t), t, null)
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(t), t, null),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public async Task SaveAs(string path, ContainerHandler handler, CancellationToke
|
|||
|
||||
path = FileMitm.GetRedirectedWritePath(path);
|
||||
var stream = new FileStream(path, FileMode.CreateNew);
|
||||
using (var bw = new BinaryWriter(stream))
|
||||
await using (var bw = new BinaryWriter(stream))
|
||||
await Pack(bw, handler, token).ConfigureAwait(false);
|
||||
|
||||
if (token.IsCancellationRequested)
|
||||
|
|
@ -145,6 +145,7 @@ public async Task SaveAs(string path, ContainerHandler handler, CancellationToke
|
|||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ private void ReadPack(BinaryReader br)
|
|||
Debug.Assert(Pointers.PtrHashFolders[f] == br.BaseStream.Position);
|
||||
var table = HashInFolder[f] = new FileHashFolder
|
||||
{
|
||||
Folder = br.ReadBytes(FileHashIndex.SIZE).ToClass<FileHashFolderInfo>()
|
||||
Folder = br.ReadBytes(FileHashIndex.SIZE).ToClass<FileHashFolderInfo>(),
|
||||
};
|
||||
table.Files = new FileHashIndex[table.Folder.FileCount];
|
||||
for (int i = 0; i < table.Files.Length; i++)
|
||||
|
|
|
|||
|
|
@ -77,11 +77,8 @@ public override void SetAlwaysShiny()
|
|||
|
||||
public static byte[] GetFixedInstruction(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
count = 1;
|
||||
else if (count >= 4092)
|
||||
count = 4091;
|
||||
count = Math.Clamp(count, 1, 4091);
|
||||
var val = ((count & 0xFFF) << 10) | 0b111000100_000000000000_1010011111;
|
||||
return BitConverter.GetBytes((uint)val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ public sealed class ShinyRateSWSH : ShinyRateInfo
|
|||
private readonly int FunctionOffset; // loop counter and break
|
||||
private static readonly byte[] FunctionPrelude = { 0xff, 0x03, 0x06, 0xd1, 0xfc, 0x6f, 0x12, 0xa9, 0xfa, 0x67, 0x13, 0xa9, 0xf8, 0x5f, 0x14, 0xa9, 0xf6, 0x57, 0x15, 0xa9, 0xf4, 0x4f, 0x16, 0xa9, 0xfd, 0x7b, 0x17, 0xa9, 0xfd, 0xc3, 0x05, 0x91, 0xfa, 0xc6, 0x00, 0xf0 };
|
||||
|
||||
private static readonly int RerollCountCheckOffset = 0x2C8;
|
||||
private const int RerollCountCheckOffset = 0x2C8;
|
||||
private static readonly byte[] RerollCountCheckDefault = { 0x3f, 0x03, 0x17, 0x6b};
|
||||
|
||||
private static readonly int RerollCountBreakOffset = 0x2CC;
|
||||
private const int RerollCountBreakOffset = 0x2CC;
|
||||
private static readonly byte[] RerollCountBreakDefault = { 0x62, 0x00, 0x00, 0x54 }; // b.cs $pc + 12
|
||||
private static readonly byte[] RerollCountBreakNop = { 0x1F, 0x20, 0x03, 0xD5 }; // nop
|
||||
|
||||
|
|
@ -84,10 +84,7 @@ public override void SetAlwaysShiny()
|
|||
|
||||
public static byte[] GetFixedInstruction(int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
count = 1;
|
||||
else if (count >= 4092)
|
||||
count = 4091;
|
||||
count = Math.Clamp(count, 1, 4091);
|
||||
var val = ((count & 0xFFF) << 10) | 0b0111000100_000000000000_11001_11111;
|
||||
return BitConverter.GetBytes((uint)val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using pkNX.Structures;
|
||||
using Util = pkNX.Randomization.Util;
|
||||
|
||||
|
|
@ -77,4 +77,4 @@ public static byte[] GetTypeChartImageData(int itemsize, int itemsPerRow, byte[]
|
|||
|
||||
return bmpData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
|
@ -38,14 +38,14 @@ internal IFileContainer GetFile(GameFile file, int language)
|
|||
Cache.Add(file, container);
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
internal void SaveAll()
|
||||
{
|
||||
foreach (var container in Cache)
|
||||
{
|
||||
var c = container.Value;
|
||||
if (c.Modified)
|
||||
c.SaveAs(c.FilePath, ProgressTracker, TokenSource.Token).RunSynchronously();
|
||||
c.SaveAs(c.FilePath!, ProgressTracker, TokenSource.Token).RunSynchronously();
|
||||
}
|
||||
var modified = Cache.Where(z => z.Value.Modified).ToArray();
|
||||
foreach (var m in modified)
|
||||
|
|
@ -174,7 +174,7 @@ internal void SaveAll()
|
|||
new(GameFile.Placement, ContainerType.SingleFile, "bin", "archive", "field", "resident", "placement.gfpak"),
|
||||
new(GameFile.Shops, ContainerType.SingleFile, "bin", "appli", "shop", "bin", "shop_data.bin"),
|
||||
new(GameFile.Rentals, ContainerType.SingleFile, "bin", "script_event_data", "rental.bin"),
|
||||
new(GameFile.SymbolBehave, ContainerType.SingleFile, "bin", "field", "param", "symbol_encount_mons_param", "symbol_encount_mons_param.bin")
|
||||
new(GameFile.SymbolBehave, ContainerType.SingleFile, "bin", "field", "param", "symbol_encount_mons_param", "symbol_encount_mons_param.bin"),
|
||||
|
||||
// Cutscenes bin\demo
|
||||
// Models bin\archive\pokemon
|
||||
|
|
@ -267,4 +267,4 @@ internal void SaveAll()
|
|||
// pretty much everything is obviously named :)
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using pkNX.Containers;
|
||||
using pkNX.Structures;
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ public static GameManager GetManager(GameLocation loc, int language)
|
|||
GameVersion.GP or GameVersion.GE or GameVersion.GG => new GameManagerGG(loc, language),
|
||||
GameVersion.SW or GameVersion.SH or GameVersion.SWSH => new GameManagerSWSH(loc, language),
|
||||
GameVersion.PLA => new GameManagerPLA(loc, language),
|
||||
_ => throw new ArgumentException(nameof(loc.Game))
|
||||
_ => throw new ArgumentException(nameof(loc.Game)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using pkNX.Containers;
|
||||
using pkNX.Structures;
|
||||
|
|
@ -21,6 +21,8 @@ public class GameManagerGG : GameManager
|
|||
protected override void SetMitm()
|
||||
{
|
||||
var basePath = Path.GetDirectoryName(ROM.RomFS);
|
||||
if (basePath is null)
|
||||
throw new InvalidDataException("Invalid RomFS path.");
|
||||
// unlike SWSH, LGPE has a unique opening movie in romfs to differentiate between versions
|
||||
bool eevee = Directory.Exists(Path.Combine(PathRomFS, "bin", "movies", "EEVEE_GO"));
|
||||
ActualGame = eevee ? GameVersion.GE : GameVersion.GP;
|
||||
|
|
@ -71,4 +73,4 @@ protected override void Terminate()
|
|||
var personal = this[GameFile.PersonalStats];
|
||||
personal[0] = Data.PersonalData.Table.SelectMany(z => ((IPersonalInfoBin)z).Write()).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using pkNX.Containers;
|
||||
|
|
@ -21,6 +21,8 @@ public class GameManagerPLA : GameManager
|
|||
protected override void SetMitm()
|
||||
{
|
||||
var basePath = Path.GetDirectoryName(ROM.RomFS);
|
||||
if (basePath is null)
|
||||
throw new InvalidDataException("Invalid RomFS path.");
|
||||
var tid = ROM.ExeFS != null ? TitleID : "arceus";
|
||||
var redirect = Path.Combine(basePath, tid);
|
||||
FileMitm.SetRedirect(basePath, redirect);
|
||||
|
|
@ -81,4 +83,4 @@ public void ResetText()
|
|||
protected override void Terminate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using pkNX.Containers;
|
||||
|
|
@ -21,6 +21,8 @@ public class GameManagerSWSH : GameManager
|
|||
protected override void SetMitm()
|
||||
{
|
||||
var basePath = Path.GetDirectoryName(ROM.RomFS);
|
||||
if (basePath is null)
|
||||
throw new InvalidDataException("Invalid ROMFS path.");
|
||||
var tid = ROM.ExeFS != null ? TitleID : "0100ABF008968000"; // no way to differentiate without exefs, so default to Sword
|
||||
var redirect = Path.Combine(basePath, tid);
|
||||
FileMitm.SetRedirect(basePath, redirect);
|
||||
|
|
@ -81,4 +83,4 @@ protected override void Terminate()
|
|||
var learn = this[GameFile.Learnsets];
|
||||
learn[0] = Learn.Files.SelectMany(z => z).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using pkNX.Structures;
|
||||
|
||||
namespace pkNX.Game;
|
||||
|
|
@ -24,7 +24,7 @@ public static IReadOnlyCollection<TextReference> GetMapping(GameVersion game)
|
|||
GameVersion.SH => SWSH,
|
||||
GameVersion.SWSH => SWSH,
|
||||
GameVersion.PLA => PLA,
|
||||
_ => null
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ public static IReadOnlyCollection<TextReference> GetMapping(GameVersion game)
|
|||
new(114, TextName.Forms),
|
||||
new(116, TextName.SpeciesClassifications),
|
||||
new(119, TextName.PokedexEntry1),
|
||||
new(120, TextName.PokedexEntry2)
|
||||
new(120, TextName.PokedexEntry2),
|
||||
};
|
||||
|
||||
private static readonly TextReference[] USUM =
|
||||
|
|
@ -126,7 +126,7 @@ public static IReadOnlyCollection<TextReference> GetMapping(GameVersion game)
|
|||
new(119, TextName.Forms),
|
||||
new(121, TextName.SpeciesClassifications),
|
||||
new(124, TextName.PokedexEntry1),
|
||||
new(125, TextName.PokedexEntry2)
|
||||
new(125, TextName.PokedexEntry2),
|
||||
};
|
||||
|
||||
private static readonly TextReference[] GG =
|
||||
|
|
@ -175,7 +175,6 @@ public static IReadOnlyCollection<TextReference> GetMapping(GameVersion game)
|
|||
new("poke_memory_feeling.dat", TextName.MemoryFeelings),
|
||||
};
|
||||
|
||||
|
||||
private static readonly TextReference[] PLA =
|
||||
{
|
||||
new("iteminfo.dat", TextName.ItemFlavor),
|
||||
|
|
@ -201,4 +200,4 @@ public static IReadOnlyCollection<TextReference> GetMapping(GameVersion game)
|
|||
new("ribbon.dat", TextName.RibbonMark),
|
||||
new("poke_memory_feeling.dat", TextName.MemoryFeelings),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace pkNX.Game;
|
||||
namespace pkNX.Game;
|
||||
|
||||
public enum TextName
|
||||
{
|
||||
|
|
@ -34,5 +34,5 @@ public enum TextName
|
|||
PokedexEntry2,
|
||||
|
||||
RibbonMark,
|
||||
MemoryFeelings
|
||||
}
|
||||
MemoryFeelings,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,6 @@ public int GetRandomForme(int species, bool mega, bool fused, bool alola, bool g
|
|||
{
|
||||
(int)Pikachu when stats.Table.Length == 1192 => 8, // LGPE Partner Pikachu
|
||||
(int)Slowbro when galar => 1, // Mega Slowbro
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(species))
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(species)),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,11 +190,10 @@ private void TryForceEvolve(IPokeData pk)
|
|||
if (!Settings.ForceFullyEvolved || pk.Level < Settings.ForceFullyEvolvedAtLevel)
|
||||
return;
|
||||
|
||||
var evos = Evos;
|
||||
int species = pk.Species;
|
||||
int form = pk.Form;
|
||||
|
||||
int timesEvolved = TryForceEvolve(evos, ref species, ref form);
|
||||
int timesEvolved = TryForceEvolve(Evos, ref species, ref form);
|
||||
if (timesEvolved == 0)
|
||||
return;
|
||||
pk.Species = species;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public static bool IsValidOutOfBoundsForme(int species, int form, int generation
|
|||
Unown => form < (generation == 2 ? 26 : 28), // A-Z : A-Z?!
|
||||
Mothim => form < 3, // Wormadam base form is kept
|
||||
Scatterbug or Spewpa => form < 18,
|
||||
_ => false
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the <see cref="GameVersion.PLA"/> games.
|
||||
/// Personal Info class with values from the <see cref="GameVersion.PLA"/> games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo8LA : IPersonalInfoPLA
|
||||
{
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ private PersonalInfo8LA GetObj(PersonalInfoLAfb e, List<PersonalInfoLAfb> forms,
|
|||
return new PersonalInfo8LA(e)
|
||||
{
|
||||
FormCount = (byte)forms.Count,
|
||||
FormStatsIndex = (f != 0 ? 0 : forms.Count == 1 ? 0 : max + formTable.Count + 1)
|
||||
FormStatsIndex = (f != 0 ? 0 : forms.Count == 1 ? 0 : max + formTable.Count + 1),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,9 +54,10 @@ public string NameSummary
|
|||
|
||||
private static IReadOnlyDictionary<ulong, string> GenerateSpawnerNameMap()
|
||||
{
|
||||
var result = new Dictionary<ulong, string>();
|
||||
|
||||
result[FnvHash.HashFnv1a_64("hoge")] = "hoge";
|
||||
var result = new Dictionary<ulong, string>
|
||||
{
|
||||
[FnvHash.HashFnv1a_64("hoge")] = "hoge",
|
||||
};
|
||||
|
||||
var gimmicks = new[] { "no", "tree", "rock", "crystal", "snow", "box", "leaves_r", "leaves_g", "yachi" };
|
||||
foreach (var gimmick in gimmicks)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class NewHugeOutbreakLottery8a
|
|||
[Category(MapSetting), Description("Maximum amount of outbreak spots to create.")]
|
||||
[FlatBufferItem(04)] public int OutbreakTotalMax { get; set; }
|
||||
|
||||
[Category(MapSetting), Description("Number of outbreaks that use the Rare2 table."), ]
|
||||
[Category(MapSetting), Description("Number of outbreaks that use the Rare2 table.")]
|
||||
[FlatBufferItem(05)] public int OutbreakRare2 { get; set; }
|
||||
|
||||
[Category(MapSetting), Description("Number of outbreaks that use the Rare1 table.")]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the <see cref="GameVersion.PLA"/> games.
|
||||
/// Personal Info class with values from the <see cref="GameVersion.PLA"/> games.
|
||||
/// </summary>
|
||||
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class PersonalTableLAfb : IFlatBufferArchive<PersonalInfoLAfb>
|
||||
|
|
@ -21,7 +21,7 @@ public class PersonalTableLAfb : IFlatBufferArchive<PersonalInfoLAfb>
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the <see cref="GameVersion.PLA"/> games.
|
||||
/// Personal Info class with values from the <see cref="GameVersion.PLA"/> games.
|
||||
/// </summary>
|
||||
[FlatBufferTable, TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class PersonalInfoLAfb
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public enum LocationType8a : ulong
|
|||
TakeOffShoesOcclusion = 0x09FBFD6B423FAEA6, // "TakeOffShoesOcclusion"
|
||||
TreeCullingFrustumFar = 0xD55673931A300690, // "TreeCullingFrustumFar"
|
||||
WeatherOcclusion = 0x2B3435F7DF6CF454, // "WeatherOcclusion"
|
||||
};
|
||||
}
|
||||
|
||||
[FlatBufferItem(0)] public string Field_00 { get; set; } = string.Empty;
|
||||
[FlatBufferItem(1)] public ulong Field_01 { get; set; }
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class PokeMiscTable8a : IFlatBufferArchive<PokeMisc8a>
|
|||
public PokeMisc8a GetEntry(int species, int form)
|
||||
{
|
||||
return Array.Find(Table, z => z.Species == species && z.Form == form) ??
|
||||
new PokeMisc8a() { Value = $"{species}-{form} is not in {nameof(PokeMiscTable8a)}." };
|
||||
new PokeMisc8a { Value = $"{species}-{form} is not in {nameof(PokeMiscTable8a)}." };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public PokedexResearchTask[] GetEntries(int species)
|
|||
|
||||
public PokedexResearchTask AddTask(int Species)
|
||||
{
|
||||
var task = new PokedexResearchTask() { Species = Species };
|
||||
var task = new PokedexResearchTask { Species = Species };
|
||||
Table = Table.Append(task);
|
||||
return task;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public string FriendlyAreaName
|
|||
"ha_area04" => "Coronet Highlands",
|
||||
"ha_area05" => "Alabaster Icelands",
|
||||
"ha_area06" => "Ancient Retreat",
|
||||
_ => string.Format("Unknown Area ({0})", Name),
|
||||
_ => $"Unknown Area ({Name})",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ public static void Divide(List<EncounterDetail8a>[,] table)
|
|||
{
|
||||
var e = table[time, weather][i];
|
||||
var effective = (e.Rate / totalRate) * 100.0;
|
||||
var detail = new EncounterDetail8a(effective, e.MultT, e.MultW, e.Unk, e.Slot);
|
||||
table[time, weather][i] = detail;
|
||||
table[time, weather][i] = e with { Rate = effective };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,11 +397,8 @@ private static IEnumerable<string> GetEffectiveTableSummary(IReadOnlyList<Encoun
|
|||
yield break;
|
||||
}
|
||||
|
||||
foreach (var tup in table)
|
||||
foreach ((double rate, _, _, _, EncounterSlot8a? slot) in table)
|
||||
{
|
||||
var rate = tup.Rate;
|
||||
var slot = tup.Slot;
|
||||
|
||||
string form = slot.Form == 0 ? string.Empty : $"-{slot.Form}";
|
||||
var spec_form = $"{speciesNames[slot.Species]}{form}";
|
||||
|
||||
|
|
|
|||
|
|
@ -37,14 +37,13 @@ public static string GetTriggerMetaSummary(TriggerMeta8a meta)
|
|||
|
||||
if (Enum.IsDefined(typeof(TriggerType8a), meta.TriggerTypeID))
|
||||
return $"{meta.TriggerTypeID}({argsSummary})";
|
||||
else
|
||||
return $"0x{(ulong)meta.TriggerTypeID:X16}({argsSummary})";
|
||||
return $"0x{(ulong)meta.TriggerTypeID:X16}({argsSummary})";
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetTriggerConditionsSummary(IEnumerable<TriggerCondition8a> conds)
|
||||
{
|
||||
foreach (var cond in conds)
|
||||
yield return $"{Condition8aUtil.GetConditionTypeSummary(cond)}: {Condition8aUtil.GetConditionSummary(cond)}";
|
||||
yield return $"{cond.GetConditionTypeSummary()}: {cond.GetConditionSummary()}";
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetTriggerCommandsSummary(IEnumerable<TriggerCommand8a> cmds)
|
||||
|
|
@ -59,8 +58,7 @@ public static string GetTriggerCommandSummary(TriggerCommand8a cmd)
|
|||
|
||||
if (Enum.IsDefined(typeof(TriggerCommandType8a), cmd.CommandTypeID))
|
||||
return $"{cmd.CommandTypeID}({argsSummary})";
|
||||
else
|
||||
return $"0x{(ulong)cmd.CommandTypeID:X16}({argsSummary})";
|
||||
return $"0x{(ulong)cmd.CommandTypeID:X16}({argsSummary})";
|
||||
}
|
||||
|
||||
public static string GetTriggerArgsSummary(params string[] args)
|
||||
|
|
@ -70,7 +68,7 @@ public static string GetTriggerArgsSummary(params string[] args)
|
|||
{
|
||||
if (firstEmpty >= 0 && !string.IsNullOrEmpty(args[i]))
|
||||
throw new ArgumentException($"Invalid TriggerArg at index {i}!");
|
||||
else if (firstEmpty < 0 && string.IsNullOrEmpty(args[i]))
|
||||
if (firstEmpty < 0 && string.IsNullOrEmpty(args[i]))
|
||||
firstEmpty = i;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ IEnumerable<string> Summary(EncounterNest8 e)
|
|||
2 => "A2",
|
||||
3 => "A3",
|
||||
4 => "A4",
|
||||
_ => throw new Exception()
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
var flawless = e.FlawlessIVs;
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ IEnumerable<string> PrettySummary(EncounterNest8 e)
|
|||
2 => "A2",
|
||||
3 => "A3",
|
||||
4 => "A4",
|
||||
_ => throw new Exception()
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
yield return $"\tAbility: {ability}";
|
||||
yield return "\tSelection Probabilities:";
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ string Summary(NestHoleCrystalEncounter8 e, uint x)
|
|||
2 => "A2", // H
|
||||
3 => "A3", // 1/2 only
|
||||
4 => "A4", // 1/2/H
|
||||
_ => throw new Exception()
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
|
||||
// Constructor
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ string Summary(NestHoleDistributionEncounter8 e, int encounterIndex)
|
|||
0 => string.Empty,
|
||||
1 => ", Shiny = Shiny.Never",
|
||||
2 => ", Shiny = Shiny.Always",
|
||||
_ => throw new Exception()
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
var ability = e.Ability switch
|
||||
{
|
||||
|
|
@ -149,7 +149,7 @@ string Summary(NestHoleDistributionEncounter8 e, int encounterIndex)
|
|||
2 => "A2", // H
|
||||
3 => "A3", // 1/2 only
|
||||
4 => "A4", // 1/2/H
|
||||
_ => throw new Exception()
|
||||
_ => throw new Exception(),
|
||||
};
|
||||
|
||||
// calc min/max ranks
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#nullable disable
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#nullable disable
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#nullable disable
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
#pragma warning disable CA1822 // Mark members as static
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
@ -283,6 +282,6 @@ public PlacementZone8_F16_IntFloat Clone() => new()
|
|||
Field_01 = Field_01,
|
||||
Field_02 = Field_02,
|
||||
Field_03 = Field_03,
|
||||
Field_04 = Field_04
|
||||
Field_04 = Field_04,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class PlacementZone8
|
|||
var ident = obj.Identifier;
|
||||
yield return $" {objects[ident.HashObjectName]}:";
|
||||
yield return $" Location: {ident.Location3f}";
|
||||
if (obj.SymbolHash is (0xCBF29CE484222645 or 0))
|
||||
if (obj.SymbolHash is 0 or 0xCBF29CE484222645)
|
||||
{
|
||||
yield return " No symbols."; // shouldn't hit here, if we have a holder we should have a symbol to hold.
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -78,10 +78,8 @@ public int[] Moves
|
|||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CA1027 // Mark enums with FlagsAttribute
|
||||
[FlatBufferEnum(typeof(byte))]
|
||||
public enum FixedGender
|
||||
#pragma warning restore CA1027 // Mark enums with FlagsAttribute
|
||||
{
|
||||
Random = 0,
|
||||
Male = 1,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#nullable disable
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#nullable disable
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
// ReSharper disable UnusedType.Global
|
||||
// ReSharper disable UnusedMember.Global
|
||||
#nullable disable
|
||||
#pragma warning disable CA1819 // Properties should not return arrays
|
||||
|
||||
namespace pkNX.Structures.FlatBuffers;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,20 +40,19 @@ public static byte[][] GetBytes(IReadOnlyDictionary<ulong, byte> zone_loc, IRead
|
|||
private static DumpableLocation GetDumpable(EncounterTable8 zone, IReadOnlyDictionary<ulong, byte> zoneLoc, IReadOnlyDictionary<ulong, byte> zoneType)
|
||||
{
|
||||
// Don't dump data that we can't correlate to a zone
|
||||
if (!zoneLoc.TryGetValue(zone.ZoneID, out var tmp))
|
||||
if (!zoneLoc.TryGetValue(zone.ZoneID, out var location))
|
||||
return DumpableLocation.Empty;
|
||||
|
||||
// Try to get the table type. Skip inaccessible tables.
|
||||
if (!zoneType.TryGetValue(zone.ZoneID, out var slottype) || slottype == (byte)Inaccessible)
|
||||
return DumpableLocation.Empty;
|
||||
|
||||
byte locID = tmp;
|
||||
var list = new List<Slot8>();
|
||||
for (int i = 0; i < zone.SubTables.Length; i++)
|
||||
{
|
||||
var weather = (SWSHEncounterType)(1 << i);
|
||||
|
||||
if (!IsPermittedWeather(locID, weather, slottype))
|
||||
if (!IsPermittedWeather(location, weather, slottype))
|
||||
continue;
|
||||
|
||||
var table = zone.SubTables[i];
|
||||
|
|
@ -73,7 +72,7 @@ private static DumpableLocation GetDumpable(EncounterTable8 zone, IReadOnlyDicti
|
|||
}
|
||||
}
|
||||
|
||||
return new DumpableLocation(list, locID, slottype);
|
||||
return new DumpableLocation(list, location, slottype);
|
||||
}
|
||||
|
||||
private static bool IsPermittedWeather(byte locID, SWSHEncounterType weather, byte slotType)
|
||||
|
|
@ -102,7 +101,7 @@ private static bool IsPermittedWeather(byte locID, SWSHEncounterType weather, by
|
|||
HiddenMain or HiddenMain2 => WeatherBleedHiddenGrass .TryGetValue(location, out var weather) && weather.HasFlag(permit),
|
||||
Surfing => WeatherBleedSymbolSurfing .TryGetValue(location, out var weather) && weather.HasFlag(permit),
|
||||
Sharpedo => WeatherBleedSymbolSharpedo.TryGetValue(location, out var weather) && weather.HasFlag(permit),
|
||||
_ => false
|
||||
_ => false,
|
||||
};
|
||||
|
||||
private class DumpableLocation
|
||||
|
|
|
|||
|
|
@ -9,19 +9,6 @@ namespace pkNX.Structures;
|
|||
/// </summary>
|
||||
public static class ArrayUtil
|
||||
{
|
||||
public static bool IsRangeAll<T>(this T[] data, T value, int offset, int length) where T : IEquatable<T>
|
||||
{
|
||||
int start = offset + length - 1;
|
||||
int end = offset;
|
||||
for (int i = start; i >= end; i--)
|
||||
{
|
||||
if (!data[i].Equals(value))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static byte[] Slice(this byte[] src, int offset, int length)
|
||||
{
|
||||
byte[] data = new byte[length];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
namespace pkNX.Structures;
|
||||
#pragma warning disable CA1027 // Mark enums with FlagsAttribute
|
||||
|
||||
public enum FixedGender : byte
|
||||
#pragma warning restore CA1027 // Mark enums with FlagsAttribute
|
||||
{
|
||||
Random = 0,
|
||||
Male = 1,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// Criteria for evolving to this branch in the <see cref="EvolutionTree"/>
|
||||
/// Criteria for evolving to this branch in the Evolution Tree
|
||||
/// </summary>
|
||||
/// <param name="Method">Evolution Method</param>
|
||||
/// <param name="Species">Evolve to Species</param>
|
||||
/// <param name="Form">Destination Form</param>
|
||||
/// <param name="Argument">Conditional Argument (different from <see cref="Level"/>)</param>
|
||||
/// <param name="Level">Conditional Argument (different from <see cref="Argument"/>)</param>
|
||||
/// <param name="LevelUp">Indicates if a level up is required to trigger evolution.</param>
|
||||
public class EvolutionMethod
|
||||
{
|
||||
public EvolutionMethod Copy(int species = -1)
|
||||
|
|
@ -22,7 +16,7 @@ public EvolutionMethod Copy(int species = -1)
|
|||
Species = (ushort)species,
|
||||
Form = Form,
|
||||
Argument = Argument,
|
||||
Level = Level
|
||||
Level = Level,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +39,7 @@ public EvolutionMethod Copy(int species = -1)
|
|||
|
||||
public override string ToString() => $"{(Species)Species}-{Form} [{Argument}] @ {Level}{(RequiresLevelUp ? "X" : "")}";
|
||||
|
||||
/// <summary>Is <see cref="AnyForm"/> if the evolved form isn't modified. Special consideration for <see cref="LevelUpFormFemale1"/>, which forces 1.</summary>
|
||||
/// <summary>Is <see cref="AnyForm"/> if the evolved form isn't modified. Special consideration for <see cref="EvolutionType.LevelUpFormFemale1"/>, which forces 1.</summary>
|
||||
private const byte AnyForm = byte.MaxValue;
|
||||
|
||||
public bool RequiresLevelUp => Method.IsLevelUpRequired();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ private static EvolutionMethod ReadEvolution(ReadOnlySpan<byte> entry)
|
|||
Argument = ReadUInt16LittleEndian(entry[2..]),
|
||||
Species = ReadUInt16LittleEndian(entry[4..]),
|
||||
Form = SByteToByte((sbyte)entry[6]),
|
||||
Level = entry[7]
|
||||
Level = entry[7],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -55,12 +55,11 @@ public static IReadOnlyList<EvolutionMethod[]> GetArray(BinLinkerAccessor data)
|
|||
|
||||
/// <summary>
|
||||
/// For evo set 7 sbyte is used for form, -1 means no forms are present.
|
||||
/// The remaining code expects to work with 0 for all base forms.
|
||||
/// This clamps the sbyte range to 0<>128, removing the negative range.
|
||||
/// The remaining code expects to work with 0 for all base forms.
|
||||
/// This clamps the sbyte range to [0-128), removing the negative range.
|
||||
/// </summary>
|
||||
private static byte SByteToByte(sbyte b)
|
||||
{
|
||||
return (byte)Math.Max(b, (sbyte)0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,17 +33,14 @@ public override byte[] Write()
|
|||
return ms.ToArray();
|
||||
}
|
||||
|
||||
private static EvolutionMethod ReadEvolution(ReadOnlySpan<byte> entry)
|
||||
private static EvolutionMethod ReadEvolution(ReadOnlySpan<byte> entry) => new()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Method = (EvolutionType)ReadUInt16LittleEndian(entry[0..]),
|
||||
Argument = ReadUInt16LittleEndian(entry[2..]),
|
||||
Species = ReadUInt16LittleEndian(entry[4..]),
|
||||
Form = entry[6],
|
||||
Level = entry[7]
|
||||
};
|
||||
}
|
||||
Method = (EvolutionType)ReadUInt16LittleEndian(entry),
|
||||
Argument = ReadUInt16LittleEndian(entry[2..]),
|
||||
Species = ReadUInt16LittleEndian(entry[4..]),
|
||||
Form = entry[6],
|
||||
Level = entry[7],
|
||||
};
|
||||
|
||||
public static IReadOnlyList<EvolutionMethod[]> GetArray(BinLinkerAccessor data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public static GameVersion GetMetLocationVersionGroup(GameVersion Version)
|
|||
SW => SWSH,
|
||||
SH => SWSH,
|
||||
PLA => PLA,
|
||||
_ => Invalid
|
||||
_ => Invalid,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ public static GameVersion GetVersion(int generation)
|
|||
6 => AS,
|
||||
7 => UM,
|
||||
8 => PLA,
|
||||
_ => Invalid
|
||||
_ => Invalid,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
|
||||
namespace pkNX.Structures;
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ private Action GetInitMethod(GameVersion game)
|
|||
GameVersion.SH => LoadSWSH,
|
||||
GameVersion.SWSH => LoadSWSH,
|
||||
GameVersion.PLA => LoadPLA,
|
||||
_ => throw new ArgumentException(nameof(game))
|
||||
_ => throw new ArgumentException(nameof(game)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -120,4 +120,4 @@ private void LoadPLA()
|
|||
HeldItems = Legal.HeldItems_SWSH;
|
||||
MaxAbilityID = Legal.MaxAbilityID_8a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,5 +202,5 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount)
|
|||
|
||||
public static readonly HashSet<int> BattlePrimals = new() { 382, 383 }; // Kyogre and Groudon
|
||||
public static readonly HashSet<int> BattleFusions = new() { 646, 800, 898 }; // Kyurem, Necrozma, Calyrex
|
||||
public static HashSet<int> BattleExclusiveForms = new(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions)));
|
||||
public static readonly HashSet<int> BattleExclusiveForms = new(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public static partial class Legal
|
|||
063, 096, 326, 517, 202, 561, 677, 178, 203, 575, 578,
|
||||
299, 525, 557, 095, 219, 222, 247, 112, 213, 689,
|
||||
082, 303, 597, 205, 227, 375, 600, 437, 530, 707,
|
||||
098, 224, 400, 515, 008, 130, 195, 419, 061, 184, 657
|
||||
098, 224, 400, 515, 008, 130, 195, 419, 061, 184, 657,
|
||||
};
|
||||
#endregion
|
||||
|
||||
|
|
@ -374,7 +374,7 @@ public static partial class Legal
|
|||
495, 498, 501, //1 - Snivy, Tepig, Oshawott
|
||||
496, 499, 502, //2
|
||||
497, 500, 503, //3
|
||||
566, 567, 696, 697, 698, 699 // Fossil Only obtain
|
||||
566, 567, 696, 697, 698, 699, // Fossil Only obtain
|
||||
};
|
||||
|
||||
public static readonly int[] Ban_Gen3BallHidden =
|
||||
|
|
@ -407,7 +407,7 @@ public static partial class Legal
|
|||
495, 498, 501, //1 - Snivy, Tepig, Oshawott
|
||||
496, 499, 502, //2
|
||||
497, 500, 503, //3
|
||||
566, 567, 696, 697, 698, 699 // Fossil Only obtain
|
||||
566, 567, 696, 697, 698, 699, // Fossil Only obtain
|
||||
};
|
||||
|
||||
public static readonly int[] WurmpleEvolutions =
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public static partial class Legal
|
|||
|
||||
public static readonly int[] Met_GG_3 =
|
||||
{
|
||||
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017
|
||||
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017,
|
||||
};
|
||||
|
||||
public static readonly int[] Met_GG_4 =
|
||||
|
|
@ -216,7 +216,6 @@ public static partial class Legal
|
|||
740, 742,
|
||||
};
|
||||
|
||||
|
||||
public static readonly int[] MovePP_GG =
|
||||
{
|
||||
// Absorb: 25 -> 15 (damage buffed from 20->40)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public static partial class Legal
|
|||
|
||||
public static readonly int[] Met_SWSH_3 =
|
||||
{
|
||||
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018
|
||||
30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018,
|
||||
};
|
||||
|
||||
public static readonly int[] Met_SWSH_4 =
|
||||
|
|
@ -275,7 +275,6 @@ public static partial class Legal
|
|||
798, 802,
|
||||
};
|
||||
|
||||
|
||||
public static readonly ushort[] TMHM_SWSH =
|
||||
{
|
||||
// TM
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public static partial class Legal
|
|||
003, 006, 009, 065, 080, 115, 127, 130, 142, 150,
|
||||
181, 212, 214, 229, 248,
|
||||
257, 282, 303, 306, 308, 310, 354, 359, 380, 381,
|
||||
445, 448, 460
|
||||
445, 448, 460,
|
||||
};
|
||||
|
||||
public static readonly ushort[] Mega_ORAS = Mega_XY.Concat(new ushort[]
|
||||
|
|
@ -19,7 +19,7 @@ public static partial class Legal
|
|||
254, 260, 302, 319, 323, 334, 362, 373, 376, 384,
|
||||
428, 475,
|
||||
531,
|
||||
719
|
||||
719,
|
||||
}).ToArray();
|
||||
|
||||
public static readonly int[] SpecialClasses_XY =
|
||||
|
|
@ -624,7 +624,7 @@ public static partial class Legal
|
|||
public static readonly int[] Z_Moves =
|
||||
{
|
||||
622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658,
|
||||
695, 696, 697, 698, 699, 700, 701, 702, 703, 719, 723, 724, 725, 726, 727, 728
|
||||
695, 696, 697, 698, 699, 700, 701, 702, 703, 719, 723, 724, 725, 726, 727, 728,
|
||||
};
|
||||
|
||||
public static readonly int[] Max_Moves =
|
||||
|
|
@ -664,21 +664,21 @@ public static partial class Legal
|
|||
006, 021, 022, 023, 024, 025, 026, 076, 130, 131, 132, 175, 184, 185, 186, 187, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
||||
275, 276, 277, 279, 303, 321, 322, 323, 324, 325, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 237, 348, 349, 350, 351, 435, 436,
|
||||
437, 438, 439, 503, 504, 505, 507, 511, 512, 513, 514, 515, 519, 520, 521, 525, 526, 559, 560, 561, 562, 573, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589,
|
||||
590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 604, 605, 606, 613
|
||||
590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 604, 605, 606, 613,
|
||||
};
|
||||
|
||||
public static readonly int[] ImportantTrainers_ORAS =
|
||||
{
|
||||
178, 231, 235, 236, 266, 271, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 518, 527, 528, 529, 530, 531, 532, 553, 554, 555, 556, 557, 561, 563, 567, 569, 570, 571, 572,
|
||||
583, 674, 675, 676, 677, 678, 679, 680, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 713, 856, 857, 898, 906, 907, 908, 909, 910, 911,
|
||||
912, 913, 942, 943, 944, 945, 946, 947
|
||||
912, 913, 942, 943, 944, 945, 946, 947,
|
||||
};
|
||||
|
||||
public static readonly int[] ImportantTrainers_SM =
|
||||
{
|
||||
012, 013, 014, 023, 052, 074, 075, 076, 077, 078, 079, 089, 090, 129, 131, 132, 138, 144, 146, 149, 152, 153, 154, 155, 156, 158, 159, 160, 164, 167, 215, 216, 217, 218, 219, 220, 221,
|
||||
222, 235, 236, 238, 239, 240, 241, 349, 350, 351, 352, 356, 357, 358, 359, 360, 392, 396, 398, 400, 401, 403, 405, 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, 435, 438, 439, 440,
|
||||
441, 447, 448, 449, 450, 451, 452, 467, 477, 478, 479, 480, 481, 482, 483, 484
|
||||
441, 447, 448, 449, 450, 451, 452, 467, 477, 478, 479, 480, 481, 482, 483, 484,
|
||||
};
|
||||
|
||||
public static readonly int[] ImportantTrainers_USUM =
|
||||
|
|
@ -686,13 +686,13 @@ public static partial class Legal
|
|||
012, 013, 014, 023, 052, 074, 075, 076, 077, 078, 079, 089, 090, 131, 132, 138, 144, 146, 149, 153, 154, 156, 159, 160, 215, 216, 217, 218, 219, 220, 221, 222, 235, 236, 238, 239, 240,
|
||||
241, 350, 351, 352, 356, 358, 359, 396, 398, 401, 405, 409, 410, 412, 415, 416, 417, 418, 419, 438, 439, 440, 441, 447, 448, 449, 450, 451, 452, 477, 478, 479, 480, 489, 490, 494, 495,
|
||||
496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 541, 542, 543, 555, 556, 557, 558, 559, 560, 561, 562, 572, 573, 578, 580, 582, 583, 623, 630, 644, 645, 647, 648, 649,
|
||||
650, 651, 652
|
||||
650, 651, 652,
|
||||
};
|
||||
|
||||
public static readonly int[] ImportantTrainers_GG =
|
||||
{
|
||||
005, 007, 008, 009, 010, 011, 013, 014, 015, 016, 017, 018, 020, 021, 022, 023, 024, 025, 027, 028, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046,
|
||||
048, 049, 050, 051, 052, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 437, 439, 597, 601
|
||||
048, 049, 050, 051, 052, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 437, 439, 597, 601,
|
||||
};
|
||||
|
||||
public static readonly int[] ImportantTrainers_SWSH =
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
namespace pkNX.Structures;
|
||||
#pragma warning disable CA1027 // Mark enums with FlagsAttribute
|
||||
|
||||
public enum TypeEffectiveness : byte
|
||||
#pragma warning restore CA1027 // Mark enums with FlagsAttribute
|
||||
{
|
||||
Immune = 0,
|
||||
NotVery = 2,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the Black 2 & White 2 games.
|
||||
/// Personal Info class with values from the Black 2 & White 2 games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo5B2W2 : IPersonalInfoB2W2
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the Black & White games.
|
||||
/// Personal Info class with values from the Black & White games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo5BW : IPersonalInfoBW
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the OR & AS games.
|
||||
/// Personal Info class with values from the OR & AS games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo6ORAS : IPersonalInfoORAS
|
||||
public sealed class PersonalInfo6AO : IPersonalInfoORAS
|
||||
{
|
||||
public const int SIZE = 0x50;
|
||||
private readonly byte[] Data;
|
||||
|
|
@ -16,7 +16,7 @@ public sealed class PersonalInfo6ORAS : IPersonalInfoORAS
|
|||
public bool[] TypeTutors { get; set; }
|
||||
public bool[][] SpecialTutors { get; set; }
|
||||
|
||||
public PersonalInfo6ORAS(byte[] data)
|
||||
public PersonalInfo6AO(byte[] data)
|
||||
{
|
||||
Data = data;
|
||||
// Unpack TMHM & Tutors
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the X & Y games.
|
||||
/// Personal Info class with values from the X & Y games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo6XY : IPersonalInfoXY
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the <see cref="GameVersion.GG"/> games.
|
||||
/// Personal Info class with values from the <see cref="GameVersion.GG"/> games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo7GG : IPersonalInfoGG
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the Sun & Moon games.
|
||||
/// Personal Info class with values from the Sun & Moon games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo7SM : IPersonalInfoSM
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PersonalInfo"/> class with values from the <see cref="GameVersion.SWSH"/> games.
|
||||
/// Personal Info class with values from the <see cref="GameVersion.SWSH"/> games.
|
||||
/// </summary>
|
||||
public sealed class PersonalInfo8SWSH : IPersonalInfoSWSH
|
||||
{
|
||||
|
|
@ -119,12 +119,12 @@ public byte[] Write()
|
|||
public ushort Quantized_floats_3 { get => ReadUInt16LittleEndian(Data.AsSpan(0x66)); set => WriteUInt16LittleEndian(Data.AsSpan(0x66), value); }
|
||||
public ushort Quantized_floats_4 { get => ReadUInt16LittleEndian(Data.AsSpan(0x68)); set => WriteUInt16LittleEndian(Data.AsSpan(0x68), value); }
|
||||
|
||||
public byte[] Bytes_0 { get => Data.AsSpan(0x6A, 10).ToArray(); }
|
||||
public byte[] Bytes_1 { get => Data.AsSpan(0x74, 10).ToArray(); }
|
||||
public byte[] Bytes_2 { get => Data.AsSpan(0x7E, 5).ToArray(); }
|
||||
public byte[] Bytes_3 { get => Data.AsSpan(0x83, 5).ToArray(); }
|
||||
public byte[] Bytes_4 { get => Data.AsSpan(0x88, 5).ToArray(); }
|
||||
public byte[] Bytes_5 { get => Data.AsSpan(0x8D, 5).ToArray(); }
|
||||
public Span<byte> Bytes_0 => Data.AsSpan(0x6A, 10);
|
||||
public Span<byte> Bytes_1 => Data.AsSpan(0x74, 10);
|
||||
public Span<byte> Bytes_2 => Data.AsSpan(0x7E, 5);
|
||||
public Span<byte> Bytes_3 => Data.AsSpan(0x83, 5);
|
||||
public Span<byte> Bytes_4 => Data.AsSpan(0x88, 5);
|
||||
public Span<byte> Bytes_5 => Data.AsSpan(0x8D, 5);
|
||||
|
||||
public ushort Shorts_0 { get => ReadUInt16LittleEndian(Data.AsSpan(0x92)); set => WriteUInt16LittleEndian(Data.AsSpan(0x92), value); }
|
||||
public ushort Shorts_1 { get => ReadUInt16LittleEndian(Data.AsSpan(0x94)); set => WriteUInt16LittleEndian(Data.AsSpan(0x94), value); }
|
||||
|
|
@ -145,7 +145,6 @@ public byte[] Write()
|
|||
|
||||
public ushort DexIndexNational { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Form that any offspring will hatch with, assuming it is holding an Everstone.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -62,19 +62,16 @@ public static class IBaseStatExtensions
|
|||
/// <summary>
|
||||
/// Sets the requested Base Stat value with the requested <see cref="index"/>.
|
||||
/// </summary>
|
||||
public static void SetBaseStatValue(this IBaseStat stats, int index, int value)
|
||||
public static int SetBaseStatValue(this IBaseStat stats, int index, int value) => index switch
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: stats.HP = value; return;
|
||||
case 1: stats.ATK = value; return;
|
||||
case 2: stats.DEF = value; return;
|
||||
case 3: stats.SPE = value; return;
|
||||
case 4: stats.SPA = value; return;
|
||||
case 5: stats.SPD = value; return;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(index));
|
||||
};
|
||||
}
|
||||
0 => stats.HP = value,
|
||||
1 => stats.ATK = value,
|
||||
2 => stats.DEF = value,
|
||||
3 => stats.SPE = value,
|
||||
4 => stats.SPA = value,
|
||||
5 => stats.SPD = value,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of base stats available.
|
||||
|
|
|
|||
|
|
@ -57,19 +57,16 @@ public static class IIEffortValueYieldExtensions
|
|||
/// <summary>
|
||||
/// Sets the requested Base Stat value with the requested <see cref="index"/>.
|
||||
/// </summary>
|
||||
public static void SetEVYieldValue(this IEffortValueYield stats, int index, int value)
|
||||
public static int SetEVYieldValue(this IEffortValueYield stats, int index, int value) => index switch
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: stats.EV_HP = value; return;
|
||||
case 1: stats.EV_ATK = value; return;
|
||||
case 2: stats.EV_DEF = value; return;
|
||||
case 3: stats.EV_SPE = value; return;
|
||||
case 4: stats.EV_SPA = value; return;
|
||||
case 5: stats.EV_SPD = value; return;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(index));
|
||||
};
|
||||
}
|
||||
0 => stats.EV_HP = value,
|
||||
1 => stats.EV_ATK = value,
|
||||
2 => stats.EV_DEF = value,
|
||||
3 => stats.EV_SPE = value,
|
||||
4 => stats.EV_SPA = value,
|
||||
5 => stats.EV_SPD = value,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of base stats available.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public interface IMovesInfo_1 : IMovesInfo
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// SpecialTutors added in BW2
|
||||
/// SpecialTutors added in B2W2
|
||||
/// </summary>
|
||||
public interface IMovesInfo_2 : IMovesInfo_1
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public static class IPersonalAbilityExtensions
|
|||
/// <summary>
|
||||
/// Gets the index of the <see cref="abilityID"/> within the specification's list of abilities.
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="abilityID">Ability ID</param>
|
||||
/// <returns>Ability Index or -1 if not found</returns>
|
||||
public static int GetIndexOfAbility(this IPersonalAbility a, int abilityID) => abilityID == a.Ability1 ? 0 : abilityID == a.Ability2 ? 1 : abilityID == a.AbilityH ? 2 : -1;
|
||||
|
|
@ -50,16 +51,13 @@ public static void SetAbilities(this IPersonalAbility a, Span<int> result)
|
|||
/// <summary>
|
||||
/// Sets the requested Ability value with the requested <see cref="index"/>.
|
||||
/// </summary>
|
||||
public static void SetAbilityAtIndex(this IPersonalAbility a, int index, int value)
|
||||
public static int SetAbilityAtIndex(this IPersonalAbility a, int index, int value) => index switch
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: a.Ability1 = value; return;
|
||||
case 1: a.Ability2 = value; return;
|
||||
case 2: a.AbilityH = value; return;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(index));
|
||||
};
|
||||
}
|
||||
0 => a.Ability1 = value,
|
||||
1 => a.Ability2 = value,
|
||||
2 => a.AbilityH = value,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of abilities available.
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ namespace pkNX.Structures;
|
|||
public interface IPersonalFormInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Count of <see cref="Form"/> values the entry can have.
|
||||
/// Count of form values the entry can have.
|
||||
/// </summary>
|
||||
byte FormCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Pointer to the first <see cref="Form"/> <see cref="IPersonalInfo"/> index
|
||||
/// Pointer to the first form <see cref="IPersonalInfo"/> index
|
||||
/// </summary>
|
||||
int FormStatsIndex { get; set; }
|
||||
|
||||
|
|
@ -24,14 +24,15 @@ public interface IPersonalFormInfo
|
|||
public static class IPersonalFormInfoExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="IPersonalFormInfo"/> has any <see cref="Form"/> entry available.
|
||||
/// Checks if the <see cref="IPersonalFormInfo"/> has any form entry available.
|
||||
/// </summary>
|
||||
public static bool HasAnyForms(this IPersonalFormInfo info) => info.FormCount > 1;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="IPersonalFormInfo"/> has the requested <see cref="Form"/> entry index available.
|
||||
/// Checks if the <see cref="IPersonalFormInfo"/> has the requested form entry index available.
|
||||
/// </summary>
|
||||
/// <param name="form"><see cref="Form"/> to retrieve for</param>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="form">Form to retrieve for</param>
|
||||
public static bool HasForm(this IPersonalFormInfo info, byte form)
|
||||
{
|
||||
if (form == 0) // no form requested
|
||||
|
|
@ -44,11 +45,12 @@ public static bool HasForm(this IPersonalFormInfo info, byte form)
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IPersonalFormInfo"/> <see cref="Form"/> entry index for the input criteria, with fallback for the original species entry.
|
||||
/// Gets the <see cref="IPersonalFormInfo"/> form entry index for the input criteria, with fallback for the original species entry.
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="species"><see cref="Species"/> to retrieve for</param>
|
||||
/// <param name="form"><see cref="Form"/> to retrieve for</param>
|
||||
/// <returns>Index the <see cref="Form"/> exists as in the <see cref="PersonalTable"/>.</returns>
|
||||
/// <param name="form">Form to retrieve for</param>
|
||||
/// <returns>Index the form exists as in the table.</returns>
|
||||
public static int FormIndex(this IPersonalFormInfo info, ushort species, byte form)
|
||||
{
|
||||
if (!info.HasForm(form))
|
||||
|
|
@ -57,8 +59,9 @@ public static int FormIndex(this IPersonalFormInfo info, ushort species, byte fo
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if the <see cref="PKM.Form"/> is valid within the <see cref="PersonalInfo.FormCount"/>
|
||||
/// Checks to see if the form is valid within the Personal Info
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="form"></param>
|
||||
public static bool IsFormWithinRange(this IPersonalFormInfo info, byte form)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public static class IPersonalItemExtensions
|
|||
/// <summary>
|
||||
/// Gets the index of the <see cref="itemID"/> within the specification's list of items.
|
||||
/// </summary>
|
||||
/// <param name="a"></param>
|
||||
/// <param name="itemID">Item ID</param>
|
||||
/// <returns>Item Index or -1 if not found</returns>
|
||||
public static int GetIndexOfItem(this IPersonalItems a, int itemID) => itemID == a.Item1 ? 0 : itemID == a.Item2 ? 1 : itemID == a.Item3 ? 2 : -1;
|
||||
|
|
@ -46,16 +47,13 @@ public static void SetItems(this IPersonalItems a, Span<int> result)
|
|||
/// <summary>
|
||||
/// Sets the requested item value with the requested <see cref="index"/>.
|
||||
/// </summary>
|
||||
public static void SetItemAtIndex(this IPersonalItems a, int index, int value)
|
||||
public static int SetItemAtIndex(this IPersonalItems a, int index, int value) => index switch
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0: a.Item1 = value; return;
|
||||
case 1: a.Item2 = value; return;
|
||||
case 2: a.Item3 = value; return;
|
||||
default: throw new ArgumentOutOfRangeException(nameof(index));
|
||||
};
|
||||
}
|
||||
0 => a.Item1 = value,
|
||||
1 => a.Item2 = value,
|
||||
2 => a.Item3 = value,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total number of items available.
|
||||
|
|
|
|||
|
|
@ -26,33 +26,33 @@ public interface IPersonalTable
|
|||
IPersonalInfo this[ushort species, byte form] { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PersonalInfo"/> entry index for a given <see cref="PKM.Species"/> and <see cref="PKM.Form"/>.
|
||||
/// Gets the Personal Info entry index for a given Species and Form.
|
||||
/// </summary>
|
||||
/// <param name="species"><see cref="PKM.Species"/></param>
|
||||
/// <param name="form"><see cref="PKM.Form"/></param>
|
||||
/// <param name="species">Species</param>
|
||||
/// <param name="form">Form</param>
|
||||
/// <returns>Entry index for the input criteria</returns>
|
||||
int GetFormIndex(ushort species, byte form);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="PersonalInfo"/> entry for a given <see cref="PKM.Species"/> and <see cref="PKM.Form"/>.
|
||||
/// Gets the Personal Info entry for a givenSpecies and Form.
|
||||
/// </summary>
|
||||
/// <param name="species"><see cref="PKM.Species"/></param>
|
||||
/// <param name="form"><see cref="PKM.Form"/></param>
|
||||
/// <param name="species">Species</param>
|
||||
/// <param name="form">Form</param>
|
||||
/// <returns>Entry for the input criteria</returns>
|
||||
IPersonalInfo GetFormEntry(ushort species, byte form);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PKM.Species"/> is within the bounds of the table.
|
||||
/// Checks if the Species is within the bounds of the table.
|
||||
/// </summary>
|
||||
/// <param name="species"><see cref="PKM.Species"/></param>
|
||||
/// <param name="species">Species</param>
|
||||
/// <returns>True if present in game</returns>
|
||||
bool IsSpeciesInGame(ushort species);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="PKM.Species"/> and <see cref="PKM.Form"/> is within the bounds of the table.
|
||||
/// Checks if the Species and Form is within the bounds of the table.
|
||||
/// </summary>
|
||||
/// <param name="species"><see cref="PKM.Species"/></param>
|
||||
/// <param name="form"><see cref="PKM.Form"/></param>
|
||||
/// <param name="species">Species</param>
|
||||
/// <param name="form">Form</param>
|
||||
/// <returns>True if present in game</returns>
|
||||
bool IsPresentInGame(ushort species, byte form);
|
||||
|
||||
|
|
@ -74,14 +74,13 @@ public interface IPersonalTable<out T> where T : IPersonalInfo
|
|||
T GetFormEntry(ushort species, byte form);
|
||||
}
|
||||
|
||||
|
||||
public static class IPersonalTableExt
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets form names for every species.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
/// <param name="species">Raw string resource (Species) for the corresponding table.</param>
|
||||
/// <param name="MaxSpecies">Max Species ID (Species ID)</param>
|
||||
/// <returns>Array of species containing an array of form names for that species.</returns>
|
||||
public static string[][] GetFormList(this IPersonalTable pt, string[] species)
|
||||
{
|
||||
|
|
@ -100,11 +99,11 @@ public static string[][] GetFormList(this IPersonalTable pt, string[] species)
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an arranged list of Form names and indexes for use with the individual <see cref="PersonalInfo"/> AltForm ID values.
|
||||
/// Gets an arranged list of Form names and indexes for use with the individual Personal Info AltForm ID values.
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
/// <param name="AltForms">Raw string resource (Forms) for the corresponding table.</param>
|
||||
/// <param name="species">Raw string resource (Species) for the corresponding table.</param>
|
||||
/// <param name="MaxSpecies">Max Species ID (Species ID)</param>
|
||||
/// <param name="baseForm">Pointers for base form IDs</param>
|
||||
/// <param name="formVal">Pointers for table indexes for each form</param>
|
||||
/// <returns>Sanitized list of species names, and outputs indexes for various lookup purposes.</returns>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// Exposes info about <see cref="MoveType"/> that an entity has.
|
||||
/// Exposes info about <see cref="Types"/> that an entity has.
|
||||
/// </summary>
|
||||
public interface IPersonalType
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@ public static bool IsType(this IPersonalType detail, Types type1, Types type2)
|
|||
/// <summary>
|
||||
/// Checks to see if the provided Types match the entry's types.
|
||||
/// </summary>
|
||||
/// <remarks>Input order matters! If input order does not matter, use <see cref="IsType(IPersonalType,int, int)"/> instead.</remarks>
|
||||
/// <remarks>Input order matters! If input order does not matter, use <see cref="IsType(IPersonalType, Types, Types)"/> instead.</remarks>
|
||||
/// <param name="detail">Object reference</param>
|
||||
/// <param name="type1">First type</param>
|
||||
/// <param name="type2">Second type</param>
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@ namespace pkNX.Structures;
|
|||
/// <summary>
|
||||
/// Personal Table storing <see cref="PersonalInfo6AO"/> used in Generation 6 games.
|
||||
/// </summary>
|
||||
public sealed class PersonalTable6ORAS : IPersonalTable, IPersonalTable<PersonalInfo6ORAS>
|
||||
public sealed class PersonalTable6AO : IPersonalTable, IPersonalTable<PersonalInfo6AO>
|
||||
{
|
||||
public PersonalInfo6ORAS[] Table { get; }
|
||||
private const int SIZE = PersonalInfo6ORAS.SIZE;
|
||||
public PersonalInfo6AO[] Table { get; }
|
||||
private const int SIZE = PersonalInfo6AO.SIZE;
|
||||
private const int MaxSpecies = Legal.MaxSpeciesID_6;
|
||||
public int MaxSpeciesID => MaxSpecies;
|
||||
|
||||
public PersonalTable6ORAS(ReadOnlySpan<byte> data)
|
||||
public PersonalTable6AO(ReadOnlySpan<byte> data)
|
||||
{
|
||||
Table = new PersonalInfo6ORAS[data.Length / SIZE];
|
||||
Table = new PersonalInfo6AO[data.Length / SIZE];
|
||||
var count = data.Length / SIZE;
|
||||
for (int i = 0, ofs = 0; i < count; i++, ofs += SIZE)
|
||||
{
|
||||
var slice = data.Slice(ofs, SIZE).ToArray();
|
||||
Table[i] = new PersonalInfo6ORAS(slice);
|
||||
Table[i] = new PersonalInfo6AO(slice);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ public void Save()
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public PersonalInfo6ORAS this[int index] => Table[(uint)index < Table.Length ? index : 0];
|
||||
public PersonalInfo6ORAS this[ushort species, byte form] => Table[GetFormIndex(species, form)];
|
||||
public PersonalInfo6ORAS GetFormEntry(ushort species, byte form) => Table[GetFormIndex(species, form)];
|
||||
public PersonalInfo6AO this[int index] => Table[(uint)index < Table.Length ? index : 0];
|
||||
public PersonalInfo6AO this[ushort species, byte form] => Table[GetFormIndex(species, form)];
|
||||
public PersonalInfo6AO GetFormEntry(ushort species, byte form) => Table[GetFormIndex(species, form)];
|
||||
|
||||
public int GetFormIndex(ushort species, byte form)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
namespace pkNX.Structures;
|
||||
|
||||
/// <summary>
|
||||
/// Personal Table storing <see cref="PersonalInfo7"/> used in Generation 7 games.
|
||||
/// Personal Table storing <see cref="PersonalInfo7SM"/> used in Generation 7 games.
|
||||
/// </summary>
|
||||
public sealed class PersonalTable7SM : IPersonalTable, IPersonalTable<PersonalInfo7SM>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,10 +92,11 @@ public void FixMissingData()
|
|||
if (s.FormCount == 1)
|
||||
continue;
|
||||
|
||||
var formsAt = MaxSpeciesID + 1 + sFormCount;
|
||||
if (s.FormStatsIndex != 0)
|
||||
Debug.Assert(s.FormStatsIndex == (MaxSpeciesID + 1) + sFormCount);
|
||||
Debug.Assert(s.FormStatsIndex == formsAt);
|
||||
|
||||
s.FormStatsIndex = (MaxSpeciesID + 1) + sFormCount;
|
||||
s.FormStatsIndex = formsAt;
|
||||
sFormCount += s.FormCount - 1;
|
||||
|
||||
for (byte f = 1; f < s.FormCount; f++)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public enum AmxFlags : ushort
|
|||
VERIFY = 0x4000,
|
||||
|
||||
/// <summary> AMX has been initialized </summary>
|
||||
INIT = 0x8000
|
||||
INIT = 0x8000,
|
||||
}
|
||||
|
||||
public static class AmxFlagsExtensions
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public int CellSize
|
|||
MAGIC_16 => 16,
|
||||
MAGIC_32 => 32,
|
||||
MAGIC_64 => 64,
|
||||
_ => throw new ArgumentException("Invalid Magic identifier.")
|
||||
_ => throw new ArgumentException("Invalid Magic identifier."),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -178,14 +178,14 @@ public Argument(VariableType type, string name, int tagID, Tag tag, Dimension[]
|
|||
public enum Register : uint
|
||||
{
|
||||
Pri,
|
||||
Alt
|
||||
Alt,
|
||||
}
|
||||
|
||||
public enum Scope : uint
|
||||
{
|
||||
Global,
|
||||
Local,
|
||||
Static
|
||||
Static,
|
||||
}
|
||||
|
||||
public class Variable
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ public static AmxOpCode Invert(this AmxOpCode spop)
|
|||
AmxOpCode.SGEQ => AmxOpCode.SLESS,
|
||||
AmxOpCode.EQ => AmxOpCode.NEQ,
|
||||
AmxOpCode.NEQ => AmxOpCode.EQ,
|
||||
_ => throw new ArgumentException(nameof(spop))
|
||||
_ => throw new ArgumentException(nameof(spop)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ public enum VariableType : uint
|
|||
Reference,
|
||||
Array,
|
||||
ArrayReference,
|
||||
Variadic
|
||||
Variadic,
|
||||
}
|
||||
|
||||
public static class VariableTypeExtensions
|
||||
|
|
@ -27,7 +27,7 @@ public static VariableType FromIdent(this byte ident)
|
|||
IDENT_ARRAY => VariableType.Array,
|
||||
IDENT_REFARRAY => VariableType.ArrayReference,
|
||||
IDENT_VARARGS => VariableType.Variadic,
|
||||
_ => VariableType.Normal
|
||||
_ => VariableType.Normal,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ internal static class StructConverter
|
|||
public static T ToStructure<T>(this byte[] bytes) where T : struct
|
||||
{
|
||||
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); }
|
||||
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T))!; }
|
||||
finally { handle.Free(); }
|
||||
}
|
||||
|
||||
public static T ToClass<T>(this byte[] bytes) where T : class
|
||||
{
|
||||
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); }
|
||||
try { return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T))!; }
|
||||
finally { handle.Free(); }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ public static string GetNamedTypeTable<T>(IList<T> arr, IList<string> names, str
|
|||
var t = arr[0].GetType();
|
||||
if (t.Name.StartsWith("tableReader_")) // flatbuffer generated wrapper
|
||||
t = t.BaseType;
|
||||
if (t is null)
|
||||
throw new ArgumentException("Type is null");
|
||||
|
||||
var list = GetTableRaw(arr, t).ToArray();
|
||||
|
||||
// slap in name to column header
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ private TextLine[] LineOffsets
|
|||
result[i] = new TextLine
|
||||
{
|
||||
Offset = BitConverter.ToInt32(Data, (i * 8) + sdo + 4) + sdo,
|
||||
Length = BitConverter.ToInt16(Data, (i * 8) + sdo + 8)
|
||||
Length = BitConverter.ToInt16(Data, (i * 8) + sdo + 8),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ private ushort TryRemapChar(ushort val)
|
|||
,
|
||||
0x2640 => 0xE08F // ♀
|
||||
,
|
||||
_ => val
|
||||
_ => val,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ private ushort TryUnmapChar(ushort val)
|
|||
,
|
||||
0xE08F => 0x2640 // ♀
|
||||
,
|
||||
_ => val
|
||||
_ => val,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public static int GetAV(this IAwakened pk, int index)
|
|||
3 => pk.AV_SPE,
|
||||
4 => pk.AV_SPA,
|
||||
5 => pk.AV_SPD,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public int GetIV(int index)
|
|||
3 => IV_SPE,
|
||||
4 => IV_SPA,
|
||||
5 => IV_SPD,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public int GetEV(int index)
|
|||
3 => EV_SPE,
|
||||
4 => EV_SPA,
|
||||
5 => EV_SPD,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index))
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ private static int AmplifyStat(int nature, int index, int initial)
|
|||
,
|
||||
-1 => (90 * initial / 100) // 90%
|
||||
,
|
||||
_ => initial
|
||||
_ => initial,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public bool OverworldSpawn
|
|||
|
||||
public bool ShowForm
|
||||
{
|
||||
set => dgv.Columns[FormColumn].Visible = value;
|
||||
set => dgv.Columns[FormColumn]!.Visible = value;
|
||||
}
|
||||
|
||||
private const string FormColumn = nameof(FormColumn);
|
||||
|
|
@ -43,7 +43,7 @@ public void Initialize()
|
|||
DisplayIndex = 1,
|
||||
Width = 135,
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter, Padding = padding },
|
||||
FlatStyle = FlatStyle.Flat
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
};
|
||||
var dgvForm = new DataGridViewTextBoxColumn
|
||||
{
|
||||
|
|
@ -51,14 +51,14 @@ public void Initialize()
|
|||
HeaderText = "Form",
|
||||
DisplayIndex = 2,
|
||||
Width = 45,
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter }
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter },
|
||||
};
|
||||
var dgvPercent = new DataGridViewTextBoxColumn
|
||||
{
|
||||
HeaderText = "Chance",
|
||||
DisplayIndex = 3,
|
||||
Width = 52,
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter }
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter },
|
||||
};
|
||||
|
||||
dgvSpecies.Items.AddRange(SpeciesNames);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public void Initialize()
|
|||
DisplayIndex = 1,
|
||||
Width = 135,
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter, Padding = padding},
|
||||
FlatStyle = FlatStyle.Flat
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
};
|
||||
var dgvForm = new DataGridViewTextBoxColumn
|
||||
{
|
||||
|
|
@ -40,14 +40,14 @@ public void Initialize()
|
|||
HeaderText = "Form",
|
||||
DisplayIndex = 2,
|
||||
Width = 45,
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter }
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter },
|
||||
};
|
||||
var dgvPercent = new DataGridViewTextBoxColumn
|
||||
{
|
||||
HeaderText = "Chance",
|
||||
DisplayIndex = 3,
|
||||
Width = 52,
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter }
|
||||
DefaultCellStyle = { Alignment = DataGridViewContentAlignment.MiddleCenter },
|
||||
};
|
||||
|
||||
dgvSpecies.Items.AddRange(SpeciesNames);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ private static string[] GetArgs(EvolutionTypeArgumentType type)
|
|||
EvolutionTypeArgumentType.Stat => Stats,
|
||||
EvolutionTypeArgumentType.Type => types,
|
||||
EvolutionTypeArgumentType.Version => Stats,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ private static string[] GetArgs(EvolutionTypeArgumentType type)
|
|||
EvolutionTypeArgumentType.Stat => Stats,
|
||||
EvolutionTypeArgumentType.Type => types,
|
||||
EvolutionTypeArgumentType.Version => Stats,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,9 +342,8 @@ public void DumpEvolutionBinary()
|
|||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = Array.Empty<byte>();
|
||||
|
||||
for (var i = 0; i < obj.Table.Length; i++)
|
||||
foreach (var e in obj.Table)
|
||||
{
|
||||
var e = obj.Table[i];
|
||||
if (e.Table?.Length is not > 0)
|
||||
continue;
|
||||
var index = pt.GetFormIndex(e.Species, (byte)e.Form);
|
||||
|
|
@ -534,8 +533,9 @@ public void DumpResident()
|
|||
Directory.CreateDirectory(folder);
|
||||
File.WriteAllBytes(dest, data);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"Unable to extract {s}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ private void AddLearnsetsLegacy(List<string> lines, string specCode, int species
|
|||
if (learn is null)
|
||||
return;
|
||||
|
||||
|
||||
lines.Add("Legacy Level Up Moves:");
|
||||
foreach (var x in learn.Mainline)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -98,9 +98,7 @@ private void Menu_SetRNGSeed_Click(object sender, EventArgs e)
|
|||
if (DialogResult.Yes != result)
|
||||
return;
|
||||
|
||||
string val = string.Empty;
|
||||
try { val = Clipboard.GetText(); }
|
||||
catch { }
|
||||
string val = GetClipboardTextString();
|
||||
if (int.TryParse(val, out int seed))
|
||||
{
|
||||
Util.Rand = new Random(seed);
|
||||
|
|
@ -110,6 +108,19 @@ private void Menu_SetRNGSeed_Click(object sender, EventArgs e)
|
|||
WinFormsUtil.Alert("Unable to set seed.");
|
||||
}
|
||||
|
||||
private static string GetClipboardTextString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Clipboard.GetText();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Unable to read clipboard text: {ex.Message}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenPath(string path, GameVersion gameOverride = GameVersion.Any)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ public void EditTypeChart()
|
|||
{
|
||||
0x4E, 0x32, 0x6E, 0x6E, 0x33, 0x70, 0x69, 0x61, 0x39, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x70, 0x6F, 0x72,
|
||||
0x74, 0x31, 0x38, 0x55, 0x6E, 0x72, 0x65, 0x6C, 0x69, 0x61, 0x62, 0x6C, 0x65, 0x50, 0x72, 0x6F, 0x74,
|
||||
0x6F, 0x63, 0x6F, 0x6C, 0x45, 0x00
|
||||
0x6F, 0x63, 0x6F, 0x6C, 0x45, 0x00,
|
||||
};
|
||||
int ofs = CodePattern.IndexOfBytes(nso.DecompressedRO, pattern);
|
||||
if (ofs < 0)
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public void EditTrainers()
|
|||
Create = FlatBufferConverter.DeserializeFrom<TrData8a>,
|
||||
Write = FlatBufferConverter.SerializeFrom,
|
||||
};
|
||||
var names = folder.GetPaths().Select(s => Path.GetFileNameWithoutExtension(s)!).ToArray();
|
||||
var names = folder.GetPaths().Select(Path.GetFileNameWithoutExtension).OfType<string>().ToArray();
|
||||
using var form = new GenericEditor<TrData8a>(cache, names, "Trainers", Randomize, canSave: true);
|
||||
form.ShowDialog();
|
||||
|
||||
|
|
@ -386,7 +386,7 @@ public void EditPokemon()
|
|||
Learn = Data.LevelUpData,
|
||||
FieldDropTables = Data.FieldDrops,
|
||||
BattleDropTabels = Data.BattleDrops,
|
||||
DexResearch = Data.DexResearch
|
||||
DexResearch = Data.DexResearch,
|
||||
};
|
||||
using var form = new PokeDataUI8a(editor, ROM, Data);
|
||||
form.ShowDialog();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user