mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
More Rubocopping
This commit is contained in:
@@ -216,7 +216,7 @@ class BattleChallengeData
|
||||
while @trainers.length < @numRounds
|
||||
newtrainer = pbBattleChallengeTrainer(@wins + @trainers.length, btTrainers)
|
||||
found = false
|
||||
for tr in @trainers
|
||||
@trainers.each do |tr|
|
||||
found = true if tr == newtrainer
|
||||
end
|
||||
@trainers.push(newtrainer) if !found
|
||||
|
||||
@@ -130,7 +130,7 @@ class PBPokemon
|
||||
end
|
||||
moves = pieces[4].split(/\s*,\s*/)
|
||||
moveid = []
|
||||
for i in 0...Pokemon::MAX_MOVES
|
||||
Pokemon::MAX_MOVES.times do |i|
|
||||
move_data = GameData::Move.try_get(moves[i])
|
||||
moveid.push(move_data.id) if move_data
|
||||
end
|
||||
|
||||
@@ -60,7 +60,7 @@ def pbGenerateBattleTrainer(idxTrainer, rules)
|
||||
# The number of possible Pokémon is <= the required number; make them
|
||||
# all Pokémon and use them
|
||||
if pokemonnumbers.length <= rules.ruleset.suggestedNumber
|
||||
for n in pokemonnumbers
|
||||
pokemonnumbers.each do |n|
|
||||
rndpoke = btpokemon[n]
|
||||
pkmn = rndpoke.createPokemon(level, indvalues, opponent)
|
||||
opponent.party.push(pkmn)
|
||||
|
||||
@@ -76,7 +76,7 @@ class BattleSwapScene
|
||||
|
||||
def pbGetCommands(list, choices)
|
||||
commands = []
|
||||
for i in 0...list.length
|
||||
list.length.times do |i|
|
||||
pkmn = list[i]
|
||||
category = pkmn.species_data.category
|
||||
cmd = _INTL("{1} - {2} Pokémon", pkmn.speciesName, category)
|
||||
|
||||
@@ -17,7 +17,7 @@ class PokemonChallengeRules
|
||||
ret = PokemonChallengeRules.new(@ruleset.copy)
|
||||
ret.setBattleType(@battletype)
|
||||
ret.setLevelAdjustment(@levelAdjustment)
|
||||
for rule in @battlerules
|
||||
@battlerules.each do |rule|
|
||||
ret.addBattleRule(rule)
|
||||
end
|
||||
return ret
|
||||
@@ -110,7 +110,7 @@ class PokemonChallengeRules
|
||||
|
||||
def createBattle(scene, trainer1, trainer2)
|
||||
battle = @battletype.pbCreateBattle(scene, trainer1, trainer2)
|
||||
for p in @battlerules
|
||||
@battlerules.each do |p|
|
||||
p.setRule(battle)
|
||||
end
|
||||
return battle
|
||||
|
||||
@@ -12,13 +12,13 @@ class PokemonRuleSet
|
||||
|
||||
def copy
|
||||
ret = PokemonRuleSet.new(@number)
|
||||
for rule in @pokemonRules
|
||||
@pokemonRules.each do |rule|
|
||||
ret.addPokemonRule(rule)
|
||||
end
|
||||
for rule in @teamRules
|
||||
@teamRules.each do |rule|
|
||||
ret.addTeamRule(rule)
|
||||
end
|
||||
for rule in @subsetRules
|
||||
@subsetRules.each do |rule|
|
||||
ret.addSubsetRule(rule)
|
||||
end
|
||||
return ret
|
||||
@@ -51,7 +51,7 @@ class PokemonRuleSet
|
||||
minLevel = 1
|
||||
maxLevel = GameData::GrowthRate.max_level
|
||||
num = self.suggestedNumber
|
||||
for rule in @pokemonRules
|
||||
@pokemonRules.each do |rule|
|
||||
case rule
|
||||
when MinimumLevelRestriction
|
||||
minLevel = rule.level
|
||||
@@ -60,7 +60,7 @@ class PokemonRuleSet
|
||||
end
|
||||
end
|
||||
totalLevel = maxLevel * num
|
||||
for rule in @subsetRules
|
||||
@subsetRules.each do |rule|
|
||||
totalLevel = rule.level if rule.is_a?(TotalLevelRestriction)
|
||||
end
|
||||
return [maxLevel, minLevel].max if totalLevel >= maxLevel * num
|
||||
@@ -126,7 +126,7 @@ class PokemonRuleSet
|
||||
|
||||
def isPokemonValid?(pkmn)
|
||||
return false if !pkmn
|
||||
for rule in @pokemonRules
|
||||
@pokemonRules.each do |rule|
|
||||
return false if !rule.isValid?(pkmn)
|
||||
end
|
||||
return true
|
||||
@@ -149,16 +149,16 @@ class PokemonRuleSet
|
||||
return false if !team || team.length < self.minTeamLength
|
||||
return false if team.length > self.maxTeamLength
|
||||
teamNumber = [self.maxLength, team.length].min
|
||||
for pkmn in team
|
||||
team.each do |pkmn|
|
||||
return false if !isPokemonValid?(pkmn)
|
||||
end
|
||||
for rule in @teamRules
|
||||
@teamRules.each do |rule|
|
||||
return false if !rule.isValid?(team)
|
||||
end
|
||||
if @subsetRules.length > 0
|
||||
pbEachCombination(team, teamNumber) { |comb|
|
||||
isValid = true
|
||||
for rule in @subsetRules
|
||||
@subsetRules.each do |rule|
|
||||
next if rule.isValid?(comb)
|
||||
isValid = false
|
||||
break
|
||||
@@ -177,7 +177,7 @@ class PokemonRuleSet
|
||||
return false if !team || team.length < self.minTeamLength
|
||||
teamNumber = [self.maxLength, team.length].min
|
||||
validPokemon = []
|
||||
for pkmn in team
|
||||
team.each do |pkmn|
|
||||
validPokemon.push(pkmn) if isPokemonValid?(pkmn)
|
||||
end
|
||||
return false if validPokemon.length < teamNumber
|
||||
@@ -200,7 +200,7 @@ class PokemonRuleSet
|
||||
error.push(_INTL("No more than {1} Pokémon may enter.", self.maxLength)) if error
|
||||
return false
|
||||
end
|
||||
for pkmn in team
|
||||
team.each do |pkmn|
|
||||
next if isPokemonValid?(pkmn)
|
||||
if pkmn
|
||||
error.push(_INTL("{1} is not allowed.", pkmn.name)) if error
|
||||
@@ -209,12 +209,12 @@ class PokemonRuleSet
|
||||
end
|
||||
return false
|
||||
end
|
||||
for rule in @teamRules
|
||||
@teamRules.each do |rule|
|
||||
next if rule.isValid?(team)
|
||||
error.push(rule.errorMessage) if error
|
||||
return false
|
||||
end
|
||||
for rule in @subsetRules
|
||||
@subsetRules.each do |rule|
|
||||
next if rule.isValid?(team)
|
||||
error.push(rule.errorMessage) if error
|
||||
return false
|
||||
|
||||
@@ -125,8 +125,8 @@ end
|
||||
#===============================================================================
|
||||
class NicknameClause
|
||||
def isValid?(team)
|
||||
for i in 0...team.length - 1
|
||||
for j in i + 1...team.length
|
||||
(team.length - 1).times do |i|
|
||||
(i + 1...team.length).each do |j|
|
||||
return false if team[i].name == team[j].name
|
||||
return false if !NicknameChecker.check(team[i].name, team[i].species)
|
||||
end
|
||||
|
||||
@@ -69,7 +69,7 @@ class BugContestState
|
||||
# can be outdoors, with its own grassy patches.
|
||||
def pbSetReception(*arg)
|
||||
@reception = []
|
||||
for i in arg
|
||||
arg.each do |i|
|
||||
@reception.push(i)
|
||||
end
|
||||
end
|
||||
@@ -77,7 +77,7 @@ class BugContestState
|
||||
def pbOffLimits?(map)
|
||||
# p [map,@contestMap,@reception]
|
||||
return false if map == @contestMap
|
||||
for i in @reception
|
||||
@reception.each do |i|
|
||||
return false if map == i
|
||||
end
|
||||
return true
|
||||
@@ -100,7 +100,7 @@ class BugContestState
|
||||
if !$PokemonEncounters.map_has_encounter_type?(@contestMap, enctype)
|
||||
enctype = :Land
|
||||
end
|
||||
for cont in @contestants
|
||||
@contestants.each do |cont|
|
||||
enc = $PokemonEncounters.choose_wild_pokemon_for_map(@contestMap, enctype)
|
||||
if !enc
|
||||
raise _INTL("No encounters for map {1}, so can't judge contest", @contestMap)
|
||||
@@ -163,7 +163,7 @@ class BugContestState
|
||||
@timer = Graphics.frame_count
|
||||
@places = []
|
||||
chosenpkmn = $player.party[@chosenPokemon]
|
||||
for i in 0...$player.party.length
|
||||
$player.party.length.times do |i|
|
||||
@otherparty.push($player.party[i]) if i != @chosenPokemon
|
||||
end
|
||||
@contestants = []
|
||||
@@ -182,7 +182,7 @@ class BugContestState
|
||||
end
|
||||
|
||||
def place
|
||||
for i in 0...3
|
||||
3.times do |i|
|
||||
return i if @places[i][0] < 0
|
||||
end
|
||||
return 3
|
||||
@@ -190,7 +190,7 @@ class BugContestState
|
||||
|
||||
def pbEnd(interrupted = false)
|
||||
return if !@inProgress
|
||||
for poke in @otherparty
|
||||
@otherparty.each do |poke|
|
||||
$player.party.push(poke)
|
||||
end
|
||||
if !interrupted
|
||||
|
||||
@@ -85,10 +85,10 @@ def pbArrangeByTier(pokemonlist, rule)
|
||||
# Sort each Pokémon into tiers. Which tier a Pokémon is put in deoends on the
|
||||
# Pokémon's position within pokemonlist (later = higher tier). pokemonlist is
|
||||
# already roughly arranged by rank from weakest to strongest.
|
||||
for i in 0...pokemonlist.length
|
||||
pokemonlist.length.times do |i|
|
||||
next if !rule.ruleset.isPokemonValid?(pokemonlist[i])
|
||||
validtiers = []
|
||||
for j in 0...tiers.length
|
||||
tiers.length.times do |j|
|
||||
validtiers.push(j) if tiers[j].ruleset.isPokemonValid?(pokemonlist[i])
|
||||
end
|
||||
if validtiers.length > 0
|
||||
@@ -98,7 +98,7 @@ def pbArrangeByTier(pokemonlist, rule)
|
||||
end
|
||||
# Now for each tier, sort the Pokemon in that tier by their BST (lowest first).
|
||||
ret = []
|
||||
for i in 0...tiers.length
|
||||
tiers.length.times do |i|
|
||||
tierPokemon[i].sort! { |a, b|
|
||||
bstA = baseStatTotal(a.species)
|
||||
bstB = baseStatTotal(b.species)
|
||||
@@ -116,7 +116,7 @@ def pbReplenishBattlePokemon(party, rule)
|
||||
while party.length < 20
|
||||
pkmn = pbRandomPokemonFromRule(rule, nil)
|
||||
found = false
|
||||
for pk in party
|
||||
party.each do |pk|
|
||||
next if !isBattlePokemonDuplicate(pkmn, pk)
|
||||
found = true
|
||||
break
|
||||
@@ -129,7 +129,7 @@ def isBattlePokemonDuplicate(pk, pk2)
|
||||
return false if pk.species != pk2.species
|
||||
moves1 = []
|
||||
moves2 = []
|
||||
for i in 0...Pokemon::MAX_MOVES
|
||||
Pokemon::MAX_MOVES.times do |i|
|
||||
moves1.push((pk.moves[i]) ? pk.moves[i].id : nil)
|
||||
moves2.push((pk2.moves[i]) ? pk2.moves[i].id : nil)
|
||||
end
|
||||
@@ -144,11 +144,11 @@ end
|
||||
|
||||
def pbRemoveDuplicates(party)
|
||||
ret = []
|
||||
for pk in party
|
||||
party.each do |pk|
|
||||
found = false
|
||||
count = 0
|
||||
firstIndex = -1
|
||||
for i in 0...ret.length
|
||||
ret.length.times do |i|
|
||||
pk2 = ret[i]
|
||||
if isBattlePokemonDuplicate(pk, pk2)
|
||||
found = true
|
||||
@@ -181,7 +181,7 @@ def pbGenerateChallenge(rule, tag)
|
||||
btpokemon = pbGetBTPokemon(tag)
|
||||
if btpokemon && btpokemon.length != 0
|
||||
suggestedLevel = rule.ruleset.suggestedLevel
|
||||
for pk in btpokemon
|
||||
btpokemon.each do |pk|
|
||||
pkmn = pk.createPokemon(suggestedLevel, 31, nil)
|
||||
party.push(pkmn) if rule.ruleset.isPokemonValid?(pkmn)
|
||||
end
|
||||
@@ -209,7 +209,7 @@ def pbGenerateChallenge(rule, tag)
|
||||
teams.delete_at(i)
|
||||
elsif teams[i].totalGames >= 250
|
||||
# retire
|
||||
for j in 0...teams[i].length
|
||||
teams[i].length.times do |j|
|
||||
party.push(teams[i][j])
|
||||
end
|
||||
teams[i] = RuledTeam.new(party, rule)
|
||||
@@ -244,12 +244,12 @@ def pbGenerateChallenge(rule, tag)
|
||||
}
|
||||
i += 1
|
||||
gameCount = 0
|
||||
for team in teams
|
||||
teams.each do |team|
|
||||
gameCount += team.games
|
||||
end
|
||||
yield(nil)
|
||||
if gameCount / teams.length >= 12
|
||||
for team in teams
|
||||
teams.each do |team|
|
||||
team.updateRating
|
||||
end
|
||||
break
|
||||
@@ -261,9 +261,9 @@ def pbGenerateChallenge(rule, tag)
|
||||
party = []
|
||||
yield(nil)
|
||||
teams.sort! { |a, b| a.rating <=> b.rating }
|
||||
for team in teams
|
||||
teams.each do |team|
|
||||
next if team.rating <= cutoffrating
|
||||
for i in 0...team.length
|
||||
team.length.times do |i|
|
||||
party.push(team[i])
|
||||
end
|
||||
end
|
||||
@@ -284,7 +284,7 @@ def pbWriteCup(id, rules)
|
||||
return if !$DEBUG
|
||||
trlists = (load_data("Data/trainer_lists.dat") rescue [])
|
||||
list = []
|
||||
for i in 0...trlists.length
|
||||
trlists.length.times do |i|
|
||||
tr = trlists[i]
|
||||
if tr[5]
|
||||
list.push("*" + (tr[3].sub(/\.txt$/, "")))
|
||||
@@ -312,7 +312,7 @@ def pbWriteCup(id, rules)
|
||||
cmd = pbMessage(_INTL("Choose a challenge."), list, -1)
|
||||
if cmd >= 0
|
||||
pbMessage(_INTL("This challenge will use the Pokémon list from {1}.", list[cmd]))
|
||||
for i in 0...trlists.length
|
||||
trlists.length.times do |i|
|
||||
tr = trlists[i]
|
||||
while !tr[5] && tr[2].include?(id)
|
||||
tr[2].delete(id)
|
||||
|
||||
@@ -61,7 +61,7 @@ def pbGetLegalMoves2(species, maxlevel)
|
||||
babyspecies = babySpecies(species)
|
||||
GameData::Species.get(babyspecies).egg_moves.each { |m| addMove(moves, m, 2) }
|
||||
movedatas = []
|
||||
for move in moves
|
||||
moves.each do |move|
|
||||
movedatas.push([move, GameData::Move.get(move)])
|
||||
end
|
||||
# Delete less powerful moves
|
||||
@@ -70,9 +70,9 @@ def pbGetLegalMoves2(species, maxlevel)
|
||||
a.delete(item)
|
||||
end
|
||||
}
|
||||
for move in moves
|
||||
moves.each do |move|
|
||||
md = GameData::Move.get(move)
|
||||
for move2 in movedatas
|
||||
movedatas.each do |move2|
|
||||
# If we have a move that always hits, remove all other moves with no
|
||||
# effect of the same type and <= base power
|
||||
if md.accuracy == 0 && move2[1].function_code == "None" &&
|
||||
@@ -130,7 +130,7 @@ end
|
||||
def hasMorePowerfulMove(moves, thismove)
|
||||
thisdata = GameData::Move.get(thismove)
|
||||
return false if thisdata.base_damage == 0
|
||||
for move in moves
|
||||
moves.each do |move|
|
||||
next if !move
|
||||
moveData = GameData::Move.get(move)
|
||||
if moveData.type == thisdata.type && moveData.base_damage > thisdata.base_damage
|
||||
@@ -262,9 +262,7 @@ def pbRandomPokemonFromRule(rules, trainer)
|
||||
sketch = false
|
||||
if moves[0] == :SKETCH
|
||||
sketch = true
|
||||
for m in 0...Pokemon::MAX_MOVES
|
||||
moves[m] = pbRandomMove
|
||||
end
|
||||
Pokemon::MAX_MOVES.times { |m| moves[m] = pbRandomMove }
|
||||
end
|
||||
next if moves.length == 0
|
||||
if (moves | []).length < Pokemon::MAX_MOVES
|
||||
@@ -303,7 +301,7 @@ def pbRandomPokemonFromRule(rules, trainer)
|
||||
hasPhysical = false
|
||||
hasSpecial = false
|
||||
hasNormal = false
|
||||
for move in newmoves
|
||||
newmoves.each do |move|
|
||||
d = GameData::Move.get(move)
|
||||
if d.base_damage >= 1
|
||||
totalbasedamage += d.base_damage
|
||||
|
||||
@@ -17,7 +17,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
# No battle trainers found; fill bttrainers with 200 randomly chosen ones from
|
||||
# all that exist (with a base money < 100)
|
||||
if bttrainers.length == 0
|
||||
for i in 0...200
|
||||
200.times do |i|
|
||||
yield(nil) if block_given? && i % 50 == 0
|
||||
trainerid = nil
|
||||
if GameData::TrainerType.exists?(:YOUNGSTER) && rand(30) == 0
|
||||
@@ -53,7 +53,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
rulesetTeam = rules.ruleset.copy.clearPokemonRules
|
||||
pkmntypes = []
|
||||
validities = []
|
||||
for pkmn in pokemonlist
|
||||
pokemonlist.each do |pkmn|
|
||||
pkmn.level = suggestedLevel if pkmn.level != suggestedLevel
|
||||
pkmntypes.push(getTypes(pkmn.species))
|
||||
validities.push(rules.ruleset.isPokemonValid?(pkmn))
|
||||
@@ -62,7 +62,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
# pokemonlist for that trainer, and copy the trainer and their set of Pokémon
|
||||
# to newbttrainers
|
||||
newbttrainers = []
|
||||
for btt in 0...bttrainers.length
|
||||
bttrainers.length.times do |btt|
|
||||
yield(nil) if block_given? && btt % 50 == 0
|
||||
trainerdata = bttrainers[btt]
|
||||
pokemonnumbers = trainerdata[5] || []
|
||||
@@ -71,7 +71,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
species = []
|
||||
types = {}
|
||||
GameData::Type.each { |t| types[t.id] = 0 }
|
||||
for pn in pokemonnumbers
|
||||
pokemonnumbers.each do |pn|
|
||||
pkmn = btpokemon[pn]
|
||||
species.push(pkmn.species)
|
||||
t = getTypes(pkmn.species)
|
||||
@@ -104,7 +104,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
# pokemonlist, or if the trainer is positioned earlier in bttrainers (i.e.
|
||||
# later trainers get better Pokémon).
|
||||
numbersPokemon = []
|
||||
for index in 0...pokemonlist.length
|
||||
pokemonlist.length.times do |index|
|
||||
next if !validities[index]
|
||||
pkmn = pokemonlist[index]
|
||||
absDiff = ((index * 8 / pokemonlist.length) - (btt * 8 / bttrainers.length)).abs
|
||||
@@ -137,7 +137,7 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
# formed from what's in numbers
|
||||
if numbers.length < Settings::MAX_PARTY_SIZE ||
|
||||
!rulesetTeam.hasValidTeam?(numbersPokemon)
|
||||
for index in 0...pokemonlist.length
|
||||
pokemonlist.length.times do |index|
|
||||
pkmn = pokemonlist[index]
|
||||
next if !validities[index]
|
||||
if species.include?(pkmn.species)
|
||||
@@ -180,18 +180,18 @@ def pbTrainerInfo(pokemonlist, trfile, rules)
|
||||
# Add the trainer and Pokémon data from above to trainer_lists.dat, and then
|
||||
# create all PBS files from it
|
||||
pbpokemonlist = []
|
||||
for pkmn in pokemonlist
|
||||
pokemonlist.each do |pkmn|
|
||||
pbpokemonlist.push(PBPokemon.fromPokemon(pkmn))
|
||||
end
|
||||
trlists = (load_data("Data/trainer_lists.dat") rescue [])
|
||||
hasDefault = false
|
||||
trIndex = -1
|
||||
for i in 0...trlists.length
|
||||
trlists.length.times do |i|
|
||||
next if !trlists[i][5]
|
||||
hasDefault = true
|
||||
break
|
||||
end
|
||||
for i in 0...trlists.length
|
||||
trlists.length.times do |i|
|
||||
if trlists[i][2].include?(trfile)
|
||||
trIndex = i
|
||||
trlists[i][0] = newbttrainers
|
||||
|
||||
@@ -9,7 +9,7 @@ class RuledTeam
|
||||
@team = []
|
||||
retnum = []
|
||||
loop do
|
||||
for i in 0...count
|
||||
count.times do |i|
|
||||
retnum[i] = rand(party.length)
|
||||
@team[i] = party[retnum[i]]
|
||||
party.delete_at(retnum[i])
|
||||
@@ -71,7 +71,7 @@ class RuledTeam
|
||||
|
||||
def load(party)
|
||||
ret = []
|
||||
for i in 0...team.length
|
||||
team.length.times do |i|
|
||||
ret.push(party[team[i]])
|
||||
end
|
||||
return ret
|
||||
@@ -208,7 +208,7 @@ class PlayerRating
|
||||
g = []
|
||||
e = []
|
||||
score = []
|
||||
for i in 0...matches.length
|
||||
matches.length.times do |i|
|
||||
match = matches[i]
|
||||
g[i] = getGFactor(match.opponentDeviation)
|
||||
e[i] = getEFactor(rating, match.opponentRating, g[i])
|
||||
@@ -216,13 +216,13 @@ class PlayerRating
|
||||
end
|
||||
# Estimated variance
|
||||
variance = 0.0
|
||||
for i in 0...matches.length
|
||||
matches.length.times do |i|
|
||||
variance += g[i] * g[i] * e[i] * (1 - e[i])
|
||||
end
|
||||
variance = 1.0 / variance
|
||||
# Improvement sum
|
||||
sum = 0.0
|
||||
for i in 0...matches.length
|
||||
matches.length.times do |i|
|
||||
v = score[i]
|
||||
sum += g[i] * (v.to_f - e[i]) if v != -1
|
||||
end
|
||||
@@ -333,15 +333,15 @@ def pbDecideWinnerScore(party0, party1, rating)
|
||||
types1 = []
|
||||
types2 = []
|
||||
abilities = []
|
||||
for j in 0...party1.length
|
||||
party1.length.times do |j|
|
||||
types1.push(party1[j].types[0])
|
||||
types2.push(party1[j].types[1] || party1[j].types[0])
|
||||
abilities.push(party1[j].ability_id)
|
||||
end
|
||||
for i in 0...party0.length
|
||||
for move in party0[i].moves
|
||||
party0.length.times do |i|
|
||||
party0[i].moves.each do |move|
|
||||
next if !move
|
||||
for j in 0...party1.length
|
||||
party1.length.times do |j|
|
||||
score += pbDecideWinnerEffectiveness(
|
||||
move.id, types1[j], types2[j], abilities[j], [-16, -8, 0, 4, 12, 20]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user