mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-02 13:16:35 -05:00
'Find' works for TPT runs
TPT runs contain pokemon, moves, and items. Now you can search for them.
This commit is contained in:
@@ -9,11 +9,16 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
||||
public const int TrainerFormat_StructTypeOffset = 0;
|
||||
public const int TrainerFormat_PokemonCountOffset = 32;
|
||||
public const int TrainerFormat_PointerOffset = 36;
|
||||
public const byte INCLUDE_MOVES = 1;
|
||||
public const byte INCLUDE_ITEM = 2;
|
||||
|
||||
public const int PokemonFormat_FixedIVStart = 0;
|
||||
public const int PokemonFormat_LevelStart = 2;
|
||||
public const int PokemonFormat_PokemonStart = 4;
|
||||
public const int PokemonFormat_MoveStart = 6;
|
||||
|
||||
public static readonly string SharedFormatString = AsciiRun.StreamDelimeter + "tpt" + AsciiRun.StreamDelimeter;
|
||||
|
||||
private const byte INCLUDE_MOVES = 1;
|
||||
private const byte INCLUDE_ITEM = 2;
|
||||
private readonly IDataModel model;
|
||||
|
||||
public byte StructType { get; }
|
||||
@@ -49,6 +54,27 @@ namespace HavenSoft.HexManiac.Core.Models.Runs {
|
||||
ElementLength = ElementContent.Sum(segment => segment.Length);
|
||||
}
|
||||
|
||||
public IEnumerable<int> Search(string parentArrayName, int id) {
|
||||
for (int i = 0; i < ElementCount; i++) {
|
||||
int start = Start + i * ElementLength;
|
||||
if (parentArrayName == EggMoveRun.MoveNamesTable && (StructType & INCLUDE_MOVES) != 0) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
var index = start + PokemonFormat_MoveStart + j * 2;
|
||||
var moveID = model.ReadMultiByteValue(index, 2);
|
||||
if (moveID == id) yield return index;
|
||||
}
|
||||
} else if (parentArrayName == EggMoveRun.PokemonNameTable) {
|
||||
var index = start + PokemonFormat_PokemonStart;
|
||||
var pokemonID = model.ReadMultiByteValue(index, 2);
|
||||
if (pokemonID == id) yield return index;
|
||||
} else if (parentArrayName == HardcodeTablesModel.ItemsTableName && (StructType & INCLUDE_ITEM) != 0) {
|
||||
var index = start + ElementLength - 2;
|
||||
var itemID = model.ReadMultiByteValue(index, 2);
|
||||
if (itemID == id) yield return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region BaseRun
|
||||
|
||||
public override int Length => ElementLength * ElementCount;
|
||||
|
||||
@@ -847,6 +847,12 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
||||
}
|
||||
}
|
||||
}
|
||||
// option 3: the value is a move used by trainer teams
|
||||
if (child is TrainerPokemonTeamRun team) {
|
||||
foreach (var result in team.Search(parentArrayName, offsets.ElementIndex)) {
|
||||
yield return (result, result + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user