Made the Battle Factory work

This commit is contained in:
Maruno17
2021-05-15 17:38:16 +01:00
parent e350cb8f4a
commit f303b84033
6 changed files with 160 additions and 158 deletions

View File

@@ -1349,7 +1349,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
@commands[index],self.baseColor,self.shadowColor) @commands[index],self.baseColor,self.shadowColor)
else else
chars=getFormattedText( chars=getFormattedText(
self.contents,rect.x,rect.y,rect.width,rect.height, self.contents,rect.x,rect.y+4,rect.width,rect.height,
@commands[index],rect.height,true,true) @commands[index],rect.height,true,true)
drawFormattedChars(self.contents,chars) drawFormattedChars(self.contents,chars)
end end

View File

@@ -19,18 +19,20 @@ class BattleChallenge
@id = id @id = id
@numRounds = numrounds @numRounds = numrounds
@rules = rules @rules = rules
register(id, id[/double/], 3,
id[/^factory/] ? BattleFactoryID : BattleTowerID,
id[/open$/] ? 1 : 0)
pbWriteCup(id, rules) pbWriteCup(id, rules)
end end
def register(id, doublebattle, numrounds, numPokemon, battletype, mode = 1) def register(id, doublebattle, numPokemon, battletype, mode = 1)
ensureType(id) ensureType(id)
if battletype == BattleFactoryID if battletype == BattleFactoryID
@bc.setExtraData(BattleFactoryData.new(@bc)) @bc.setExtraData(BattleFactoryData.new(@bc))
numPokemon = 3 numPokemon = 3
battletype = BattleTowerID battletype = BattleTowerID
end end
@numRounds = numrounds @rules = modeToRules(doublebattle, numPokemon, battletype, mode) if !@rules
@rules = modeToRules(doublebattle, numPokemon, battletype, mode)
end end
def rules def rules
@@ -371,7 +373,7 @@ class BattleFactoryData
def pbPrepareRentals def pbPrepareRentals
@rentals = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, []) @rentals = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps, [])
@trainerid = @bcdata.nextTrainer @trainerid = @bcdata.nextTrainer
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge) bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid] trainerdata = bttrainers[@trainerid]
@opponent = NPCTrainer.new( @opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]), pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
@@ -386,19 +388,19 @@ class BattleFactoryData
screen = BattleSwapScreen.new(scene) screen = BattleSwapScreen.new(scene)
@rentals = screen.pbStartRent(@rentals) @rentals = screen.pbStartRent(@rentals)
@bcdata.pbAddSwap @bcdata.pbAddSwap
pbBattleChallenge.setParty(@rentals) @bcdata.setParty(@rentals)
} }
end end
def pbPrepareSwaps def pbPrepareSwaps
@oldopponent = @opponent.party @oldopponent = @opponent.party
trainerid = @bcdata.nextTrainer trainerid = @bcdata.nextTrainer
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge) bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[trainerid] trainerdata = bttrainers[trainerid]
@opponent = NPCTrainer.new( @opponent = NPCTrainer.new(
pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]), pbGetMessageFromHash(MessageTypes::TrainerNames, trainerdata[1]),
trainerdata[0]) trainerdata[0])
opponentPkmn = pbBattleFactoryPokemon(challenge.rules, @bcdata.wins, @bcdata.swaps, opponentPkmn = pbBattleFactoryPokemon(pbBattleChallenge.rules, @bcdata.wins, @bcdata.swaps,
[].concat(@rentals).concat(@oldopponent)) [].concat(@rentals).concat(@oldopponent))
@opponent.party = opponentPkmn.shuffle[0, 3] @opponent.party = opponentPkmn.shuffle[0, 3]
end end
@@ -416,7 +418,7 @@ class BattleFactoryData
end end
def pbBattle(challenge) def pbBattle(challenge)
bttrainers = pbGetBTTrainers(@bcdata.currentChallenge) bttrainers = pbGetBTTrainers(pbBattleChallenge.currentChallenge)
trainerdata = bttrainers[@trainerid] trainerdata = bttrainers[@trainerid]
return pbOrganizedBattleEx(@opponent, challenge.rules, return pbOrganizedBattleEx(@opponent, challenge.rules,
pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]), pbGetMessageFromHash(MessageTypes::EndSpeechLose, trainerdata[4]),

