Add bvid util

This commit is contained in:
Kurt 2018-08-18 20:10:30 -07:00
parent 3dad767d15
commit a200dc85c7
8 changed files with 187 additions and 29 deletions

View File

@ -22,40 +22,38 @@ public BV6(byte[] data)
private readonly byte[] Data;
private int Mode { get => Data[0x00]; set => Data[0x00] = (byte)value; }
private static readonly string[] BVmode =
{
"Link", "Maison", "Super Maison", "Battle Spot - Free", "Battle Spot - Rating",
"Battle Spot - Special", "UNUSED", "JP-1", "JP-2", "BROKEN",
};
private int Style { get => Data[0x01]; set => Data[0x01] = (byte)value; }
private static readonly string[] BVstyle = { "Single", "Double", "Triple", "Rotation", "Multi", };
private string Debug1
public int Mode { get => Data[0x00]; set => Data[0x00] = (byte)value; }
public int Style { get => Data[0x01]; set => Data[0x01] = (byte)value; }
public string Debug1
{
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x6, 24));
set => Encoding.Unicode.GetBytes(value.PadRight(12, '\0')).CopyTo(Data, 0x6);
}
private string Debug2
public string Debug2
{
get => Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x50, 24));
set => Encoding.Unicode.GetBytes(value.PadRight(12, '\0')).CopyTo(Data, 0x50);
}
private ulong RNGConst1 { get => BitConverter.ToUInt64(Data, 0x1A0); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1A0); }
private ulong RNGConst2 { get => BitConverter.ToUInt64(Data, 0x1A4); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1A4); }
private ulong RNGSeed1 { get => BitConverter.ToUInt64(Data, 0x1A8); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1A8); }
private ulong RNGSeed2 { get => BitConverter.ToUInt64(Data, 0x1B0); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1B0); }
private int Background { get => BitConverter.ToInt32(Data, 0x1BC); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1BC); }
private int _1CE { get => BitConverter.ToUInt16(Data, 0x1CE); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1CE); }
private int IntroID { get => BitConverter.ToUInt16(Data, 0x1E4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E4); }
private int MusicID { get => BitConverter.ToUInt16(Data, 0x1F0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1F0); }
public ulong RNGConst1 { get => BitConverter.ToUInt64(Data, 0x1A0); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1A0); }
public ulong RNGConst2 { get => BitConverter.ToUInt64(Data, 0x1A4); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1A4); }
public ulong RNGSeed1 { get => BitConverter.ToUInt64(Data, 0x1A8); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1A8); }
public ulong RNGSeed2 { get => BitConverter.ToUInt64(Data, 0x1B0); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1B0); }
public int Background { get => BitConverter.ToInt32(Data, 0x1BC); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1BC); }
public int _1CE { get => BitConverter.ToUInt16(Data, 0x1CE); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1CE); }
public int IntroID { get => BitConverter.ToUInt16(Data, 0x1E4); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1E4); }
public int MusicID { get => BitConverter.ToUInt16(Data, 0x1F0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1F0); }
public override PKM[] BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
public override int Generation => 6;
private const string NPC = "NPC";
private string[] PlayerNames
public string[] PlayerNames
{
get
{
@ -81,7 +79,7 @@ private string[] PlayerNames
}
}
private PKM[][] PlayerTeams
public PKM[][] PlayerTeams
{
get
{
@ -122,11 +120,7 @@ private PKM[][] PlayerTeams
private int MatchMinute { get => Data[0x2E55]; set => Data[0x2E55] = (byte)value; }
private int MatchSecond { get => Data[0x2E56]; set => Data[0x2E56] = (byte)value; }
private int MatchFlags { get => Data[0x2E57]; set => Data[0x2E57] = (byte)value; }
public DateTime MatchStamp
{
get => new DateTime(MatchYear, MatchMonth, MatchDay, MatchHour, MatchMinute, MatchSecond);
set { MatchYear = value.Year; MatchDay = value.Day; MatchMonth = value.Month; MatchHour = value.Hour; MatchMinute = value.Minute; MatchSecond = value.Second; }
}
private int UploadYear { get => BitConverter.ToUInt16(Data, 0x2E58); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2E58); }
private int UploadDay { get => Data[0x2E5A]; set => Data[0x2E5A] = (byte)value; }
private int UploadMonth { get => Data[0x2E5B]; set => Data[0x2E5B] = (byte)value; }
@ -135,10 +129,56 @@ public DateTime MatchStamp
private int UploadSecond { get => Data[0x2E5E]; set => Data[0x2E5E] = (byte)value; }
private int UploadFlags { get => Data[0x2E5F]; set => Data[0x2E5F] = (byte)value; }
public DateTime UploadStamp
public DateTime? MatchStamp
{
get => new DateTime(UploadYear, UploadMonth, UploadDay, UploadHour, UploadMinute, UploadSecond);
set { UploadYear = value.Year; UploadDay = value.Day; UploadMonth = value.Month; UploadHour = value.Hour; UploadMinute = value.Minute; UploadSecond = value.Second; }
get
{
if (!Util.IsDateValid(MatchYear, MatchMonth, MatchDay))
return null;
return new DateTime(MatchYear, MatchMonth, MatchDay, MatchHour, MatchMinute, MatchSecond);
}
set
{
if (value.HasValue)
{
MatchYear = value.Value.Year;
MatchDay = value.Value.Day;
MatchMonth = value.Value.Month;
MatchHour = value.Value.Hour;
MatchMinute = value.Value.Minute;
MatchSecond = value.Value.Second;
}
else
{
MatchYear = MatchDay = MatchMonth = MatchHour = MatchMinute = MatchSecond = MatchFlags = 0;
}
}
}
public DateTime? UploadStamp
{
get
{
if (!Util.IsDateValid(UploadYear, UploadMonth, UploadDay))
return null;
return new DateTime(UploadYear, UploadMonth, UploadDay, UploadHour, UploadMinute, UploadSecond);
}
set
{
if (value.HasValue)
{
UploadYear = value.Value.Year;
UploadDay = value.Value.Day;
UploadMonth = value.Value.Month;
UploadHour = value.Value.Hour;
UploadMinute = value.Value.Minute;
UploadSecond = value.Value.Second;
}
else
{
UploadYear = UploadDay = UploadMonth = UploadHour = UploadMinute = UploadSecond = UploadFlags = 0;
}
}
}
// Battle Instruction Parsing
@ -146,10 +186,17 @@ public DateTime UploadStamp
private static readonly string[] Target =
{
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Opposite Enemy", "B", "C", "D",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Opposite Enemy", "11", "12", "13",
"All except User", "Everyone"
};
private static readonly string[] Rotate = { "0", "Right", "Left", "3" };
public static readonly string[] BVmode =
{
"Link", "Maison", "Super Maison", "Battle Spot - Free", "Battle Spot - Rating",
"Battle Spot - Special", "UNUSED", "JP-1", "JP-2", "BROKEN",
};
public static readonly string[] BVstyle = { "Single", "Double", "Triple", "Rotation", "Multi", };
}
}

View File

@ -0,0 +1,16 @@
namespace PKHeX.Core
{
public enum BattleMode
{
Link,
Maison,
MaisonSuper,
BattleSpotFree,
BattleSpotRating,
BattleSpotSpecial,
UNUSED,
JP1,
JP2,
BAD,
}
}

View File

@ -0,0 +1,11 @@
namespace PKHeX.Core
{
public enum BattleStyle
{
Single,
Double,
Triple,
Rotation,
Multi,
}
}

View File

@ -0,0 +1,23 @@
namespace PKHeX.Core
{
public enum MoveTarget : byte
{
// Specific target
_0 = 0,
_1 = 1,
_2 = 2,
_3 = 3,
_4 = 4,
_5 = 5,
_6 = 6,
Self = 7,
_8 = 8,
_9 = 9,
// No pkm target
_10 = 10,
_11 = 11,
_12 = 12,
Counter = 13,
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PKHeX.Core
{
public enum RotateDirection
{
None,
Right,
Left,
}
}

View File

@ -0,0 +1,26 @@
namespace PKHeX.Core
{
public enum TurnActionCode
{
None = 0,
Fight = 1,
Switch = 3,
Run = 4,
UNK5 = 5,
Rotate = 6,
UNK7 = 7,
MegaEvolve = 8,
}
public struct TurnActionInstruction
{
public int PlayerID;
public int Count;
public TurnActionInstruction(byte Op)
{
PlayerID = Op >> 5;
Count = Op & 0xF;
}
}
}

View File

@ -0,0 +1,8 @@
namespace PKHeX.Core
{
public enum TurnStartCode
{
Fight = 1,
Switch = 9,
}
}

View File

@ -0,0 +1,14 @@
namespace PKHeX.Core
{
public struct TurnStartInstruction
{
public TurnStartCode TurnCode;
public int Count;
public TurnStartInstruction(byte Op)
{
TurnCode = (TurnStartCode)(Op >> 4);
Count = Op & 0xF;
}
}
}