mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Add DynamaxLevel parsing for ShowdownSet
This commit is contained in:
parent
98c1420b22
commit
50a64d8beb
4 changed files with 15 additions and 7 deletions
|
@ -236,7 +236,7 @@ public static class CommonEdits
|
|||
if (pk is IGigantamax c)
|
||||
c.CanGigantamax = Set.CanGigantamax;
|
||||
if (pk is IDynamaxLevel d)
|
||||
d.DynamaxLevel = d.GetSuggestedDynamaxLevel(pk);
|
||||
d.DynamaxLevel = d.GetSuggestedDynamaxLevel(pk, requested: Set.DynamaxLevel);
|
||||
|
||||
if (pk is ITechRecord8 t)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace PKHeX.Core;
|
|||
/// <summary>
|
||||
/// Interface containing details relevant for battling.
|
||||
/// </summary>
|
||||
public interface IBattleTemplate : ISpeciesForm, IGigantamax, INature
|
||||
public interface IBattleTemplate : ISpeciesForm, IGigantamax, IDynamaxLevel, INature
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="PKM.Context"/> of the Set entity it is specific to.
|
||||
|
|
|
@ -70,6 +70,9 @@ public sealed class ShowdownSet : IBattleTemplate
|
|||
/// <inheritdoc/>
|
||||
public bool CanGigantamax { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public byte DynamaxLevel { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Any lines that failed to be parsed.
|
||||
/// </summary>
|
||||
|
@ -97,7 +100,7 @@ public sealed class ShowdownSet : IBattleTemplate
|
|||
Form = ShowdownParsing.GetFormFromString(FormName, Strings, Species, Context);
|
||||
|
||||
// Handle edge case with fixed-gender forms.
|
||||
if (Species is (int) Meowstic or (int) Indeedee)
|
||||
if (Species is (int)Meowstic or (int)Indeedee or (int)Basculegion)
|
||||
ReviseGenderedForms();
|
||||
}
|
||||
|
||||
|
@ -206,6 +209,7 @@ public sealed class ShowdownSet : IBattleTemplate
|
|||
case "Nature": return (Nature = StringUtil.FindIndexIgnoreCase(Strings.natures, value)) >= 0;
|
||||
case "EV" or "EVs": ParseLineEVs(value); return true;
|
||||
case "IV" or "IVs": ParseLineIVs(value); return true;
|
||||
case "Dynamax Level": return (DynamaxLevel = (byte)Util.ToInt32(value)) is (>= 0 and <= 10);
|
||||
case "Level":
|
||||
{
|
||||
if (!int.TryParse(value.Trim(), out int val))
|
||||
|
@ -281,10 +285,12 @@ public sealed class ShowdownSet : IBattleTemplate
|
|||
result.Add($"Ability: {Strings.Ability[Ability]}");
|
||||
if (Level != 100)
|
||||
result.Add($"Level: {Level}");
|
||||
if (CanGigantamax)
|
||||
result.Add("Gigantamax: Yes");
|
||||
if (Shiny)
|
||||
result.Add("Shiny: Yes");
|
||||
if (DynamaxLevel != 10)
|
||||
result.Add($"Dynamax Level: {DynamaxLevel}");
|
||||
if (CanGigantamax)
|
||||
result.Add("Gigantamax: Yes");
|
||||
|
||||
if ((uint)Nature < Strings.Natures.Count)
|
||||
result.Add($"{Strings.Natures[Nature]} Nature");
|
||||
|
@ -406,6 +412,8 @@ public sealed class ShowdownSet : IBattleTemplate
|
|||
|
||||
if (pk is IGigantamax g)
|
||||
CanGigantamax = g.CanGigantamax;
|
||||
if (pk is IDynamaxLevel d)
|
||||
DynamaxLevel = d.DynamaxLevel;
|
||||
|
||||
if (Array.IndexOf(Moves, (int)Move.HiddenPower) != -1)
|
||||
HiddenPowerType = HiddenPower.GetType(IVs, Context);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using static PKHeX.Core.Species;
|
||||
using static PKHeX.Core.Species;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
|
@ -22,7 +22,7 @@ public static class DynamaxLevelExtensions
|
|||
return pk is PK8 && CanHaveDynamaxLevel(pk.Species);
|
||||
}
|
||||
|
||||
public static byte GetSuggestedDynamaxLevel(this IDynamaxLevel _, PKM pk) => _.CanHaveDynamaxLevel(pk) ? (byte)10 : (byte)0;
|
||||
public static byte GetSuggestedDynamaxLevel(this IDynamaxLevel _, PKM pk, byte requested = 10) => _.CanHaveDynamaxLevel(pk) ? requested : (byte)0;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the species is prevented from gaining any <see cref="IDynamaxLevel.DynamaxLevel"/> via candy in <see cref="GameVersion.SWSH"/>.
|
||||
|
|
Loading…
Add table
Reference in a new issue