View File

@@ -24,7 +24,7 @@ def pbBattleChallengeTrainer(win_count, bttrainers)
[49, 200, 100] # 200-300 - This line is used for all higher win_counts [49, 200, 100] # 200-300 - This line is used for all higher win_counts
] ]
slot = nil slot = nil
table.each { |val| slot = val if val[0] <= win_count && slot[0] < val[0] } table.each { |val| slot = val if val[0] <= win_count && (!slot || slot[0] < val[0]) }
return 0 if !slot return 0 if !slot
# Scale the start point and length based on how many trainers are in bttrainers # Scale the start point and length based on how many trainers are in bttrainers
offset = slot[1] * bttrainers.length / 300 offset = slot[1] * bttrainers.length / 300
@@ -84,7 +84,7 @@ end
#=============================================================================== #===============================================================================
# Generate a full team's worth of Pokémon which obey the given rules. # Generate a full team's worth of Pokémon which obey the given rules.
#=============================================================================== #===============================================================================
def pbBattleFactoryPokemon(rules, win_count, swap_count, _rentals) def pbBattleFactoryPokemon(rules, win_count, swap_count, rentals)
btpokemon = pbGetBTPokemon(pbBattleChallenge.currentChallenge) btpokemon = pbGetBTPokemon(pbBattleChallenge.currentChallenge)
level = rules.ruleset.suggestedLevel level = rules.ruleset.suggestedLevel
pokemonNumbers = [0, 0] # Start and end indices in btpokemon pokemonNumbers = [0, 0] # Start and end indices in btpokemon
@@ -94,32 +94,33 @@ def pbBattleFactoryPokemon(rules, win_count, swap_count, _rentals)
# Choose a range of Pokémon in btpokemon to randomly select from. The higher # Choose a range of Pokémon in btpokemon to randomly select from. The higher
# the set number, the later the range lies within btpokemon (typically). # the set number, the later the range lies within btpokemon (typically).
# This table's start point and end point values are based on a btpokemon size # This table's start point and end point values are based on a btpokemon size
# of 882. They are scaled based on the actual size of btpokemon. # of 881. They are scaled based on the actual size of btpokemon.
# Group 1 is 0 - 173. Group 2 is 174 - 371. Group 3 is 372 - 881.
if level == GameData::GrowthRate.max_level # Open Level (Level 100) if level == GameData::GrowthRate.max_level # Open Level (Level 100)
table = [ table = [
[372, 467], [372, 491], # Group 3 (first quarter)
[468, 563], [492, 610], # Group 3 (second quarter)
[564, 659], [611, 729], # Group 3 (third quarter)
[660, 755], [730, 849], # Group 3 (fourth quarter)
[372, 881], [372, 881], # All of Group 3
[372, 881], [372, 881], # All of Group 3
[372, 881], [372, 881], # All of Group 3
[372, 881] # This line is used for all higher sets [372, 881] # This line is used for all higher sets (all of Group 3)
] ]
else else
table = [ table = [
[110, 199], [ 0, 173], # Group 1
[162, 266], [174, 272], # Group 2 (first half)
[267, 371], [273, 371], # Group 2 (second half)
[372, 467], [372, 491], # Group 3 (first quarter)
[468, 563], [492, 610], # Group 3 (second quarter)
[564, 659], [611, 729], # Group 3 (third quarter)
[660, 755], [730, 849], # Group 3 (fourth quarter)
[372, 849] # This line is used for all higher sets [372, 881] # This line is used for all higher sets (all of Group 3)
] ]
end end
pokemonNumbers[0] = table[set][0] * btpokemon.length / 882 pokemonNumbers[0] = table[set][0] * btpokemon.length / 881
pokemonNumbers[1] = table[set][1] * btpokemon.length / 882 pokemonNumbers[1] = table[set][1] * btpokemon.length / 881
# Choose two IV values for Pokémon to use (the one for the current set, and # Choose two IV values for Pokémon to use (the one for the current set, and
# the one for the next set). The iv_threshold below determines which of these # the one for the next set). The iv_threshold below determines which of these
# two values a given Pokémon uses. The higher the set number, the higher these # two values a given Pokémon uses. The higher the set number, the higher these
@@ -139,16 +140,24 @@ def pbBattleFactoryPokemon(rules, win_count, swap_count, _rentals)
] ]
thresholds.each { |val| iv_threshold = val[1] if swap_count >= val[0] } thresholds.each { |val| iv_threshold = val[1] if swap_count >= val[0] }
# Randomly choose Pokémon from the range to fill the party with # Randomly choose Pokémon from the range to fill the party with
old_min = rules.ruleset.minLength
old_max = rules.ruleset.maxLength
if rentals.length == 0
rules.ruleset.setNumber(6) # Rentals
else
rules.ruleset.setNumber(old_max + rentals.length) # Opponent
end
party = [] party = []
loop do loop do
party.clear party.clear
while party.length < Settings::MAX_PARTY_SIZE while party.length < ((rentals.length == 0) ? 6 : old_max)
rnd = pokemonNumbers[0] + rand(pokemonNumbers[1] - pokemonNumbers[0] + 1) rnd = pokemonNumbers[0] + rand(pokemonNumbers[1] - pokemonNumbers[0] + 1)
rndpoke = btpokemon[rnd] rndpoke = btpokemon[rnd]
indvalue = (party.length < iv_threshold) ? ivs[0] : ivs[1] indvalue = (party.length < iv_threshold) ? ivs[0] : ivs[1]
party.push(rndpoke.createPokemon(level, indvalue, nil)) party.push(rndpoke.createPokemon(level, indvalue, nil))
end end
break if rules.ruleset.isValid?(party) break if rules.ruleset.isValid?(party.concat(rentals))
end end
rules.ruleset.setNumberRange(old_min, old_max)
return party return party
end end

