mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-23 19:27:16 -05:00
Disallow raids matching if has mark
Closes #3133 not an ideal solution, but the encounter matching API is kinda limited in deferred-invalid vs deferred-notIdeal. probably need to unify the match logic and generators so they can cache one secondary-check invalid
This commit is contained in:
parent
5f8e2b13c5
commit
acfbef6cfa
|
|
@ -34,6 +34,9 @@ public override bool IsMatch(PKM pkm, DexLevel evo)
|
|||
if (VerifyCorrelation != null && !VerifyCorrelation(pkm, (T)this))
|
||||
return false;
|
||||
|
||||
if (pkm is IRibbonSetMark8 m8 && m8.HasMark())
|
||||
return false;
|
||||
|
||||
return base.IsMatch(pkm, evo);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,11 +25,8 @@ public override void Verify(LegalityAnalysis data)
|
|||
|
||||
private void VerifyNoMarksPresent(LegalityAnalysis data, IRibbonIndex m)
|
||||
{
|
||||
for (var x = RibbonIndex.MarkLunchtime; x <= RibbonIndex.MarkSlump; x++)
|
||||
{
|
||||
if (m.GetRibbon((int)x))
|
||||
data.AddLine(GetInvalid(string.Format(LRibbonMarkingFInvalid_0, x)));
|
||||
}
|
||||
if (m.HasMark(out var x))
|
||||
data.AddLine(GetInvalid(string.Format(LRibbonMarkingFInvalid_0, x)));
|
||||
}
|
||||
|
||||
private void VerifyMarksPresent(LegalityAnalysis data, IRibbonIndex m)
|
||||
|
|
|
|||
|
|
@ -186,6 +186,19 @@ public override int HeldItem
|
|||
private const int RibbonBytesCount = 0x20;
|
||||
private const int RibbonByteNone = 0xFF; // signed -1
|
||||
|
||||
public bool HasMark()
|
||||
{
|
||||
for (int i = 0; i < RibbonBytesCount; i++)
|
||||
{
|
||||
var val = Data[RibbonBytesOffset + i];
|
||||
if (val == RibbonByteNone)
|
||||
return false;
|
||||
if ((RibbonIndex)val is > MarkLunchtime and < MarkSlump)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte GetRibbonAtIndex(int byteIndex)
|
||||
{
|
||||
if ((uint)byteIndex >= RibbonBytesCount)
|
||||
|
|
|
|||
|
|
@ -347,6 +347,16 @@ public void Trade(ITrainerInfo tr, int Day = 1, int Month = 1, int Year = 2015)
|
|||
public bool RIB47_6 { get => FlagUtil.GetFlag(Data, 0x47, 6); set => FlagUtil.SetFlag(Data, 0x47, 6, value); }
|
||||
public bool RIB47_7 { get => FlagUtil.GetFlag(Data, 0x47, 7); set => FlagUtil.SetFlag(Data, 0x47, 7, value); }
|
||||
|
||||
public bool HasMark()
|
||||
{
|
||||
var d = Data;
|
||||
if ((BitConverter.ToUInt16(d, 0x3A) & 0xFFE0) != 0)
|
||||
return true;
|
||||
if (BitConverter.ToUInt32(d, 0x40) != 0)
|
||||
return true;
|
||||
return (d[0x44] & 3) != 0;
|
||||
}
|
||||
|
||||
public uint U48 { get => BitConverter.ToUInt32(Data, 0x48); set => BitConverter.GetBytes(value).CopyTo(Data, 0x48); }
|
||||
|
||||
// 0x4C-0x4F unused
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ public interface IRibbonSetMark8
|
|||
bool RibbonMarkThorny { get; set; }
|
||||
bool RibbonMarkVigor { get; set; }
|
||||
bool RibbonMarkSlump { get; set; }
|
||||
|
||||
bool HasMark();
|
||||
}
|
||||
|
||||
internal static partial class RibbonExtensions
|
||||
|
|
|
|||
|
|
@ -110,5 +110,17 @@ public static class RibbonIndexExtensions
|
|||
{
|
||||
public static bool GetRibbonIndex(this IRibbonIndex x, RibbonIndex r) => x.GetRibbon((int)r);
|
||||
public static void SetRibbonIndex(this IRibbonIndex x, RibbonIndex r, bool value = true) => x.SetRibbon((int)r, value);
|
||||
|
||||
public static bool HasMark(this IRibbonIndex m, out RibbonIndex x)
|
||||
{
|
||||
for (x = RibbonIndex.MarkLunchtime; x <= RibbonIndex.MarkSlump; x++)
|
||||
{
|
||||
if (m.GetRibbon((int) x))
|
||||
return true;
|
||||
}
|
||||
|
||||
x = (RibbonIndex)0xFF;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user