Fixed various bugs found when generating Battle Frontier challenge lists

This commit is contained in:
Maruno17
2021-12-29 14:37:41 +00:00
parent a7e8005f53
commit fb29f19a28
8 changed files with 34 additions and 24 deletions

View File

@@ -176,7 +176,7 @@ def pbGenerateChallenge(rule, tag)
rule = rule.copy.setNumber(2)
yield(nil)
party = load_data(tag + ".rxdata") rescue []
teams = load_data(tag + "teams.rxdata") rescue []
teams = load_data(tag + "_teams.rxdata") rescue []
if teams.length < 10
btpokemon = pbGetBTPokemon(tag)
if btpokemon && btpokemon.length != 0
@@ -218,7 +218,7 @@ def pbGenerateChallenge(rule, tag)
end
i += 1
end
save_data(teams, tag + "teams.rxdata")
save_data(teams, tag + "_teams.rxdata")
yield(nil)
while teams.length < maxteams
yield(nil) if teams.length % 10 == 0
@@ -256,7 +256,7 @@ def pbGenerateChallenge(rule, tag)
end
end
teams.sort! { |a, b| b.rating <=> a.rating }
save_data(teams, tag + "teams.rxdata")
save_data(teams, tag + "_teams.rxdata")
end
party = []
yield(nil)

View File

@@ -202,7 +202,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
yield(nil) if block_given?
if trIndex < 0
info = [newbttrainers, pbpokemonlist, [trfile],
trfile + "tr.txt", trfile + "pm.txt", !hasDefault]
trfile + "_trainers.txt", trfile + "_pkmn.txt", !hasDefault]
trlists.push(info)
end
yield(nil) if block_given?

View File

@@ -380,7 +380,7 @@ def pbRuledBattle(team1, team2, rule)
trainer2 = NPCTrainer.new("PLAYER2", t_type)
items1 = []
items2 = []
team1.each_with_index do |p, i|
team1.team.each_with_index do |p, i|
next if !p
if p.level != level
p.level = level
@@ -389,7 +389,7 @@ def pbRuledBattle(team1, team2, rule)
items1[i] = p.item_id
trainer1.party.push(p)
end
team2.each_with_index do |p, i|
team2.team.each_with_index do |p, i|
next if !p
if p.level != level
p.level = level
@@ -404,12 +404,12 @@ def pbRuledBattle(team1, team2, rule)
battle.controlPlayer = true
battle.internalBattle = false
decision = battle.pbStartBattle
team1.each_with_index do |p, i|
team1.team.each_with_index do |p, i|
next if !p
p.heal
p.item = items1[i]
end
team2.each_with_index do |p, i|
team2.team.each_with_index do |p, i|
next if !p
p.heal
p.item = items2[i]