Simplify max item count give/modify

999 is true max, set suggested give count to -4 from max (or 1).
Apply giveAll's max value restriction to modifyAll
Prevent giveall/modifyall for PCItems/FreeSpace due to mixed item types.

Closes #1228
Closes #1227
This commit is contained in:
Kurt 2017-06-14 18:43:28 -07:00
parent 86720b547b
commit 8f833d8171
7 changed files with 56 additions and 47 deletions

View file

@ -383,7 +383,7 @@ namespace PKHeX.Core
{
get
{
int max = Version == GameVersion.FRLG ? 995 : 95;
int max = Version == GameVersion.FRLG ? 999 : 99;
var PCItems = new [] {LegalItems, LegalKeyItems, LegalKeyItems, LegalBalls, LegalTMHMs, LegalBerries}.SelectMany(a => a).ToArray();
InventoryPouch[] pouch =
{

View file

@ -365,12 +365,12 @@ namespace PKHeX.Core
{
InventoryPouch[] pouch =
{
new InventoryPouch(InventoryType.Items, LegalItems, 995, OFS_PouchHeldItem, 20), // 20 COLO, 30 XD
new InventoryPouch(InventoryType.Items, LegalItems, 999, OFS_PouchHeldItem, 20), // 20 COLO, 30 XD
new InventoryPouch(InventoryType.KeyItems, LegalKeyItems, 1, OFS_PouchKeyItem, 43),
new InventoryPouch(InventoryType.Balls, LegalBalls, 995, OFS_PouchBalls, 16),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 995, OFS_PouchTMHM, 64),
new InventoryPouch(InventoryType.Berries, LegalBerries, 995, OFS_PouchBerry, 46),
new InventoryPouch(InventoryType.Medicine, LegalCologne, 995, OFS_PouchCologne, 3), // Cologne
new InventoryPouch(InventoryType.Balls, LegalBalls, 999, OFS_PouchBalls, 16),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 999, OFS_PouchTMHM, 64),
new InventoryPouch(InventoryType.Berries, LegalBerries, 999, OFS_PouchBerry, 46),
new InventoryPouch(InventoryType.Medicine, LegalCologne, 999, OFS_PouchCologne, 3), // Cologne
};
foreach (var p in pouch)
p.getPouchBigEndian(ref Data);

View file

@ -329,13 +329,13 @@ namespace PKHeX.Core
{
InventoryPouch[] pouch =
{
new InventoryPouch(InventoryType.Items, LegalItems, 995, OFS_PouchHeldItem, 30), // 20 COLO, 30 XD
new InventoryPouch(InventoryType.Items, LegalItems, 999, OFS_PouchHeldItem, 30), // 20 COLO, 30 XD
new InventoryPouch(InventoryType.KeyItems, LegalKeyItems, 1, OFS_PouchKeyItem, 43),
new InventoryPouch(InventoryType.Balls, LegalBalls, 995, OFS_PouchBalls, 16),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 995, OFS_PouchTMHM, 64),
new InventoryPouch(InventoryType.Berries, LegalBerries, 995, OFS_PouchBerry, 46),
new InventoryPouch(InventoryType.Medicine, LegalCologne, 995, OFS_PouchCologne, 3), // Cologne
new InventoryPouch(InventoryType.BattleItems, LegalDisc, 995, OFS_PouchDisc, 60)
new InventoryPouch(InventoryType.Balls, LegalBalls, 999, OFS_PouchBalls, 16),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 999, OFS_PouchTMHM, 64),
new InventoryPouch(InventoryType.Berries, LegalBerries, 999, OFS_PouchBerry, 46),
new InventoryPouch(InventoryType.Medicine, LegalCologne, 999, OFS_PouchCologne, 3), // Cologne
new InventoryPouch(InventoryType.BattleItems, LegalDisc, 999, OFS_PouchDisc, 60)
};
foreach (var p in pouch)
p.getPouchBigEndian(ref Data);

View file

@ -286,14 +286,14 @@ namespace PKHeX.Core
{
InventoryPouch[] pouch =
{
new InventoryPouch(InventoryType.Items, LegalItems, 995, OFS_PouchHeldItem),
new InventoryPouch(InventoryType.Items, LegalItems, 999, OFS_PouchHeldItem),
new InventoryPouch(InventoryType.KeyItems, LegalKeyItems, 1, OFS_PouchKeyItem),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 95, OFS_PouchTMHM),
new InventoryPouch(InventoryType.Medicine, LegalMedicine, 995, OFS_PouchMedicine),
new InventoryPouch(InventoryType.Berries, LegalBerries, 995, OFS_PouchBerry),
new InventoryPouch(InventoryType.Balls, LegalBalls, 995, OFS_PouchBalls),
new InventoryPouch(InventoryType.BattleItems, LegalBattleItems, 995, OFS_BattleItems),
new InventoryPouch(InventoryType.MailItems, LegalMailItems, 995, OFS_MailItems),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 99, OFS_PouchTMHM),
new InventoryPouch(InventoryType.Medicine, LegalMedicine, 999, OFS_PouchMedicine),
new InventoryPouch(InventoryType.Berries, LegalBerries, 999, OFS_PouchBerry),
new InventoryPouch(InventoryType.Balls, LegalBalls, 999, OFS_PouchBalls),
new InventoryPouch(InventoryType.BattleItems, LegalBattleItems, 999, OFS_BattleItems),
new InventoryPouch(InventoryType.MailItems, LegalMailItems, 999, OFS_MailItems),
};
foreach (var p in pouch)
p.getPouch(ref Data);

