mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-22 17:53:54 -05:00
Misc updates
condense some logic
This commit is contained in:
@@ -94,8 +94,8 @@ private void VerifyG1TradeEvo(LegalityAnalysis data)
|
||||
if (!mustevolve)
|
||||
return;
|
||||
// Pokemon have been traded but it is not evolved, trade evos are sequential dex numbers
|
||||
var unevolved = LegalityAnalysis.SpeciesStrings[pkm.Species];
|
||||
var evolved = LegalityAnalysis.SpeciesStrings[pkm.Species + 1];
|
||||
var unevolved = LegalityAnalysis.SpeciesStrings[pkm.Species];
|
||||
data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,26 +380,13 @@ public override InventoryPouch[] Inventory
|
||||
new InventoryPouchGB(InventoryType.PCItems, legalItems, 99, Offsets.PCItems, 50)
|
||||
};
|
||||
foreach (var p in pouch)
|
||||
{
|
||||
p.GetPouch(Data);
|
||||
}
|
||||
return pouch;
|
||||
}
|
||||
set
|
||||
{
|
||||
foreach (var p in value)
|
||||
{
|
||||
int ofs = 0;
|
||||
for (int i = 0; i < p.Count; i++)
|
||||
{
|
||||
while (p.Items[ofs].Count == 0)
|
||||
ofs++;
|
||||
p.Items[i] = p.Items[ofs++];
|
||||
}
|
||||
while (ofs < p.Items.Length)
|
||||
p.Items[ofs++] = new InventoryItem();
|
||||
p.SetPouch(Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,6 @@ public SAV2(byte[] data = null, GameVersion versionOverride = GameVersion.Any)
|
||||
pkDat.CopyTo(Data, dest);
|
||||
}
|
||||
|
||||
// Daycare currently undocumented for all Gen II games.
|
||||
if (Offsets.Daycare >= 0)
|
||||
{
|
||||
int offset = Offsets.Daycare;
|
||||
@@ -437,26 +436,13 @@ public override InventoryPouch[] Inventory
|
||||
new InventoryPouchGB(InventoryType.PCItems, LegalItems.Concat(LegalKeyItems).Concat(LegalBalls).Concat(LegalTMHMs).ToArray(), 99, Offsets.PouchPC, 50)
|
||||
};
|
||||
foreach (var p in pouch)
|
||||
{
|
||||
p.GetPouch(Data);
|
||||
}
|
||||
return pouch;
|
||||
}
|
||||
set
|
||||
{
|
||||
foreach (var p in value)
|
||||
{
|
||||
int ofs = 0;
|
||||
for (int i = 0; i < p.Count; i++)
|
||||
{
|
||||
while (p.Items[ofs].Count == 0)
|
||||
ofs++;
|
||||
p.Items[i] = p.Items[ofs++];
|
||||
}
|
||||
while (ofs < p.Items.Length)
|
||||
p.Items[ofs++] = new InventoryItem();
|
||||
p.SetPouch(Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,9 @@ public override void SetPouch(byte[] Data)
|
||||
{
|
||||
if (Items.Length != PouchDataSize)
|
||||
throw new ArgumentException("Item array length does not match original pouch size.");
|
||||
|
||||
SlideItemsDown();
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case InventoryType.TMHMs:
|
||||
@@ -107,5 +110,18 @@ public override void SetPouch(byte[] Data)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SlideItemsDown()
|
||||
{
|
||||
int ofs = 0;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
while (Items[ofs].Count == 0)
|
||||
ofs++;
|
||||
Items[i] = Items[ofs++];
|
||||
}
|
||||
while (ofs < Items.Length)
|
||||
Items[ofs++] = new InventoryItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user