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 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

View File

@@ -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]

View File

@@ -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
#=============================================================================

View File

@@ -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

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
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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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