2015-11-22 21:38:16 +00:00
|
|
|
|
using System;
|
2015-11-26 15:49:44 +00:00
|
|
|
|
using System.Linq;
|
2015-11-22 21:38:16 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2015-11-22 21:38:16 +00:00
|
|
|
|
{
|
2017-06-20 04:43:44 +00:00
|
|
|
|
public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4
|
2015-11-22 21:38:16 +00:00
|
|
|
|
{
|
2017-01-08 07:54:09 +00:00
|
|
|
|
public const int Size = 0x108;
|
|
|
|
|
public const int SizeFull = 0x310;
|
|
|
|
|
public const uint EonTicketConst = 0x225D73C2;
|
2016-09-04 17:38:53 +00:00
|
|
|
|
public override int Format => 6;
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
|
|
|
|
public WC6(byte[] data = null)
|
|
|
|
|
{
|
2016-06-20 04:22:43 +00:00
|
|
|
|
Data = (byte[])(data?.Clone() ?? new byte[Size]);
|
2016-04-22 02:16:55 +00:00
|
|
|
|
if (Data.Length == SizeFull)
|
|
|
|
|
{
|
2017-08-16 04:16:47 +00:00
|
|
|
|
byte[] wc6 = new byte[Size];
|
|
|
|
|
if (Data[0x205] != 0) // Valid data
|
|
|
|
|
Array.Copy(Data, SizeFull - Size, wc6, 0, wc6.Length);
|
|
|
|
|
Data = wc6;
|
|
|
|
|
|
2016-04-22 02:16:55 +00:00
|
|
|
|
DateTime now = DateTime.Now;
|
2016-07-30 20:25:58 +00:00
|
|
|
|
Year = (uint)now.Year;
|
2016-04-22 02:16:55 +00:00
|
|
|
|
Month = (uint)now.Month;
|
|
|
|
|
Day = (uint)now.Day;
|
|
|
|
|
}
|
2016-11-13 23:40:34 +00:00
|
|
|
|
if (Year < 2000)
|
|
|
|
|
Data = new byte[Data.Length]; // Invalidate
|
2015-11-22 21:38:16 +00:00
|
|
|
|
}
|
2016-06-20 04:22:43 +00:00
|
|
|
|
|
2015-11-22 21:38:16 +00:00
|
|
|
|
// General Card Properties
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override int CardID {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0); }
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override string CardTitle { // Max len 36 char, followed by null terminator
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 2, 72));
|
|
|
|
|
set => Encoding.Unicode.GetBytes(value.PadRight(36, '\0')).CopyTo(Data, 2); }
|
|
|
|
|
private uint RawDate {
|
|
|
|
|
get => BitConverter.ToUInt32(Data, 0x4C);
|
|
|
|
|
set => BitConverter.GetBytes(value).CopyTo(Data, 0x4C); }
|
2016-08-10 14:02:31 +00:00
|
|
|
|
private uint Year {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => RawDate / 10000;
|
|
|
|
|
set => RawDate = value * 10000 + RawDate % 10000; }
|
2016-08-10 14:02:31 +00:00
|
|
|
|
private uint Month {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => RawDate % 10000 / 100;
|
|
|
|
|
set => RawDate = Year * 10000 + value * 100 + RawDate % 100; }
|
2016-08-10 14:02:31 +00:00
|
|
|
|
private uint Day {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => RawDate % 100;
|
|
|
|
|
set => RawDate = Year * 10000 + Month * 100 + value; }
|
2016-08-10 14:02:31 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the date of the card.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public DateTime? Date
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Check to see if date is valid
|
2016-08-13 00:16:03 +00:00
|
|
|
|
if (!Util.IsDateValid(Year, Month, Day))
|
2016-08-10 14:02:31 +00:00
|
|
|
|
return null;
|
2016-08-13 00:16:03 +00:00
|
|
|
|
|
|
|
|
|
return new DateTime((int)Year, (int)Month, (int)Day);
|
2016-08-10 14:02:31 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value.HasValue)
|
|
|
|
|
{
|
|
|
|
|
// Only update the properties if a value is provided.
|
2016-08-13 00:16:03 +00:00
|
|
|
|
Year = (ushort)value.Value.Year;
|
2016-08-10 14:02:31 +00:00
|
|
|
|
Month = (byte)value.Value.Month;
|
|
|
|
|
Day = (byte)value.Value.Day;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Clear the Met Date.
|
|
|
|
|
// If code tries to access MetDate again, null will be returned.
|
|
|
|
|
Year = 0;
|
|
|
|
|
Month = 0;
|
|
|
|
|
Day = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int CardLocation { get => Data[0x50]; set => Data[0x50] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int CardType { get => Data[0x51]; set => Data[0x51] = (byte)value; }
|
|
|
|
|
public override bool GiftUsed { get => Data[0x52] >> 1 > 0; set => Data[0x52] = (byte)(Data[0x52] & ~2 | (value ? 2 : 0)); }
|
|
|
|
|
public bool MultiObtain { get => Data[0x53] == 1; set => Data[0x53] = (byte)(value ? 1 : 0); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
|
|
|
|
// Item Properties
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override bool IsItem { get => CardType == 1; set { if (value) CardType = 1; } }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override int ItemID {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x68);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x68); }
|
2016-06-20 04:22:43 +00:00
|
|
|
|
public override int Quantity {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x70);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x70); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
|
|
|
|
// Pokémon Properties
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public override bool IsPokémon { get => CardType == 0; set { if (value) CardType = 0; } }
|
2017-01-05 06:25:45 +00:00
|
|
|
|
public override bool IsShiny => PIDType == 2;
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int TID {
|
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x68);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x68); }
|
|
|
|
|
public int SID {
|
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x6A);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x6A); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int OriginGame {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0x6C];
|
|
|
|
|
set => Data[0x6C] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public uint EncryptionConstant {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt32(Data, 0x70);
|
|
|
|
|
set => BitConverter.GetBytes(value).CopyTo(Data, 0x70); }
|
2016-10-23 19:48:49 +00:00
|
|
|
|
public override int Ball {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0x76];
|
|
|
|
|
set => Data[0x76] = (byte)value; }
|
2016-09-04 17:38:53 +00:00
|
|
|
|
public override int HeldItem {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x78);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x78); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Move1 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x7A);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7A); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Move2 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x7C);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7C); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Move3 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x7E);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Move4 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x80);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80); }
|
2016-09-04 17:38:53 +00:00
|
|
|
|
public override int Species {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0x82);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x82); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Form {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0x84];
|
|
|
|
|
set => Data[0x84] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Language {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0x85];
|
|
|
|
|
set => Data[0x85] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public string Nickname {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x86, 0x1A));
|
|
|
|
|
set => Encoding.Unicode.GetBytes(value.PadRight(12 + 1, '\0')).CopyTo(Data, 0x86); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Nature {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0xA0];
|
|
|
|
|
set => Data[0xA0] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int Gender {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0xA1];
|
|
|
|
|
set => Data[0xA1] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int AbilityType {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0xA2];
|
|
|
|
|
set => Data[0xA2] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int PIDType {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Data[0xA3];
|
|
|
|
|
set => Data[0xA3] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int EggLocation {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xA4);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xA4); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int MetLocation {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xA6);
|
|
|
|
|
set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xA6); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int CNT_Cool { get => Data[0xA9]; set => Data[0xA9] = (byte)value; }
|
|
|
|
|
public int CNT_Beauty { get => Data[0xAA]; set => Data[0xAA] = (byte)value; }
|
|
|
|
|
public int CNT_Cute { get => Data[0xAB]; set => Data[0xAB] = (byte)value; }
|
|
|
|
|
public int CNT_Smart { get => Data[0xAC]; set => Data[0xAC] = (byte)value; }
|
|
|
|
|
public int CNT_Tough { get => Data[0xAD]; set => Data[0xAD] = (byte)value; }
|
|
|
|
|
public int CNT_Sheen { get => Data[0xAE]; set => Data[0xAE] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int IV_HP { get => Data[0xAF]; set => Data[0xAF] = (byte)value; }
|
|
|
|
|
public int IV_ATK { get => Data[0xB0]; set => Data[0xB0] = (byte)value; }
|
|
|
|
|
public int IV_DEF { get => Data[0xB1]; set => Data[0xB1] = (byte)value; }
|
|
|
|
|
public int IV_SPE { get => Data[0xB2]; set => Data[0xB2] = (byte)value; }
|
|
|
|
|
public int IV_SPA { get => Data[0xB3]; set => Data[0xB3] = (byte)value; }
|
|
|
|
|
public int IV_SPD { get => Data[0xB4]; set => Data[0xB4] = (byte)value; }
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int OTGender { get => Data[0xB5]; set => Data[0xB5] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public string OT {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0xB6, 0x1A)); set => Encoding.Unicode.GetBytes(value.PadRight(value.Length + 1, '\0')).CopyTo(Data, 0xB6);
|
|
|
|
|
}
|
|
|
|
|
public override int Level { get => Data[0xD0]; set => Data[0xD0] = (byte)value; }
|
|
|
|
|
public override bool IsEgg { get => Data[0xD1] == 1; set => Data[0xD1] = (byte)(value ? 1 : 0); }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public uint PID {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt32(Data, 0xD4); set => BitConverter.GetBytes(value).CopyTo(Data, 0xD4);
|
|
|
|
|
}
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int RelearnMove1 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xD8); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xD8);
|
|
|
|
|
}
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int RelearnMove2 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xDA); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xDA);
|
|
|
|
|
}
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int RelearnMove3 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xDC); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xDC);
|
|
|
|
|
}
|
2015-11-22 21:38:16 +00:00
|
|
|
|
public int RelearnMove4 {
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => BitConverter.ToUInt16(Data, 0xDE); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xDE);
|
|
|
|
|
}
|
|
|
|
|
public int OT_Intensity { get => Data[0xE0]; set => Data[0xE0] = (byte)value; }
|
|
|
|
|
public int OT_Memory { get => Data[0xE1]; set => Data[0xE1] = (byte)value; }
|
|
|
|
|
public int OT_TextVar { get => BitConverter.ToUInt16(Data, 0xE2); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xE2); }
|
|
|
|
|
public int OT_Feeling { get => Data[0xE4]; set => Data[0xE4] = (byte)value; }
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int EV_HP { get => Data[0xE5]; set => Data[0xE5] = (byte)value; }
|
|
|
|
|
public int EV_ATK { get => Data[0xE6]; set => Data[0xE6] = (byte)value; }
|
|
|
|
|
public int EV_DEF { get => Data[0xE7]; set => Data[0xE7] = (byte)value; }
|
|
|
|
|
public int EV_SPE { get => Data[0xE8]; set => Data[0xE8] = (byte)value; }
|
|
|
|
|
public int EV_SPA { get => Data[0xE9]; set => Data[0xE9] = (byte)value; }
|
|
|
|
|
public int EV_SPD { get => Data[0xEA]; set => Data[0xEA] = (byte)value; }
|
2017-01-06 02:33:11 +00:00
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
private byte RIB0 { get => Data[0x74]; set => Data[0x74] = value; }
|
|
|
|
|
public bool RibbonChampionBattle { get => (RIB0 & (1 << 0)) == 1 << 0; set => RIB0 = (byte)(RIB0 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // Battle Champ Ribbon
|
|
|
|
|
public bool RibbonChampionRegional { get => (RIB0 & (1 << 1)) == 1 << 1; set => RIB0 = (byte)(RIB0 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Regional Champ Ribbon
|
|
|
|
|
public bool RibbonChampionNational { get => (RIB0 & (1 << 2)) == 1 << 2; set => RIB0 = (byte)(RIB0 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // National Champ Ribbon
|
|
|
|
|
public bool RibbonCountry { get => (RIB0 & (1 << 3)) == 1 << 3; set => RIB0 = (byte)(RIB0 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Country Ribbon
|
|
|
|
|
public bool RibbonNational { get => (RIB0 & (1 << 4)) == 1 << 4; set => RIB0 = (byte)(RIB0 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // National Ribbon
|
|
|
|
|
public bool RibbonEarth { get => (RIB0 & (1 << 5)) == 1 << 5; set => RIB0 = (byte)(RIB0 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Earth Ribbon
|
|
|
|
|
public bool RibbonWorld { get => (RIB0 & (1 << 6)) == 1 << 6; set => RIB0 = (byte)(RIB0 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // World Ribbon
|
|
|
|
|
public bool RibbonEvent { get => (RIB0 & (1 << 7)) == 1 << 7; set => RIB0 = (byte)(RIB0 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Event Ribbon
|
|
|
|
|
private byte RIB1 { get => Data[0x75]; set => Data[0x75] = value; }
|
|
|
|
|
public bool RibbonChampionWorld { get => (RIB1 & (1 << 0)) == 1 << 0; set => RIB1 = (byte)(RIB1 & ~(1 << 0) | (value ? 1 << 0 : 0)); } // World Champ Ribbon
|
|
|
|
|
public bool RibbonBirthday { get => (RIB1 & (1 << 1)) == 1 << 1; set => RIB1 = (byte)(RIB1 & ~(1 << 1) | (value ? 1 << 1 : 0)); } // Birthday Ribbon
|
|
|
|
|
public bool RibbonSpecial { get => (RIB1 & (1 << 2)) == 1 << 2; set => RIB1 = (byte)(RIB1 & ~(1 << 2) | (value ? 1 << 2 : 0)); } // Special Ribbon
|
|
|
|
|
public bool RibbonSouvenir { get => (RIB1 & (1 << 3)) == 1 << 3; set => RIB1 = (byte)(RIB1 & ~(1 << 3) | (value ? 1 << 3 : 0)); } // Souvenir Ribbon
|
|
|
|
|
public bool RibbonWishing { get => (RIB1 & (1 << 4)) == 1 << 4; set => RIB1 = (byte)(RIB1 & ~(1 << 4) | (value ? 1 << 4 : 0)); } // Wishing Ribbon
|
|
|
|
|
public bool RibbonClassic { get => (RIB1 & (1 << 5)) == 1 << 5; set => RIB1 = (byte)(RIB1 & ~(1 << 5) | (value ? 1 << 5 : 0)); } // Classic Ribbon
|
|
|
|
|
public bool RibbonPremier { get => (RIB1 & (1 << 6)) == 1 << 6; set => RIB1 = (byte)(RIB1 & ~(1 << 6) | (value ? 1 << 6 : 0)); } // Premier Ribbon
|
|
|
|
|
public bool RIB1_7 { get => (RIB1 & (1 << 7)) == 1 << 7; set => RIB1 = (byte)(RIB1 & ~(1 << 7) | (value ? 1 << 7 : 0)); } // Empty
|
2015-11-22 21:38:16 +00:00
|
|
|
|
|
|
|
|
|
// Meta Accessible Properties
|
2017-01-06 02:33:11 +00:00
|
|
|
|
public int[] IVs
|
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD };
|
2017-01-06 02:33:11 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value?.Length != 6) return;
|
|
|
|
|
IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2];
|
|
|
|
|
IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public int[] EVs
|
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD };
|
2017-01-06 02:33:11 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value?.Length != 6) return;
|
|
|
|
|
EV_HP = value[0]; EV_ATK = value[1]; EV_DEF = value[2];
|
|
|
|
|
EV_SPE = value[3]; EV_SPA = value[4]; EV_SPD = value[5];
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-17 21:27:24 +00:00
|
|
|
|
public bool IsNicknamed => Nickname.Length > 0;
|
|
|
|
|
|
2016-09-04 17:38:53 +00:00
|
|
|
|
public override int[] Moves
|
2015-11-22 21:38:16 +00:00
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => new[] { Move1, Move2, Move3, Move4 };
|
2017-01-05 06:25:45 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value.Length > 0) Move1 = value[0];
|
|
|
|
|
if (value.Length > 1) Move2 = value[1];
|
|
|
|
|
if (value.Length > 2) Move3 = value[2];
|
|
|
|
|
if (value.Length > 3) Move4 = value[3];
|
|
|
|
|
}
|
2015-11-22 21:38:16 +00:00
|
|
|
|
}
|
2016-10-23 19:48:49 +00:00
|
|
|
|
public override int[] RelearnMoves
|
2015-11-22 21:38:16 +00:00
|
|
|
|
{
|
2017-05-13 03:32:36 +00:00
|
|
|
|
get => new[] { RelearnMove1, RelearnMove2, RelearnMove3, RelearnMove4 };
|
2015-11-22 21:38:16 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value.Length > 0) RelearnMove1 = value[0];
|
|
|
|
|
if (value.Length > 1) RelearnMove2 = value[1];
|
|
|
|
|
if (value.Length > 2) RelearnMove3 = value[2];
|
|
|
|
|
if (value.Length > 3) RelearnMove4 = value[3];
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public override PKM ConvertToPKM(SaveFile SAV)
|
2015-11-26 15:49:44 +00:00
|
|
|
|
{
|
|
|
|
|
if (!IsPokémon)
|
|
|
|
|
return null;
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
int currentLevel = Level > 0 ? Level : (int)(Util.Rand32()%100 + 1);
|
|
|
|
|
var pi = PersonalTable.AO.GetFormeEntry(Species, Form);
|
2015-11-26 15:49:44 +00:00
|
|
|
|
PK6 pk = new PK6
|
|
|
|
|
{
|
|
|
|
|
Species = Species,
|
|
|
|
|
HeldItem = HeldItem,
|
|
|
|
|
TID = TID,
|
|
|
|
|
SID = SID,
|
|
|
|
|
Met_Level = currentLevel,
|
2017-06-18 01:37:19 +00:00
|
|
|
|
Nature = Nature != 0xFF ? Nature : (int)(Util.Rand32() % 25),
|
2017-02-15 00:28:10 +00:00
|
|
|
|
Gender = Gender != 3 ? Gender : pi.RandomGender,
|
2015-11-26 15:49:44 +00:00
|
|
|
|
AltForm = Form,
|
2017-06-18 01:37:19 +00:00
|
|
|
|
EncryptionConstant = EncryptionConstant != 0 ? EncryptionConstant : Util.Rand32(),
|
2017-02-15 00:28:10 +00:00
|
|
|
|
Version = OriginGame != 0 ? OriginGame : SAV.Game,
|
|
|
|
|
Language = Language != 0 ? Language : SAV.Language,
|
2016-10-23 19:48:49 +00:00
|
|
|
|
Ball = Ball,
|
2015-11-26 15:49:44 +00:00
|
|
|
|
Country = SAV.Country,
|
|
|
|
|
Region = SAV.SubRegion,
|
|
|
|
|
ConsoleRegion = SAV.ConsoleRegion,
|
|
|
|
|
Move1 = Move1, Move2 = Move2, Move3 = Move3, Move4 = Move4,
|
|
|
|
|
RelearnMove1 = RelearnMove1, RelearnMove2 = RelearnMove2,
|
|
|
|
|
RelearnMove3 = RelearnMove3, RelearnMove4 = RelearnMove4,
|
|
|
|
|
Met_Location = MetLocation,
|
|
|
|
|
Egg_Location = EggLocation,
|
|
|
|
|
CNT_Cool = CNT_Cool,
|
|
|
|
|
CNT_Beauty = CNT_Beauty,
|
|
|
|
|
CNT_Cute = CNT_Cute,
|
|
|
|
|
CNT_Smart = CNT_Smart,
|
|
|
|
|
CNT_Tough = CNT_Tough,
|
|
|
|
|
CNT_Sheen = CNT_Sheen,
|
|
|
|
|
|
|
|
|
|
OT_Name = OT.Length > 0 ? OT : SAV.OT,
|
|
|
|
|
OT_Gender = OTGender != 3 ? OTGender % 2 : SAV.Gender,
|
|
|
|
|
HT_Name = OT.Length > 0 ? SAV.OT : "",
|
|
|
|
|
HT_Gender = OT.Length > 0 ? SAV.Gender : 0,
|
|
|
|
|
CurrentHandler = OT.Length > 0 ? 1 : 0,
|
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
EXP = PKX.GetEXP(Level, Species),
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
|
|
|
|
// Ribbons
|
2016-07-16 22:52:33 +00:00
|
|
|
|
RibbonCountry = RibbonCountry,
|
|
|
|
|
RibbonNational = RibbonNational,
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
2016-07-16 22:52:33 +00:00
|
|
|
|
RibbonEarth = RibbonEarth,
|
|
|
|
|
RibbonWorld = RibbonWorld,
|
|
|
|
|
RibbonClassic = RibbonClassic,
|
|
|
|
|
RibbonPremier = RibbonPremier,
|
|
|
|
|
RibbonEvent = RibbonEvent,
|
|
|
|
|
RibbonBirthday = RibbonBirthday,
|
|
|
|
|
RibbonSpecial = RibbonSpecial,
|
|
|
|
|
RibbonSouvenir = RibbonSouvenir,
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
2016-07-16 22:52:33 +00:00
|
|
|
|
RibbonWishing = RibbonWishing,
|
|
|
|
|
RibbonChampionBattle = RibbonChampionBattle,
|
|
|
|
|
RibbonChampionRegional = RibbonChampionRegional,
|
|
|
|
|
RibbonChampionNational = RibbonChampionNational,
|
|
|
|
|
RibbonChampionWorld = RibbonChampionWorld,
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
2017-02-15 00:28:10 +00:00
|
|
|
|
OT_Friendship = pi.BaseFriendship,
|
2016-05-08 21:29:08 +00:00
|
|
|
|
OT_Intensity = OT_Intensity,
|
|
|
|
|
OT_Memory = OT_Memory,
|
|
|
|
|
OT_TextVar = OT_TextVar,
|
|
|
|
|
OT_Feeling = OT_Feeling,
|
2015-11-27 03:14:41 +00:00
|
|
|
|
FatefulEncounter = true,
|
2017-01-06 02:33:11 +00:00
|
|
|
|
|
|
|
|
|
EVs = EVs,
|
2015-11-26 15:49:44 +00:00
|
|
|
|
};
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.Move1_PP = pk.GetMovePP(Move1, 0);
|
|
|
|
|
pk.Move2_PP = pk.GetMovePP(Move2, 0);
|
|
|
|
|
pk.Move3_PP = pk.GetMovePP(Move3, 0);
|
|
|
|
|
pk.Move4_PP = pk.GetMovePP(Move4, 0);
|
2016-04-17 20:52:37 +00:00
|
|
|
|
|
2016-11-17 17:12:17 +00:00
|
|
|
|
pk.MetDate = Date ?? DateTime.Now;
|
|
|
|
|
|
2017-01-30 23:37:22 +00:00
|
|
|
|
if (SAV.Generation > 6 && OriginGame == 0) // Gen7
|
2016-04-17 20:52:37 +00:00
|
|
|
|
{
|
2016-11-17 17:12:17 +00:00
|
|
|
|
pk.Version = (int)GameVersion.OR;
|
2016-04-17 20:52:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-27 03:07:20 +00:00
|
|
|
|
if (pk.CurrentHandler == 0) // OT
|
|
|
|
|
{
|
|
|
|
|
pk.OT_Memory = 3;
|
|
|
|
|
pk.OT_TextVar = 9;
|
|
|
|
|
pk.OT_Intensity = 1;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.OT_Feeling = Util.Rand.Next(0, 9);
|
2015-11-27 03:07:20 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pk.HT_Memory = 3;
|
|
|
|
|
pk.HT_TextVar = 9;
|
|
|
|
|
pk.HT_Intensity = 1;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.HT_Feeling = Util.Rand.Next(0, 9);
|
2015-11-27 03:07:20 +00:00
|
|
|
|
pk.HT_Friendship = pk.OT_Friendship;
|
|
|
|
|
}
|
2015-11-26 15:49:44 +00:00
|
|
|
|
pk.IsNicknamed = IsNicknamed;
|
2017-06-21 05:53:39 +00:00
|
|
|
|
pk.Nickname = IsNicknamed ? Nickname : PKX.GetSpeciesNameGeneration(Species, pk.Language, Format);
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
|
|
|
|
// More 'complex' logic to determine final values
|
|
|
|
|
|
|
|
|
|
// Dumb way to generate random IVs.
|
|
|
|
|
int[] finalIVs = new int[6];
|
2015-12-03 04:42:16 +00:00
|
|
|
|
switch (IVs[0])
|
2015-11-26 15:49:44 +00:00
|
|
|
|
{
|
2015-12-03 04:42:16 +00:00
|
|
|
|
case 0xFE:
|
2017-03-16 10:01:42 +00:00
|
|
|
|
do { // 3 Perfect IVs
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
finalIVs[i] = IVs[i] > 31 ? (int)(Util.Rand32() & 0x1F) : IVs[i];
|
2017-03-16 10:01:42 +00:00
|
|
|
|
} while (finalIVs.Count(r => r == 31) < 3); // 3*31
|
2015-12-03 04:42:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case 0xFD:
|
2015-12-05 19:29:16 +00:00
|
|
|
|
do { // 2 other 31s
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
finalIVs[i] = IVs[i] > 31 ? (int)(Util.Rand32() & 0x1F) : IVs[i];
|
2015-12-05 19:29:16 +00:00
|
|
|
|
} while (finalIVs.Count(r => r == 31) < 2); // 2*31
|
2015-12-03 04:42:16 +00:00
|
|
|
|
break;
|
|
|
|
|
default: // Random IVs
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
2017-06-18 01:37:19 +00:00
|
|
|
|
finalIVs[i] = IVs[i] > 31 ? (int)(Util.Rand32() & 0x1F) : IVs[i];
|
2015-12-03 04:42:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2015-11-26 15:49:44 +00:00
|
|
|
|
pk.IVs = finalIVs;
|
|
|
|
|
|
|
|
|
|
int av = 0;
|
|
|
|
|
switch (AbilityType)
|
|
|
|
|
{
|
|
|
|
|
case 00: // 0 - 0
|
|
|
|
|
case 01: // 1 - 1
|
|
|
|
|
case 02: // 2 - H
|
|
|
|
|
av = AbilityType;
|
|
|
|
|
break;
|
|
|
|
|
case 03: // 0/1
|
|
|
|
|
case 04: // 0/1/H
|
2017-06-18 01:37:19 +00:00
|
|
|
|
av = (int)(Util.Rand32()%(AbilityType - 1));
|
2015-11-26 15:49:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2017-05-17 03:34:24 +00:00
|
|
|
|
pk.Ability = pi.Abilities[av];
|
2015-11-26 15:49:44 +00:00
|
|
|
|
pk.AbilityNumber = 1 << av;
|
|
|
|
|
|
|
|
|
|
switch (PIDType)
|
|
|
|
|
{
|
|
|
|
|
case 00: // Specified
|
|
|
|
|
pk.PID = PID;
|
|
|
|
|
break;
|
|
|
|
|
case 01: // Random
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.PID = Util.Rand32();
|
2015-11-26 15:49:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 02: // Random Shiny
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.PID = Util.Rand32();
|
2015-12-03 02:18:23 +00:00
|
|
|
|
pk.PID = (uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF));
|
2015-11-26 15:49:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 03: // Random Nonshiny
|
2017-06-18 01:37:19 +00:00
|
|
|
|
pk.PID = Util.Rand32();
|
2017-03-16 10:02:54 +00:00
|
|
|
|
if ((uint)(((TID ^ SID ^ (pk.PID & 0xFFFF)) << 16) + (pk.PID & 0xFFFF)) < 16) pk.PID ^= 0x10000000;
|
2015-11-26 15:49:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsEgg)
|
|
|
|
|
{
|
|
|
|
|
pk.IsEgg = true;
|
2016-08-10 14:02:31 +00:00
|
|
|
|
pk.EggMetDate = Date;
|
2017-07-14 04:05:20 +00:00
|
|
|
|
pk.Nickname = PKX.GetSpeciesNameGeneration(0, pk.Language, Format);
|
|
|
|
|
pk.IsNicknamed = true;
|
2015-11-26 15:49:44 +00:00
|
|
|
|
}
|
2017-07-14 04:05:20 +00:00
|
|
|
|
pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship;
|
2015-11-26 15:49:44 +00:00
|
|
|
|
|
|
|
|
|
pk.RefreshChecksum();
|
|
|
|
|
return pk;
|
|
|
|
|
}
|
2015-11-22 21:38:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|