mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Block parties without battleable pkms
#1257 not perfect but less restrictive, probably more obvious.
This commit is contained in:
parent
9efd49b0bc
commit
e697a9edc7
3 changed files with 37 additions and 15 deletions
|
@ -330,6 +330,14 @@ namespace PKHeX.Core
|
|||
public int SlotCount => BoxCount * BoxSlotCount;
|
||||
public virtual int PartyCount { get; protected set; }
|
||||
public virtual int MultiplayerSpriteID { get => 0; set { } }
|
||||
public bool IsPartyAllEggs(params int[] except)
|
||||
{
|
||||
if (!HasParty)
|
||||
return false;
|
||||
|
||||
var party = PartyData;
|
||||
return party.Length == party.Where((t, i) => t.IsEgg || except.Contains(i)).Count();
|
||||
}
|
||||
|
||||
// Varied Methods
|
||||
protected abstract void SetChecksums();
|
||||
|
|
|
@ -44,10 +44,10 @@ namespace PKHeX.WinForms.Controls
|
|||
|
||||
var editor = m.SE.PKME_Tabs;
|
||||
var sav = m.SE.SAV;
|
||||
if (info.Slot == 30 && editor.IsEmptyOrEgg)
|
||||
{ WinFormsUtil.Alert("Can't have empty/egg first info.Slot."); return; }
|
||||
if (info.IsParty && editor.IsEmptyOrEgg && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
|
||||
{ WinFormsUtil.Alert("Can't have empty/egg party."); return; }
|
||||
if (m.SE.SAV.IsSlotLocked(info.Box, info.Slot))
|
||||
{ WinFormsUtil.Alert("Can't set to locked info.Slot."); return; }
|
||||
{ WinFormsUtil.Alert("Can't set to locked slot."); return; }
|
||||
|
||||
PKM pk = editor.PreparePKM();
|
||||
|
||||
|
@ -97,8 +97,8 @@ namespace PKHeX.WinForms.Controls
|
|||
{ System.Media.SystemSounds.Asterisk.Play(); return; }
|
||||
|
||||
var sav = m.SE.SAV;
|
||||
if (info.Slot == 30 && sav.PartyCount == 1 && !m.SE.HaX)
|
||||
{ WinFormsUtil.Alert("Can't delete first slot."); return; }
|
||||
if (info.IsParty && sav.IsPartyAllEggs(info.Slot - 30) && !m.SE.HaX)
|
||||
{ WinFormsUtil.Alert("Can't delete this slot."); return; }
|
||||
if (sav.IsSlotLocked(info.Box, info.Slot))
|
||||
{ WinFormsUtil.Alert("Can't delete locked slot."); return; }
|
||||
|
||||
|
|
|
@ -200,22 +200,31 @@ namespace PKHeX.WinForms.Controls
|
|||
}
|
||||
if (SAV.IsSlotLocked(DragInfo.Destination.Box, DragInfo.Destination.Slot))
|
||||
{
|
||||
DragInfo.Destination.Slot = -1; // Invalidate
|
||||
WinFormsUtil.Alert("Unable to set to locked slot.");
|
||||
AlertInvalidate("Unable to set to locked slot.");
|
||||
return;
|
||||
}
|
||||
bool noEgg = DragInfo.Destination.IsParty && SE.SAV.IsPartyAllEggs(DragInfo.Destination.Slot - 30) && !SE.HaX;
|
||||
if (DragInfo.Source.Offset < 0) // external source
|
||||
{
|
||||
TryLoadFiles(files, e);
|
||||
if (!TryLoadFiles(files, e, noEgg))
|
||||
AlertInvalidate("Unable to set to this slot.");
|
||||
return;
|
||||
}
|
||||
if (!TrySetPKMDestination(sender, e, overwrite, clone, noEgg))
|
||||
{
|
||||
AlertInvalidate("Unable to set to this slot.");
|
||||
return;
|
||||
}
|
||||
|
||||
TrySetPKMDestination(sender, e, overwrite, clone);
|
||||
|
||||
if (DragInfo.Source.Parent == null) // internal file
|
||||
DragInfo.Reset();
|
||||
}
|
||||
private bool TryLoadFiles(string[] files, DragEventArgs e)
|
||||
private void AlertInvalidate(string msg)
|
||||
{
|
||||
DragInfo.Destination.Slot = -1; // Invalidate
|
||||
WinFormsUtil.Alert(msg);
|
||||
}
|
||||
private bool TryLoadFiles(string[] files, DragEventArgs e, bool noEgg)
|
||||
{
|
||||
if (files.Length <= 0)
|
||||
return false;
|
||||
|
@ -240,6 +249,9 @@ namespace PKHeX.WinForms.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
if (noEgg && (pk.Species == 0 || pk.IsEgg))
|
||||
return false;
|
||||
|
||||
string[] errata = SAV.IsPKMCompatible(pk);
|
||||
if (errata.Length > 0)
|
||||
{
|
||||
|
@ -256,19 +268,21 @@ namespace PKHeX.WinForms.Controls
|
|||
Console.WriteLine(c);
|
||||
return true;
|
||||
}
|
||||
private bool TrySetPKMDestination(object sender, DragEventArgs e, bool overwrite, bool clone)
|
||||
private bool TrySetPKMDestination(object sender, DragEventArgs e, bool overwrite, bool clone, bool noEgg)
|
||||
{
|
||||
PKM pkz = GetPKM(true);
|
||||
bool result = false;
|
||||
if (noEgg && (pkz.Species == 0 || pkz.IsEgg))
|
||||
return false;
|
||||
|
||||
if (DragInfo.Source.IsValid)
|
||||
result = TrySetPKMSource(sender, overwrite, clone);
|
||||
TrySetPKMSource(sender, overwrite, clone);
|
||||
|
||||
// Copy from temp to destination slot.
|
||||
SetPKM(pkz, false, null);
|
||||
|
||||
e.Effect = clone ? DragDropEffects.Copy : DragDropEffects.Link;
|
||||
SetCursor(SE.GetDefaultCursor, sender);
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
private bool TrySetPKMSource(object sender, bool overwrite, bool clone)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue