Added method $Trainer.party_full?

This commit is contained in:
Maruno17
2021-01-11 23:41:35 +00:00
parent f72ce06654
commit 2ab552ad3c
11 changed files with 40 additions and 28 deletions

View File

@@ -7,7 +7,7 @@ class PokeBattle_NullBattlePeer
def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle=false); end def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle=false); end
def pbStorePokemon(player,pkmn) 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 return -1
end end
@@ -23,7 +23,7 @@ end
#=============================================================================== #===============================================================================
class PokeBattle_RealBattlePeer class PokeBattle_RealBattlePeer
def pbStorePokemon(player,pkmn) def pbStorePokemon(player,pkmn)
if player.party.length < MAX_PARTY_SIZE if !player.party_full?
player.party[player.party.length] = pkmn player.party[player.party.length] = pkmn
return -1 return -1
end end

View File

@@ -65,7 +65,7 @@ end
def pbDayCareWithdraw(index) def pbDayCareWithdraw(index)
if !$PokemonGlobal.daycare[index][0] if !$PokemonGlobal.daycare[index][0]
raise _INTL("There's no Pokémon here...") 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...") raise _INTL("Can't store the Pokémon...")
else else
$Trainer.party[$Trainer.party.length] = $PokemonGlobal.daycare[index][0] $Trainer.party[$Trainer.party.length] = $PokemonGlobal.daycare[index][0]

View File

@@ -147,6 +147,10 @@ class PokeBattle_Trainer
return p[p.length - 1] return p[p.length - 1]
end end
def party_full?
return @party.length >= MAX_PARTY_SIZE
end
#============================================================================= #=============================================================================
# Pokédex # Pokédex
#============================================================================= #=============================================================================

View File

