mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 18:08:31 -05:00
Add $suggest for friendship properties
This commit is contained in:
@@ -41,6 +41,9 @@ public static class BatchMods
|
||||
new TypeSuggestion<PKM>(nameof(PKM.Move3_PP), p => p.SetSuggestedMovePP(2)),
|
||||
new TypeSuggestion<PKM>(nameof(PKM.Move4_PP), p => p.SetSuggestedMovePP(3)),
|
||||
|
||||
new ComplexSuggestion(nameof(PKM.CurrentFriendship), (_, _, info) => BatchModifications.SetSuggestedCurrentFriendship(info)),
|
||||
new ComplexSuggestion(nameof(PKM.OriginalTrainerFriendship), (_, _, info) => BatchModifications.SetSuggestedOriginalTrainerFriendship(info)),
|
||||
new ComplexSuggestion(nameof(PKM.HandlingTrainerFriendship), (_, _, info) => BatchModifications.SetSuggestedHandlingTrainerFriendship(info)),
|
||||
new ComplexSuggestion(nameof(PKM.Moves), (_, _, info) => BatchModifications.SetSuggestedMoveset(info)),
|
||||
new ComplexSuggestion(PROP_EVS, (_, _, info) => BatchModifications.SetEVs(info.Entity)),
|
||||
new ComplexSuggestion(nameof(PKM.RelearnMoves), (_, value, info) => BatchModifications.SetSuggestedRelearnData(info, value)),
|
||||
|
||||
@@ -145,4 +145,25 @@ public static ModifyResult SetContestStats(PKM pk, LegalityAnalysis la, ReadOnly
|
||||
pk.SetSuggestedContestStats(la.EncounterMatch, la.Info.EvoChainsAllGens);
|
||||
return ModifyResult.Modified;
|
||||
}
|
||||
|
||||
public static ModifyResult SetSuggestedCurrentFriendship(BatchInfo info)
|
||||
{
|
||||
var pk = info.Entity;
|
||||
pk.CurrentFriendship = HistoryVerifier.GetSuggestedFriendshipCurrent(pk, info.Legality.EncounterMatch);
|
||||
return ModifyResult.Modified;
|
||||
}
|
||||
|
||||
public static ModifyResult SetSuggestedOriginalTrainerFriendship(BatchInfo info)
|
||||
{
|
||||
var pk = info.Entity;
|
||||
pk.OriginalTrainerFriendship = HistoryVerifier.GetSuggestedFriendshipOT(pk, info.Legality.EncounterMatch);
|
||||
return ModifyResult.Modified;
|
||||
}
|
||||
|
||||
public static ModifyResult SetSuggestedHandlingTrainerFriendship(BatchInfo info)
|
||||
{
|
||||
var pk = info.Entity;
|
||||
pk.HandlingTrainerFriendship = HistoryVerifier.GetSuggestedFriendshipHT(pk);
|
||||
return ModifyResult.Modified;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,47 @@ public override void Verify(LegalityAnalysis data)
|
||||
VerifyHTMisc(data);
|
||||
}
|
||||
|
||||
public static byte GetSuggestedFriendshipCurrent(PKM pk, IEncounterTemplate enc)
|
||||
{
|
||||
if (pk.CurrentHandler == 0)
|
||||
return GetSuggestedFriendshipOT(pk, enc);
|
||||
return GetSuggestedFriendshipHT(pk);
|
||||
}
|
||||
|
||||
public static byte GetSuggestedFriendshipOT(PKM pk, IEncounterTemplate enc)
|
||||
{
|
||||
if (pk.IsEgg)
|
||||
return enc is IHatchCycle h ? h.EggCycles : pk.PersonalInfo.HatchCycles;
|
||||
|
||||
if (pk.Format <= 2)
|
||||
return GetSuggestedFriendshipByMove(pk);
|
||||
// VC transfers use S/M personal info
|
||||
if (enc is EncounterTransfer7 t7)
|
||||
return PersonalTable.SM[t7.Species].BaseFriendship;
|
||||
|
||||
// 3+
|
||||
bool neverOT = !GetCanOTHandle(enc, pk, enc.Generation);
|
||||
if (neverOT)
|
||||
return (byte)GetBaseFriendship(enc);
|
||||
return GetSuggestedFriendshipByMove(pk);
|
||||
}
|
||||
|
||||
public static byte GetSuggestedFriendshipHT(PKM pk)
|
||||
{
|
||||
if (pk.IsUntraded)
|
||||
return 0;
|
||||
return GetSuggestedFriendshipByMove(pk);
|
||||
}
|
||||
|
||||
private static byte GetSuggestedFriendshipByMove(PKM pk)
|
||||
{
|
||||
if (pk.HasMove((ushort)Move.Return))
|
||||
return byte.MaxValue;
|
||||
if (pk.HasMove((ushort)Move.Frustration))
|
||||
return 0;
|
||||
return pk.PersonalInfo.BaseFriendship;
|
||||
}
|
||||
|
||||
private void VerifyTradeState(LegalityAnalysis data)
|
||||
{
|
||||
var pk = data.Entity;
|
||||
|
||||
Reference in New Issue
Block a user