From 81baabfef2e7de695dc290e4bcb895183fc46efb Mon Sep 17 00:00:00 2001 From: Yako Date: Tue, 10 Jun 2025 14:44:54 +0200 Subject: [PATCH] Update DocTool to account for dynamic type names and add trainer items (not held items) to export --- DS_Map/DocTool.cs | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/DS_Map/DocTool.cs b/DS_Map/DocTool.cs index bb69d0e..66f9521 100644 --- a/DS_Map/DocTool.cs +++ b/DS_Map/DocTool.cs @@ -37,6 +37,7 @@ namespace DSPRE string[] moveNames = RomInfo.GetAttackNames(); string[] trainerNames = RomInfo.GetSimpleTrainerNames(); string[] trainerClassNames = RomInfo.GetTrainerClassNames(); + string[] typeNames = RomInfo.GetTypeNames(); // Handle Forms int extraCount = RomInfo.GetPersonalFilesCount() - pokeNames.Length; @@ -56,11 +57,11 @@ namespace DSPRE Directory.CreateDirectory(docsFolderPath); } - ExportPersonalDataToCSV(pokePersonalDataPath, pokeNames, abilityNames); + ExportPersonalDataToCSV(pokePersonalDataPath, pokeNames, abilityNames, typeNames); ExportLearnsetDataToCSV(learnsetDataPath, pokeNames, moveNames); ExportEvolutionDataToCSV(evolutionDataPath, pokeNames, itemNames, moveNames); ExportTrainersToText(trainerDataPath, trainerNames, trainerClassNames, pokeNames, itemNames, moveNames, abilityNames); - ExportMoveDataToCSV(moveDataPath, moveNames); + ExportMoveDataToCSV(moveDataPath, moveNames, typeNames); ExportTMHMDataToCSV(TMHMDataPath, pokeNames); @@ -68,7 +69,7 @@ namespace DSPRE } - private static void ExportPersonalDataToCSV(string pokePersonalDataPath, string[] pokeNames, string[] abilityNames) + private static void ExportPersonalDataToCSV(string pokePersonalDataPath, string[] pokeNames, string[] abilityNames, string[] typeNames) { // Write the Pokemon Personal Data to the CSV file PokemonPersonalData curPersonalData = null; @@ -80,7 +81,11 @@ namespace DSPRE for (int i = 0; i < RomInfo.GetPersonalFilesCount(); i++) { curPersonalData = new PokemonPersonalData(i); - sw.WriteLine($"{i},{pokeNames[i]},{curPersonalData.type1},{curPersonalData.type2}," + + + string type1String = (int) curPersonalData.type1 < typeNames.Length ? typeNames[(int)curPersonalData.type1] : "UnknownType_" + (int)curPersonalData.type1; + string type2String = (int) curPersonalData.type2 < typeNames.Length ? typeNames[(int)curPersonalData.type2] : "UnknownType_" + (int)curPersonalData.type2; + + sw.WriteLine($"{i},{pokeNames[i]},{type1String},{type2String}," + $"{curPersonalData.baseHP},{curPersonalData.baseAtk},{curPersonalData.baseDef}, " + $"{curPersonalData.baseSpAtk},{curPersonalData.baseSpDef},{curPersonalData.baseSpeed}," + $"{abilityNames[curPersonalData.firstAbility]},{abilityNames[curPersonalData.secondAbility]}"); @@ -192,6 +197,7 @@ namespace DSPRE string trainerName = trainerNames[i]; string trainerClass = trainerClassNames[curTrainerProperties.trainerClass]; + string[] trainerItems = curTrainerProperties.trainerItems.Select(item => item != 0 ? itemNames[(int)item] : "None").ToArray(); // Create array of party pokemon PartyPokemon[] partyPokemon = new PartyPokemon[curTrainerProperties.partyCount]; @@ -229,7 +235,8 @@ namespace DSPRE // Need to account for the case where the mon has no moves if (partyPokemon[j].moves == null) { - moves[j] = new string[] { "None" }; + LearnsetData learnset = new LearnsetData((int)partyPokemon[j].pokeID); + moves[j] = learnset.GetLearnsetAtLevel(levels[j]).Select(move => moveNames[move]).ToArray(); } else { @@ -248,14 +255,14 @@ namespace DSPRE SetMonGendersAndAbilitiesAndNature(i, curTrainerProperties.trainerClass, partyPokemon, monFlags, ref abilityNames, ref monGenders, ref abilities, ref natures); - sw.Write(TrainerToDocFormat(i, trainerName, trainerClass, monNames, monGenders, items, abilities, levels, natures, ivs, moves)); + sw.Write(TrainerToDocFormat(i, trainerName, trainerClass, trainerItems, monNames, monGenders, items, abilities, levels, natures, ivs, moves)); } sw.Close(); } - private static void ExportMoveDataToCSV(string moveDataPath, string[] moveNames) + private static void ExportMoveDataToCSV(string moveDataPath, string[] moveNames, string[] typeNames) { StreamWriter sw = new StreamWriter(moveDataPath); @@ -281,7 +288,9 @@ namespace DSPRE if (curMoveDataFile.battleeffect < battleSeqDesc.Length) { battleSeqDescString = battleSeqDesc[curMoveDataFile.battleeffect]; - } + } + + string typeString = (int)curMoveDataFile.movetype < typeNames.Length ? typeNames[(int)curMoveDataFile.movetype] : "UnknownType_" + (int)curMoveDataFile.movetype; sw.WriteLine($"{i},{moveNames[i]},{curMoveDataFile.movetype},{curMoveDataFile.split}," + $"{curMoveDataFile.damage},{curMoveDataFile.accuracy},{curMoveDataFile.priority}," + @@ -330,12 +339,22 @@ namespace DSPRE sw.Close(); } - private static string TrainerToDocFormat(int index, string trainerName, string trainerClass, string[] monNames, string[] monGenders, string[] items, string[] abilities, + private static string TrainerToDocFormat(int index, string trainerName, string trainerClass, string[] trainerItems, string[] monNames, string[] monGenders, string[] items, string[] abilities, int[] levels, string[] natures, int[] ivs, string[][] moves) { StringBuilder sb = new StringBuilder(); - sb.Append($"[{index}] {trainerClass} {trainerName}:\n\n"); + sb.Append($"[{index}] {trainerClass} {trainerName}"); + + // If trainer has at least one item then list all non-zero id items behind the trainer name + if (trainerItems.Length > 0 && trainerItems[0] != "None") + { + sb.Append(" @ ("); + sb.Append(string.Join(", ", trainerItems.Where(item => item != "None"))); + sb.Append(")"); + } + + sb.Append(":\n\n"); for (int i = 0; i < monNames.Length; i++) {