Skip to content

Commit

Permalink
Merge pull request #3382 from kwsch/pla
Browse files Browse the repository at this point in the history
Update 22.02.04
Individual commits from this PR are not cherry-pickable in a vacuum; these were manually re-committed from a staging repo in order to group together changes for general public viewing. There were over 250 commits on the private development repo for this update.
  • Loading branch information
kwsch committed Feb 5, 2022
2 parents b0197a8 + d4a6392 commit eed5bb0
Show file tree
Hide file tree
Showing 426 changed files with 19,646 additions and 2,664 deletions.
6 changes: 3 additions & 3 deletions .github/README-de.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ PKHeX erwartet Spielstände, die mit konsolenspezifischen Schlüsseln entschlüs

## Screenshots

![Main Window](https://i.imgur.com/ApbTkM0.png)
![Main Window](https://i.imgur.com/5421hUR.png)

## Erstellen

PKHeX ist eine Windows Forms Anwendung, die das [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137) benötigt, mit experimenteller Unterstützung für [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0).
PKHeX ist eine Windows Forms Anwendung, die das [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137) benötigt, mit experimenteller Unterstützung für [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0).

Die Anwendung kann mit jedem Kompiler erstellt werde, der C# 8 unterstützt.
Die Anwendung kann mit jedem Kompiler erstellt werde, der C# 10 unterstützt.

### Erstell Konfiguration

Expand Down
6 changes: 3 additions & 3 deletions .github/README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ PKHeX espera archivos de guardado que no estén cifrados con las claves específ

## Capturas de Pantalla

![Pantalla principal](https://i.imgur.com/tw9zZap.png)
![Pantalla principal](https://i.imgur.com/umit9S2.png)

## Building

PKHeX es una aplicación de Windows Forms que requiere [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137), con soporte experimental para [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0).
PKHeX es una aplicación de Windows Forms que requiere [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137), con soporte experimental para [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0).

El archivo ejecutable puede ser construido con cualquier compilador que soporte C# 8.
El archivo ejecutable puede ser construido con cualquier compilador que soporte C# 10.

### Configuraciones del Build

Expand Down
6 changes: 3 additions & 3 deletions .github/README-fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ PKHeX attend des fichiers de sauvegarde qui ne sont pas chiffrés avec des clés

## Captures d'écran

![Main Window](https://i.imgur.com/OqOD05v.png)
![Main Window](https://i.imgur.com/EhtQ14x.png)

## Construction

PKHeX est une application Windows Forms qui nécessite [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137), avec une prise en charge expérimentale de [.NET 5.0.](https://dotnet.microsoft.com/download/dotnet/5.0)
PKHeX est une application Windows Forms qui nécessite [.NET Framework v4.6](https://www.microsoft.com/en-us/download/details.aspx?id=48137), avec une prise en charge expérimentale de [.NET 6.0.](https://dotnet.microsoft.com/download/dotnet/6.0)

L'exécutable peut être construit avec n'importe quel compilateur prenant en charge C# 8.
L'exécutable peut être construit avec n'importe quel compilateur prenant en charge C# 10.

### Construire les configurations

Expand Down
71 changes: 71 additions & 0 deletions PKHeX.Core/Editing/Applicators/MoveShopRecordApplicator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;

namespace PKHeX.Core;

/// <summary>
/// Logic for modifying the Move Shop Record flags of a <see cref="PA8"/>.
/// </summary>
public static class MoveShopRecordApplicator
{
public static void ClearMoveShopFlags(this IMoveShop8 shop)
{
var bits = shop.MoveShopPermitFlags;
for (int i = 0; i < bits.Length; i++)
shop.SetPurchasedRecordFlag(i, false);

if (shop is IMoveShop8Mastery m)
m.ClearMoveShopFlagsMastered();
}

public static void ClearMoveShopFlagsMastered(this IMoveShop8Mastery shop)
{
var bits = shop.MoveShopPermitFlags;
for (int i = 0; i < bits.Length; i++)
shop.SetMasteredRecordFlag(i, false);
}

public static void SetMoveShopFlags(this IMoveShop8 shop, bool value, int max = 100)
{
var bits = shop.MoveShopPermitFlags;
max = Math.Min(bits.Length, max);
for (int i = 0; i < max; i++)
shop.SetPurchasedRecordFlag(i, value);
}

public static void SetMoveShopFlagsMastered(this IMoveShop8Mastery shop)
{
var bits = shop.MoveShopPermitFlags;
for (int i = 0; i < bits.Length; i++)
shop.SetMasteredRecordFlag(i, shop.GetPurchasedRecordFlag(i));
}

public static void SetMoveShopFlags(this IMoveShop8 shop)
{
var permit = shop.MoveShopPermitFlags;
for (int index = 0; index < permit.Length; index++)
{
if (permit[index])
shop.SetPurchasedRecordFlag(index, true);
}
}

/// <summary>
/// Sets the Shop Record flags for the <see cref="shop"/> based on the current moves.
/// </summary>
/// <param name="shop">Pokémon to modify.</param>
/// <param name="moves">Moves to set flags for. If a move is not a Technical Record, it is skipped.</param>
public static void SetMoveShopFlags(this IMoveShop8 shop, IEnumerable<int> moves)
{
var permit = shop.MoveShopPermitFlags;
var moveIDs = shop.MoveShopPermitIndexes;
foreach (var m in moves)
{
var index = moveIDs.IndexOf(m);
if (index == -1)
continue;
if (permit[index])
shop.SetPurchasedRecordFlag(index, true);
}
}
}
27 changes: 12 additions & 15 deletions PKHeX.Core/Editing/Applicators/TechnicalRecordApplicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,51 @@ public static class TechnicalRecordApplicator
/// <param name="pk">Pokémon to modify.</param>
/// <param name="value">Value to set for the record.</param>
/// <param name="max">Max record to set.</param>
public static void SetRecordFlags(this PKM pk, bool value, int max = 100)
public static void SetRecordFlags(this ITechRecord8 pk, bool value, int max = 100)
{
if (pk is not PK8 pk8)
return;
for (int i = 0; i < max; i++)
pk8.SetMoveRecordFlag(i, value);
pk.SetMoveRecordFlag(i, value);
}

/// <summary>
/// Clears the Technical Record flags for the <see cref="pk"/>.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
public static void ClearRecordFlags(this PKM pk) => pk.SetRecordFlags(false, 112);
public static void ClearRecordFlags(this ITechRecord8 pk) => pk.SetRecordFlags(false, 112);

/// <summary>
/// Sets the Technical Record flags for the <see cref="pk"/> based on the current moves.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
/// <param name="moves">Moves to set flags for. If a move is not a Technical Record, it is skipped.</param>
public static void SetRecordFlags(this PKM pk, IEnumerable<int> moves)
public static void SetRecordFlags(this ITechRecord8 pk, IEnumerable<int> moves)
{
if (pk is not PK8 pk8)
if (pk is PA8)
return;
var permit = pk8.PersonalInfo.TMHM.AsSpan(PersonalInfoSWSH.CountTM);
var moveIDs = Legal.TMHM_SWSH.AsSpan(PersonalInfoSWSH.CountTM);

var permit = pk.TechRecordPermitFlags;
var moveIDs = pk.TechRecordPermitIndexes;
foreach (var m in moves)
{
var index = moveIDs.IndexOf(m);
if (index == -1)
continue;
if (permit[index])
pk8.SetMoveRecordFlag(index, true);
pk.SetMoveRecordFlag(index, true);
}
}

/// <summary>
/// Sets all the Technical Record flags for the <see cref="pk"/> if they are permitted to be learned in-game.
/// </summary>
/// <param name="pk">Pokémon to modify.</param>
public static void SetRecordFlags(this PKM pk)
public static void SetRecordFlags(this ITechRecord8 pk)
{
if (pk is not PK8 pk8)
return;
var permit = pk8.PersonalInfo.TMHM.AsSpan(PersonalInfoSWSH.CountTM); // tm[100], tr[100]
var permit = pk.TechRecordPermitFlags;
for (int i = 0; i < permit.Length; i++)
{
if (permit[i])
pk8.SetMoveRecordFlag(i, true);
pk.SetMoveRecordFlag(i, true);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion PKHeX.Core/Editing/Bulk/BatchEditing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class BatchEditing
{
public static readonly Type[] Types =
{
typeof (PK8), typeof (PB8),
typeof (PK8), typeof (PA8), typeof (PB8),
typeof (PB7),
typeof (PK7), typeof (PK6), typeof (PK5), typeof (PK4), typeof(BK4),
typeof (PK3), typeof (XK3), typeof (CK3),
Expand Down
8 changes: 4 additions & 4 deletions PKHeX.Core/Editing/Bulk/Suggestion/BatchModifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ internal static class BatchModifications
public static ModifyResult SetSuggestedRelearnData(BatchInfo info, string propValue)
{
var pk = info.Entity;
if (pk.Format >= 8)
if (pk is ITechRecord8 t)
{
pk.ClearRecordFlags();
t.ClearRecordFlags();
if (IsAll(propValue))
pk.SetRecordFlags(); // all
t.SetRecordFlags(); // all
else if (!IsNone(propValue))
pk.SetRecordFlags(pk.Moves); // whatever fit the current moves
t.SetRecordFlags(pk.Moves); // whatever fit the current moves
}

pk.SetRelearnMoves(info.SuggestedRelearn);
Expand Down
9 changes: 7 additions & 2 deletions PKHeX.Core/Editing/CommonEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,19 @@ public static void ApplySetDetails(this PKM pk, IBattleTemplate Set)
b.ResetCalculatedValues();
}
}
if (pk is IGanbaru g)
g.SetSuggestedGanbaruValues(pk);

if (pk is IGigantamax c)
c.CanGigantamax = Set.CanGigantamax;
if (pk is IDynamaxLevel d)
d.DynamaxLevel = d.CanHaveDynamaxLevel(pk) ? (byte)10 : (byte)0;

pk.ClearRecordFlags();
pk.SetRecordFlags(Set.Moves);
if (pk is ITechRecord8 t)
{
t.ClearRecordFlags();
t.SetRecordFlags(Set.Moves);
}

if (ShowdownSetBehaviorNature && pk.Format >= 8)
pk.Nature = pk.StatNature;
Expand Down
12 changes: 7 additions & 5 deletions PKHeX.Core/Editing/Saves/BoxManip/BoxManipBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,25 @@ protected BoxManipBase(BoxManipType type, Func<SaveFile, bool> usable)
public static readonly IReadOnlyList<BoxManipBase> ClearCommon = new List<BoxManipBase>
{
new BoxManipClear(BoxManipType.DeleteAll, _ => true),
new BoxManipClear(BoxManipType.DeleteEggs, pk => pk.IsEgg, s => s.Generation >= 2),
new BoxManipClear(BoxManipType.DeleteEggs, pk => pk.IsEgg, s => s.Generation >= 2 & s is not SAV8LA),
new BoxManipClearComplex(BoxManipType.DeletePastGen, (pk, sav) => pk.Generation != sav.Generation, s => s.Generation >= 4),
new BoxManipClearComplex(BoxManipType.DeleteForeign, (pk, sav) => !sav.IsOriginalHandler(pk, pk.Format > 2)),
new BoxManipClear(BoxManipType.DeleteUntrained, pk => pk.EVTotal == 0),
new BoxManipClear(BoxManipType.DeleteItemless, pk => pk.HeldItem == 0),
new BoxManipClear(BoxManipType.DeleteUntrained, pk => pk.EVTotal == 0, s => s is not SAV8LA),
new BoxManipClear(BoxManipType.DeleteUntrained, pk => !((PA8)pk).IsGanbaruValuesMax(pk), s => s is SAV8LA),
new BoxManipClear(BoxManipType.DeleteItemless, pk => pk.HeldItem == 0, s => s is not SAV8LA),
new BoxManipClear(BoxManipType.DeleteIllegal, pk => !new LegalityAnalysis(pk).Valid),
new BoxManipClearDuplicate<string>(BoxManipType.DeleteClones, pk => SearchUtil.GetCloneDetectMethod(CloneDetectionMethod.HashDetails)(pk)),
};

public static readonly IReadOnlyList<BoxManipModify> ModifyCommon = new List<BoxManipModify>
{
new(BoxManipType.ModifyHatchEggs, pk => pk.ForceHatchPKM(), s => s.Generation >= 2),
new(BoxManipType.ModifyHatchEggs, pk => pk.ForceHatchPKM(), s => s.Generation >= 2 & s is not SAV8LA),
new(BoxManipType.ModifyMaxFriendship, pk => pk.MaximizeFriendship()),
new(BoxManipType.ModifyMaxLevel, pk => pk.MaximizeLevel()),
new(BoxManipType.ModifyResetMoves, pk => pk.SetMoves(pk.GetMoveSet()), s => s.Generation >= 3),
new(BoxManipType.ModifyRandomMoves, pk => pk.SetMoves(pk.GetMoveSet(true))),
new(BoxManipType.ModifyHyperTrain,pk => pk.SetSuggestedHyperTrainingData(), s => s.Generation >= 7),
new(BoxManipType.ModifyHyperTrain,pk => pk.SetSuggestedHyperTrainingData(), s => s.Generation >= 7 && s is not SAV8LA),
new(BoxManipType.ModifyGanbaru,pk => ((IGanbaru)pk).SetSuggestedGanbaruValues(pk), s => s is SAV8LA),
new(BoxManipType.ModifyRemoveNicknames, pk => pk.SetDefaultNickname()),
new(BoxManipType.ModifyRemoveItem, pk => pk.HeldItem = 0, s => s.Generation >= 2),
new(BoxManipType.ModifyHeal, pk => pk.Heal(), s => s.Generation >= 8 || s is SAV7b),
Expand Down
1 change: 1 addition & 0 deletions PKHeX.Core/Editing/Saves/BoxManip/BoxManipType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum BoxManipType
ModifyResetMoves,
ModifyRandomMoves,
ModifyHyperTrain,
ModifyGanbaru,
ModifyRemoveNicknames,
ModifyRemoveItem,
ModifyHeal,
Expand Down
6 changes: 6 additions & 0 deletions PKHeX.Core/Editing/Saves/Slots/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static List<SlotInfoMisc> GetExtraSlots(this SaveFile sav, bool all = fal
SAV7b lgpe => GetExtraSlots7b(lgpe),
SAV8SWSH ss => GetExtraSlots8(ss),
SAV8BS bs => GetExtraSlots8b(bs),
SAV8LA la => GetExtraSlots8a(la),
_ => None,
};

Expand Down Expand Up @@ -218,5 +219,10 @@ private static List<SlotInfoMisc> GetExtraSlots8b(SAV8BS sav)
new(sav.Data, 8, sav.UgSaveData.GetSlotOffset(8), true) { Type = StorageSlotType.Misc },
};
}

private static List<SlotInfoMisc> GetExtraSlots8a(SAV8LA sav)
{
return new List<SlotInfoMisc>();
}
}
}
13 changes: 13 additions & 0 deletions PKHeX.Core/Game/Enums/Ball.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ public enum Ball : byte
Sport = 24,
Dream = 25,
Beast = 26,

// Legends: Arceus
Strange = 27,
LAPoke = 28,
LAGreat = 29,
LAUltra = 30,
LAFeather = 31,
LAWing = 32,
LAJet = 33,
LAHeavy = 34,
LALeaden = 35,
LAGigaton = 36,
LAOrigin = 37,
}

public static class BallExtensions
Expand Down
3 changes: 2 additions & 1 deletion PKHeX.Core/Game/Enums/GameVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public enum GameVersion
SH = 45,

// HOME = 46,
// PLA = 47,
PLA = 47,

/// <summary>
/// Pokémon Brilliant Diamond (NX)
Expand Down Expand Up @@ -459,6 +459,7 @@ public enum GameVersion
/// </summary>
/// <see cref="SWSH"/>
/// <see cref="BDSP"/>
/// <see cref="PLA"/>
Gen8,

/// <summary>
Expand Down
24 changes: 24 additions & 0 deletions PKHeX.Core/Game/Enums/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,30 @@ public enum Move
GlacialLance,
AstralBarrage,
EerieSpell,
DireClaw,
PsyshieldBash,
PowerShift,
StoneAxe,
SpringtideStorm,
MysticalPower,
RagingFury,
WaveCrash,
Chloroblast,
MountainGale,
VictoryDance,
HeadlongRush,
BarbBarrage,
EsperWing,
BitterMalice,
Shelter,
TripleArrows,
InfernalParade,
CeaselessEdge,
BleakwindStorm,
WildboltStorm,
SandsearStorm,
LunarBlessing,
TakeHeart,
MAX_COUNT,
}
}
7 changes: 7 additions & 0 deletions PKHeX.Core/Game/Enums/Species.cs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,13 @@ public enum Species : ushort
Glastrier,
Spectrier,
Calyrex,
Wyrdeer,
Kleavor,
Ursaluna,
Basculegion,
Sneasler,
Overqwil,
Enamorus,
MAX_COUNT,
}
}
5 changes: 3 additions & 2 deletions PKHeX.Core/Game/GameStrings/GameDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public GameDataSource(GameStrings s)
private static IReadOnlyList<ComboItem> GetBalls(string[] itemList)
{
// ignores Poke/Great/Ultra
ReadOnlySpan<ushort> ball_nums = stackalloc ushort[] { 007, 576, 013, 492, 497, 014, 495, 493, 496, 494, 011, 498, 008, 006, 012, 015, 009, 005, 499, 010, 001, 016, 851 };
ReadOnlySpan<byte> ball_vals = stackalloc byte[] { 007, 025, 013, 017, 022, 014, 020, 018, 021, 019, 011, 023, 008, 006, 012, 015, 009, 005, 024, 010, 001, 016, 026 };
ReadOnlySpan<ushort> ball_nums = stackalloc ushort[] { 007, 576, 013, 492, 497, 014, 495, 493, 496, 494, 011, 498, 008, 006, 012, 015, 009, 005, 499, 010, 001, 016, 851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771 };
ReadOnlySpan<byte> ball_vals = stackalloc byte[] { 007, 025, 013, 017, 022, 014, 020, 018, 021, 019, 011, 023, 008, 006, 012, 015, 009, 005, 024, 010, 001, 016, 026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037 };
return Util.GetVariedCBListBall(itemList, ball_nums, ball_vals);
}

Expand All @@ -84,6 +84,7 @@ private static IReadOnlyList<ComboItem> GetVersionList(GameStrings s)
var list = s.gamelist;
ReadOnlySpan<byte> games = stackalloc byte[]
{
47, // 8 legends arceus
48, 49, // 8 bdsp
44, 45, // 8 swsh
42, 43, // 7 gg
Expand Down
Loading

0 comments on commit eed5bb0

Please sign in to comment.