diff --git a/Data/Scripts/012_Battle/006_Other battle types/008_PokeBattle_BattlePeer.rb b/Data/Scripts/012_Battle/006_Other battle types/008_PokeBattle_BattlePeer.rb index 9570bfb65..88e7f11c3 100644 --- a/Data/Scripts/012_Battle/006_Other battle types/008_PokeBattle_BattlePeer.rb +++ b/Data/Scripts/012_Battle/006_Other battle types/008_PokeBattle_BattlePeer.rb @@ -7,7 +7,7 @@ class PokeBattle_NullBattlePeer def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle=false); end def pbStorePokemon(player,pkmn) - player.party[player.party.length] = pkmn if player.party.length < MAX_PARTY_SIZE + player.party[player.party.length] = pkmn if !player.party_full? return -1 end @@ -23,7 +23,7 @@ end #=============================================================================== class PokeBattle_RealBattlePeer def pbStorePokemon(player,pkmn) - if player.party.length < MAX_PARTY_SIZE + if !player.party_full? player.party[player.party.length] = pkmn return -1 end diff --git a/Data/Scripts/013_Overworld/013_PField_DayCare.rb b/Data/Scripts/013_Overworld/013_PField_DayCare.rb index 7edf44264..87d1d2131 100644 --- a/Data/Scripts/013_Overworld/013_PField_DayCare.rb +++ b/Data/Scripts/013_Overworld/013_PField_DayCare.rb @@ -65,7 +65,7 @@ end def pbDayCareWithdraw(index) if !$PokemonGlobal.daycare[index][0] raise _INTL("There's no Pokémon here...") - elsif $Trainer.party.length >= MAX_PARTY_SIZE + elsif $Trainer.party_full? raise _INTL("Can't store the Pokémon...") else $Trainer.party[$Trainer.party.length] = $PokemonGlobal.daycare[index][0] diff --git a/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb b/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb index 4375268cc..f9026c190 100644 --- a/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb +++ b/Data/Scripts/014_Trainers/001_PokeBattle_Trainer.rb @@ -147,6 +147,10 @@ class PokeBattle_Trainer return p[p.length - 1] end + def party_full? + return @party.length >= MAX_PARTY_SIZE + end + #============================================================================= # Pokédex #============================================================================= diff --git a/Data/Scripts/015_Items/002_PItem_ItemEffects.rb b/Data/Scripts/015_Items/002_PItem_ItemEffects.rb index 58fd28dda..c2e8dcb88 100644 --- a/Data/Scripts/015_Items/002_PItem_ItemEffects.rb +++ b/Data/Scripts/015_Items/002_PItem_ItemEffects.rb @@ -985,7 +985,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene| next true end # Unfusing - if $Trainer.party.length >= MAX_PARTY_SIZE + if $Trainer.party_full? scene.pbDisplay(_INTL("You have no room to separate the Pokémon.")) next false end @@ -1034,7 +1034,7 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene| next true end # Unfusing - if $Trainer.party.length >= MAX_PARTY_SIZE + if $Trainer.party_full? scene.pbDisplay(_INTL("You have no room to separate the Pokémon.")) next false end @@ -1083,7 +1083,7 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene| next true end # Unfusing - if $Trainer.party.length >= MAX_PARTY_SIZE + if $Trainer.party_full? scene.pbDisplay(_INTL("You have no room to separate the Pokémon.")) next false end diff --git a/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb b/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb index 692565d15..94c1f92e6 100644 --- a/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb +++ b/Data/Scripts/015_Items/003_PItem_BattleItemEffects.rb @@ -23,7 +23,7 @@ ItemHandlers::CanUseInBattle.copy(:POKEDOLL,:FLUFFYTAIL,:POKETOY) ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| - if battle.pbPlayer.party.length >= MAX_PARTY_SIZE && $PokemonStorage.full? + if battle.pbPlayer.party_full? && $PokemonStorage.full? scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages next false end diff --git a/Data/Scripts/016_Pokemon/005_Pokemon_Evolution.rb b/Data/Scripts/016_Pokemon/005_Pokemon_Evolution.rb index 6db5f869a..66ff4ea7f 100644 --- a/Data/Scripts/016_Pokemon/005_Pokemon_Evolution.rb +++ b/Data/Scripts/016_Pokemon/005_Pokemon_Evolution.rb @@ -452,7 +452,7 @@ PBEvolution.register(:Ninjask, { PBEvolution.register(:Shedinja, { "parameterType" => nil, "afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| - next false if $Trainer.party.length >= MAX_PARTY_SIZE + next false if $Trainer.party_full? next false if !$PokemonBag.pbHasItem?(:POKEBALL) PokemonEvolutionScene.pbDuplicatePokemon(pkmn, new_species) $PokemonBag.pbDeleteItem(:POKEBALL) diff --git a/Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb b/Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb index f9ccd61dc..d576469dc 100644 --- a/Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb +++ b/Data/Scripts/016_Pokemon/009_Pokemon_Storage.rb @@ -3,9 +3,9 @@ class PokemonBox attr_accessor :name attr_accessor :background - BOX_WIDTH = 6 + BOX_WIDTH = 6 BOX_HEIGHT = 5 - BOX_SIZE = BOX_WIDTH * BOX_HEIGHT + BOX_SIZE = BOX_WIDTH * BOX_HEIGHT def initialize(name, maxPokemon = BOX_SIZE) @pokemon = [] @@ -121,6 +121,10 @@ class PokemonStorage raise ArgumentError.new("Not supported") end + def party_full? + return $Trainer.party_full? + end + def maxBoxes return @boxes.length end @@ -179,7 +183,7 @@ class PokemonStorage return false if !found end if boxDst==-1 # Copying into party - return false if self.party.length >= MAX_PARTY_SIZE + return false if party_full? self.party[self.party.length] = self[boxSrc,indexSrc] self.party.compact! else # Copying into box @@ -200,7 +204,7 @@ class PokemonStorage end def pbMoveCaughtToParty(pkmn) - return false if self.party.length >= MAX_PARTY_SIZE + return false if party_full? self.party[self.party.length] = pkmn end @@ -306,6 +310,10 @@ class RegionalStorage return getCurrentStorage.party end + def party_full? + return getCurrentStorage.party_full? + end + def maxBoxes return getCurrentStorage.maxBoxes end diff --git a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb index 7f474f3a4..ec6856af9 100644 --- a/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb +++ b/Data/Scripts/017_UI/017_PScreen_PokemonStorage.rb @@ -1681,7 +1681,7 @@ class PokemonStorageScreen if box==-1 raise _INTL("Can't withdraw from party..."); end - if @storage.party.length >= MAX_PARTY_SIZE + if @storage.party_full? pbDisplay(_INTL("Your party's full!")) return false end diff --git a/Data/Scripts/017_UI/019_PScreen_PC.rb b/Data/Scripts/017_UI/019_PScreen_PC.rb index abd9a499b..f74612edc 100644 --- a/Data/Scripts/017_UI/019_PScreen_PC.rb +++ b/Data/Scripts/017_UI/019_PScreen_PC.rb @@ -48,7 +48,7 @@ class StorageSystemPC ) if command>=0 && command<3 if command==1 # Withdraw - if $PokemonStorage.party.length >= MAX_PARTY_SIZE + if $PokemonStorage.party_full? pbMessage(_INTL("Your party is full!")) next end diff --git a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb index 20b293bb6..ea4e78fc8 100644 --- a/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb +++ b/Data/Scripts/020_System and utilities/004_PSystem_PokemonUtilities.rb @@ -2,7 +2,7 @@ # Nicknaming and storing Pokémon #=============================================================================== def pbBoxesFull? - return ($Trainer.party.length >= MAX_PARTY_SIZE && $PokemonStorage.full?) + return ($Trainer.party_full? && $PokemonStorage.full?) end def pbNickname(pkmn) @@ -21,9 +21,7 @@ def pbStorePokemon(pkmn) return end pkmn.pbRecordFirstMoves - if $Trainer.party.length < MAX_PARTY_SIZE - $Trainer.party[$Trainer.party.length] = pkmn - else + if $Trainer.party_full? oldcurbox = $PokemonStorage.currentBox storedbox = $PokemonStorage.pbStoreCaught(pkmn) curboxname = $PokemonStorage[oldcurbox].name @@ -45,6 +43,8 @@ def pbStorePokemon(pkmn) end pbMessage(_INTL("It was stored in box \"{1}.\"", boxname)) end + else + $Trainer.party[$Trainer.party.length] = pkmn end end @@ -85,10 +85,10 @@ def pbAddPokemonSilent(pkmn, level = 1, see_form = true) $Trainer.owned[pkmn.species] = true pbSeenForm(pkmn) if see_form pkmn.pbRecordFirstMoves - if $Trainer.party.length < MAX_PARTY_SIZE - $Trainer.party[$Trainer.party.length] = pkmn - else + if $Trainer.party_full? $PokemonStorage.pbStoreCaught(pkmn) + else + $Trainer.party[$Trainer.party.length] = pkmn end return true end @@ -97,7 +97,7 @@ end # Giving Pokémon/eggs to the player (can only add to party) #=============================================================================== def pbAddToParty(pkmn, level = 1, see_form = true) - return false if !pkmn || $Trainer.party.length >= MAX_PARTY_SIZE + return false if !pkmn || $Trainer.party_full? pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) species_name = pkmn.speciesName pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name)) @@ -107,7 +107,7 @@ def pbAddToParty(pkmn, level = 1, see_form = true) end def pbAddToPartySilent(pkmn, level = nil, see_form = true) - return false if !pkmn || $Trainer.party.length >= MAX_PARTY_SIZE + return false if !pkmn || $Trainer.party_full? pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) $Trainer.seen[pkmn.species] = true $Trainer.owned[pkmn.species] = true @@ -118,7 +118,7 @@ def pbAddToPartySilent(pkmn, level = nil, see_form = true) end def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner_gender = 0, see_form = true) - return false if !pkmn || $Trainer.party.length >= MAX_PARTY_SIZE + return false if !pkmn || $Trainer.party_full? pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon) # Set original trainer to a foreign one pkmn.owner = Pokemon::Owner.new_foreign(owner_name || "", owner_gender) @@ -139,7 +139,7 @@ def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner end def pbGenerateEgg(pkmn, text = "") - return false if !pkmn || $Trainer.party.length >= MAX_PARTY_SIZE + return false if !pkmn || $Trainer.party_full? pkmn = Pokemon.new(pkmn, EGG_LEVEL) if !pkmn.is_a?(Pokemon) # Set egg's details pkmn.name = _INTL("Egg") diff --git a/Data/Scripts/021_Debug/001_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/021_Debug/001_Debug menus/003_Debug_MenuExtraCode.rb index f4b0a1a63..d8ad406cf 100644 --- a/Data/Scripts/021_Debug/001_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/021_Debug/001_Debug menus/003_Debug_MenuExtraCode.rb @@ -291,7 +291,7 @@ def pbDebugDayCare when 0 # Withdraw Pokémon 1 if !$PokemonGlobal.daycare[0][0] pbPlayBuzzerSE - elsif $Trainer.party.length >= MAX_PARTY_SIZE + elsif $Trainer.party_full? pbPlayBuzzerSE pbMessage(_INTL("Party is full, can't withdraw Pokémon.")) else @@ -303,7 +303,7 @@ def pbDebugDayCare when 1 # Withdraw Pokémon 2 if !$PokemonGlobal.daycare[1][0] pbPlayBuzzerSE - elsif $Trainer.party.length >= MAX_PARTY_SIZE + elsif $Trainer.party_full? pbPlayBuzzerSE pbMessage(_INTL("Party is full, can't withdraw Pokémon.")) else @@ -344,7 +344,7 @@ def pbDebugDayCare when 4 # Collect egg if $PokemonGlobal.daycareEgg!=1 pbPlayBuzzerSE - elsif $Trainer.party.length >= MAX_PARTY_SIZE + elsif $Trainer.party_full? pbPlayBuzzerSE pbMessage(_INTL("Party is full, can't collect the egg.")) else