View File

@@ -42,7 +42,7 @@ def pbOrganizedBattleEx(opponent, challengedata, endspeech, endspeechwin)
if Input.press?(Input::CTRL) && $DEBUG if Input.press?(Input::CTRL) && $DEBUG
pbMessage(_INTL("SKIPPING BATTLE...")) pbMessage(_INTL("SKIPPING BATTLE..."))
pbMessage(_INTL("AFTER WINNING...")) pbMessage(_INTL("AFTER WINNING..."))
endspeech.each { |msg| pbMessage(msg || "...") } pbMessage(endspeech || "...")
$PokemonTemp.lastbattle = nil $PokemonTemp.lastbattle = nil
return true return true
end end

View File

@@ -1,75 +1,69 @@
class BattleSwapScene class BattleSwapScene
def pbStartRentScene(rentals) def pbStartRentScene(rentals)
# Create sprite hash @rentals = rentals
@sprites={} @mode = 0 # rental (pick 3 out of 6 initial Pokémon)
@mode=0 # rental @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
# Allocate viewport @viewport.z = 99999
@rentals=rentals @sprites = {}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height) addBackgroundPlane(@sprites, "bg", "rentbg", @viewport)
@viewport.z=99999 @sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize( _INTL("RENTAL POKéMON"), 0, 0, Graphics.width, 64, @viewport)
_INTL("RENTAL POKéMON"),0,0,Graphics.width,64,@viewport) @sprites["list"] = Window_AdvancedCommandPokemonEx.newWithSize(
@sprites["help"]=Window_UnformattedTextPokemon.newWithSize("", [], 0, 64, Graphics.width, Graphics.height - 128 , @viewport)
0,Graphics.height-64,Graphics.width,64,@viewport) @sprites["help"] = Window_UnformattedTextPokemon.newWithSize("",
@sprites["list"]=Window_AdvancedCommandPokemonEx.newWithSize( 0, Graphics.height - 64, Graphics.width, 64, @viewport)
[],0,64,Graphics.width,Graphics.height-128,@viewport) @sprites["msgwindow"] = Window_AdvancedTextPokemon.newWithSize("",
@sprites["msgwindow"]=Window_AdvancedTextPokemon.newWithSize("", 0, Graphics.height - 64, Graphics.height, 64, @viewport)
0,Graphics.height-64,Graphics.height,64,@viewport) @sprites["msgwindow"].visible = false
@sprites["msgwindow"].visible=false
addBackgroundPlane(@sprites,"bg","rentbg",@viewport)
pbUpdateChoices([]) pbUpdateChoices([])
pbDeactivateWindows(@sprites) pbDeactivateWindows(@sprites)
# Fade in all sprites
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end
def pbStartSwapScene(currentPokemon,newPokemon) def pbStartSwapScene(currentPokemon, newPokemon)
# Create sprite hash @currentPokemon = currentPokemon
@sprites={} @newPokemon = newPokemon
@mode=1 # swap @mode = 1 # swap (pick 1 out of 3 opponent's Pokémon to take)
# Allocate viewport @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z = 99999
@viewport.z=99999 @sprites = {}
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize( addBackgroundPlane(@sprites, "bg", "swapbg", @viewport)
_INTL("POKéMON SWAP"),0,0,Graphics.width,64,@viewport) @sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
@sprites["help"]=Window_UnformattedTextPokemon.newWithSize( _INTL("POKéMON SWAP"), 0, 0, Graphics.width, 64, @viewport)
"",0,Graphics.height-64,Graphics.width,64,@viewport) @sprites["list"] = Window_AdvancedCommandPokemonEx.newWithSize(
@sprites["list"]=Window_AdvancedCommandPokemonEx.newWithSize( [], 0, 64, Graphics.width, Graphics.height - 128, @viewport)
[],0,64,Graphics.width,Graphics.height-128,@viewport) @sprites["help"] = Window_UnformattedTextPokemon.newWithSize(
@sprites["msgwindow"]=Window_AdvancedTextPokemon.newWithSize( "", 0, Graphics.height - 64, Graphics.width, 64, @viewport)
"",0,Graphics.height-64,Graphics.width,64,@viewport) @sprites["msgwindow"] = Window_AdvancedTextPokemon.newWithSize(
@sprites["msgwindow"].visible=false "", 0, Graphics.height - 64, Graphics.width, 64, @viewport)
addBackgroundPlane(@sprites,"bg","swapbg",@viewport) @sprites["msgwindow"].visible = false
@currentPokemon=currentPokemon pbInitSwapScreen
@newPokemon=newPokemon
pbInitSwapScreen()
pbDeactivateWindows(@sprites) pbDeactivateWindows(@sprites)
# Fade in all sprites
pbFadeInAndShow(@sprites) { pbUpdate } pbFadeInAndShow(@sprites) { pbUpdate }
end end
def pbInitSwapScreen def pbInitSwapScreen
commands=pbGetCommands(@currentPokemon,[]) commands = pbGetCommands(@currentPokemon, [])
commands.push(_INTL("CANCEL")) commands.push(_INTL("CANCEL"))
@sprites["help"].text=_INTL("Select Pokémon to swap.") @sprites["help"].text = _INTL("Select Pokémon to swap.")
@sprites["list"].commands=commands @sprites["list"].commands = commands
@sprites["list"].index=0 @sprites["list"].index = 0
@mode=1 @mode = 1
end end
# End the scene here # End the scene here
def pbEndScene def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate } # Fade out all sprites pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites) # Dispose all sprites pbDisposeSpriteHash(@sprites)
@viewport.dispose # Dispose the viewport @viewport.dispose
end end
def pbShowCommands(commands) def pbShowCommands(commands)
UIHelper.pbShowCommands(@sprites["msgwindow"],nil,commands) { pbUpdate } UIHelper.pbShowCommands(@sprites["msgwindow"], nil, commands) { pbUpdate }
end end
def pbConfirm(message) def pbConfirm(message)
UIHelper.pbConfirm(@sprites["msgwindow"],message) { pbUpdate } UIHelper.pbConfirm(@sprites["msgwindow"], message) { pbUpdate }
end end
def pbGetCommands(list, choices) def pbGetCommands(list, choices)
@@ -77,9 +71,8 @@ class BattleSwapScene
for i in 0...list.length for i in 0...list.length
pkmn = list[i] pkmn = list[i]
category = pkmn.species_data.category category = pkmn.species_data.category
selected = shadowctagFromColor(Color.new(232, 0, 0))
cmd = _INTL("{1} - {2} Pokémon", pkmn.speciesName, category) cmd = _INTL("{1} - {2} Pokémon", pkmn.speciesName, category)
cmd = selected + cmd if choices.include?(i) cmd = "<c3=E82010,F8A8B8>" + cmd if choices.include?(i) # Red text
commands.push(cmd) commands.push(cmd)
end end
return commands return commands
@@ -87,19 +80,18 @@ class BattleSwapScene
# Processes the scene # Processes the scene
def pbChoosePokemon(canCancel) def pbChoosePokemon(canCancel)
pbActivateWindow(@sprites,"list") { pbActivateWindow(@sprites, "list") {
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
pbUpdate pbUpdate
if Input.trigger?(Input::BACK) && canCancel if Input.trigger?(Input::BACK) && canCancel
return -1 return -1
end elsif Input.trigger?(Input::USE)
if Input.trigger?(Input::USE) index = @sprites["list"].index
index=@sprites["list"].index if index == @sprites["list"].commands.length - 1 && canCancel
if index==@sprites["list"].commands.length-1 && canCancel
return -1 return -1
elsif index==@sprites["list"].commands.length-2 && canCancel && @mode==2 elsif index == @sprites["list"].commands.length - 2 && canCancel && @mode == 2
return -2 return -2
else else
return index return index
@@ -110,44 +102,42 @@ class BattleSwapScene
end end
def pbUpdateChoices(choices) def pbUpdateChoices(choices)
commands=pbGetCommands(@rentals,choices) commands = pbGetCommands(@rentals, choices)
@choices=choices @choices = choices
if choices.length==0 if choices.length == 0
@sprites["help"].text=_INTL("Choose the first Pokémon.") @sprites["help"].text = _INTL("Choose the first Pokémon.")
elsif choices.length==1 elsif choices.length == 1
@sprites["help"].text=_INTL("Choose the second Pokémon.") @sprites["help"].text = _INTL("Choose the second Pokémon.")
else else
@sprites["help"].text=_INTL("Choose the third Pokémon.") @sprites["help"].text = _INTL("Choose the third Pokémon.")
end end
@sprites["list"].commands=commands @sprites["list"].commands = commands
end end
def pbSwapChosen(_pkmnindex) def pbSwapChosen(_pkmnindex)
commands=pbGetCommands(@newPokemon,[]) commands=pbGetCommands(@newPokemon, [])
commands.push(_INTL("PKMN FOR SWAP")) commands.push(_INTL("PKMN FOR SWAP"))
commands.push(_INTL("CANCEL")) commands.push(_INTL("CANCEL"))
@sprites["help"].text=_INTL("Select Pokémon to accept.") @sprites["help"].text = _INTL("Select Pokémon to accept.")
@sprites["list"].commands=commands @sprites["list"].commands = commands
@sprites["list"].index=0 @sprites["list"].index = 0
@mode=2 @mode = 2
end end
def pbSwapCanceled def pbSwapCanceled
pbInitSwapScreen pbInitSwapScreen
end end
def pbSummary(list,index) def pbSummary(list, index)
visibleSprites=pbFadeOutAndHide(@sprites) { pbUpdate } visibleSprites = pbFadeOutAndHide(@sprites) { pbUpdate }
scene=PokemonSummary_Scene.new scene = PokemonSummary_Scene.new
screen=PokemonSummaryScreen.new(scene) screen = PokemonSummaryScreen.new(scene)
@sprites["list"].index=screen.pbStartScreen(list,index) @sprites["list"].index = screen.pbStartScreen(list, index)
pbFadeInAndShow(@sprites,visibleSprites) { pbUpdate } pbFadeInAndShow(@sprites, visibleSprites) { pbUpdate }
end end
# Update the scene here, this is called once each frame
def pbUpdate def pbUpdate
pbUpdateSpriteHash(@sprites) pbUpdateSpriteHash(@sprites)
# Add other things that should be updated
end end
end end
@@ -160,30 +150,30 @@ class BattleSwapScreen
def pbStartRent(rentals) def pbStartRent(rentals)
@scene.pbStartRentScene(rentals) @scene.pbStartRentScene(rentals)
chosen=[] chosen = []
loop do loop do
index=@scene.pbChoosePokemon(false) index = @scene.pbChoosePokemon(false)
commands=[] commands = []
commands.push(_INTL("SUMMARY")) commands.push(_INTL("SUMMARY"))
if chosen.any? { |item| item==index } if chosen.include?(index)
commands.push(_INTL("DESELECT")) commands.push(_INTL("DESELECT"))
else else
commands.push(_INTL("RENT")) commands.push(_INTL("RENT"))
end end
commands.push(_INTL("OTHERS")) commands.push(_INTL("OTHERS"))
command=@scene.pbShowCommands(commands) command = @scene.pbShowCommands(commands)
if command==0 if command == 0
@scene.pbSummary(rentals,index) @scene.pbSummary(rentals, index)
elsif command==1 elsif command == 1
if chosen.any? { |item| item==index } if chosen.include?(index)
chosen.delete(index) chosen.delete(index)
@scene.pbUpdateChoices(chosen.clone) @scene.pbUpdateChoices(chosen.clone)
else else
chosen.push(index) chosen.push(index)
@scene.pbUpdateChoices(chosen.clone) @scene.pbUpdateChoices(chosen.clone)
if chosen.length==3 if chosen.length == 3
if @scene.pbConfirm(_INTL("Are these three Pokémon OK?")) if @scene.pbConfirm(_INTL("Are these three Pokémon OK?"))
retval=[] retval = []
chosen.each { |i| retval.push(rentals[i]) } chosen.each { |i| retval.push(rentals[i]) }
@scene.pbEndScene @scene.pbEndScene
return retval return retval
@@ -197,30 +187,30 @@ class BattleSwapScreen
end end
end end
def pbStartSwap(currentPokemon,newPokemon) def pbStartSwap(currentPokemon, newPokemon)
@scene.pbStartSwapScene(currentPokemon,newPokemon) @scene.pbStartSwapScene(currentPokemon, newPokemon)
loop do loop do
pkmn=@scene.pbChoosePokemon(true) pkmn = @scene.pbChoosePokemon(true)
if pkmn>=0 if pkmn >= 0
commands=[_INTL("SUMMARY"),_INTL("SWAP"),_INTL("RECHOOSE")] commands = [_INTL("SUMMARY"), _INTL("SWAP"), _INTL("RECHOOSE")]
command=@scene.pbShowCommands(commands) command = @scene.pbShowCommands(commands)
if command==0 if command == 0
@scene.pbSummary(currentPokemon,pkmn) @scene.pbSummary(currentPokemon, pkmn)
elsif command==1 elsif command == 1
@scene.pbSwapChosen(pkmn) @scene.pbSwapChosen(pkmn)
yourPkmn=pkmn yourPkmn = pkmn
loop do loop do
pkmn=@scene.pbChoosePokemon(true) pkmn = @scene.pbChoosePokemon(true)
if pkmn>=0 if pkmn >= 0
if @scene.pbConfirm(_INTL("Accept this Pokémon?")) if @scene.pbConfirm(_INTL("Accept this Pokémon?"))
@scene.pbEndScene @scene.pbEndScene
currentPokemon[yourPkmn]=newPokemon[pkmn] currentPokemon[yourPkmn] = newPokemon[pkmn]
return true return true
end end
elsif pkmn==-2 elsif pkmn == -2
@scene.pbSwapCanceled @scene.pbSwapCanceled
break # Back to first screen break # Back to first screen
elsif pkmn==-1 elsif pkmn == -1
if @scene.pbConfirm(_INTL("Quit swapping?")) if @scene.pbConfirm(_INTL("Quit swapping?"))
@scene.pbEndScene @scene.pbEndScene
return false return false

View File

@@ -29,7 +29,7 @@ class PokemonRuleSet
end end
def maxLength def maxLength
return (@number < 0) ? 6 : @number return (@number < 0) ? Settings::MAX_PARTY_SIZE : @number
end end
alias number maxLength alias number maxLength
@@ -38,7 +38,7 @@ class PokemonRuleSet
end end
def maxTeamLength def maxTeamLength
return [6, self.maxLength].max return [Settings::MAX_PARTY_SIZE, self.maxLength].max
end end
# Returns the length of a valid subset of a Pokemon team. # Returns the length of a valid subset of a Pokemon team.
@@ -68,7 +68,7 @@ class PokemonRuleSet
def setNumberRange(minValue, maxValue) def setNumberRange(minValue, maxValue)
@minLength = [1, minValue].max @minLength = [1, minValue].max
@number = [maxValue, 6].min @number = [1, maxValue].max
return self return self
end end
@@ -139,10 +139,11 @@ class PokemonRuleSet
return false return false
end end
# Returns true if the team's length is greater or equal to the suggested number # Returns true if the team's length is greater or equal to the suggested
# and is 6 or less, the team as a whole meets the requirements of any team # number and is Settings::MAX_PARTY_SIZE or less, the team as a whole meets
# rules, and at least one subset of the team meets the requirements of any # the requirements of any team rules, and at least one subset of the team
# subset rules. Each Pokemon in the team must be valid. # meets the requirements of any subset rules. Each Pokemon in the team must be
# valid.
def canRegisterTeam?(team) def canRegisterTeam?(team)
return false if !team || team.length < self.minTeamLength return false if !team || team.length < self.minTeamLength
return false if team.length > self.maxTeamLength return false if team.length > self.maxTeamLength
@@ -168,9 +169,9 @@ class PokemonRuleSet
return true return true
end end
# Returns true if the team's length is greater or equal to the suggested number # Returns true if the team's length is greater or equal to the suggested
# and at least one subset of the team meets the requirements of any team rules # number and at least one subset of the team meets the requirements of any
# and subset rules. Not all Pokemon in the team have to be valid. # team rules and subset rules. Not all Pokemon in the team have to be valid.
def hasValidTeam?(team) def hasValidTeam?(team)
return false if !team || team.length < self.minTeamLength return false if !team || team.length < self.minTeamLength
teamNumber = [self.maxLength, team.length].min teamNumber = [self.maxLength, team.length].min
@@ -201,9 +202,9 @@ class PokemonRuleSet
for pkmn in team for pkmn in team
next if isPokemonValid?(pkmn) next if isPokemonValid?(pkmn)
if pkmn if pkmn
error.push(_INTL("This team is not allowed.", pkmn.name)) if error
else
error.push(_INTL("{1} is not allowed.", pkmn.name)) if error error.push(_INTL("{1} is not allowed.", pkmn.name)) if error
else
error.push(_INTL("This team is not allowed.")) if error
end end
return false return false
end end
@@ -230,8 +231,8 @@ class StandardRules < PokemonRuleSet
def initialize(number, level = nil) def initialize(number, level = nil)
super(number) super(number)
addPokemonRule(StandardRestriction.new) addPokemonRule(StandardRestriction.new)
addPokemonRule(SpeciesClause.new) addTeamRule(SpeciesClause.new)
addPokemonRule(ItemClause.new) addTeamRule(ItemClause.new)
addPokemonRule(MaximumLevelRestriction.new(level)) if level addPokemonRule(MaximumLevelRestriction.new(level)) if level
end end
end end
@@ -277,8 +278,8 @@ class FancyCup < PokemonRuleSet
addPokemonRule(HeightRestriction.new(2)) addPokemonRule(HeightRestriction.new(2))
addPokemonRule(WeightRestriction.new(20)) addPokemonRule(WeightRestriction.new(20))
addPokemonRule(BabyRestriction.new) addPokemonRule(BabyRestriction.new)
addPokemonRule(SpeciesClause.new) addTeamRule(SpeciesClause.new)
addPokemonRule(ItemClause.new) addTeamRule(ItemClause.new)
end end
def name def name
@@ -295,8 +296,8 @@ class LittleCup < PokemonRuleSet
addPokemonRule(StandardRestriction.new) addPokemonRule(StandardRestriction.new)
addPokemonRule(MaximumLevelRestriction.new(5)) addPokemonRule(MaximumLevelRestriction.new(5))
addPokemonRule(BabyRestriction.new) addPokemonRule(BabyRestriction.new)
addPokemonRule(SpeciesClause.new) addTeamRule(SpeciesClause.new)
addPokemonRule(ItemClause.new) addTeamRule(ItemClause.new)
end end
def name def name
@@ -314,8 +315,8 @@ class LightCup < PokemonRuleSet
addPokemonRule(MaximumLevelRestriction.new(50)) addPokemonRule(MaximumLevelRestriction.new(50))
addPokemonRule(WeightRestriction.new(99)) addPokemonRule(WeightRestriction.new(99))
addPokemonRule(BabyRestriction.new) addPokemonRule(BabyRestriction.new)
addPokemonRule(SpeciesClause.new) addTeamRule(SpeciesClause.new)
addPokemonRule(ItemClause.new) addTeamRule(ItemClause.new)
end end
def name def name