mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-07-22 07:37:00 +00:00
Update 6.8
This commit is contained in:
@@ -1,22 +1,47 @@
|
||||
|
||||
class PokemonStorage
|
||||
class PokemonGlobalMetadata
|
||||
attr_accessor :seen_transfer_box_tutorial
|
||||
end
|
||||
|
||||
def transferBoxTutorial
|
||||
pbMessage(_INTL("This is the \\C[1]Transfer Box\\C[0]."))
|
||||
pbMessage(_INTL("This box can be used to transfer Pokémon between \\C[1]Pokémon Infinite Fusion\\C[0] and \\C[1]Pokémon Infinite Fusion: Hoenn\\C[0] or between savefiles."))
|
||||
pbMessage(_INTL("Any Pokémon that is placed in this box will be accessible from every savefile of either game. You can deposit or withdraw Pokémon just like you would for any other box."))
|
||||
end
|
||||
|
||||
class StorageTransferBox < PokemonBox
|
||||
TRANSFER_BOX_NAME = _INTL("Transfer Box")
|
||||
TRANSFER_BOX_NAME_DISABLED = _INTL("Transfer Box (Off)")
|
||||
|
||||
def initialize()
|
||||
super(TRANSFER_BOX_NAME,PokemonBox::BOX_SIZE)
|
||||
@pokemon = []
|
||||
@background = 16
|
||||
@background = "transfer"
|
||||
@disabled= false
|
||||
for i in 0...PokemonBox::BOX_SIZE
|
||||
@pokemon[i] = nil
|
||||
end
|
||||
loadTransferBoxPokemon
|
||||
if can_use_transfer_box?
|
||||
loadTransferBoxPokemon
|
||||
else
|
||||
pbMessage(_INTL("The Transfer Box is disabled because your savefile is flagged as randomized. You can still use it as a normal PC box, but the Pokémon you put in it won't be available in your other savefiles"))
|
||||
end
|
||||
end
|
||||
|
||||
def can_use_transfer_box?
|
||||
return !$game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE] && !@disabled
|
||||
end
|
||||
|
||||
def setDisabled
|
||||
unless @disabled
|
||||
@name = TRANSFER_BOX_NAME_DISABLED
|
||||
pbMessage(_INTL("\\C[2]The Transfer Box is disabled because your savefile is flagged as randomized. You can still use it as a normal PC box, but the Pokémon you put in it won't be available in your other savefiles"))
|
||||
end
|
||||
@disabled= true
|
||||
end
|
||||
|
||||
def loadTransferBoxPokemon
|
||||
echoln "Loading transfer box"
|
||||
path = transferBoxSavePath
|
||||
if File.exist?(path)
|
||||
File.open(path, "rb") do |f|
|
||||
@@ -29,12 +54,44 @@ class StorageTransferBox < PokemonBox
|
||||
end
|
||||
|
||||
def []=(i,value)
|
||||
return unless value.nil? || value.is_a?(Pokemon)
|
||||
return if check_is_duplicate(value)
|
||||
@pokemon[i] = value
|
||||
saveTransferBox()
|
||||
Game.save()
|
||||
if can_use_transfer_box?
|
||||
saveTransferBox()
|
||||
Game.save()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# If you have a pokemon has the same id as the one you're trying to deposit /withdraw, then
|
||||
# blocked
|
||||
def check_is_duplicate(box_pokemon)
|
||||
return false unless box_pokemon.is_a?(Pokemon)
|
||||
used_ids = []
|
||||
$Trainer.party.each { |pokemon|
|
||||
used_ids << pokemon.personalID
|
||||
}
|
||||
$PokemonStorage.boxes.each { |box|
|
||||
box.pokemon.each { |pokemon|
|
||||
used_ids << pokemon.personalID if pokemon.is_a?(Pokemon)
|
||||
}
|
||||
}
|
||||
$PokemonGlobal.daycare.each { |daycare_data|
|
||||
pokemon = daycare_data[0]
|
||||
used_ids << pokemon.personalID if pokemon
|
||||
}
|
||||
|
||||
if used_ids.count(box_pokemon.personalID) > 1
|
||||
pbPlayBuzzerSE
|
||||
pbMessage(_INTL("This Pokémon cannot be transferred."))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def saveTransferBox
|
||||
return unless can_use_transfer_box?
|
||||
path = transferBoxSavePath
|
||||
dir = File.dirname(path)
|
||||
Dir.mkdir(dir) unless Dir.exist?(dir)
|
||||
@@ -42,7 +99,7 @@ class StorageTransferBox < PokemonBox
|
||||
Marshal.dump(@pokemon, f)
|
||||
end
|
||||
echoln "Transfer box saved to #{path}"
|
||||
$game_temp.must_save_now=true
|
||||
Game.save
|
||||
rescue => e
|
||||
echoln "Failed to save transfer box: #{e}"
|
||||
end
|
||||
@@ -56,11 +113,24 @@ class StorageTransferBox < PokemonBox
|
||||
File.join(parent_dir, "infinitefusion_common", "transfer_pokemon_storage")
|
||||
end
|
||||
|
||||
def isAvailableWallpaper?
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#Never add more than 1, it would just be a copy
|
||||
def addPokemonStorageTransferBox()
|
||||
$PokemonStorage.boxes << StorageTransferBox.new
|
||||
already_has = false
|
||||
$PokemonStorage.boxes.each do|box|
|
||||
already_has = true if box.is_a?(StorageTransferBox)
|
||||
end
|
||||
|
||||
unless already_has
|
||||
$PokemonStorage.boxes << StorageTransferBox.new
|
||||
else
|
||||
echoln "Player already has transfer box - not adding"
|
||||
end
|
||||
end
|
||||
|
||||
def verifyTransferBoxAutosave()
|
||||
@@ -70,4 +140,18 @@ def verifyTransferBoxAutosave()
|
||||
return confirmed
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# class PokemonStorageScreen
|
||||
# alias pokemonStorageScreen_pbWithdraw pbWithdraw
|
||||
# def pbWithdraw(pokemon,heldpkmn)
|
||||
# box = @storage[@storage.currentBox]
|
||||
# if box.is_a?(StorageTransferBox) && box.can_use_transfer_box?
|
||||
# return unless check_withdrawable(pokemon)
|
||||
# end
|
||||
# pokemonStorageScreen_pbWithdraw(pokemon,heldpkmn)
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user