public static void SetEncounterMasteryFlags(this IMoveShop8Mastery shop, ReadOnlySpan <int> moves, Learnset mastery, int level) { var possible = shop.MoveShopPermitIndexes; var permit = shop.MoveShopPermitFlags; foreach (var move in moves) { var index = possible.IndexOf((ushort)move); if (index == -1) { continue; } if (!permit[index]) { continue; } // If the Pokémon is caught with any move shop move in its learnset // and it is high enough level to master it, the game will automatically // give it the "Mastered" flag but not the "Purchased" flag // For moves that are not in the learnset, it returns -1 which is true, thus set as mastered. if (level >= mastery.GetMoveLevel(move)) { shop.SetMasteredRecordFlag(index, true); } } }
public static bool IsValidPurchasedEncounter(this IMoveShop8 shop, Learnset learn, int level, ushort alpha, bool allowPurchasedAlpha) { var permit = shop.MoveShopPermitIndexes; var current = shop.MoveShopPermitFlags; for (int i = 0; i < current.Length; i++) { if (!current[i]) { continue; } if (!shop.GetPurchasedRecordFlag(i)) { continue; } var move = permit[i]; // Can only purchase a move if it is not already in the available learnset. var learnLevel = learn.GetMoveLevel(move); if ((uint)learnLevel <= level) { return(false); } // Can only purchase an Alpha Move if it was pre-1.1 patch. if (move == alpha && !allowPurchasedAlpha) { return(false); } } return(true); }
public static bool IsValidMasteredEncounter(this IMoveShop8Mastery shop, Span <int> moves, Learnset learn, Learnset mastery, int level, ushort alpha, bool allowPurchasedAlpha) { foreach (var move in moves) { if (move == 0) { continue; } var index = shop.MoveShopPermitIndexes.IndexOf((ushort)move); if (index == -1) { continue; // manually mastered for encounter, not a tutor } bool p = shop.GetPurchasedRecordFlag(index); bool m = shop.GetMasteredRecordFlag(index); var masteryLevel = mastery.GetMoveLevel(move); if (masteryLevel > level && move != alpha) // no master flag set { if (!p && m) { // Check for seed of mastery usage if (learn.GetMoveLevel(move) > level) { return(false); } } } else { // Pre 1.1 patch, players could purchase the Alpha Move from the move shop. // After the patch, the Alpha Move is considered purchased (even without the flag). // Players won't be able to waste money after the patch :) // For legality, allow the Alpha Move to be flagged as Purchased if it was a pre-patch capture. if (p && (move != alpha || !allowPurchasedAlpha)) { return(false); } if (!m) { return(false); } } } return(true); }
public static void SetMasteredFlag(this IMoveShop8Mastery shop, Learnset learn, Learnset mastery, int level, int index, int move) { if (shop.GetMasteredRecordFlag(index)) { return; } if (level < (uint)learn.GetMoveLevel(move)) // Can't learn it yet; must purchase. { shop.SetPurchasedRecordFlag(index, true); shop.SetMasteredRecordFlag(index, true); return; } if (level < (uint)mastery.GetMoveLevel(move)) // Can't master it yet; must Seed of Mastery { shop.SetMasteredRecordFlag(index, true); } }