mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +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.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
|
||||
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)),
|
||||
|
|
|
@ -67,11 +67,11 @@ public static class LocationsHOME
|
|||
/// </summary>
|
||||
public static GameVersion GetVersionSWSH(GameVersion version) => version switch
|
||||
{
|
||||
GameVersion.PLA => GameVersion.SW,
|
||||
GameVersion.BD => GameVersion.SW,
|
||||
GameVersion.SP => GameVersion.SH,
|
||||
GameVersion.SL => GameVersion.SW,
|
||||
GameVersion.VL => GameVersion.SH,
|
||||
PLA => SW,
|
||||
BD => SW,
|
||||
SP => SH,
|
||||
SL => SW,
|
||||
VL => SH,
|
||||
_ => version,
|
||||
};
|
||||
|
||||
|
@ -80,22 +80,22 @@ public static class LocationsHOME
|
|||
/// </summary>
|
||||
public static ushort GetMetSWSH(ushort loc, GameVersion version) => version switch
|
||||
{
|
||||
GameVersion.PLA => SWLA,
|
||||
GameVersion.BD => SWBD,
|
||||
GameVersion.SP => SHSP,
|
||||
GameVersion.SL => SWSL,
|
||||
GameVersion.VL => SHVL,
|
||||
PLA => SWLA,
|
||||
BD => SWBD,
|
||||
SP => SHSP,
|
||||
SL => SWSL,
|
||||
VL => SHVL,
|
||||
_ => loc,
|
||||
};
|
||||
|
||||
public static GameVersion GetVersionSWSHOriginal(ushort loc) => loc switch
|
||||
{
|
||||
SWLA => GameVersion.PLA,
|
||||
SWBD => GameVersion.BD,
|
||||
SHSP => GameVersion.SP,
|
||||
SWSL => GameVersion.SL,
|
||||
SHVL => GameVersion.VL,
|
||||
_ => GameVersion.SW,
|
||||
SWLA => PLA,
|
||||
SWBD => BD,
|
||||
SHSP => SP,
|
||||
SWSL => SL,
|
||||
SHVL => VL,
|
||||
_ => SW,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -68,8 +68,8 @@ public static class EncounterUtil
|
|||
/// <param name="lang">Language to apply the name in</param>
|
||||
public static string GetTrainerName(ITrainerInfo tr, int lang) => lang switch
|
||||
{
|
||||
(int)LanguageID.Japanese => tr.Language == 1 ? tr.OT : "ゲーフリ",
|
||||
_ => tr.Language == 1 ? "GF" : tr.OT,
|
||||
(int)LanguageID.Japanese => tr.Language == 1 ? tr.OT : TrainerName.GameFreakJPN,
|
||||
_ => tr.Language == 1 ? TrainerName.GameFreakINT : tr.OT,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -132,7 +132,7 @@ public sealed record EncounterSlot8GO(int StartDate, int EndDate, ushort Species
|
|||
pk.OriginalTrainerName = tr.OT;
|
||||
pk.ID32 = tr.ID32;
|
||||
pk.OriginalTrainerGender = tr.Gender;
|
||||
pk.HandlingTrainerName = "PKHeX";
|
||||
pk.HandlingTrainerName = TrainerName.ProgramINT;
|
||||
pk.CurrentHandler = 1;
|
||||
if (pk is IHandlerLanguage l)
|
||||
l.HandlingTrainerLanguage = 2;
|
||||
|
|
|
@ -180,7 +180,8 @@ public sealed class SK2 : GBPKM, ICaughtData2
|
|||
|
||||
// Only copies until first 0x50 terminator, but just copy everything
|
||||
Nickname = Nickname,
|
||||
OriginalTrainerName = IsRental ? Japanese ? "1337" : "PKHeX" : OriginalTrainerName,
|
||||
OriginalTrainerName = !IsRental ? OriginalTrainerName
|
||||
: Japanese ? TrainerName.GameFreakJPN : TrainerName.ProgramINT,
|
||||
};
|
||||
|
||||
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>
|
||||
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 SID16 { get; set; } = 54321;
|
||||
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 ushort TID16 { 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 PlayedMinutes { get; set; }
|
||||
public virtual int PlayedSeconds { get; set; }
|
||||
|
|
|
@ -806,8 +806,8 @@ public static class SaveUtil
|
|||
/// </summary>
|
||||
public static string GetSafeTrainerName(SaveFile? sav, LanguageID lang) => lang switch
|
||||
{
|
||||
LanguageID.Japanese => sav?.Generation >= 3 ? "PKHeX" : "1337",
|
||||
_ => "PKHeX",
|
||||
LanguageID.Japanese => sav?.Generation >= 3 ? TrainerName.ProgramJPN : TrainerName.GameFreakJPN,
|
||||
_ => TrainerName.ProgramINT,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -14,7 +14,7 @@ public class SwishCryptoTests
|
|||
[Fact]
|
||||
public void CanMakeBlankSAV8()
|
||||
{
|
||||
var sav = SaveUtil.GetBlankSAV(GameVersion.SW, "PKHeX");
|
||||
var sav = SaveUtil.GetBlankSAV(GameVersion.SW, TrainerName.ProgramINT);
|
||||
sav.Should().NotBeNull();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ShowdownSetTests
|
|||
var pk7 = new PK7 {Species = set.Species, Form = set.Form, Moves = set.Moves};
|
||||
var encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
||||
Assert.False(encounters.Any());
|
||||
pk7.HandlingTrainerName = "PKHeX";
|
||||
pk7.HandlingTrainerName = TrainerName.ProgramINT;
|
||||
encounters = EncounterMovesetGenerator.GenerateEncounters(pk7, set.Moves, GameVersion.MN);
|
||||
var first = encounters.FirstOrDefault();
|
||||
Assert.NotNull(first);
|
||||
|
@ -100,7 +100,7 @@ public class ShowdownSetTests
|
|||
public void SimulatorGetSplitBreed()
|
||||
{
|
||||
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();
|
||||
Assert.True(encs.Count > 0);
|
||||
Assert.True(encs.All(z => z.Species > 150));
|
||||
|
@ -117,7 +117,7 @@ public class ShowdownSetTests
|
|||
public void SimulatorGetVCEgg1()
|
||||
{
|
||||
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();
|
||||
Assert.True(encs.Count > 0);
|
||||
|
||||
|
@ -209,100 +209,118 @@ public class ShowdownSetTests
|
|||
}
|
||||
|
||||
private const string LowLevelElectrode =
|
||||
@"BOLICHI (Electrode)
|
||||
IVs: 19 HP / 16 Atk / 18 Def / 25 SpA / 19 SpD / 25 Spe
|
||||
Ability: Static
|
||||
Level: 3
|
||||
Hasty Nature
|
||||
- Charge
|
||||
- Tackle
|
||||
- Screech
|
||||
- Sonic Boom";
|
||||
"""
|
||||
BOLICHI (Electrode)
|
||||
IVs: 19 HP / 16 Atk / 18 Def / 25 SpA / 19 SpD / 25 Spe
|
||||
Ability: Static
|
||||
Level: 3
|
||||
Hasty Nature
|
||||
- Charge
|
||||
- Tackle
|
||||
- Screech
|
||||
- Sonic Boom
|
||||
""";
|
||||
|
||||
private const string SetDuplicateMoves =
|
||||
@"Kingler-Gmax @ Master Ball
|
||||
Ability: Sheer Force
|
||||
Shiny: Yes
|
||||
EVs: 252 Atk / 4 SpD / 252 Spe
|
||||
Jolly Nature
|
||||
- Crabhammer
|
||||
- Rock Slide
|
||||
- Rock Slide
|
||||
- X-Scissor";
|
||||
"""
|
||||
Kingler-Gmax @ Master Ball
|
||||
Ability: Sheer Force
|
||||
Shiny: Yes
|
||||
EVs: 252 Atk / 4 SpD / 252 Spe
|
||||
Jolly Nature
|
||||
- Crabhammer
|
||||
- Rock Slide
|
||||
- Rock Slide
|
||||
- X-Scissor
|
||||
""";
|
||||
|
||||
private const string SetROCKSMetang =
|
||||
@"Metang
|
||||
IVs: 20 HP / 3 Atk / 26 Def / 1 SpA / 6 SpD / 8 Spe
|
||||
Ability: Clear Body
|
||||
Level: 30
|
||||
Adamant Nature
|
||||
- Take Down
|
||||
- Confusion
|
||||
- Metal Claw
|
||||
- Refresh";
|
||||
"""
|
||||
Metang
|
||||
IVs: 20 HP / 3 Atk / 26 Def / 1 SpA / 6 SpD / 8 Spe
|
||||
Ability: Clear Body
|
||||
Level: 30
|
||||
Adamant Nature
|
||||
- Take Down
|
||||
- Confusion
|
||||
- Metal Claw
|
||||
- Refresh
|
||||
""";
|
||||
|
||||
private const string SetGlaceonUSUMTutor =
|
||||
@"Glaceon (F) @ Assault Vest
|
||||
IVs: 0 Atk
|
||||
EVs: 252 HP / 252 SpA / 4 SpD
|
||||
Ability: Ice Body
|
||||
Shiny: Yes
|
||||
Modest Nature
|
||||
- Blizzard
|
||||
- Water Pulse
|
||||
- Shadow Ball
|
||||
- Hyper Voice";
|
||||
"""
|
||||
Glaceon (F) @ Assault Vest
|
||||
IVs: 0 Atk
|
||||
EVs: 252 HP / 252 SpA / 4 SpD
|
||||
Ability: Ice Body
|
||||
Shiny: Yes
|
||||
Modest Nature
|
||||
- Blizzard
|
||||
- Water Pulse
|
||||
- Shadow Ball
|
||||
- Hyper Voice
|
||||
""";
|
||||
|
||||
private const string SetSmeargle =
|
||||
@"Smeargle @ Focus Sash
|
||||
Ability: Own Tempo
|
||||
EVs: 248 HP / 8 Def / 252 Spe
|
||||
Jolly Nature
|
||||
- Sticky Web
|
||||
- Nuzzle
|
||||
- Taunt
|
||||
- Whirlwind";
|
||||
"""
|
||||
Smeargle @ Focus Sash
|
||||
Ability: Own Tempo
|
||||
EVs: 248 HP / 8 Def / 252 Spe
|
||||
Jolly Nature
|
||||
- Sticky Web
|
||||
- Nuzzle
|
||||
- Taunt
|
||||
- Whirlwind
|
||||
""";
|
||||
|
||||
private const string SetCelebi =
|
||||
@"Celebi @ Toxic Orb
|
||||
Ability: Natural Cure
|
||||
Jolly Nature
|
||||
- Recover
|
||||
- Heal Bell
|
||||
- Safeguard
|
||||
- Hold Back";
|
||||
"""
|
||||
Celebi @ Toxic Orb
|
||||
Ability: Natural Cure
|
||||
Jolly Nature
|
||||
- Recover
|
||||
- Heal Bell
|
||||
- Safeguard
|
||||
- Hold Back
|
||||
""";
|
||||
|
||||
private const string SetNicknamedTypeNull =
|
||||
@"Reliance (Type: Null) @ Eviolite
|
||||
EVs: 252 HP / 4 Def / 252 SpD
|
||||
Ability: Battle Armor
|
||||
Careful Nature
|
||||
- Facade
|
||||
- Swords Dance
|
||||
- Sleep Talk
|
||||
- Rest";
|
||||
"""
|
||||
Reliance (Type: Null) @ Eviolite
|
||||
EVs: 252 HP / 4 Def / 252 SpD
|
||||
Ability: Battle Armor
|
||||
Careful Nature
|
||||
- Facade
|
||||
- Swords Dance
|
||||
- Sleep Talk
|
||||
- Rest
|
||||
""";
|
||||
|
||||
private const string SetMunchSnorLax =
|
||||
@"Snorlax @ Choice Band
|
||||
Ability: Thick Fat
|
||||
Level: 50
|
||||
EVs: 84 HP / 228 Atk / 180 Def / 12 SpD / 4 Spe
|
||||
Adamant Nature
|
||||
- Double-Edge
|
||||
- High Horsepower
|
||||
- Self-Destruct
|
||||
- Fire Punch";
|
||||
"""
|
||||
Snorlax @ Choice Band
|
||||
Ability: Thick Fat
|
||||
Level: 50
|
||||
EVs: 84 HP / 228 Atk / 180 Def / 12 SpD / 4 Spe
|
||||
Adamant Nature
|
||||
- Double-Edge
|
||||
- High Horsepower
|
||||
- Self-Destruct
|
||||
- Fire Punch
|
||||
""";
|
||||
|
||||
private const string SetSlowpoke12 =
|
||||
@"Threat (Slowpoke) @ Eviolite
|
||||
Ability: Regenerator
|
||||
Shiny: Yes
|
||||
EVs: 248 HP / 252 Atk / 8 SpD
|
||||
Adamant Nature
|
||||
- Body Slam
|
||||
- Earthquake
|
||||
- Belly Drum
|
||||
- Iron Tail";
|
||||
"""
|
||||
Threat (Slowpoke) @ Eviolite
|
||||
Ability: Regenerator
|
||||
Shiny: Yes
|
||||
EVs: 248 HP / 252 Atk / 8 SpD
|
||||
Adamant Nature
|
||||
- Body Slam
|
||||
- Earthquake
|
||||
- Belly Drum
|
||||
- Iron Tail
|
||||
""";
|
||||
|
||||
private static readonly string[] Sets =
|
||||
[
|
||||
|
@ -310,13 +328,15 @@ Adamant Nature
|
|||
SetNicknamedTypeNull,
|
||||
SetMunchSnorLax,
|
||||
|
||||
@"Greninja @ Choice Specs
|
||||
Ability: Battle Bond
|
||||
EVs: 252 SpA / 4 SpD / 252 Spe
|
||||
Timid Nature
|
||||
- Hydro Pump
|
||||
- Spikes
|
||||
- Water Shuriken
|
||||
- Dark Pulse",
|
||||
"""
|
||||
Greninja @ Choice Specs
|
||||
Ability: Battle Bond
|
||||
EVs: 252 SpA / 4 SpD / 252 Spe
|
||||
Timid Nature
|
||||
- Hydro Pump
|
||||
- Spikes
|
||||
- Water Shuriken
|
||||
- Dark Pulse
|
||||
""",
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue