2019-03-15 19:35:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2016-11-10 16:14:54 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.Core
|
2016-11-10 16:14:54 +00:00
|
|
|
|
{
|
2019-10-04 02:09:02 +00:00
|
|
|
|
public sealed class BV7 : BattleVideo
|
2016-11-10 16:14:54 +00:00
|
|
|
|
{
|
|
|
|
|
internal const int SIZE = 0x2BC0;
|
2018-09-15 05:37:47 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
internal new static bool IsValid(byte[] data)
|
2016-11-10 16:14:54 +00:00
|
|
|
|
{
|
|
|
|
|
return data.Length == SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BV7(byte[] data)
|
|
|
|
|
{
|
|
|
|
|
Data = (byte[])data.Clone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly byte[] Data;
|
|
|
|
|
public override PKM[] BattlePKMs => PlayerTeams.SelectMany(t => t).ToArray();
|
|
|
|
|
public override int Generation => 7;
|
|
|
|
|
|
|
|
|
|
private PKM[][] PlayerTeams
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var Teams = new PKM[4][];
|
|
|
|
|
int[] offsets = {0xE41, 0x145E, 0x1A7B, 0x2098};
|
|
|
|
|
for (int t = 0; t < 4; t++)
|
|
|
|
|
{
|
|
|
|
|
Teams[t] = new PKM[6];
|
|
|
|
|
for (int p = 0; p < 6; p++)
|
|
|
|
|
{
|
2020-01-04 22:48:39 +00:00
|
|
|
|
int offset = offsets[t] + (PokeCrypto.SIZE_6PARTY * p);
|
|
|
|
|
Teams[t][p] = new PK7(Data.Slice(offset, PokeCrypto.SIZE_6STORED)) {Identifier = $"Team {t}, Slot {p}"};
|
2016-11-10 16:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Teams;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
var Teams = value;
|
|
|
|
|
int[] offsets = { 0xE41, 0x145E, 0x1A7B, 0x2098 };
|
|
|
|
|
for (int t = 0; t < 4; t++)
|
|
|
|
|
{
|
|
|
|
|
for (int p = 0; p < 6; p++)
|
|
|
|
|
{
|
2020-01-04 22:48:39 +00:00
|
|
|
|
int offset = offsets[t] + (PokeCrypto.SIZE_6PARTY * p);
|
2016-11-10 16:14:54 +00:00
|
|
|
|
Teams[t][p].EncryptedPartyData.CopyTo(Data, offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-12 06:29:30 +00:00
|
|
|
|
|
2019-03-15 19:35:55 +00:00
|
|
|
|
private const string NPC = "NPC";
|
|
|
|
|
|
|
|
|
|
public string[] PlayerNames
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
string[] trainers = new string[4];
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
trainers[i] = Util.TrimFromZero(Encoding.Unicode.GetString(Data, 0x12C + (0x1A * i), 0x1A));
|
|
|
|
|
if (string.IsNullOrWhiteSpace(trainers[i]))
|
|
|
|
|
trainers[i] = NPC;
|
|
|
|
|
}
|
|
|
|
|
return trainers;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-01-19 00:57:25 +00:00
|
|
|
|
if (value.Length != 4)
|
2019-03-15 19:35:55 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
string tr = value[i] == NPC ? string.Empty : value[i];
|
|
|
|
|
Encoding.Unicode.GetBytes(tr.PadRight(0x1A / 2)).CopyTo(Data, 0xEC + (0x1A * i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int MatchYear { get => BitConverter.ToUInt16(Data, 0x2BB0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x2BB0); }
|
|
|
|
|
private int MatchDay { get => Data[0x2BB3]; set => Data[0x2BB3] = (byte)value; }
|
|
|
|
|
private int MatchMonth { get => Data[0x2BB2]; set => Data[0x2BB2] = (byte)value; }
|
|
|
|
|
private int MatchHour { get => Data[0x2BB4]; set => Data[0x2BB4] = (byte)value; }
|
|
|
|
|
private int MatchMinute { get => Data[0x2BB5]; set => Data[0x2BB5] = (byte)value; }
|
|
|
|
|
private int MatchSecond { get => Data[0x2BB6]; set => Data[0x2BB6] = (byte)value; }
|
|
|
|
|
|
|
|
|
|
public DateTime? MatchStamp
|
|
|
|
|
{
|
|
|
|
|
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 = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 03:32:36 +00:00
|
|
|
|
public int MusicID { get => Data[0x21C]; set => Data[0x21C] = (byte)value; }
|
|
|
|
|
public bool SilentBGM { get => MusicID == 0xFF; set => MusicID = (byte)(value ? 0xFF : MusicID); }
|
2016-11-10 16:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|