Skip to content

Commit

Permalink
Merge pull request #110 from Mygod/max-moves
Browse files Browse the repository at this point in the history
Max moves support
  • Loading branch information
Mygod authored Nov 19, 2024
2 parents 6ce0faa + 6b95ecd commit 3b9de9c
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/classes/Move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,24 @@ export default class Moves extends Masterfile {
data: { moveSettings },
} = object
try {
const id: number =
Rpc.HoloPokemonMove[templateId.substring(11) as MoveProto]
const isMax = templateId.startsWith('VN_BM_')
const proto = isMax ? templateId : templateId.substring(11)
const id = Rpc.HoloPokemonMove[proto as MoveProto]
if (id || id === 0) {
if (!this.parsedMoves[id]) {
this.parsedMoves[id] = {
moveId: id,
moveName: this.capitalize(
templateId.substring(11).replace('_FAST', ''),
isMax ? moveSettings.vfxName : proto.replace('_FAST', '')
),
proto: templateId.substring(11),
proto,
fast: templateId.endsWith('_FAST'),
}
}
this.parsedMoves[id].type =
Rpc.HoloPokemonType[moveSettings.pokemonType as TypeProto]
this.parsedMoves[id].power = moveSettings.power
this.parsedMoves[id].power = isMax
? moveSettings.obMoveSettingsNumber18[2] : moveSettings.power
this.parsedMoves[id].durationMs = moveSettings.durationMs
this.parsedMoves[id].energyDelta = moveSettings.energyDelta
}
Expand Down
39 changes: 39 additions & 0 deletions src/classes/Pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,45 @@ export default class Pokemon extends Masterfile {
}
}

addSourdoughMoveMappings({ data: {
sourdoughMoveMappingSettings: { mappings }
} }: NiaMfObj) {
for (let i = 0; i < mappings.length; i += 1) try {
let id = Rpc.HoloPokemonId[
mappings[i].pokemonId as PokemonIdProto
]
if (!this.parsedPokemon[id]) {
this.parsedPokemon[id] = {}
}
let target = this.parsedPokemon[id]
if (mappings[i].form) {
let formId = Rpc.PokemonDisplayProto.Form[mappings[i].form as FormProto]
if (!this.parsedPokemon[id].forms) {
this.parsedPokemon[id].forms = []
}
const formName = this.formName(id, mappings[i].form)
if (!this.skipForms(formName)) {
this.parsedForms[formId] = {
...this.parsedForms[formId],
formName,
formId,
}
if (!this.parsedPokemon[id].forms.includes(formId)) {
this.parsedPokemon[id].forms.push(formId)
}
target = this.parsedForms[formId]
}
}
target.gmaxMove = Rpc.HoloPokemonMove[mappings[i].move as MoveProto]
} catch (e) {
console.warn(
e,
`Failed to parse gmax move mapping #${i}`,
JSON.stringify(mappings[i], null, 2),
)
}
}

missingPokemon() {
Object.values(Rpc.HoloPokemonId).forEach((id) => {
try {
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function generate({
const final: FinalResult = {}
const urlToFetch =
url ||
'https://raw.githubusercontent.com/PokeMiners/game_masters/master/latest/latest.json'
'https://raw.githubusercontent.com/alexelgt/game_masters/refs/heads/master/GAME_MASTER.json'
const {
pokemon,
types,
Expand Down Expand Up @@ -91,6 +91,8 @@ export async function generate({
AllPokemon.addForm(data[i])
} else if (data[i].data.pokemonSettings) {
AllPokemon.addPokemon(data[i])
} else if (data[i].data.sourdoughMoveMappingSettings) {
AllPokemon.addSourdoughMoveMappings(data[i])
} else if (data[i].data.itemSettings) {
AllItems.addItem(data[i])
} else if (data[i].data.moveSettings) {
Expand Down Expand Up @@ -305,6 +307,7 @@ export async function generate({
forms: localForms,
itemRequirement: localItems,
questRequirement: localEvolutionQuests,
// TODO gmaxMove
})
if (pokemon.options.includeRawForms || raw) {
final.forms = localForms
Expand Down
1 change: 1 addition & 0 deletions src/typings/dataTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ interface SingleForm extends BaseStats {
costumeName: string
}[]
sizeSettings?: { name: string; value: number }[]
gmaxMove?: number
}

export interface TempEvolutions extends BaseStats {
Expand Down
13 changes: 11 additions & 2 deletions src/typings/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ export interface NiaMfObj {
moveSettings?: {
movementId: string
pokemonType: string
power: number
power?: number
durationMs: number
energyDelta: number
energyDelta?: number
vfxName: string
obMoveSettingsNumber18: number[]
}
combatMove?: {
uniqueId: string | number
Expand All @@ -102,6 +104,13 @@ export interface NiaMfObj {
buffActivationChance: number
}[]
}
sourdoughMoveMappingSettings?: {
mappings: {
pokemonId: string
form?: string
move: string
}[]
}
itemSettings?: {
itemId: string | number
itemType: string | number
Expand Down
1 change: 1 addition & 0 deletions src/typings/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ interface Form extends BaseStats {
transferable?: boolean
costumeOverrideEvos?: CostumeOverrideEvo | StringBool
sizeSettings?: { name: boolean; value: boolean } | string
gmaxMove?: Move | StringBool
}

type CostumeOverrideEvo = {
Expand Down

0 comments on commit 3b9de9c

Please sign in to comment.