mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-24 15:47:15 -05:00
Add replace trainer name (Z)
profanity OT/nick => replace with this not that it is currently being used, as none of the official events have bad OT names, and HOME can't transfer in stuff-yet-to-reset.
This commit is contained in:
parent
e6a59740bb
commit
4c2cc2f45f
71
PKHeX.Core/PKM/Strings/Trainer/ReplaceTrainerName9a.cs
Normal file
71
PKHeX.Core/PKM/Strings/Trainer/ReplaceTrainerName9a.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Logic for replacing the name of a Pokémon in <see cref="EntityContext.Gen9a"/>.
|
||||
/// </summary>
|
||||
public static class ReplaceTrainerName9a
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if the original name is a trigger for replacement, and if the current name is a valid replacement.
|
||||
/// </summary>
|
||||
/// <param name="original">Original name to check for replacement trigger.</param>
|
||||
/// <param name="current">Current name to check for valid replacement.</param>
|
||||
/// <param name="language">Entity language.</param>
|
||||
public static bool IsTriggerAndReplace(ReadOnlySpan<char> original, ReadOnlySpan<char> current, LanguageID language)
|
||||
{
|
||||
if (!IsTrigger(original, language))
|
||||
return false;
|
||||
return IsReplace(current, language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified name should be replaced based on language-specific rules.
|
||||
/// </summary>
|
||||
/// <remarks>This method checks for undefined characters in the name and applies additional rules for
|
||||
/// certain languages. For example, names longer than five characters are flagged for replacement in Asian languages
|
||||
/// such as Japanese, Korean, Simplified Chinese, and Traditional Chinese.</remarks>
|
||||
/// <param name="name">The name to evaluate, represented as a read-only span of characters.</param>
|
||||
/// <param name="language">The language identifier used to apply language-specific rules.</param>
|
||||
/// <returns><see langword="true"/> if the name contains undefined characters or violates language-specific constraints;
|
||||
/// otherwise, <see langword="false"/>.</returns>
|
||||
public static bool IsTrigger(ReadOnlySpan<char> name, LanguageID language)
|
||||
{
|
||||
bool result = !ReplaceTrainerName8.IsValid(name, language);
|
||||
if (result)
|
||||
return true;
|
||||
|
||||
// Skip CheckNgWords: Numbers, whitespace, whitewords, nn::ngc -- implicitly flagged by our WordFilter. No legitimate events trigger this.
|
||||
|
||||
return false; // OK
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the provided name is one of the valid replacement names for the specified language and game version.
|
||||
/// </summary>
|
||||
/// <param name="name">Current name to check for valid replacement.</param>
|
||||
/// <param name="language">Entity language.</param>
|
||||
public static bool IsReplace(ReadOnlySpan<char> name, LanguageID language)
|
||||
{
|
||||
var expect = GetName(language);
|
||||
return name.SequenceEqual(expect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the replacement name for <see cref="EntityContext.Gen9"/> in the given language.
|
||||
/// </summary>
|
||||
public static string GetName(LanguageID language) => language switch
|
||||
{
|
||||
LanguageID.Japanese => "ゼット.",
|
||||
LanguageID.French => "Zed",
|
||||
LanguageID.Italian => "Zeta",
|
||||
LanguageID.German => "Zett",
|
||||
LanguageID.Spanish => "Zeta",
|
||||
LanguageID.SpanishL => "Zeta",
|
||||
LanguageID.Korean => "제트.",
|
||||
LanguageID.ChineseS or LanguageID.ChineseT => "Z.",
|
||||
|
||||
_ => "Z",
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user