mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-25 21:40:21 +00:00
Extract TrainerName const to static class
Central location for where these values are defined.
This commit is contained in:
parent
1dcda6d2e8
commit
99ebc47866
11 changed files with 148 additions and 118 deletions
|
@ -58,10 +58,6 @@ public static class BatchMods
|
||||||
new ComplexSet(nameof(PKM.MetDate), (pk, cmd) => pk.MetDate = ParseDate(cmd.PropertyValue)),
|
new ComplexSet(nameof(PKM.MetDate), (pk, cmd) => pk.MetDate = ParseDate(cmd.PropertyValue)),
|
||||||
new ComplexSet(nameof(PKM.EggMetDate), (pk, cmd) => pk.EggMetDate = ParseDate(cmd.PropertyValue)),
|
new ComplexSet(nameof(PKM.EggMetDate), (pk, cmd) => pk.EggMetDate = ParseDate(cmd.PropertyValue)),
|
||||||
|
|
||||||
// Value Swap
|
|
||||||
new ComplexSet(nameof(PKM.EncryptionConstant), value => value == nameof(PKM.PID), (pk, _) => pk.EncryptionConstant = pk.PID),
|
|
||||||
new ComplexSet(nameof(PKM.PID), value => value == nameof(PKM.EncryptionConstant), (pk, _) => pk.PID = pk.EncryptionConstant),
|
|
||||||
|
|
||||||
// Realign to Derived Value
|
// Realign to Derived Value
|
||||||
new ComplexSet(nameof(PKM.Ability), value => value.Length == 2 && value.StartsWith(CONST_SPECIAL), (pk, cmd) => pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30)),
|
new ComplexSet(nameof(PKM.Ability), value => value.Length == 2 && value.StartsWith(CONST_SPECIAL), (pk, cmd) => pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30)),
|
||||||
new ComplexSet(nameof(PKM.AbilityNumber), value => value.Length == 2 && value.StartsWith(CONST_SPECIAL), (pk, cmd) => pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30)),
|
new ComplexSet(nameof(PKM.AbilityNumber), value => value.Length == 2 && value.StartsWith(CONST_SPECIAL), (pk, cmd) => pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30)),
|
||||||
|
|
|
@ -67,11 +67,11 @@ public static class LocationsHOME
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GameVersion GetVersionSWSH(GameVersion version) => version switch
|
public static GameVersion GetVersionSWSH(GameVersion version) => version switch
|
||||||
{
|
{
|
||||||
GameVersion.PLA => GameVersion.SW,
|
PLA => SW,
|
||||||
GameVersion.BD => GameVersion.SW,
|
BD => SW,
|
||||||
GameVersion.SP => GameVersion.SH,
|
SP => SH,
|
||||||
GameVersion.SL => GameVersion.SW,
|
SL => SW,
|
||||||
GameVersion.VL => GameVersion.SH,
|
VL => SH,
|
||||||
_ => version,
|
_ => version,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,22 +80,22 @@ public static class LocationsHOME
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ushort GetMetSWSH(ushort loc, GameVersion version) => version switch
|
public static ushort GetMetSWSH(ushort loc, GameVersion version) => version switch
|
||||||
{
|
{
|
||||||
GameVersion.PLA => SWLA,
|
PLA => SWLA,
|
||||||
GameVersion.BD => SWBD,
|
BD => SWBD,
|
||||||
GameVersion.SP => SHSP,
|
SP => SHSP,
|
||||||
GameVersion.SL => SWSL,
|
SL => SWSL,
|
||||||
GameVersion.VL => SHVL,
|
VL => SHVL,
|
||||||
_ => loc,
|
_ => loc,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static GameVersion GetVersionSWSHOriginal(ushort loc) => loc switch
|
public static GameVersion GetVersionSWSHOriginal(ushort loc) => loc switch
|
||||||
{
|
{
|
||||||
SWLA => GameVersion.PLA,
|
SWLA => PLA,
|
||||||
SWBD => GameVersion.BD,
|
SWBD => BD,
|
||||||
SHSP => GameVersion.SP,
|
SHSP => SP,
|
||||||
SWSL => GameVersion.SL,
|
SWSL => SL,
|
||||||
SHVL => GameVersion.VL,
|
SHVL => VL,
|
||||||
_ => GameVersion.SW,
|
_ => SW,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -68,8 +68,8 @@ public static class EncounterUtil
|
||||||
/// <param name="lang">Language to apply the name in</param>
|
/// <param name="lang">Language to apply the name in</param>
|
||||||
public static string GetTrainerName(ITrainerInfo tr, int lang) => lang switch
|
public static string GetTrainerName(ITrainerInfo tr, int lang) => lang switch
|
||||||
{
|
{
|
||||||
(int)LanguageID.Japanese => tr.Language == 1 ? tr.OT : "ゲーフリ",
|
(int)LanguageID.Japanese => tr.Language == 1 ? tr.OT : TrainerName.GameFreakJPN,
|
||||||
_ => tr.Language == 1 ? "GF" : tr.OT,
|
_ => tr.Language == 1 ? TrainerName.GameFreakINT : tr.OT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -132,7 +132,7 @@ public sealed record EncounterSlot8GO(int StartDate, int EndDate, ushort Species
|
||||||
pk.OriginalTrainerName = tr.OT;
|
pk.OriginalTrainerName = tr.OT;
|
||||||
pk.ID32 = tr.ID32;
|
pk.ID32 = tr.ID32;
|
||||||
pk.OriginalTrainerGender = tr.Gender;
|
pk.OriginalTrainerGender = tr.Gender;
|
||||||
pk.HandlingTrainerName = "PKHeX";
|
pk.HandlingTrainerName = TrainerName.ProgramINT;
|
||||||
pk.CurrentHandler = 1;
|
pk.CurrentHandler = 1;
|
||||||
if (pk is IHandlerLanguage l)
|
if (pk is IHandlerLanguage l)
|
||||||
l.HandlingTrainerLanguage = 2;
|
l.HandlingTrainerLanguage = 2;
|
||||||
|
|
|
@ -180,7 +180,8 @@ public sealed class SK2 : GBPKM, ICaughtData2
|
||||||
|
|
||||||
// Only copies until first 0x50 terminator, but just copy everything
|
// Only copies until first 0x50 terminator, but just copy everything
|
||||||
Nickname = Nickname,
|
Nickname = Nickname,
|
||||||
OriginalTrainerName = IsRental ? Japanese ? "1337" : "PKHeX" : OriginalTrainerName,
|
OriginalTrainerName = !IsRental ? OriginalTrainerName
|
||||||
|
: Japanese ? TrainerName.GameFreakJPN : TrainerName.ProgramINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static bool IsJapanese(ReadOnlySpan<byte> data)
|
private static bool IsJapanese(ReadOnlySpan<byte> data)
|
||||||
|
|
13
PKHeX.Core/PKM/Util/TrainerName.cs
Normal file
13
PKHeX.Core/PKM/Util/TrainerName.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
namespace PKHeX.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Common trainer names used in the program.
|
||||||
|
/// </summary>
|
||||||
|
public static class TrainerName
|
||||||
|
{
|
||||||
|
public const string GameFreakJPN = "ゲーフリ";
|
||||||
|
public const string GameFreakINT = "GF";
|
||||||
|
|
||||||
|
public const string ProgramJPN = "PKHeX";
|
||||||
|
public const string ProgramINT = "PKHeX";
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ namespace PKHeX.Core;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record SimpleTrainerInfo : ITrainerInfo, IRegionOrigin
|
public sealed record SimpleTrainerInfo : ITrainerInfo, IRegionOrigin
|
||||||
{
|
{
|
||||||
public string OT { get; set; } = "PKHeX";
|
public string OT { get; set; } = TrainerName.ProgramINT;
|
||||||
public ushort TID16 { get; set; } = 12345;
|
public ushort TID16 { get; set; } = 12345;
|
||||||
public ushort SID16 { get; set; } = 54321;
|
public ushort SID16 { get; set; } = 54321;
|
||||||
public byte Gender { get; set; }
|
public byte Gender { get; set; }
|
||||||
|
|
|
@ -131,7 +131,7 @@ public abstract class SaveFile : ITrainerInfo, IGameValueLimit, IGeneration, IVe
|
||||||
public virtual uint ID32 { get; set; }
|
public virtual uint ID32 { get; set; }
|
||||||
public virtual ushort TID16 { get; set; }
|
public virtual ushort TID16 { get; set; }
|
||||||
public virtual ushort SID16 { get; set; }
|
public virtual ushort SID16 { get; set; }
|
||||||
public virtual string OT { get; set; } = "PKHeX";
|
public virtual string OT { get; set; } = TrainerName.ProgramINT;
|
||||||
public virtual int PlayedHours { get; set; }
|
public virtual int PlayedHours { get; set; }
|
||||||
public virtual int PlayedMinutes { get; set; }
|
public virtual int PlayedMinutes { get; set; }
|
||||||
public virtual int PlayedSeconds { get; set; }
|
public virtual int PlayedSeconds { get; set; }
|
||||||
|
|
|
@ -806,8 +806,8 @@ public static class SaveUtil
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetSafeTrainerName(SaveFile? sav, LanguageID lang) => lang switch
|
public static string GetSafeTrainerName(SaveFile? sav, LanguageID lang) => lang switch
|
||||||
{
|
{
|
||||||
LanguageID.Japanese => sav?.Generation >= 3 ? "PKHeX" : "1337",
|
LanguageID.Japanese => sav?.Generation >= 3 ? TrainerName.ProgramJPN : TrainerName.GameFreakJPN,
|
||||||
_ => "PKHeX",
|
_ => TrainerName.ProgramINT,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class SwishCryptoTests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanMakeBlankSAV8()
|
public void CanMakeBlankSAV8()
|
||||||
{
|
{
|
||||||
var sav = SaveUtil.GetBlankSAV(GameVersion.SW, "PKHeX");
|
var sav = SaveUtil.GetBlankSAV(GameVersion.SW, TrainerName.ProgramINT);
|
||||||
sav.Should().NotBeNull();
|
sav.Should().NotBeNull();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class ShowdownSetTests
|
||||||
var pk7 = new PK7 {Species = set.Species, Form = set.Form, Moves = set.Moves};
|
var pk7 = new PK7 {Species = set.Species, Form = set.Form, Moves = set.Moves};
|
||||||
var encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
var encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
||||||
Assert.False(encounters.Any());
|
Assert.False(encounters.Any());
|
||||||
pk7.HandlingTrainerName = "PKHeX";
|
pk7.HandlingTrainerName = TrainerName.ProgramINT;
|
||||||
encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
||||||
var first = encounters.FirstOrDefault();
|
var first = encounters.FirstOrDefault();
|
||||||
Assert.NotNull(first);
|
Assert.NotNull(first);
|
||||||
|
@ -100,7 +100,7 @@ public class ShowdownSetTests
|
||||||
public void SimulatorGetSplitBreed()
|
public void SimulatorGetSplitBreed()
|
||||||
{
|
{
|
||||||
var set = new ShowdownSet(SetMunchSnorLax);
|
var set = new ShowdownSet(SetMunchSnorLax);
|
||||||
var pk7 = new PK7 { Species = set.Species, Form = set.Form, Moves = set.Moves, HandlingTrainerName = "PKHeX" }; // !! specify the HT name, we need tutors for this one
|
var pk7 = new PK7 { Species = set.Species, Form = set.Form, Moves = set.Moves, HandlingTrainerName = TrainerName.ProgramINT }; // !! specify the HT name, we need tutors for this one
|
||||||
var encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.SN).ToList();
|
var encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.SN).ToList();
|
||||||
Assert.True(encs.Count > 0);
|
Assert.True(encs.Count > 0);
|
||||||
Assert.True(encs.All(z => z.Species > 150));
|
Assert.True(encs.All(z => z.Species > 150));
|
||||||
|
@ -117,7 +117,7 @@ public class ShowdownSetTests
|
||||||
public void SimulatorGetVCEgg1()
|
public void SimulatorGetVCEgg1()
|
||||||
{
|
{
|
||||||
var set = new ShowdownSet(SetSlowpoke12);
|
var set = new ShowdownSet(SetSlowpoke12);
|
||||||
var pk7 = new PK7 { Species = set.Species, Form = set.Form, Moves = set.Moves, HandlingTrainerName = "PKHeX" };
|
var pk7 = new PK7 { Species = set.Species, Form = set.Form, Moves = set.Moves, HandlingTrainerName = TrainerName.ProgramINT };
|
||||||
var encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.GD).ToList();
|
var encs = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.GD).ToList();
|
||||||
Assert.True(encs.Count > 0);
|
Assert.True(encs.Count > 0);
|
||||||
|
|
||||||
|
@ -209,100 +209,118 @@ public class ShowdownSetTests
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string LowLevelElectrode =
|
private const string LowLevelElectrode =
|
||||||
@"BOLICHI (Electrode)
|
"""
|
||||||
IVs: 19 HP / 16 Atk / 18 Def / 25 SpA / 19 SpD / 25 Spe
|
BOLICHI (Electrode)
|
||||||
Ability: Static
|
IVs: 19 HP / 16 Atk / 18 Def / 25 SpA / 19 SpD / 25 Spe
|
||||||
Level: 3
|
Ability: Static
|
||||||
Hasty Nature
|
Level: 3
|
||||||
- Charge
|
Hasty Nature
|
||||||
- Tackle
|
- Charge
|
||||||
- Screech
|
- Tackle
|
||||||
- Sonic Boom";
|
- Screech
|
||||||
|
- Sonic Boom
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetDuplicateMoves =
|
private const string SetDuplicateMoves =
|
||||||
@"Kingler-Gmax @ Master Ball
|
"""
|
||||||
Ability: Sheer Force
|
Kingler-Gmax @ Master Ball
|
||||||
Shiny: Yes
|
Ability: Sheer Force
|
||||||
EVs: 252 Atk / 4 SpD / 252 Spe
|
Shiny: Yes
|
||||||
Jolly Nature
|
EVs: 252 Atk / 4 SpD / 252 Spe
|
||||||
- Crabhammer
|
Jolly Nature
|
||||||
- Rock Slide
|
- Crabhammer
|
||||||
- Rock Slide
|
- Rock Slide
|
||||||
- X-Scissor";
|
- Rock Slide
|
||||||
|
- X-Scissor
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetROCKSMetang =
|
private const string SetROCKSMetang =
|
||||||
@"Metang
|
"""
|
||||||
IVs: 20 HP / 3 Atk / 26 Def / 1 SpA / 6 SpD / 8 Spe
|
Metang
|
||||||
Ability: Clear Body
|
IVs: 20 HP / 3 Atk / 26 Def / 1 SpA / 6 SpD / 8 Spe
|
||||||
Level: 30
|
Ability: Clear Body
|
||||||
Adamant Nature
|
Level: 30
|
||||||
- Take Down
|
Adamant Nature
|
||||||
- Confusion
|
- Take Down
|
||||||
- Metal Claw
|
- Confusion
|
||||||
- Refresh";
|
- Metal Claw
|
||||||
|
- Refresh
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetGlaceonUSUMTutor =
|
private const string SetGlaceonUSUMTutor =
|
||||||
@"Glaceon (F) @ Assault Vest
|
"""
|
||||||
IVs: 0 Atk
|
Glaceon (F) @ Assault Vest
|
||||||
EVs: 252 HP / 252 SpA / 4 SpD
|
IVs: 0 Atk
|
||||||
Ability: Ice Body
|
EVs: 252 HP / 252 SpA / 4 SpD
|
||||||
Shiny: Yes
|
Ability: Ice Body
|
||||||
Modest Nature
|
Shiny: Yes
|
||||||
- Blizzard
|
Modest Nature
|
||||||
- Water Pulse
|
- Blizzard
|
||||||
- Shadow Ball
|
- Water Pulse
|
||||||
- Hyper Voice";
|
- Shadow Ball
|
||||||
|
- Hyper Voice
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetSmeargle =
|
private const string SetSmeargle =
|
||||||
@"Smeargle @ Focus Sash
|
"""
|
||||||
Ability: Own Tempo
|
Smeargle @ Focus Sash
|
||||||
EVs: 248 HP / 8 Def / 252 Spe
|
Ability: Own Tempo
|
||||||
Jolly Nature
|
EVs: 248 HP / 8 Def / 252 Spe
|
||||||
- Sticky Web
|
Jolly Nature
|
||||||
- Nuzzle
|
- Sticky Web
|
||||||
- Taunt
|
- Nuzzle
|
||||||
- Whirlwind";
|
- Taunt
|
||||||
|
- Whirlwind
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetCelebi =
|
private const string SetCelebi =
|
||||||
@"Celebi @ Toxic Orb
|
"""
|
||||||
Ability: Natural Cure
|
Celebi @ Toxic Orb
|
||||||
Jolly Nature
|
Ability: Natural Cure
|
||||||
- Recover
|
Jolly Nature
|
||||||
- Heal Bell
|
- Recover
|
||||||
- Safeguard
|
- Heal Bell
|
||||||
- Hold Back";
|
- Safeguard
|
||||||
|
- Hold Back
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetNicknamedTypeNull =
|
private const string SetNicknamedTypeNull =
|
||||||
@"Reliance (Type: Null) @ Eviolite
|
"""
|
||||||
EVs: 252 HP / 4 Def / 252 SpD
|
Reliance (Type: Null) @ Eviolite
|
||||||
Ability: Battle Armor
|
EVs: 252 HP / 4 Def / 252 SpD
|
||||||
Careful Nature
|
Ability: Battle Armor
|
||||||
- Facade
|
Careful Nature
|
||||||
- Swords Dance
|
- Facade
|
||||||
- Sleep Talk
|
- Swords Dance
|
||||||
- Rest";
|
- Sleep Talk
|
||||||
|
- Rest
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetMunchSnorLax =
|
private const string SetMunchSnorLax =
|
||||||
@"Snorlax @ Choice Band
|
"""
|
||||||
Ability: Thick Fat
|
Snorlax @ Choice Band
|
||||||
Level: 50
|
Ability: Thick Fat
|
||||||
EVs: 84 HP / 228 Atk / 180 Def / 12 SpD / 4 Spe
|
Level: 50
|
||||||
Adamant Nature
|
EVs: 84 HP / 228 Atk / 180 Def / 12 SpD / 4 Spe
|
||||||
- Double-Edge
|
Adamant Nature
|
||||||
- High Horsepower
|
- Double-Edge
|
||||||
- Self-Destruct
|
- High Horsepower
|
||||||
- Fire Punch";
|
- Self-Destruct
|
||||||
|
- Fire Punch
|
||||||
|
""";
|
||||||
|
|
||||||
private const string SetSlowpoke12 =
|
private const string SetSlowpoke12 =
|
||||||
@"Threat (Slowpoke) @ Eviolite
|
"""
|
||||||
Ability: Regenerator
|
Threat (Slowpoke) @ Eviolite
|
||||||
Shiny: Yes
|
Ability: Regenerator
|
||||||
EVs: 248 HP / 252 Atk / 8 SpD
|
Shiny: Yes
|
||||||
Adamant Nature
|
EVs: 248 HP / 252 Atk / 8 SpD
|
||||||
- Body Slam
|
Adamant Nature
|
||||||
- Earthquake
|
- Body Slam
|
||||||
- Belly Drum
|
- Earthquake
|
||||||
- Iron Tail";
|
- Belly Drum
|
||||||
|
- Iron Tail
|
||||||
|
""";
|
||||||
|
|
||||||
private static readonly string[] Sets =
|
private static readonly string[] Sets =
|
||||||
[
|
[
|
||||||
|
@ -310,13 +328,15 @@ Adamant Nature
|
||||||
SetNicknamedTypeNull,
|
SetNicknamedTypeNull,
|
||||||
SetMunchSnorLax,
|
SetMunchSnorLax,
|
||||||
|
|
||||||
@"Greninja @ Choice Specs
|
"""
|
||||||
Ability: Battle Bond
|
Greninja @ Choice Specs
|
||||||
EVs: 252 SpA / 4 SpD / 252 Spe
|
Ability: Battle Bond
|
||||||
Timid Nature
|
EVs: 252 SpA / 4 SpD / 252 Spe
|
||||||
- Hydro Pump
|
Timid Nature
|
||||||
- Spikes
|
- Hydro Pump
|
||||||
- Water Shuriken
|
- Spikes
|
||||||
- Dark Pulse",
|
- Water Shuriken
|
||||||
|
- Dark Pulse
|
||||||
|
""",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue