Fix Scarlet & Violet PKM Cards reading

This commit is contained in:
Manu 2022-11-19 01:37:26 +01:00
parent da7f3d7935
commit 97b5b34dde
8 changed files with 3465 additions and 18 deletions

View File

@ -1,5 +1,8 @@
using System.Buffers.Binary;
using System.Diagnostics.Metrics;
using System.Globalization;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using Enums;
namespace SwitchGiftDataManager.Core
@ -274,11 +277,15 @@ namespace SwitchGiftDataManager.Core
var type = wc.Type!.ToString()!;
var content = type.Equals("Pokemon") ? $"{((PokemonGift)wc.Content!).GetSpeciesName()}" : type;
var str = $"{wc.WCID:0000}_{content}";
System.Text.StringBuilder sb = new();
var sb = new System.Text.StringBuilder();
foreach (char c in str)
if (c != '\\' && c != '/' && c != ':' && c != '*' && c != '?' && c != '"' && c != '<' && c != '>' && c != '|')
sb.Append(c);
return sb.ToString().ToLower();
var _sb = new System.Text.StringBuilder();
foreach (char c in sb.ToString().Normalize(NormalizationForm.FormD))
if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
_sb.Append(c);
return _sb.ToString().ToLower();
}
public ReadOnlySpan<byte> ForgeMetaInfo(object? data = null)

View File

@ -89,8 +89,12 @@ namespace SwitchGiftDataManager.Core
str = Properties.Resources.Items.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id];
else if ((GiftType9)type is GiftType9.Clothing)
{
var category = (ClothingType8A)id;
var description = ""; //TODO
var category = (ClothingType9)id;
var description = category switch
{
ClothingType9.Bags => Properties.Resources.SCVIClothingBags.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt],
_ => "",
};
if (string.IsNullOrWhiteSpace(description))
description = $"{opt:X4}";
str = $"[{category}] {description}";

View File

@ -37,17 +37,20 @@ namespace SwitchGiftDataManager.Core
var test = (ShinyType9)Data![ShinyTypeOffset];
var pidtype = (ShinyType9)Data![ShinyTypeOffset] switch
{
ShinyType9.ShinyLocked => PIDType.RandomPID,
ShinyType9.ShinyRandom => PIDType.RandomPID,
ShinyType9.ShinyStar => PIDType.FixedPID,
ShinyType9.ShinySquare => PIDType.FixedPID,
ShinyType9.Fixed => PIDType.FixedPID,
_ => PIDType.RandomPID,
_ => throw new ArgumentOutOfRangeException(),
};
var shinytype = (ShinyType9)Data![ShinyTypeOffset] switch
{
ShinyType9.ShinyLocked => ShinyType.ShinyLocked,
ShinyType9.ShinyRandom => ShinyType.ShinyPossible,
ShinyType9.ShinyStar or ShinyType9.ShinySquare => ShinyType.ShinyForced,
ShinyType9.Fixed => PokemonGift.IsShiny(pid, tid, sid) ? ShinyType.ShinyForced :
PokemonGift.IsTIDAbusePossible(tid, sid, pidtype) ? ShinyType.ShinyTIDAbuse : ShinyType.ShinyLocked,
ShinyType9.ShinyLocked => ShinyType.ShinyLocked,
ShinyType9.Shiny => ShinyType.ShinyForced,
ShinyType9.ShinyRandom => ShinyType.ShinyPossible,
ShinyType9.ShinyHighOdds => ShinyType.ShinyHighOdds,
_ => throw new ArgumentOutOfRangeException(),
};

View File

@ -6,7 +6,7 @@ namespace SwitchGiftDataManager.Core
internal abstract class Wondercard
{
public static int GenOffset = 0x0F;
protected const int MaxItemCount = 7;
protected const int MaxItemCount = 6;
public Games Game { get; }
public ushort WCID { get; protected set; }

View File

@ -104,11 +104,11 @@
internal enum ShinyType9 : byte
{
Fixed = 0,
ShinyLocked = 1,
Shiny = 2,
ShinyRandom = 3,
ShinyHighOdds = 4,
ShinyLocked = 0,
ShinyRandom = 1,
ShinyStar = 2,
ShinySquare = 3,
Fixed = 4,
}
internal enum ClothingType8: byte
@ -136,4 +136,17 @@
Eyes = 0x08,
None = 0xFF,
}
internal enum ClothingType9 : byte
{
Heads = 0x00,
Tops = 0x01,
Bottoms = 0x02,
Outfit = 0x03,
Bags = 0x04,
Shoes = 0x5,
Glasses = 0x06,
Eyes = 0x08,
None = 0xFF,
}
}

View File

@ -218,6 +218,7 @@ namespace SwitchGiftDataManager.Core.Properties {
///
///
///
///
///Fancy Bottoms (Oshawott)
///Fancy Bottoms (Cyndaquil)
///Fancy Bottoms (Rowlet)
@ -230,7 +231,7 @@ namespace SwitchGiftDataManager.Core.Properties {
///Fancy Bottoms (Mountainscape)
///Fancy Bottoms (Townscape)
///Fancy Bottoms (Spiritomb)
///Fancy Bottoms (Honchkrow) /// [rest of string was truncated]&quot;;.
///Fancy Bottoms (Honchkrow [rest of string was truncated]&quot;;.
/// </summary>
internal static string PLAClothingBottoms {
get {
@ -389,8 +390,84 @@ namespace SwitchGiftDataManager.Core.Properties {
///
///
///
///
///Baneful Fox Mask (White lily)
///Baneful Fox Mask (Shiny).
///Baneful Fox Mask (Shiny)
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
/// /// [rest of string was truncated]&quot;;.
/// </summary>
internal static string PLAClothingHeads {
get {
@ -480,6 +557,7 @@ namespace SwitchGiftDataManager.Core.Properties {
///
///
///
///
///Fancy Kimono (Oshawott)
///Fancy Kimono (Cyndaquil)
///Fancy Kimono (Rowlet)
@ -493,7 +571,7 @@ namespace SwitchGiftDataManager.Core.Properties {
///Fancy Kimono (Townscape)
///Fancy Kimono (Spiritomb)
///Fancy Kimono (Honchkrow)
///Fancy Kimono [rest of string was truncated]&quot;;.
///Fancy Kimo [rest of string was truncated]&quot;;.
/// </summary>
internal static string PLAClothingTops {
get {
@ -501,6 +579,269 @@ namespace SwitchGiftDataManager.Core.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to None
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string SCVIClothingBags {
get {
return ResourceManager.GetString("SCVIClothingBags", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to None,
///Bulbasaur,

View File

@ -133,6 +133,9 @@
<data name="PLAClothingTops" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PLAClothingTops.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="SCVIClothingBags" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SCVIClothingBags.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="Species" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Species.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>

File diff suppressed because it is too large Load Diff