Files
infinitefusion-e18/Data/Scripts/052_InfiniteFusion/Gameplay/Utilities/MenuUtils.rb
2025-09-28 15:53:01 -04:00

92 lines
2.5 KiB
Ruby

def obtainBadgeMessage(badgeName)
Kernel.pbMessage(_INTL("\\me[Badge get]{1} obtained the {2}!", $Trainer.name, badgeName))
end
def promptCaughtPokemonAction(pokemon)
pickedOption = false
return pbStorePokemon(pokemon) if !$Trainer.party_full?
return promptKeepOrRelease(pokemon) if isOnPinkanIsland() && !$game_switches[SWITCH_PINKAN_FINISHED]
while !pickedOption
command = pbMessage(_INTL("\\ts[]Your team is full!"),
[_INTL("Add to your party"), _INTL("Store to PC"),], 2)
echoln ("command " + command.to_s)
case command
when 0 # SWAP
if swapCaughtPokemon(pokemon)
echoln pickedOption
pickedOption = true
end
else
# STORE
pbStorePokemon(pokemon)
echoln pickedOption
pickedOption = true
end
end
end
def promptKeepOrRelease(pokemon)
pickedOption = false
while !pickedOption
command = pbMessage(_INTL("\\ts[]Your team is full!"),
[_INTL("Release a party member"), _INTL("Release this #{pokemon.name}"),], 2)
echoln ("command " + command.to_s)
case command
when 0 # SWAP
if swapReleaseCaughtPokemon(pokemon)
pickedOption = true
end
else
pickedOption = true
end
end
end
# def pbChoosePokemon(variableNumber, nameVarNumber, ableProc = nil, allowIneligible = false)
def swapCaughtPokemon(caughtPokemon)
pbChoosePokemon(1, 2,
proc { |poke|
!poke.egg? &&
!(poke.isShadow? rescue false)
})
index = pbGet(1)
return false if index == -1
$PokemonStorage.pbStoreCaught($Trainer.party[index])
pbRemovePokemonAt(index)
pbStorePokemon(caughtPokemon)
tmp = $Trainer.party[index]
$Trainer.party[index] = $Trainer.party[-1]
$Trainer.party[-1] = tmp
return true
end
def swapReleaseCaughtPokemon(caughtPokemon)
pbChoosePokemon(1, 2,
proc { |poke|
!poke.egg? &&
!(poke.isShadow? rescue false)
})
index = pbGet(1)
return false if index == -1
releasedPokemon = $Trainer.party[index]
pbMessage(_INTL("{1} was released.",releasedPokemon.name))
pbRemovePokemonAt(index)
pbStorePokemon(caughtPokemon)
tmp = $Trainer.party[index]
$Trainer.party[index] = $Trainer.party[-1]
$Trainer.party[-1] = tmp
return true
end
def select_any_pokemon()
commands = []
for dex_num in 1..NB_POKEMON
species = getPokemon(dex_num)
commands.push([dex_num - 1, species.real_name, species.id])
end
return pbChooseList(commands, 0, nil, 1)
end