Set Slot id to 3 if no pcd found

Closes #730
Adds ability to set a PCD to a PGT slot (grabs the PGT from card)
This commit is contained in:
Kurt
2017-01-20 08:43:41 -08:00
parent 492a29e950
commit 4f99ef6c09
2 changed files with 14 additions and 6 deletions

View File

@@ -203,7 +203,10 @@ private void clickSet(object sender, EventArgs e)
int lastUnfilled = getLastUnfilledByType(mg, mga);
if (lastUnfilled > -1 && lastUnfilled < index)
index = lastUnfilled;
if (mg.Type != mga.Gifts[index].Type)
if (mg is PCD && mga.Gifts[index] is PGT)
mg = (mg as PCD).Gift;
else if (mg.Type != mga.Gifts[index].Type)
{
WinFormsUtil.Alert("Can't set slot here.", $"{mg.Type} != {mga.Gifts[index].Type}");
return;
@@ -417,14 +420,18 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
{ WinFormsUtil.Alert("Data size invalid.", files[0]); return; }
byte[] data = File.ReadAllBytes(files[0]);
if (data.Length != mga.Gifts[index].Data.Length)
MysteryGift mg = MysteryGift.getMysteryGift(data, new FileInfo(files[0]).Extension);
if (mg is PCD && mga.Gifts[index] is PGT)
mg = (mg as PCD).Gift;
else if (mg.Type != mga.Gifts[index].Type)
{
WinFormsUtil.Alert("Can't set slot here.",
$"{data.Length} != {mga.Gifts[index].Data.Length}, {mga.Gifts[index].Type}", files[0]);
WinFormsUtil.Alert("Can't set slot here.", $"{mg.Type} != {mga.Gifts[index].Type}");
return;
}
mga.Gifts[index].Data = data;
setBackground(index, Core.Properties.Resources.slotSet);
mga.Gifts[index] = mg.Clone();
setCardID(mga.Gifts[index].CardID);
viewGiftData(mga.Gifts[index]);
}

View File

@@ -605,6 +605,7 @@ private static int[] matchMysteryGifts(MysteryGift[] value)
if (pgt == null)
continue;
cardMatch[i] = pgt.Slot = 3;
for (byte j = 0; j < 3; j++)
{
var pcd = value[8 + j] as PCD;