Many more Rubocop-inspired code improvements

This commit is contained in:
Maruno17
2021-12-18 19:06:22 +00:00
parent d17fc40a47
commit 13a238cc6a
107 changed files with 651 additions and 652 deletions

View File

@@ -57,9 +57,10 @@ end
def withRestr(_rule, minbs, maxbs, legendary)
ret = PokemonChallengeRules.new.addPokemonRule(BaseStatRestriction.new(minbs, maxbs))
if legendary == 0
case legendary
when 0
ret.addPokemonRule(NonlegendaryRestriction.new)
elsif legendary == 1
when 1
ret.addPokemonRule(InverseRestriction.new(NonlegendaryRestriction.new))
end
return ret
@@ -298,14 +299,16 @@ def pbWriteCup(id, rules)
else
cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"),
[_INTL("YES"), _INTL("NO")], 2)
if cmd == 0
case cmd
when 0
cmd = 2
elsif cmd == 1
when 1
cmd = 0
end
end
return if cmd == 0 # No
if cmd == 1 # Yes, use existing
case cmd
when 1 # Yes, use existing
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]))
@@ -321,7 +324,7 @@ def pbWriteCup(id, rules)
Compiler.write_trainer_lists
end
return
elsif cmd == 2 # Yes, use new
when 2 # Yes, use new
return if !pbConfirmMessage(_INTL("This may take a long time. Are you sure?"))
mw = pbCreateMessageWindow
t = Time.now

View File

@@ -159,7 +159,7 @@ def pbRandomPokemonFromRule(rules, trainer)
r = rand(20)
bst = baseStatTotal(species)
next if level < minimumLevel(species)
if iteration % 2 == 0
if iteration.even?
next if r < 16 && bst < 400
next if r < 13 && bst < 500
else
@@ -339,7 +339,7 @@ def pbRandomPokemonFromRule(rules, trainer)
break
end
end
if item == :LIGHTCLAY && !moves.any? { |m| m == :LIGHTSCREEN || m == :REFLECT }
if item == :LIGHTCLAY && !moves.any? { |m| [:LIGHTSCREEN, :REFLECT].include?(m) }
item = :LEFTOVERS
end
if item == :BLACKSLUDGE

View File

@@ -60,7 +60,7 @@ class RuledTeam
def updateRating
@totalGames = 0 if !@totalGames
oldgames = self.games
@history.updateAndClear()
@history.updateAndClear
newgames = self.games
@totalGames += (oldgames - newgames)
end
@@ -420,10 +420,11 @@ def pbRuledBattle(team1, team2, rule)
p.item = items2[i]
end
end
if decision == 1 # Team 1 wins
case decision
when 1 # Team 1 wins
team1.addMatch(team2, 1)
team2.addMatch(team1, 0)
elsif decision == 2 # Team 2 wins
when 2 # Team 2 wins
team1.addMatch(team2, 0)
team2.addMatch(team1, 1)
else