mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-11 23:24:59 +00:00
More Rubocopping
This commit is contained in:
@@ -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