@@ -985,7 +985,7 @@ ItemHandlers::UseOnPokemon.add(:DNASPLICERS,proc { |item,pkmn,scene|
next true next true
end end
# Unfusing # Unfusing
if $Trainer.party.length >= MAX_PARTY_SIZE if $Trainer.party_full?
scene.pbDisplay(_INTL("You have no room to separate the Pokémon.")) scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
next false next false
end end
@@ -1034,7 +1034,7 @@ ItemHandlers::UseOnPokemon.add(:NSOLARIZER,proc { |item,pkmn,scene|
next true next true
end end
# Unfusing # Unfusing
if $Trainer.party.length >= MAX_PARTY_SIZE if $Trainer.party_full?
scene.pbDisplay(_INTL("You have no room to separate the Pokémon.")) scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
next false next false
end end
@@ -1083,7 +1083,7 @@ ItemHandlers::UseOnPokemon.add(:NLUNARIZER,proc { |item,pkmn,scene|
next true next true
end end
# Unfusing # Unfusing
if $Trainer.party.length >= MAX_PARTY_SIZE if $Trainer.party_full?
scene.pbDisplay(_INTL("You have no room to separate the Pokémon.")) scene.pbDisplay(_INTL("You have no room to separate the Pokémon."))
next false next false
end end

View File

@@ -23,7 +23,7 @@ ItemHandlers::CanUseInBattle.copy(:POKEDOLL,:FLUFFYTAIL,:POKETOY)
ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls
proc { |item,pokemon,battler,move,firstAction,battle,scene,showMessages| 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 scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages
next false next false
end end

View File

@@ -452,7 +452,7 @@ PBEvolution.register(:Ninjask, {
PBEvolution.register(:Shedinja, { PBEvolution.register(:Shedinja, {
"parameterType" => nil, "parameterType" => nil,
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species| "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) next false if !$PokemonBag.pbHasItem?(:POKEBALL)
PokemonEvolutionScene.pbDuplicatePokemon(pkmn, new_species) PokemonEvolutionScene.pbDuplicatePokemon(pkmn, new_species)
$PokemonBag.pbDeleteItem(:POKEBALL) $PokemonBag.pbDeleteItem(:POKEBALL)

View File

@@ -3,9 +3,9 @@ class PokemonBox
attr_accessor :name attr_accessor :name
attr_accessor :background attr_accessor :background
BOX_WIDTH = 6 BOX_WIDTH = 6
BOX_HEIGHT = 5 BOX_HEIGHT = 5
BOX_SIZE = BOX_WIDTH * BOX_HEIGHT BOX_SIZE = BOX_WIDTH * BOX_HEIGHT
def initialize(name, maxPokemon = BOX_SIZE) def initialize(name, maxPokemon = BOX_SIZE)
@pokemon = [] @pokemon = []
@@ -121,6 +121,10 @@ class PokemonStorage
raise ArgumentError.new("Not supported") raise ArgumentError.new("Not supported")
end end
def party_full?
return $Trainer.party_full?
end
def maxBoxes def maxBoxes
return @boxes.length return @boxes.length
end end
@@ -179,7 +183,7 @@ class PokemonStorage
return false if !found return false if !found
end end
if boxDst==-1 # Copying into party 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[self.party.length] = self[boxSrc,indexSrc]
self.party.compact! self.party.compact!
else # Copying into box else # Copying into box
@@ -200,7 +204,7 @@ class PokemonStorage
end end
def pbMoveCaughtToParty(pkmn) def pbMoveCaughtToParty(pkmn)
return false if self.party.length >= MAX_PARTY_SIZE return false if party_full?
self.party[self.party.length] = pkmn self.party[self.party.length] = pkmn
end end
@@ -306,6 +310,10 @@ class RegionalStorage
return getCurrentStorage.party return getCurrentStorage.party
end end
def party_full?
return getCurrentStorage.party_full?
end
def maxBoxes def maxBoxes
return getCurrentStorage.maxBoxes return getCurrentStorage.maxBoxes
end end

View File

@@ -1681,7 +1681,7 @@ class PokemonStorageScreen
if box==-1 if box==-1
raise _INTL("Can't withdraw from party..."); raise _INTL("Can't withdraw from party...");
end end
if @storage.party.length >= MAX_PARTY_SIZE if @storage.party_full?
pbDisplay(_INTL("Your party's full!")) pbDisplay(_INTL("Your party's full!"))
return false return false
end end

View File

@@ -48,7 +48,7 @@ class StorageSystemPC
) )
if command>=0 && command<3 if command>=0 && command<3
if command==1 # Withdraw if command==1 # Withdraw
if $PokemonStorage.party.length >= MAX_PARTY_SIZE if $PokemonStorage.party_full?
pbMessage(_INTL("Your party is full!")) pbMessage(_INTL("Your party is full!"))
next next
end end

View File

@@ -2,7 +2,7 @@
# Nicknaming and storing Pokémon # Nicknaming and storing Pokémon
#=============================================================================== #===============================================================================
def pbBoxesFull? def pbBoxesFull?
return ($Trainer.party.length >= MAX_PARTY_SIZE && $PokemonStorage.full?) return ($Trainer.party_full? && $PokemonStorage.full?)
end end
def pbNickname(pkmn) def pbNickname(pkmn)
@@ -21,9 +21,7 @@ def pbStorePokemon(pkmn)
return return
end end
pkmn.pbRecordFirstMoves pkmn.pbRecordFirstMoves
if $Trainer.party.length < MAX_PARTY_SIZE if $Trainer.party_full?
$Trainer.party[$Trainer.party.length] = pkmn
else
oldcurbox = $PokemonStorage.currentBox oldcurbox = $PokemonStorage.currentBox
storedbox = $PokemonStorage.pbStoreCaught(pkmn) storedbox = $PokemonStorage.pbStoreCaught(pkmn)
curboxname = $PokemonStorage[oldcurbox].name curboxname = $PokemonStorage[oldcurbox].name
@@ -45,6 +43,8 @@ def pbStorePokemon(pkmn)
end end
pbMessage(_INTL("It was stored in box \"{1}.\"", boxname)) pbMessage(_INTL("It was stored in box \"{1}.\"", boxname))
end end
else
$Trainer.party[$Trainer.party.length] = pkmn
end end
end end
@@ -85,10 +85,10 @@ def pbAddPokemonSilent(pkmn, level = 1, see_form = true)
$Trainer.owned[pkmn.species] = true $Trainer.owned[pkmn.species] = true
pbSeenForm(pkmn) if see_form pbSeenForm(pkmn) if see_form
pkmn.pbRecordFirstMoves pkmn.pbRecordFirstMoves
if $Trainer.party.length < MAX_PARTY_SIZE if $Trainer.party_full?
$Trainer.party[$Trainer.party.length] = pkmn
else
$PokemonStorage.pbStoreCaught(pkmn) $PokemonStorage.pbStoreCaught(pkmn)
else
$Trainer.party[$Trainer.party.length] = pkmn
end end
return true return true
end end
@@ -97,7 +97,7 @@ end
# Giving Pokémon/eggs to the player (can only add to party) # Giving Pokémon/eggs to the player (can only add to party)
#=============================================================================== #===============================================================================
def pbAddToParty(pkmn, level = 1, see_form = true) 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) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon)
species_name = pkmn.speciesName species_name = pkmn.speciesName
pbMessage(_INTL("{1} obtained {2}!\\me[Pkmn get]\\wtnp[80]\1", $Trainer.name, species_name)) 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 end
def pbAddToPartySilent(pkmn, level = nil, see_form = true) 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) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon)
$Trainer.seen[pkmn.species] = true $Trainer.seen[pkmn.species] = true
$Trainer.owned[pkmn.species] = true $Trainer.owned[pkmn.species] = true
@@ -118,7 +118,7 @@ def pbAddToPartySilent(pkmn, level = nil, see_form = true)
end end
def pbAddForeignPokemon(pkmn, level = 1, owner_name = nil, nickname = nil, owner_gender = 0, see_form = true) 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) pkmn = Pokemon.new(pkmn, level) if !pkmn.is_a?(Pokemon)
# Set original trainer to a foreign one # Set original trainer to a foreign one
pkmn.owner = Pokemon::Owner.new_foreign(owner_name || "", owner_gender) 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 end
def pbGenerateEgg(pkmn, text = "") 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) pkmn = Pokemon.new(pkmn, EGG_LEVEL) if !pkmn.is_a?(Pokemon)
# Set egg's details # Set egg's details
pkmn.name = _INTL("Egg") pkmn.name = _INTL("Egg")

View File

@@ -291,7 +291,7 @@ def pbDebugDayCare
when 0 # Withdraw Pokémon 1 when 0 # Withdraw Pokémon 1
if !$PokemonGlobal.daycare[0][0] if !$PokemonGlobal.daycare[0][0]
pbPlayBuzzerSE pbPlayBuzzerSE
elsif $Trainer.party.length >= MAX_PARTY_SIZE elsif $Trainer.party_full?
pbPlayBuzzerSE pbPlayBuzzerSE
pbMessage(_INTL("Party is full, can't withdraw Pokémon.")) pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
else else
@@ -303,7 +303,7 @@ def pbDebugDayCare
when 1 # Withdraw Pokémon 2 when 1 # Withdraw Pokémon 2
if !$PokemonGlobal.daycare[1][0] if !$PokemonGlobal.daycare[1][0]
pbPlayBuzzerSE pbPlayBuzzerSE
elsif $Trainer.party.length >= MAX_PARTY_SIZE elsif $Trainer.party_full?
pbPlayBuzzerSE pbPlayBuzzerSE
pbMessage(_INTL("Party is full, can't withdraw Pokémon.")) pbMessage(_INTL("Party is full, can't withdraw Pokémon."))
else else
@@ -344,7 +344,7 @@ def pbDebugDayCare
when 4 # Collect egg when 4 # Collect egg
if $PokemonGlobal.daycareEgg!=1 if $PokemonGlobal.daycareEgg!=1
pbPlayBuzzerSE pbPlayBuzzerSE
elsif $Trainer.party.length >= MAX_PARTY_SIZE elsif $Trainer.party_full?
pbPlayBuzzerSE pbPlayBuzzerSE
pbMessage(_INTL("Party is full, can't collect the egg.")) pbMessage(_INTL("Party is full, can't collect the egg."))
else else