2022-06-18 18:04:24 +00:00
|
|
|
using System;
|
2019-11-19 01:37:38 +00:00
|
|
|
using static PKHeX.Core.RibbonIndex;
|
2022-01-03 05:35:59 +00:00
|
|
|
using static System.Buffers.Binary.BinaryPrimitives;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Generation 8 Mystery Gift Template File
|
|
|
|
/// </summary>
|
2023-12-04 04:13:20 +00:00
|
|
|
public sealed class WC8(byte[] Data) : DataMysteryGift(Data), ILangNick, INature, IGigantamax, IDynamaxLevel, IRibbonIndex, IMemoryOT, ILangNicknamedTemplate, IEncounterServerDate, IRestrictVersion,
|
2022-06-18 18:04:24 +00:00
|
|
|
IRibbonSetEvent3, IRibbonSetEvent4, IRibbonSetCommon3, IRibbonSetCommon4, IRibbonSetCommon6, IRibbonSetCommon7, IRibbonSetCommon8, IRibbonSetMark8
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2023-12-04 04:13:20 +00:00
|
|
|
public WC8() : this(new byte[Size]) { }
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public const int Size = 0x2D0;
|
|
|
|
public const int CardStart = 0x0;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int Generation => 8;
|
Refactoring: Move Source (Legality) (#3560)
Rewrites a good amount of legality APIs pertaining to:
* Legal moves that can be learned
* Evolution chains & cross-generation paths
* Memory validation with forgotten moves
In generation 8, there are 3 separate contexts an entity can exist in: SW/SH, BD/SP, and LA. Not every entity can cross between them, and not every entity from generation 7 can exist in generation 8 (Gogoat, etc). By creating class models representing the restrictions to cross each boundary, we are able to better track and validate data.
The old implementation of validating moves was greedy: it would iterate for all generations and evolutions, and build a full list of every move that can be learned, storing it on the heap. Now, we check one game group at a time to see if the entity can learn a move that hasn't yet been validated. End result is an algorithm that requires 0 allocation, and a smaller/quicker search space.
The old implementation of storing move parses was inefficient; for each move that was parsed, a new object is created and adjusted depending on the parse. Now, move parse results are `struct` and store the move parse contiguously in memory. End result is faster parsing and 0 memory allocation.
* `PersonalTable` objects have been improved with new API methods to check if a species+form can exist in the game.
* `IEncounterTemplate` objects have been improved to indicate the `EntityContext` they originate in (similar to `Generation`).
* Some APIs have been extended to accept `Span<T>` instead of Array/IEnumerable
2022-08-03 23:15:27 +00:00
|
|
|
public override EntityContext Context => EntityContext.Gen8;
|
2023-01-22 04:02:33 +00:00
|
|
|
public override bool FatefulEncounter => true;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public enum GiftType : byte
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Pokemon = 1,
|
|
|
|
Item = 2,
|
|
|
|
BP = 3,
|
|
|
|
Clothing = 4,
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-08-25 20:10:39 +00:00
|
|
|
public byte RestrictVersion { get => Data[0xE]; set => Data[0xE] = value; }
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-08-25 20:10:39 +00:00
|
|
|
public bool CanBeReceivedByVersion(int v) => RestrictVersion switch
|
|
|
|
{
|
|
|
|
0 when !IsEntity => true, // Whatever, essentially unrestricted for SW/SH receipt. No Entity gifts are 0.
|
|
|
|
1 => v is (int)GameVersion.SW,
|
|
|
|
2 => v is (int)GameVersion.SH,
|
|
|
|
3 => v is (int)GameVersion.SW or (int)GameVersion.SH,
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(RestrictVersion), RestrictVersion, null),
|
|
|
|
};
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// General Card Properties
|
|
|
|
public override int CardID
|
|
|
|
{
|
|
|
|
get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x8));
|
|
|
|
set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x8), (ushort)value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public byte CardFlags { get => Data[CardStart + 0x10]; set => Data[CardStart + 0x10] = value; }
|
|
|
|
public GiftType CardType { get => (GiftType)Data[CardStart + 0x11]; set => Data[CardStart + 0x11] = (byte)value; }
|
|
|
|
public bool GiftRepeatable { get => (CardFlags & 1) == 0; set => CardFlags = (byte)((CardFlags & ~1) | (value ? 0 : 1)); }
|
|
|
|
public override bool GiftUsed { get => false; set { } }
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int CardTitleIndex
|
|
|
|
{
|
|
|
|
get => Data[CardStart + 0x15];
|
|
|
|
set => Data[CardStart + 0x15] = (byte) value;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override string CardTitle
|
|
|
|
{
|
|
|
|
get => "Mystery Gift"; // TODO: Use text string from CardTitleIndex
|
|
|
|
set => throw new Exception();
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Item Properties
|
|
|
|
public override bool IsItem { get => CardType == GiftType.Item; set { if (value) CardType = GiftType.Item; } }
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int ItemID
|
|
|
|
{
|
|
|
|
get => GetItem(0);
|
|
|
|
set => SetItem(0, (ushort)value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int Quantity
|
|
|
|
{
|
|
|
|
get => GetQuantity(0);
|
|
|
|
set => SetQuantity(0, (ushort)value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int GetItem(int index) => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x20 + (0x4 * index)));
|
|
|
|
public void SetItem(int index, ushort item) => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x20 + (4 * index)), item);
|
|
|
|
public int GetQuantity(int index) => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x22 + (0x4 * index)));
|
|
|
|
public void SetQuantity(int index, ushort quantity) => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x22 + (4 * index)), quantity);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Pokémon Properties
|
|
|
|
public override bool IsEntity { get => CardType == GiftType.Pokemon; set { if (value) CardType = GiftType.Pokemon; } }
|
2020-07-18 01:40:11 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override bool IsShiny => Shiny.IsShiny();
|
2022-01-06 00:46:23 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override Shiny Shiny => PIDType switch
|
|
|
|
{
|
2023-05-10 15:32:09 +00:00
|
|
|
ShinyType8.FixedValue => FixedShinyType(),
|
2022-06-18 18:04:24 +00:00
|
|
|
ShinyType8.Random => Shiny.Random,
|
|
|
|
ShinyType8.Never => Shiny.Never,
|
|
|
|
ShinyType8.AlwaysStar => Shiny.AlwaysStar,
|
|
|
|
ShinyType8.AlwaysSquare => Shiny.AlwaysSquare,
|
|
|
|
_ => throw new ArgumentOutOfRangeException(),
|
|
|
|
};
|
|
|
|
|
2023-05-10 15:32:09 +00:00
|
|
|
private Shiny FixedShinyType() => IsHOMEGift && IsHOMEShinyPossible() ? Shiny.Random : GetShinyXor() switch
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
0 => Shiny.AlwaysSquare,
|
|
|
|
<= 15 => Shiny.AlwaysStar,
|
|
|
|
_ => Shiny.Never,
|
|
|
|
};
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
private uint GetShinyXor()
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
// Player owned anti-shiny fixed PID
|
2023-01-22 04:02:33 +00:00
|
|
|
if (ID32 == 0)
|
|
|
|
return uint.MaxValue;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
var xor = PID ^ ID32;
|
|
|
|
return (xor >> 16) ^ (xor & 0xFFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override uint ID32
|
|
|
|
{
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(CardStart + 0x20));
|
|
|
|
set => WriteUInt32LittleEndian(Data.AsSpan(CardStart + 0x20), value);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2022-06-05 18:09:49 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public override ushort TID16
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x20));
|
2023-01-22 04:02:33 +00:00
|
|
|
set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x20), value);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2022-01-06 00:46:23 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public override ushort SID16
|
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x22));
|
2023-01-22 04:02:33 +00:00
|
|
|
set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x22), value);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int OriginGame
|
|
|
|
{
|
|
|
|
get => ReadInt32LittleEndian(Data.AsSpan(CardStart + 0x24));
|
|
|
|
set => WriteInt32LittleEndian(Data.AsSpan(CardStart + 0x24), value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public uint EncryptionConstant
|
|
|
|
{
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(CardStart + 0x28));
|
|
|
|
set => WriteUInt32LittleEndian(Data.AsSpan(CardStart + 0x28), value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public uint PID
|
|
|
|
{
|
|
|
|
get => ReadUInt32LittleEndian(Data.AsSpan(CardStart + 0x2C));
|
|
|
|
set => WriteUInt32LittleEndian(Data.AsSpan(CardStart + 0x2C), value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Nicknames, OT Names 0x30 - 0x228
|
|
|
|
public override int EggLocation { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x228)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x228), (ushort)value); }
|
|
|
|
public int MetLocation { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x22A)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x22A), (ushort)value); }
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int Ball
|
|
|
|
{
|
|
|
|
get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x22C));
|
|
|
|
set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x22C), (ushort)value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int HeldItem
|
|
|
|
{
|
|
|
|
get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x22E));
|
|
|
|
set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x22E), (ushort)value);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-08-27 06:43:36 +00:00
|
|
|
public ushort Move1 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x230)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x230), value); }
|
|
|
|
public ushort Move2 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x232)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x232), value); }
|
|
|
|
public ushort Move3 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x234)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x234), value); }
|
|
|
|
public ushort Move4 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x236)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x236), value); }
|
|
|
|
public ushort RelearnMove1 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x238)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x238), value); }
|
|
|
|
public ushort RelearnMove2 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x23A)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x23A), value); }
|
|
|
|
public ushort RelearnMove3 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x23C)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x23C), value); }
|
|
|
|
public ushort RelearnMove4 { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x23E)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x23E), value); }
|
|
|
|
|
|
|
|
public override ushort Species { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x240)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x240), value); }
|
|
|
|
public override byte Form { get => Data[CardStart + 0x242]; set => Data[CardStart + 0x242] = value; }
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int Gender { get => Data[CardStart + 0x243]; set => Data[CardStart + 0x243] = (byte)value; }
|
|
|
|
public override byte Level { get => Data[CardStart + 0x244]; set => Data[CardStart + 0x244] = value; }
|
|
|
|
public override bool IsEgg { get => Data[CardStart + 0x245] == 1; set => Data[CardStart + 0x245] = value ? (byte)1 : (byte)0; }
|
|
|
|
public int Nature { get => (sbyte)Data[CardStart + 0x246]; set => Data[CardStart + 0x246] = (byte)value; }
|
|
|
|
public override int AbilityType { get => Data[CardStart + 0x247]; set => Data[CardStart + 0x247] = (byte)value; }
|
|
|
|
|
|
|
|
public ShinyType8 PIDType { get => (ShinyType8)Data[CardStart + 0x248]; set => Data[CardStart + 0x248] = (byte)value; }
|
|
|
|
|
|
|
|
public int MetLevel { get => Data[CardStart + 0x249]; set => Data[CardStart + 0x249] = (byte)value; }
|
|
|
|
public byte DynamaxLevel { get => Data[CardStart + 0x24A]; set => Data[CardStart + 0x24A] = value; }
|
|
|
|
public bool CanGigantamax { get => Data[CardStart + 0x24B] != 0; set => Data[CardStart + 0x24B] = value ? (byte)1 : (byte)0; }
|
|
|
|
|
|
|
|
// Ribbons 0x24C-0x26C
|
|
|
|
private const int RibbonBytesOffset = 0x24C;
|
|
|
|
private const int RibbonBytesCount = 0x20;
|
|
|
|
private const int RibbonByteNone = 0xFF; // signed -1
|
|
|
|
|
2023-12-18 00:41:15 +00:00
|
|
|
private ReadOnlySpan<byte> RibbonSpan => Data.AsSpan(RibbonBytesOffset, RibbonBytesCount);
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public bool HasMarkEncounter8
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2023-01-22 04:02:33 +00:00
|
|
|
get
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2023-12-18 00:41:15 +00:00
|
|
|
foreach (var value in RibbonSpan)
|
2023-01-22 04:02:33 +00:00
|
|
|
{
|
|
|
|
if (value == RibbonByteNone)
|
2023-12-18 00:41:15 +00:00
|
|
|
return false; // end
|
|
|
|
if (((RibbonIndex)value).IsEncounterMark8())
|
2023-01-22 04:02:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public byte GetRibbonAtIndex(int byteIndex)
|
|
|
|
{
|
2023-12-09 23:21:10 +00:00
|
|
|
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)byteIndex, RibbonBytesCount);
|
2022-06-18 18:04:24 +00:00
|
|
|
return Data[RibbonBytesOffset + byteIndex];
|
|
|
|
}
|
2021-01-23 04:28:54 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void SetRibbonAtIndex(int byteIndex, byte ribbonIndex)
|
|
|
|
{
|
2023-12-09 23:21:10 +00:00
|
|
|
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)byteIndex, RibbonBytesCount);
|
2022-06-18 18:04:24 +00:00
|
|
|
Data[RibbonBytesOffset + byteIndex] = ribbonIndex;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int IV_HP { get => Data[CardStart + 0x26C]; set => Data[CardStart + 0x26C] = (byte)value; }
|
|
|
|
public int IV_ATK { get => Data[CardStart + 0x26D]; set => Data[CardStart + 0x26D] = (byte)value; }
|
|
|
|
public int IV_DEF { get => Data[CardStart + 0x26E]; set => Data[CardStart + 0x26E] = (byte)value; }
|
|
|
|
public int IV_SPE { get => Data[CardStart + 0x26F]; set => Data[CardStart + 0x26F] = (byte)value; }
|
|
|
|
public int IV_SPA { get => Data[CardStart + 0x270]; set => Data[CardStart + 0x270] = (byte)value; }
|
|
|
|
public int IV_SPD { get => Data[CardStart + 0x271]; set => Data[CardStart + 0x271] = (byte)value; }
|
|
|
|
|
|
|
|
public int OTGender { get => Data[CardStart + 0x272]; set => Data[CardStart + 0x272] = (byte)value; }
|
|
|
|
|
|
|
|
public int EV_HP { get => Data[CardStart + 0x273]; set => Data[CardStart + 0x273] = (byte)value; }
|
|
|
|
public int EV_ATK { get => Data[CardStart + 0x274]; set => Data[CardStart + 0x274] = (byte)value; }
|
|
|
|
public int EV_DEF { get => Data[CardStart + 0x275]; set => Data[CardStart + 0x275] = (byte)value; }
|
|
|
|
public int EV_SPE { get => Data[CardStart + 0x276]; set => Data[CardStart + 0x276] = (byte)value; }
|
|
|
|
public int EV_SPA { get => Data[CardStart + 0x277]; set => Data[CardStart + 0x277] = (byte)value; }
|
|
|
|
public int EV_SPD { get => Data[CardStart + 0x278]; set => Data[CardStart + 0x278] = (byte)value; }
|
|
|
|
|
|
|
|
public byte OT_Intensity { get => Data[CardStart + 0x279]; set => Data[CardStart + 0x279] = value; }
|
|
|
|
public byte OT_Memory { get => Data[CardStart + 0x27A]; set => Data[CardStart + 0x27A] = value; }
|
|
|
|
public byte OT_Feeling { get => Data[CardStart + 0x27B]; set => Data[CardStart + 0x27B] = value; }
|
|
|
|
public ushort OT_TextVar { get => ReadUInt16LittleEndian(Data.AsSpan(CardStart + 0x27C)); set => WriteUInt16LittleEndian(Data.AsSpan(CardStart + 0x27C), value); }
|
|
|
|
|
2023-06-11 16:03:39 +00:00
|
|
|
public ushort Checksum => ReadUInt16LittleEndian(Data.AsSpan(0x2CC));
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Meta Accessible Properties
|
|
|
|
public override int[] IVs
|
|
|
|
{
|
2023-12-04 04:13:20 +00:00
|
|
|
get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD];
|
2022-06-18 18:04:24 +00:00
|
|
|
set
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2023-12-04 04:13:20 +00:00
|
|
|
if (value.Length != 6)
|
|
|
|
return;
|
2022-06-18 18:04:24 +00:00
|
|
|
IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2];
|
|
|
|
IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5];
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override void GetIVs(Span<int> value)
|
|
|
|
{
|
|
|
|
if (value.Length != 6)
|
|
|
|
return;
|
|
|
|
value[0] = IV_HP;
|
|
|
|
value[1] = IV_ATK;
|
|
|
|
value[2] = IV_DEF;
|
|
|
|
value[3] = IV_SPE;
|
|
|
|
value[4] = IV_SPA;
|
|
|
|
value[5] = IV_SPD;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int[] EVs
|
|
|
|
{
|
2023-12-04 04:13:20 +00:00
|
|
|
get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD];
|
2022-06-18 18:04:24 +00:00
|
|
|
set
|
2022-03-14 02:24:08 +00:00
|
|
|
{
|
2023-12-04 04:13:20 +00:00
|
|
|
if (value.Length != 6)
|
|
|
|
return;
|
2022-06-18 18:04:24 +00:00
|
|
|
EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2];
|
|
|
|
EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5];
|
2022-03-14 02:24:08 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2022-03-14 02:24:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool GetIsNicknamed(int language) => ReadUInt16LittleEndian(Data.AsSpan(GetNicknameOffset(language))) != 0;
|
|
|
|
|
|
|
|
public bool CanBeAnyLanguage()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 9; i++)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
var ofs = GetLanguageOffset(i);
|
|
|
|
var lang = ReadInt16LittleEndian(Data.AsSpan(ofs));
|
|
|
|
if (lang != 0)
|
|
|
|
return false;
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool CanHaveLanguage(int language)
|
|
|
|
{
|
|
|
|
if (language is < (int)LanguageID.Japanese or > (int)LanguageID.ChineseT)
|
|
|
|
return false;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (CanBeAnyLanguage())
|
2021-02-02 02:35:37 +00:00
|
|
|
return true;
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
for (int i = 0; i < 9; i++)
|
2021-02-02 02:35:37 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
var ofs = GetLanguageOffset(i);
|
|
|
|
var lang = ReadInt16LittleEndian(Data.AsSpan(ofs));
|
|
|
|
if (lang == language)
|
2021-02-02 02:35:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
return GetLanguage(language) == 0;
|
|
|
|
}
|
2021-02-02 02:35:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public int GetLanguage(int redeemLanguage) => Data[GetLanguageOffset(GetLanguageIndex(redeemLanguage))];
|
|
|
|
private static int GetLanguageOffset(int index) => 0x30 + (index * 0x1C) + 0x1A;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool GetHasOT(int language) => ReadUInt16LittleEndian(Data.AsSpan(GetOTOffset(language))) != 0;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private static int GetLanguageIndex(int language)
|
|
|
|
{
|
|
|
|
var lang = (LanguageID) language;
|
|
|
|
if (lang is < LanguageID.Japanese or LanguageID.UNUSED_6 or > LanguageID.ChineseT)
|
|
|
|
return (int) LanguageID.English; // fallback
|
|
|
|
return lang < LanguageID.UNUSED_6 ? language - 1 : language - 2;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override int Location { get => MetLocation; set => MetLocation = (ushort)value; }
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-08-22 00:34:32 +00:00
|
|
|
public override Moveset Moves
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2022-08-27 06:43:36 +00:00
|
|
|
get => new(Move1, Move2, Move3, Move4);
|
2022-06-18 18:04:24 +00:00
|
|
|
set
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-08-22 00:34:32 +00:00
|
|
|
Move1 = value.Move1;
|
|
|
|
Move2 = value.Move2;
|
|
|
|
Move3 = value.Move3;
|
|
|
|
Move4 = value.Move4;
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-08-22 00:34:32 +00:00
|
|
|
public override Moveset Relearn
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2022-08-27 06:43:36 +00:00
|
|
|
get => new(RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4);
|
2022-06-18 18:04:24 +00:00
|
|
|
set
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-08-22 00:34:32 +00:00
|
|
|
RelearnMove1 = value.Move1;
|
|
|
|
RelearnMove2 = value.Move2;
|
|
|
|
RelearnMove3 = value.Move3;
|
|
|
|
RelearnMove4 = value.Move4;
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-09-17 09:00:26 +00:00
|
|
|
public override string OT_Name
|
|
|
|
{
|
|
|
|
get => GetOT(Language);
|
|
|
|
set
|
|
|
|
{
|
|
|
|
for (int i = 1; i < (int)LanguageID.ChineseT; i++)
|
|
|
|
SetOT(i, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Nickname => GetIsNicknamed(Language) ? GetNickname(Language) : string.Empty;
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool IsNicknamed => false;
|
|
|
|
public int Language => 2;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
private Span<byte> GetNicknameSpan(int language) => Data.AsSpan(GetNicknameOffset(language), 0x1A);
|
|
|
|
public string GetNickname(int language) => StringConverter8.GetString(GetNicknameSpan(language));
|
|
|
|
public void SetNickname(int language, ReadOnlySpan<char> value) => StringConverter8.SetString(GetNicknameSpan(language), value, 12, StringConverterOption.ClearZero);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
private Span<byte> GetOTSpan(int language) => Data.AsSpan(GetOTOffset(language), 0x1A);
|
|
|
|
public string GetOT(int language) => StringConverter8.GetString(GetOTSpan(language));
|
|
|
|
public void SetOT(int language, ReadOnlySpan<char> value) => StringConverter8.SetString(GetOTSpan(language), value, 12, StringConverterOption.ClearZero);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private static int GetNicknameOffset(int language)
|
|
|
|
{
|
|
|
|
int index = GetLanguageIndex(language);
|
|
|
|
return 0x30 + (index * 0x1C);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private static int GetOTOffset(int language)
|
|
|
|
{
|
|
|
|
int index = GetLanguageIndex(language);
|
|
|
|
return 0x12C + (index * 0x1C);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool IsHOMEGift => CardID >= 9000;
|
2020-03-14 21:22:45 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool CanHandleOT(int language) => !GetHasOT(language);
|
2021-02-03 06:12:36 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override GameVersion Version
|
|
|
|
{
|
|
|
|
get => OriginGame != 0 ? (GameVersion)OriginGame : GameVersion.SWSH;
|
|
|
|
set { }
|
|
|
|
}
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public override PK8 ConvertToPKM(ITrainerInfo tr, EncounterCriteria criteria)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
if (!IsEntity)
|
|
|
|
throw new ArgumentException(nameof(IsEntity));
|
|
|
|
|
|
|
|
int currentLevel = Level > 0 ? Level : 1 + Util.Rand.Next(100);
|
|
|
|
int metLevel = MetLevel > 0 ? MetLevel : currentLevel;
|
|
|
|
var pi = PersonalTable.SWSH.GetFormEntry(Species, Form);
|
|
|
|
var language = tr.Language;
|
|
|
|
bool hasOT = GetHasOT(language);
|
2022-08-25 20:10:39 +00:00
|
|
|
var version = OriginGame != 0 ? OriginGame : (int)this.GetCompatibleVersion((GameVersion)tr.Game);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
var pk = new PK8
|
|
|
|
{
|
2023-06-09 08:59:04 +00:00
|
|
|
EncryptionConstant = EncryptionConstant != 0 ? EncryptionConstant : Util.Rand32(),
|
2023-01-22 04:02:33 +00:00
|
|
|
TID16 = TID16,
|
|
|
|
SID16 = SID16,
|
2022-06-18 18:04:24 +00:00
|
|
|
Species = Species,
|
|
|
|
Form = Form,
|
|
|
|
CurrentLevel = currentLevel,
|
|
|
|
Ball = Ball != 0 ? Ball : 4, // Default is Pokeball
|
|
|
|
Met_Level = metLevel,
|
|
|
|
HeldItem = HeldItem,
|
|
|
|
|
|
|
|
EXP = Experience.GetEXP(currentLevel, pi.EXPGrowth),
|
|
|
|
|
|
|
|
Move1 = Move1,
|
|
|
|
Move2 = Move2,
|
|
|
|
Move3 = Move3,
|
|
|
|
Move4 = Move4,
|
|
|
|
RelearnMove1 = RelearnMove1,
|
|
|
|
RelearnMove2 = RelearnMove2,
|
|
|
|
RelearnMove3 = RelearnMove3,
|
|
|
|
RelearnMove4 = RelearnMove4,
|
|
|
|
|
2022-08-25 20:10:39 +00:00
|
|
|
Version = version,
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2022-09-17 09:00:26 +00:00
|
|
|
OT_Name = hasOT ? GetOT(language) : tr.OT,
|
2022-06-18 18:04:24 +00:00
|
|
|
OT_Gender = OTGender < 2 ? OTGender : tr.Gender,
|
|
|
|
HT_Name = hasOT ? tr.OT : string.Empty,
|
|
|
|
HT_Gender = hasOT ? tr.Gender : 0,
|
|
|
|
HT_Language = (byte)(hasOT ? language : 0),
|
|
|
|
CurrentHandler = hasOT ? 1 : 0,
|
|
|
|
OT_Friendship = pi.BaseFriendship,
|
|
|
|
|
|
|
|
OT_Intensity = OT_Intensity,
|
|
|
|
OT_Memory = OT_Memory,
|
|
|
|
OT_TextVar = OT_TextVar,
|
|
|
|
OT_Feeling = OT_Feeling,
|
|
|
|
FatefulEncounter = true,
|
|
|
|
|
|
|
|
EV_HP = EV_HP,
|
|
|
|
EV_ATK = EV_ATK,
|
|
|
|
EV_DEF = EV_DEF,
|
|
|
|
EV_SPE = EV_SPE,
|
|
|
|
EV_SPA = EV_SPA,
|
|
|
|
EV_SPD = EV_SPD,
|
|
|
|
|
|
|
|
CanGigantamax = CanGigantamax,
|
|
|
|
DynamaxLevel = DynamaxLevel,
|
|
|
|
|
|
|
|
Met_Location = MetLocation,
|
|
|
|
Egg_Location = EggLocation,
|
|
|
|
};
|
|
|
|
pk.SetMaximumPPCurrent();
|
|
|
|
|
|
|
|
if ((tr.Generation > Generation && OriginGame == 0) || !CanBeReceivedByVersion(pk.Version))
|
2021-06-24 07:36:04 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
// give random valid game
|
|
|
|
var rnd = Util.Rand;
|
|
|
|
do { pk.Version = (int)GameVersion.SW + rnd.Next(2); }
|
|
|
|
while (!CanBeReceivedByVersion(pk.Version));
|
2021-06-24 07:36:04 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (OTGender >= 2)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.TID16 = tr.TID16;
|
|
|
|
pk.SID16 = tr.SID16;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-05-08 07:03:45 +00:00
|
|
|
// Initial updates of HOME did not assign a TSV of 0.
|
|
|
|
// After enough server updates, HOME can now assign a TSV of 0.
|
|
|
|
// They will XOR the PID to ensure the shiny state of gifts is matched.
|
|
|
|
// Don't set a Secret ID.
|
2022-06-18 18:04:24 +00:00
|
|
|
if (IsHOMEGift)
|
2023-01-22 04:02:33 +00:00
|
|
|
pk.ID32 %= 1_000_000;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Official code explicitly corrects for Meowstic
|
|
|
|
if (pk.Species == (int)Core.Species.Meowstic)
|
2022-08-27 06:43:36 +00:00
|
|
|
pk.Form = (byte)(pk.Gender & 1);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-06-11 16:03:39 +00:00
|
|
|
var date = GetSuggestedDate();
|
2023-06-11 03:18:34 +00:00
|
|
|
pk.MetDate = date;
|
|
|
|
|
|
|
|
// Prior to 3.0.0, HOME would set the Encryption Constant exactly and not give a random value if it was 0.
|
|
|
|
if (IsHOMEGiftOld(date))
|
|
|
|
pk.EncryptionConstant = EncryptionConstant;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var nickname_language = GetLanguage(language);
|
|
|
|
pk.Language = nickname_language != 0 ? nickname_language : tr.Language;
|
|
|
|
pk.IsNicknamed = GetIsNicknamed(language);
|
|
|
|
pk.Nickname = pk.IsNicknamed ? GetNickname(language) : SpeciesName.GetSpeciesNameGeneration(Species, pk.Language, Generation);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
for (var i = 0; i < RibbonBytesCount; i++)
|
|
|
|
{
|
|
|
|
var ribbon = GetRibbonAtIndex(i);
|
|
|
|
if (ribbon != RibbonByteNone)
|
|
|
|
pk.SetRibbon(ribbon);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
SetPINGA(pk, criteria);
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (IsEgg)
|
|
|
|
SetEggMetData(pk);
|
|
|
|
pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-06-11 16:03:39 +00:00
|
|
|
if (!IsHOMEGiftOld(date))
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.HeightScalar = PokeSizeUtil.GetRandomScalar();
|
|
|
|
pk.WeightScalar = PokeSizeUtil.GetRandomScalar();
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.ResetPartyStats();
|
|
|
|
pk.RefreshChecksum();
|
|
|
|
return pk;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-06-11 03:18:34 +00:00
|
|
|
private bool IsHOMEGiftOld(DateOnly date)
|
|
|
|
{
|
|
|
|
// 2023/05/30 -- every date prior [*,29th] is an old gift.
|
|
|
|
const int DayNumberHOME300 = 738669;
|
|
|
|
return IsHOMEGift && date.DayNumber < DayNumberHOME300;
|
|
|
|
}
|
|
|
|
|
2023-06-11 16:03:39 +00:00
|
|
|
private DateOnly GetSuggestedDate()
|
|
|
|
{
|
|
|
|
if (!IsDateRestricted)
|
2023-08-12 23:01:16 +00:00
|
|
|
return EncounterDate.GetDateSwitch();
|
2023-06-11 16:03:39 +00:00
|
|
|
if (EncounterServerDate.WC8GiftsChk.TryGetValue(Checksum, out var range))
|
|
|
|
return range.Start;
|
|
|
|
if (EncounterServerDate.WC8Gifts.TryGetValue(CardID, out range))
|
|
|
|
return range.Start;
|
2023-08-12 23:01:16 +00:00
|
|
|
return EncounterDate.GetDateSwitch();
|
2023-06-11 16:03:39 +00:00
|
|
|
}
|
|
|
|
|
2023-08-17 07:07:54 +00:00
|
|
|
private void SetEggMetData(PK8 pk)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
pk.IsEgg = true;
|
2023-08-12 23:01:16 +00:00
|
|
|
pk.EggMetDate = EncounterDate.GetDateSwitch();
|
Refactoring: Move Source (Legality) (#3560)
Rewrites a good amount of legality APIs pertaining to:
* Legal moves that can be learned
* Evolution chains & cross-generation paths
* Memory validation with forgotten moves
In generation 8, there are 3 separate contexts an entity can exist in: SW/SH, BD/SP, and LA. Not every entity can cross between them, and not every entity from generation 7 can exist in generation 8 (Gogoat, etc). By creating class models representing the restrictions to cross each boundary, we are able to better track and validate data.
The old implementation of validating moves was greedy: it would iterate for all generations and evolutions, and build a full list of every move that can be learned, storing it on the heap. Now, we check one game group at a time to see if the entity can learn a move that hasn't yet been validated. End result is an algorithm that requires 0 allocation, and a smaller/quicker search space.
The old implementation of storing move parses was inefficient; for each move that was parsed, a new object is created and adjusted depending on the parse. Now, move parse results are `struct` and store the move parse contiguously in memory. End result is faster parsing and 0 memory allocation.
* `PersonalTable` objects have been improved with new API methods to check if a species+form can exist in the game.
* `IEncounterTemplate` objects have been improved to indicate the `EntityContext` they originate in (similar to `Generation`).
* Some APIs have been extended to accept `Span<T>` instead of Array/IEnumerable
2022-08-03 23:15:27 +00:00
|
|
|
pk.Nickname = SpeciesName.GetEggName(pk.Language, Generation);
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.IsNicknamed = true;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-08-17 07:07:54 +00:00
|
|
|
private void SetPINGA(PK8 pk, EncounterCriteria criteria)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2023-08-17 07:07:54 +00:00
|
|
|
var pi = pk.PersonalInfo;
|
|
|
|
pk.Nature = pk.StatNature = (int)criteria.GetNature(Nature == -1 ? Core.Nature.Random : (Nature)Nature);
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.Gender = criteria.GetGender(Gender, pi);
|
|
|
|
var av = GetAbilityIndex(criteria);
|
|
|
|
pk.RefreshAbility(av);
|
2023-05-10 15:32:09 +00:00
|
|
|
SetPID(pk);
|
2022-06-18 18:04:24 +00:00
|
|
|
SetIVs(pk);
|
|
|
|
}
|
2021-12-09 08:46:59 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
private int GetAbilityIndex(EncounterCriteria criteria) => AbilityType switch
|
|
|
|
{
|
|
|
|
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
|
|
|
03 or 04 => criteria.GetAbilityFromNumber(Ability), // 0/1 or 0/1/H
|
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
|
|
|
|
};
|
2020-12-25 01:12:08 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override AbilityPermission Ability => AbilityType switch
|
|
|
|
{
|
|
|
|
0 => AbilityPermission.OnlyFirst,
|
|
|
|
1 => AbilityPermission.OnlySecond,
|
|
|
|
2 => AbilityPermission.OnlyHidden,
|
|
|
|
3 => AbilityPermission.Any12,
|
|
|
|
_ => AbilityPermission.Any12H,
|
|
|
|
};
|
|
|
|
|
2023-06-11 03:18:34 +00:00
|
|
|
private uint GetPID(PKM tr, ShinyType8 type) => type switch
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
ShinyType8.Never => GetAntishiny(tr), // Random, Never Shiny
|
|
|
|
ShinyType8.Random => Util.Rand32(), // Random, Any
|
2023-01-22 04:02:33 +00:00
|
|
|
ShinyType8.AlwaysStar => (1u ^ (PID & 0xFFFF) ^ tr.TID16 ^ tr.SID16) << 16 | (PID & 0xFFFF), // Fixed, Force Star
|
|
|
|
ShinyType8.AlwaysSquare => (0u ^ (PID & 0xFFFF) ^ tr.TID16 ^ tr.SID16) << 16 | (PID & 0xFFFF), // Fixed, Force Square
|
2023-05-10 15:32:09 +00:00
|
|
|
ShinyType8.FixedValue => GetFixedPID(tr),
|
2022-06-18 18:04:24 +00:00
|
|
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
|
|
|
};
|
|
|
|
|
2023-06-11 03:18:34 +00:00
|
|
|
private uint GetFixedPID(PKM tr)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
var pid = PID;
|
2023-01-22 04:02:33 +00:00
|
|
|
if (pid != 0 && ID32 != 0)
|
2022-06-02 04:27:54 +00:00
|
|
|
return pid;
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (!tr.IsShiny(pid, 8))
|
2022-05-08 04:25:26 +00:00
|
|
|
return pid;
|
2023-06-04 01:19:16 +00:00
|
|
|
if (IsHOMEGift && !IsHOMEShinyPossible())
|
2023-05-10 15:32:09 +00:00
|
|
|
return ForceAntiShiny(pid);
|
2022-06-18 18:04:24 +00:00
|
|
|
return pid;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-05-10 15:32:09 +00:00
|
|
|
private static uint ForceAntiShiny(uint pid) => pid ^ 0x1000_0000;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
private static uint GetAntishiny(ITrainerID32 tr)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
|
|
|
var pid = Util.Rand32();
|
|
|
|
if (tr.IsShiny(pid, 8))
|
2023-05-10 15:32:09 +00:00
|
|
|
return ForceAntiShiny(pid);
|
2022-06-18 18:04:24 +00:00
|
|
|
return pid;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-08-17 07:07:54 +00:00
|
|
|
private void SetPID(PK8 pk)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2023-05-10 15:32:09 +00:00
|
|
|
pk.PID = GetPID(pk, PIDType);
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void SetIVs(PKM pk)
|
|
|
|
{
|
|
|
|
Span<int> finalIVs = stackalloc int[6];
|
|
|
|
GetIVs(finalIVs);
|
2022-08-24 06:11:26 +00:00
|
|
|
var ivflag = finalIVs.Find(static iv => (byte)(iv - 0xFC) < 3);
|
2022-06-18 18:04:24 +00:00
|
|
|
var rng = Util.Rand;
|
2022-08-24 06:11:26 +00:00
|
|
|
if (ivflag == default) // Random IVs
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
for (int i = 0; i < finalIVs.Length; i++)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (finalIVs[i] > 31)
|
|
|
|
finalIVs[i] = rng.Next(32);
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
else // 1/2/3 perfect IVs
|
|
|
|
{
|
|
|
|
int IVCount = ivflag - 0xFB;
|
|
|
|
do { finalIVs[rng.Next(6)] = 31; }
|
|
|
|
while (finalIVs.Count(31) < IVCount);
|
|
|
|
for (int i = 0; i < finalIVs.Length; i++)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (finalIVs[i] != 31)
|
|
|
|
finalIVs[i] = rng.Next(32);
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
pk.SetIVs(finalIVs);
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override bool IsMatchExact(PKM pk, EvoCriteria evo)
|
|
|
|
{
|
|
|
|
if (!IsEgg)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (OTGender < 2)
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2023-01-22 04:02:33 +00:00
|
|
|
if (SID16 != pk.SID16) return false;
|
|
|
|
if (TID16 != pk.TID16) return false;
|
2022-06-18 18:04:24 +00:00
|
|
|
if (OTGender != pk.OT_Gender) return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CanBeAnyLanguage() && !CanHaveLanguage(pk.Language))
|
|
|
|
return false;
|
2021-02-02 02:35:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var OT = GetOT(pk.Language); // May not be guaranteed to work.
|
|
|
|
if (!string.IsNullOrEmpty(OT) && OT != pk.OT_Name) return false;
|
|
|
|
if (OriginGame != 0 && OriginGame != pk.Version) return false;
|
|
|
|
if (EncryptionConstant != 0)
|
|
|
|
{
|
|
|
|
if (EncryptionConstant != pk.EncryptionConstant)
|
|
|
|
return false;
|
|
|
|
}
|
2023-06-09 08:59:04 +00:00
|
|
|
else if (IsHOMEGift)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2023-06-11 03:18:34 +00:00
|
|
|
// Prior to 3.0.0, HOME would set the Encryption Constant exactly and not give a random value if it was 0.
|
|
|
|
if (pk.MetDate is { } x && IsHOMEGiftOld(x))
|
|
|
|
{
|
|
|
|
// HOME gifts -- PID and EC are zeroes...
|
|
|
|
if (EncryptionConstant != pk.EncryptionConstant)
|
|
|
|
return false;
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
if (IsShiny)
|
2020-03-14 21:22:45 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (!pk.IsShiny)
|
2020-03-14 21:22:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
else // Never or Random (HOME ID specific)
|
2020-03-14 21:22:45 +00:00
|
|
|
{
|
2023-05-10 15:32:09 +00:00
|
|
|
if (pk.IsShiny && !IsHOMEShinyPossible())
|
2020-09-30 06:10:48 +00:00
|
|
|
return false;
|
2020-03-14 21:22:45 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-12-08 07:28:47 +00:00
|
|
|
if (Form != evo.Form && !FormInfo.IsFormChangeable(Species, Form, pk.Form, Context, pk.Context))
|
2022-06-18 18:04:24 +00:00
|
|
|
return false;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var shinyType = Shiny;
|
|
|
|
if (PIDType == ShinyType8.FixedValue)
|
2023-05-10 15:32:09 +00:00
|
|
|
shinyType = FixedShinyType();
|
2022-06-18 18:04:24 +00:00
|
|
|
if (IsEgg)
|
|
|
|
{
|
|
|
|
if (EggLocation != pk.Egg_Location) // traded
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (pk.Egg_Location != Locations.LinkTrade6)
|
2019-11-16 01:34:18 +00:00
|
|
|
return false;
|
2023-01-22 04:02:33 +00:00
|
|
|
if (PIDType == ShinyType8.Random && pk is { IsShiny: true, ShinyXor: > 1 })
|
2022-06-18 18:04:24 +00:00
|
|
|
return false; // shiny traded egg will always have xor0/1.
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
if (!shinyType.IsValid(pk))
|
2019-11-16 01:34:18 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
return false; // can't be traded away for unshiny
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
if (pk is { IsEgg: true, IsNative: false })
|
2019-11-16 01:34:18 +00:00
|
|
|
return false;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!shinyType.IsValid(pk)) return false;
|
|
|
|
if (!IsMatchEggLocation(pk)) return false;
|
|
|
|
if (MetLocation != pk.Met_Location) return false;
|
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
if (MetLevel != 0 && MetLevel != pk.Met_Level) return false;
|
|
|
|
if ((Ball == 0 ? 4 : Ball) != pk.Ball) return false;
|
|
|
|
if (OTGender < 2 && OTGender != pk.OT_Gender) return false;
|
|
|
|
if (Nature != -1 && pk.Nature != Nature) return false;
|
|
|
|
if (Gender != 3 && Gender != pk.Gender) return false;
|
2020-07-02 22:18:36 +00:00
|
|
|
|
2023-11-09 07:32:41 +00:00
|
|
|
if (pk is PK8 and IGigantamax g && g.CanGigantamax != CanGigantamax && !Gigantamax.CanToggle(pk.Species, pk.Form, Species, Form))
|
2022-06-18 18:04:24 +00:00
|
|
|
return false;
|
2021-02-03 21:29:48 +00:00
|
|
|
|
2022-08-31 04:15:07 +00:00
|
|
|
if (pk is PK8 pk8 && pk8.DynamaxLevel < DynamaxLevel)
|
2022-06-18 18:04:24 +00:00
|
|
|
return false;
|
2019-11-16 01:34:18 +00:00
|
|
|
|
2023-07-15 18:22:48 +00:00
|
|
|
if (IsHOMEGift)
|
2022-02-13 06:24:48 +00:00
|
|
|
{
|
2023-07-15 18:22:48 +00:00
|
|
|
// Prior to 3.0.0, HOME would set the Height and Weight exactly and not give a random value if it was 0.
|
|
|
|
// However, entering HOME will re-randomize the Height and Weight.
|
|
|
|
if (pk.MetDate is { } x && IsHOMEGiftOld(x))
|
|
|
|
{
|
|
|
|
// Need to defer and not mismatch date ranges.
|
|
|
|
if (!EncounterServerDate.IsValidDateWC8(this, x))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (pk.Context is not (EntityContext.Gen8 or EntityContext.Gen8b))
|
|
|
|
{
|
|
|
|
// Only these 3 can transfer to PLA and get 0 scale prior to 3.0.0
|
|
|
|
if (Species is not ((ushort)Core.Species.Pikachu or (ushort)Core.Species.Eevee or (ushort)Core.Species.Rotom or (ushort)Core.Species.Pichu))
|
|
|
|
{
|
|
|
|
if (pk is IScaledSize { HeightScalar: 0, WeightScalar: 0 })
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-13 06:24:48 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
// Duplicate card; one with Nickname specified and another without.
|
|
|
|
if (CardID == 0122 && pk.IsNicknamed != GetIsNicknamed(pk.Language))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// PID Types 0 and 1 do not use the fixed PID value.
|
|
|
|
// Values 2,3 are specific shiny states, and 4 is fixed value.
|
|
|
|
// 2,3,4 can change if it is a traded egg to ensure the same shiny state.
|
|
|
|
var type = PIDType;
|
|
|
|
if (type is ShinyType8.Never or ShinyType8.Random)
|
|
|
|
return true;
|
2023-06-11 03:18:34 +00:00
|
|
|
if (pk.PID == GetPID(pk, type))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2023-05-10 15:32:09 +00:00
|
|
|
private bool IsHOMEShinyPossible()
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
2023-01-22 04:02:33 +00:00
|
|
|
// no defined TID16/SID16 and having a fixed PID can cause the player's TID16/SID16 to match the PID's shiny calc.
|
2023-05-10 15:32:09 +00:00
|
|
|
// All PIDs are fixed for HOME gifts.
|
2023-06-09 08:59:04 +00:00
|
|
|
return ID32 == 0 && PID != 0;
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsDateRestricted => IsHOMEGift;
|
|
|
|
|
2023-08-12 23:01:16 +00:00
|
|
|
protected override bool IsMatchDeferred(PKM pk) => false;
|
2022-06-18 18:04:24 +00:00
|
|
|
protected override bool IsMatchPartial(PKM pk) => false; // no version compatibility checks yet.
|
|
|
|
|
|
|
|
#region Lazy Ribbon Implementation
|
|
|
|
public bool RibbonEarth { get => this.GetRibbonIndex(Earth); set => this.SetRibbonIndex(Earth, value); }
|
|
|
|
public bool RibbonNational { get => this.GetRibbonIndex(National); set => this.SetRibbonIndex(National, value); }
|
|
|
|
public bool RibbonCountry { get => this.GetRibbonIndex(Country); set => this.SetRibbonIndex(Country, value); }
|
|
|
|
public bool RibbonChampionBattle { get => this.GetRibbonIndex(ChampionBattle); set => this.SetRibbonIndex(ChampionBattle, value); }
|
|
|
|
public bool RibbonChampionRegional { get => this.GetRibbonIndex(ChampionRegional); set => this.SetRibbonIndex(ChampionRegional, value); }
|
|
|
|
public bool RibbonChampionNational { get => this.GetRibbonIndex(ChampionNational); set => this.SetRibbonIndex(ChampionNational, value); }
|
|
|
|
public bool RibbonClassic { get => this.GetRibbonIndex(Classic); set => this.SetRibbonIndex(Classic, value); }
|
|
|
|
public bool RibbonWishing { get => this.GetRibbonIndex(Wishing); set => this.SetRibbonIndex(Wishing, value); }
|
|
|
|
public bool RibbonPremier { get => this.GetRibbonIndex(Premier); set => this.SetRibbonIndex(Premier, value); }
|
|
|
|
public bool RibbonEvent { get => this.GetRibbonIndex(Event); set => this.SetRibbonIndex(Event, value); }
|
|
|
|
public bool RibbonBirthday { get => this.GetRibbonIndex(Birthday); set => this.SetRibbonIndex(Birthday, value); }
|
|
|
|
public bool RibbonSpecial { get => this.GetRibbonIndex(Special); set => this.SetRibbonIndex(Special, value); }
|
|
|
|
public bool RibbonWorld { get => this.GetRibbonIndex(World); set => this.SetRibbonIndex(World, value); }
|
|
|
|
public bool RibbonChampionWorld { get => this.GetRibbonIndex(ChampionWorld); set => this.SetRibbonIndex(ChampionWorld, value); }
|
|
|
|
public bool RibbonSouvenir { get => this.GetRibbonIndex(Souvenir); set => this.SetRibbonIndex(Souvenir, value); }
|
|
|
|
public bool RibbonChampionG3 { get => this.GetRibbonIndex(ChampionG3); set => this.SetRibbonIndex(ChampionG3, value); }
|
|
|
|
public bool RibbonArtist { get => this.GetRibbonIndex(Artist); set => this.SetRibbonIndex(Artist, value); }
|
|
|
|
public bool RibbonEffort { get => this.GetRibbonIndex(Effort); set => this.SetRibbonIndex(Effort, value); }
|
|
|
|
public bool RibbonChampionSinnoh { get => this.GetRibbonIndex(ChampionSinnoh); set => this.SetRibbonIndex(ChampionSinnoh, value); }
|
|
|
|
public bool RibbonAlert { get => this.GetRibbonIndex(Alert); set => this.SetRibbonIndex(Alert, value); }
|
|
|
|
public bool RibbonShock { get => this.GetRibbonIndex(Shock); set => this.SetRibbonIndex(Shock, value); }
|
|
|
|
public bool RibbonDowncast { get => this.GetRibbonIndex(Downcast); set => this.SetRibbonIndex(Downcast, value); }
|
|
|
|
public bool RibbonCareless { get => this.GetRibbonIndex(Careless); set => this.SetRibbonIndex(Careless, value); }
|
|
|
|
public bool RibbonRelax { get => this.GetRibbonIndex(Relax); set => this.SetRibbonIndex(Relax, value); }
|
|
|
|
public bool RibbonSnooze { get => this.GetRibbonIndex(Snooze); set => this.SetRibbonIndex(Snooze, value); }
|
|
|
|
public bool RibbonSmile { get => this.GetRibbonIndex(Smile); set => this.SetRibbonIndex(Smile, value); }
|
|
|
|
public bool RibbonGorgeous { get => this.GetRibbonIndex(Gorgeous); set => this.SetRibbonIndex(Gorgeous, value); }
|
|
|
|
public bool RibbonRoyal { get => this.GetRibbonIndex(Royal); set => this.SetRibbonIndex(Royal, value); }
|
|
|
|
public bool RibbonGorgeousRoyal { get => this.GetRibbonIndex(GorgeousRoyal); set => this.SetRibbonIndex(GorgeousRoyal, value); }
|
|
|
|
public bool RibbonFootprint { get => this.GetRibbonIndex(Footprint); set => this.SetRibbonIndex(Footprint, value); }
|
|
|
|
public bool RibbonRecord { get => this.GetRibbonIndex(Record); set => this.SetRibbonIndex(Record, value); }
|
|
|
|
public bool RibbonLegend { get => this.GetRibbonIndex(Legend); set => this.SetRibbonIndex(Legend, value); }
|
|
|
|
public bool RibbonChampionKalos { get => this.GetRibbonIndex(ChampionKalos); set => this.SetRibbonIndex(ChampionKalos, value); }
|
|
|
|
public bool RibbonChampionG6Hoenn { get => this.GetRibbonIndex(ChampionG6Hoenn); set => this.SetRibbonIndex(ChampionG6Hoenn, value); }
|
|
|
|
public bool RibbonBestFriends { get => this.GetRibbonIndex(BestFriends); set => this.SetRibbonIndex(BestFriends, value); }
|
|
|
|
public bool RibbonTraining { get => this.GetRibbonIndex(Training); set => this.SetRibbonIndex(Training, value); }
|
|
|
|
public bool RibbonBattlerSkillful { get => this.GetRibbonIndex(BattlerSkillful); set => this.SetRibbonIndex(BattlerSkillful, value); }
|
|
|
|
public bool RibbonBattlerExpert { get => this.GetRibbonIndex(BattlerExpert); set => this.SetRibbonIndex(BattlerExpert, value); }
|
|
|
|
public bool RibbonContestStar { get => this.GetRibbonIndex(ContestStar); set => this.SetRibbonIndex(ContestStar, value); }
|
|
|
|
public bool RibbonMasterCoolness { get => this.GetRibbonIndex(MasterCoolness); set => this.SetRibbonIndex(MasterCoolness, value); }
|
|
|
|
public bool RibbonMasterBeauty { get => this.GetRibbonIndex(MasterBeauty); set => this.SetRibbonIndex(MasterBeauty, value); }
|
|
|
|
public bool RibbonMasterCuteness { get => this.GetRibbonIndex(MasterCuteness); set => this.SetRibbonIndex(MasterCuteness, value); }
|
|
|
|
public bool RibbonMasterCleverness { get => this.GetRibbonIndex(MasterCleverness); set => this.SetRibbonIndex(MasterCleverness, value); }
|
|
|
|
public bool RibbonMasterToughness { get => this.GetRibbonIndex(MasterToughness); set => this.SetRibbonIndex(MasterToughness, value); }
|
|
|
|
|
|
|
|
public bool RibbonChampionAlola { get => this.GetRibbonIndex(ChampionAlola); set => this.SetRibbonIndex(ChampionAlola, value); }
|
|
|
|
public bool RibbonBattleRoyale { get => this.GetRibbonIndex(BattleRoyale); set => this.SetRibbonIndex(BattleRoyale, value); }
|
|
|
|
public bool RibbonBattleTreeGreat { get => this.GetRibbonIndex(BattleTreeGreat); set => this.SetRibbonIndex(BattleTreeGreat, value); }
|
|
|
|
public bool RibbonBattleTreeMaster { get => this.GetRibbonIndex(BattleTreeMaster); set => this.SetRibbonIndex(BattleTreeMaster, value); }
|
|
|
|
public bool RibbonChampionGalar { get => this.GetRibbonIndex(ChampionGalar); set => this.SetRibbonIndex(ChampionGalar, value); }
|
|
|
|
public bool RibbonTowerMaster { get => this.GetRibbonIndex(TowerMaster); set => this.SetRibbonIndex(TowerMaster, value); }
|
|
|
|
public bool RibbonMasterRank { get => this.GetRibbonIndex(MasterRank); set => this.SetRibbonIndex(MasterRank, value); }
|
|
|
|
public bool RibbonMarkLunchtime { get => this.GetRibbonIndex(MarkLunchtime); set => this.SetRibbonIndex(MarkLunchtime, value); }
|
|
|
|
public bool RibbonMarkSleepyTime { get => this.GetRibbonIndex(MarkSleepyTime); set => this.SetRibbonIndex(MarkSleepyTime, value); }
|
|
|
|
public bool RibbonMarkDusk { get => this.GetRibbonIndex(MarkDusk); set => this.SetRibbonIndex(MarkDusk, value); }
|
|
|
|
public bool RibbonMarkDawn { get => this.GetRibbonIndex(MarkDawn); set => this.SetRibbonIndex(MarkDawn, value); }
|
|
|
|
public bool RibbonMarkCloudy { get => this.GetRibbonIndex(MarkCloudy); set => this.SetRibbonIndex(MarkCloudy, value); }
|
|
|
|
public bool RibbonMarkRainy { get => this.GetRibbonIndex(MarkRainy); set => this.SetRibbonIndex(MarkRainy, value); }
|
|
|
|
public bool RibbonMarkStormy { get => this.GetRibbonIndex(MarkStormy); set => this.SetRibbonIndex(MarkStormy, value); }
|
|
|
|
public bool RibbonMarkSnowy { get => this.GetRibbonIndex(MarkSnowy); set => this.SetRibbonIndex(MarkSnowy, value); }
|
|
|
|
public bool RibbonMarkBlizzard { get => this.GetRibbonIndex(MarkBlizzard); set => this.SetRibbonIndex(MarkBlizzard, value); }
|
|
|
|
public bool RibbonMarkDry { get => this.GetRibbonIndex(MarkDry); set => this.SetRibbonIndex(MarkDry, value); }
|
|
|
|
public bool RibbonMarkSandstorm { get => this.GetRibbonIndex(MarkSandstorm); set => this.SetRibbonIndex(MarkSandstorm, value); }
|
|
|
|
public bool RibbonMarkMisty { get => this.GetRibbonIndex(MarkMisty); set => this.SetRibbonIndex(MarkMisty, value); }
|
|
|
|
public bool RibbonMarkDestiny { get => this.GetRibbonIndex(MarkDestiny); set => this.SetRibbonIndex(MarkDestiny, value); }
|
|
|
|
public bool RibbonMarkFishing { get => this.GetRibbonIndex(MarkFishing); set => this.SetRibbonIndex(MarkFishing, value); }
|
|
|
|
public bool RibbonMarkCurry { get => this.GetRibbonIndex(MarkCurry); set => this.SetRibbonIndex(MarkCurry, value); }
|
|
|
|
public bool RibbonMarkUncommon { get => this.GetRibbonIndex(MarkUncommon); set => this.SetRibbonIndex(MarkUncommon, value); }
|
|
|
|
public bool RibbonMarkRare { get => this.GetRibbonIndex(MarkRare); set => this.SetRibbonIndex(MarkRare, value); }
|
|
|
|
public bool RibbonMarkRowdy { get => this.GetRibbonIndex(MarkRowdy); set => this.SetRibbonIndex(MarkRowdy, value); }
|
|
|
|
public bool RibbonMarkAbsentMinded { get => this.GetRibbonIndex(MarkAbsentMinded); set => this.SetRibbonIndex(MarkAbsentMinded, value); }
|
|
|
|
public bool RibbonMarkJittery { get => this.GetRibbonIndex(MarkJittery); set => this.SetRibbonIndex(MarkJittery, value); }
|
|
|
|
public bool RibbonMarkExcited { get => this.GetRibbonIndex(MarkExcited); set => this.SetRibbonIndex(MarkExcited, value); }
|
|
|
|
public bool RibbonMarkCharismatic { get => this.GetRibbonIndex(MarkCharismatic); set => this.SetRibbonIndex(MarkCharismatic, value); }
|
|
|
|
public bool RibbonMarkCalmness { get => this.GetRibbonIndex(MarkCalmness); set => this.SetRibbonIndex(MarkCalmness, value); }
|
|
|
|
public bool RibbonMarkIntense { get => this.GetRibbonIndex(MarkIntense); set => this.SetRibbonIndex(MarkIntense, value); }
|
|
|
|
public bool RibbonMarkZonedOut { get => this.GetRibbonIndex(MarkZonedOut); set => this.SetRibbonIndex(MarkZonedOut, value); }
|
|
|
|
public bool RibbonMarkJoyful { get => this.GetRibbonIndex(MarkJoyful); set => this.SetRibbonIndex(MarkJoyful, value); }
|
|
|
|
public bool RibbonMarkAngry { get => this.GetRibbonIndex(MarkAngry); set => this.SetRibbonIndex(MarkAngry, value); }
|
|
|
|
public bool RibbonMarkSmiley { get => this.GetRibbonIndex(MarkSmiley); set => this.SetRibbonIndex(MarkSmiley, value); }
|
|
|
|
public bool RibbonMarkTeary { get => this.GetRibbonIndex(MarkTeary); set => this.SetRibbonIndex(MarkTeary, value); }
|
|
|
|
public bool RibbonMarkUpbeat { get => this.GetRibbonIndex(MarkUpbeat); set => this.SetRibbonIndex(MarkUpbeat, value); }
|
|
|
|
public bool RibbonMarkPeeved { get => this.GetRibbonIndex(MarkPeeved); set => this.SetRibbonIndex(MarkPeeved, value); }
|
|
|
|
public bool RibbonMarkIntellectual { get => this.GetRibbonIndex(MarkIntellectual); set => this.SetRibbonIndex(MarkIntellectual, value); }
|
|
|
|
public bool RibbonMarkFerocious { get => this.GetRibbonIndex(MarkFerocious); set => this.SetRibbonIndex(MarkFerocious, value); }
|
|
|
|
public bool RibbonMarkCrafty { get => this.GetRibbonIndex(MarkCrafty); set => this.SetRibbonIndex(MarkCrafty, value); }
|
|
|
|
public bool RibbonMarkScowling { get => this.GetRibbonIndex(MarkScowling); set => this.SetRibbonIndex(MarkScowling, value); }
|
|
|
|
public bool RibbonMarkKindly { get => this.GetRibbonIndex(MarkKindly); set => this.SetRibbonIndex(MarkKindly, value); }
|
|
|
|
public bool RibbonMarkFlustered { get => this.GetRibbonIndex(MarkFlustered); set => this.SetRibbonIndex(MarkFlustered, value); }
|
|
|
|
public bool RibbonMarkPumpedUp { get => this.GetRibbonIndex(MarkPumpedUp); set => this.SetRibbonIndex(MarkPumpedUp, value); }
|
|
|
|
public bool RibbonMarkZeroEnergy { get => this.GetRibbonIndex(MarkZeroEnergy); set => this.SetRibbonIndex(MarkZeroEnergy, value); }
|
|
|
|
public bool RibbonMarkPrideful { get => this.GetRibbonIndex(MarkPrideful); set => this.SetRibbonIndex(MarkPrideful, value); }
|
|
|
|
public bool RibbonMarkUnsure { get => this.GetRibbonIndex(MarkUnsure); set => this.SetRibbonIndex(MarkUnsure, value); }
|
|
|
|
public bool RibbonMarkHumble { get => this.GetRibbonIndex(MarkHumble); set => this.SetRibbonIndex(MarkHumble, value); }
|
|
|
|
public bool RibbonMarkThorny { get => this.GetRibbonIndex(MarkThorny); set => this.SetRibbonIndex(MarkThorny, value); }
|
|
|
|
public bool RibbonMarkVigor { get => this.GetRibbonIndex(MarkVigor); set => this.SetRibbonIndex(MarkVigor, value); }
|
|
|
|
public bool RibbonMarkSlump { get => this.GetRibbonIndex(MarkSlump); set => this.SetRibbonIndex(MarkSlump, value); }
|
|
|
|
public bool RibbonTwinklingStar { get => this.GetRibbonIndex(TwinklingStar); set => this.SetRibbonIndex(TwinklingStar, value); }
|
2022-11-25 01:42:17 +00:00
|
|
|
public bool RibbonHisui { get => this.GetRibbonIndex(Hisui); set => this.SetRibbonIndex(Hisui, value); }
|
2022-06-18 18:04:24 +00:00
|
|
|
|
2022-08-24 04:25:22 +00:00
|
|
|
public int GetRibbonByte(int index) => Array.IndexOf(Data, (byte)index, RibbonBytesOffset, RibbonBytesCount);
|
2023-12-18 00:41:15 +00:00
|
|
|
public bool GetRibbon(int index) => RibbonSpan.Contains((byte)index);
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
public void SetRibbon(int index, bool value = true)
|
|
|
|
{
|
2023-12-18 00:41:15 +00:00
|
|
|
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)index, (uint)RibbonIndexExtensions.MAX_G8);
|
2022-06-18 18:04:24 +00:00
|
|
|
if (value)
|
2019-11-19 01:37:38 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (GetRibbon(index))
|
|
|
|
return;
|
2022-08-24 04:25:22 +00:00
|
|
|
var openIndex = Array.IndexOf(Data, RibbonByteNone, RibbonBytesOffset, RibbonBytesCount);
|
2023-12-09 23:21:10 +00:00
|
|
|
ArgumentOutOfRangeException.ThrowIfNegative(openIndex, nameof(openIndex)); // Full?
|
2022-06-18 18:04:24 +00:00
|
|
|
SetRibbonAtIndex(openIndex, (byte)index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var ofs = GetRibbonByte(index);
|
|
|
|
if (ofs < 0)
|
|
|
|
return;
|
|
|
|
SetRibbonAtIndex(ofs, RibbonByteNone);
|
2019-11-19 01:37:38 +00:00
|
|
|
}
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
#endregion
|
2019-11-16 01:34:18 +00:00
|
|
|
}
|