View file

@ -412,11 +412,11 @@ namespace PKHeX.Core
{
InventoryPouch[] pouch =
{
new InventoryPouch(InventoryType.Items, LegalItems, 995, OFS_PouchHeldItem),
new InventoryPouch(InventoryType.Items, LegalItems, 999, OFS_PouchHeldItem),
new InventoryPouch(InventoryType.KeyItems, LegalKeyItems, 1, OFS_PouchKeyItem),
new InventoryPouch(InventoryType.TMHMs, LegalTMHMs, 1, OFS_PouchTMHM),
new InventoryPouch(InventoryType.Medicine, LegalMedicine, 995, OFS_PouchMedicine),
new InventoryPouch(InventoryType.Berries, LegalBerries, 995, OFS_PouchBerry),
new InventoryPouch(InventoryType.Medicine, LegalMedicine, 999, OFS_PouchMedicine),
new InventoryPouch(InventoryType.Berries, LegalBerries, 999, OFS_PouchBerry),
};
foreach (var p in pouch)
p.getPouch(ref Data);

View file

@ -691,11 +691,11 @@ namespace PKHeX.Core
ushort[] legalMedicine = ORAS ? Legal.Pouch_Medicine_AO : Legal.Pouch_Medicine_XY;
InventoryPouch[] pouch =
{
new InventoryPouch(InventoryType.Items, legalItems, 995, OFS_PouchHeldItem),
new InventoryPouch(InventoryType.Items, legalItems, 999, OFS_PouchHeldItem),
new InventoryPouch(InventoryType.KeyItems, legalKey, 1, OFS_PouchKeyItem),
new InventoryPouch(InventoryType.TMHMs, legalTMHM, 1, OFS_PouchTMHM),
new InventoryPouch(InventoryType.Medicine, legalMedicine, 995, OFS_PouchMedicine),
new InventoryPouch(InventoryType.Berries, Legal.Pouch_Berry_XY, 995, OFS_PouchBerry),
new InventoryPouch(InventoryType.Medicine, legalMedicine, 999, OFS_PouchMedicine),
new InventoryPouch(InventoryType.Berries, Legal.Pouch_Berry_XY, 999, OFS_PouchBerry),
};
foreach (var p in pouch)
p.getPouch(ref Data);

View file

@ -248,7 +248,19 @@ namespace PKHeX.WinForms
else
NUD_Count.Maximum = pouch.MaxCount;
NUD_Count.Value = pouch.Type == InventoryType.KeyItems ? 1 : pouch.MaxCount;
bool disable = pouch.Type == InventoryType.PCItems || pouch.Type == InventoryType.FreeSpace;
NUD_Count.Visible = L_Count.Visible = B_GiveAll.Visible = !disable;
if (disable && !Main.HaX)
{
giveMenu.Items.Remove(giveAll);
giveMenu.Items.Remove(giveModify);
}
else if (!giveMenu.Items.Contains(giveAll))
{
giveMenu.Items.Insert(0, giveAll);
giveMenu.Items.Add(giveModify);
}
NUD_Count.Value = Math.Max(1, pouch.MaxCount - 4);
}
// Initialize String Tables
@ -297,30 +309,13 @@ namespace PKHeX.WinForms
int Count = (int)NUD_Count.Value;
for (int i = 0; i < legalitems.Length; i++)
{
int item = legalitems[i];
ushort item = legalitems[i];
var itemname = itemlist[item];
int c = Count;
// Override for HMs
switch (SAV.Generation)
{
case 1:
if (197 >= item && item <= 201)
c = 1;
break;
case 2:
if (item >= 244)
c = 1;
break;
case 3:
if (Legal.Pouch_HM_RS.Contains(legalitems[i]))
c = 1;
break;
default:
if (new[] { 420, 421, 422, 423, 423, 424, 425, 426, 427, 737 }.Contains(legalitems[i]))
c = 1;
break;
}
if (getIsCappedItemCount(item, SAV))
c = 1;
int l = 0;
dgv.Rows[i].Cells[l++].Value = itemname;
@ -334,6 +329,20 @@ namespace PKHeX.WinForms
}
System.Media.SystemSounds.Asterisk.Play();
}
private static bool getIsCappedItemCount(ushort item, SaveFile sav)
{
switch (sav.Generation)
{
case 1:
return 196 >= item && item <= 200; // HMs
case 2:
return item >= 244;
case 3:
return Legal.Pouch_HM_RS.Contains(item);
default:
return new[] {420, 421, 422, 423, 423, 424, 425, 426, 427, 737}.Contains(item);
}
}
private void removeAllItems(object sender, EventArgs e)
{
// Get Current Pouch
@ -369,7 +378,7 @@ namespace PKHeX.WinForms
string item = dgv.Rows[i].Cells[0].Value.ToString();
int itemindex = Array.IndexOf(itemlist, item);
if (itemindex > 0)
dgv.Rows[i].Cells[1].Value = NUD_Count.Value;
dgv.Rows[i].Cells[1].Value = getIsCappedItemCount((ushort)itemindex, SAV) ? 1 : NUD_Count.Value;
}
WinFormsUtil.Alert("Item count modified.");