Skip to content

Commit

Permalink
Clear template OT & Nickname strings; add latest events legality
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu098vm committed Jul 15, 2024
1 parent bd12664 commit a8af4ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
25 changes: 8 additions & 17 deletions TeraFinder.Core/Classes/EncounterTF9/EncounterRaidTF9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ public bool GeneratePK9(TeraDetails rngResult, uint id32, GameVersion version, s
Version = version,
Language = ot_language,
HandlingTrainerLanguage = (byte)ot_language,
OriginalTrainerName = ot_name,
HandlingTrainerName = ot_name,
OriginalTrainerName = IsNonLatinIllegal(ot_language, ot_name) ? "TF" : ot_name,
HandlingTrainerName = IsNonLatinIllegal(ot_language, ot_name) ? "TF" : ot_name,
OriginalTrainerGender = ot_gender,
TeraTypeOriginal = (MoveType)rngResult.TeraType,
EncryptionConstant = rngResult.EC,
Expand Down Expand Up @@ -185,26 +185,17 @@ public bool GeneratePK9(TeraDetails rngResult, uint id32, GameVersion version, s
legality = new LegalityAnalysis(result);
if (!legality.Valid)
{
//CHS, CHT, KOR and JPN have OT Name length restrictions
var la_ot = legality.Results.Where(l => l.Identifier is CheckIdentifier.Trainer).FirstOrDefault();
if (la_ot.Judgement is Severity.Invalid && (LanguageID)result.Language is LanguageID.ChineseS or LanguageID.ChineseT or LanguageID.Korean or LanguageID.Japanese)
{
result.OriginalTrainerName = "TF";
result.RefreshChecksum();
legality = new LegalityAnalysis(result);
}

//Seed 0xC4C200B6 produces equal EC and PID, which PKHeX flags as invalid
if (!legality.Valid)
{
var la_ec = legality.Results.Where(l => l.Identifier is CheckIdentifier.EC).FirstOrDefault();
if (la_ec.Judgement is Severity.Invalid && rngResult.EC == rngResult.PID)
return true;
}
var la_ec = legality.Results.Where(l => l.Identifier is CheckIdentifier.EC).FirstOrDefault();
if (la_ec.Judgement is Severity.Invalid && rngResult.EC == rngResult.PID)
return true;
}
return legality.Valid;
}

private static bool IsNonLatinIllegal(int languageID, string name) => (((LanguageID)languageID is LanguageID.Japanese or
LanguageID.ChineseS or LanguageID.ChineseT or LanguageID.Korean) && (name.Length >= 7));


//Get the encounter names from a pool of encounters
public static HashSet<string> GetAvailableSpecies(EncounterRaidTF9[] encounters, byte stars, string[] speciesNames, string[] formsNames, string[] typesNames, Dictionary<string, string> pluginStrings)
Expand Down
Binary file modified TeraFinder.Core/Resources/raid_default/encounter_might_paldea.pkl
Binary file not shown.
Binary file modified TeraFinder.Core/Resources/raid_default/template.pk9
Binary file not shown.
4 changes: 4 additions & 0 deletions TeraFinder.Plugins/Utils/GridUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static void SaveSelectedPk9(this DataGridView dataGrid, CalculatorForm f,
var encounters = f.Editor.GetCurrentEncounters(content, map);
if (EncounterRaidTF9.TryGenerateTeraDetails(seed, encounters, version, progress, eventProgress, content, map, id32, groupid, out var enc, out var result))
{
var checkActiveHandler = ParseSettings.Settings.Handler.CheckActiveHandler;
ParseSettings.Settings.Handler.CheckActiveHandler = false;
if (!enc.GeneratePK9(result.Value, id32, version, f.Editor.SAV.OT, f.Editor.SAV.Language, f.Editor.SAV.Gender, out var pk9, out var la))
{
Expand All @@ -171,6 +172,7 @@ public static void SaveSelectedPk9(this DataGridView dataGrid, CalculatorForm f,
MessageBox.Show($"{strings["GridUtil.ErrorParsing"]}\n{strings["GridUtil.MissingData"]} [{enc.Identifier}].\n{strings["GridUtil.CheckWiki"]}");
else
MessageBox.Show($"{strings["GridUtil.ErrorParsing"]} {strings["GridUtil.Report"]}\n{la.Report()}");
ParseSettings.Settings.Handler.CheckActiveHandler = checkActiveHandler;
return;
}

Expand All @@ -196,6 +198,8 @@ public static void SaveSelectedPk9(this DataGridView dataGrid, CalculatorForm f,
File.WriteAllBytes(sfd.FileName, pk9.Data);
MessageBox.Show($"{strings["GridUtil.Exported"]} {sfd.FileName}");
}

ParseSettings.Settings.Handler.CheckActiveHandler = checkActiveHandler;
}
}
catch (Exception ex)
Expand Down

0 comments on commit a8af4ed

Please sign in to comment.