Yet more Rubocopping

This commit is contained in:
Maruno17
2021-12-23 00:27:17 +00:00
parent 514fe13ca2
commit 132a16950d
171 changed files with 1455 additions and 1647 deletions

View File

@@ -197,13 +197,13 @@ class PokemonRuleSet
error.push(_INTL("{1} Pokémon are needed.", self.minLength)) if error && self.minLength > 1
return false
elsif team.length > self.maxLength
error.push(_INTL("No more than {1} Pokémon may enter.", self.maxLength)) if error
error&.push(_INTL("No more than {1} Pokémon may enter.", self.maxLength))
return false
end
team.each do |pkmn|
next if isPokemonValid?(pkmn)
if pkmn
error.push(_INTL("{1} is not allowed.", pkmn.name)) if error
error&.push(_INTL("{1} is not allowed.", pkmn.name))
elsif error
error.push(_INTL("This team is not allowed."))
end
@@ -211,12 +211,12 @@ class PokemonRuleSet
end
@teamRules.each do |rule|
next if rule.isValid?(team)
error.push(rule.errorMessage) if error
error&.push(rule.errorMessage)
return false
end
@subsetRules.each do |rule|
next if rule.isValid?(team)
error.push(rule.errorMessage) if error
error&.push(rule.errorMessage)
return false
end
return true

View File

@@ -153,7 +153,7 @@ end
#===============================================================================
class AblePokemonRestriction
def isValid?(pkmn)
return pkmn && pkmn.able?
return pkmn&.able?
end
end

View File

@@ -24,7 +24,7 @@ class BugContestState
def pbContestHeld?
return false if !@lastContest
timenow = pbGetTimeNow
return timenow.to_i - @lastContest < 86400
return timenow.to_i - @lastContest < 86_400
end
def expired?
@@ -193,13 +193,13 @@ class BugContestState
@otherparty.each do |poke|
$player.party.push(poke)
end
if !interrupted
if interrupted
@ended = false
else
if @lastPokemon
pbNicknameAndStore(@lastPokemon)
end
@ended = true
else
@ended = false
end
$stats.bug_contest_wins += 1 if place == 0
@lastPokemon = nil
@@ -302,22 +302,18 @@ Events.onMapSceneChange += proc { |_sender, e|
Events.onMapUpdate += proc { |_sender, _e|
if !$game_player.move_route_forcing && !pbMapInterpreterRunning? &&
!$game_temp.message_window_showing
if pbBugContestState.expired?
pbMessage(_INTL("ANNOUNCER: BEEEEEP!"))
pbMessage(_INTL("Time's up!"))
pbBugContestState.pbStartJudging
end
!$game_temp.message_window_showing && pbBugContestState.expired?
pbMessage(_INTL("ANNOUNCER: BEEEEEP!"))
pbMessage(_INTL("Time's up!"))
pbBugContestState.pbStartJudging
end
}
Events.onMapChanging += proc { |_sender, e|
newmapID = e[0]
if pbInBugContest?
if pbBugContestState.pbOffLimits?(newmapID)
# Clear bug contest if player flies/warps/teleports out of the contest
pbBugContestState.pbEnd(true)
end
if pbInBugContest? && pbBugContestState.pbOffLimits?(newmapID)
# Clear bug contest if player flies/warps/teleports out of the contest
pbBugContestState.pbEnd(true)
end
}

View File

@@ -293,10 +293,7 @@ def pbWriteCup(id, rules)
end
end
cmd = 0
if trlists.length != 0
cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"),
[_INTL("NO"), _INTL("YES, USE EXISTING"), _INTL("YES, USE NEW")], 1)
else
if trlists.length == 0
cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"),
[_INTL("YES"), _INTL("NO")], 2)
case cmd
@@ -305,6 +302,9 @@ def pbWriteCup(id, rules)
when 1
cmd = 0
end
else
cmd = pbMessage(_INTL("Generate Pokémon teams for this challenge?"),
[_INTL("NO"), _INTL("YES, USE EXISTING"), _INTL("YES, USE NEW")], 1)
end
return if cmd == 0 # No
case cmd

View File

@@ -284,18 +284,20 @@ def pbRandomPokemonFromRule(rules, trainer)
newmoves.push(m) if m && !newmoves.include?(m)
end
if (newmoves.include?(spitup) || newmoves.include?(swallow)) &&
!newmoves.include?(stockpile)
next unless sketch
!newmoves.include?(stockpile) && !sketch
next
end
if (!newmoves.include?(spitup) && !newmoves.include?(swallow)) &&
newmoves.include?(stockpile)
next unless sketch
newmoves.include?(stockpile) && !sketch
next
end
if newmoves.include?(sleeptalk) && !newmoves.include?(rest)
next unless (sketch || !moves.include?(rest)) && rand(100) < 20
if newmoves.include?(sleeptalk) && !newmoves.include?(rest) &&
!((sketch || !moves.include?(rest)) && rand(100) < 20)
next
end
if newmoves.include?(snore) && !newmoves.include?(rest)
next unless (sketch || !moves.include?(rest)) && rand(100) < 20
if newmoves.include?(snore) && !newmoves.include?(rest) &&
!((sketch || !moves.include?(rest)) && rand(100) < 20)
next
end
totalbasedamage = 0
hasPhysical = false
@@ -310,13 +312,13 @@ def pbRandomPokemonFromRule(rules, trainer)
hasSpecial = true if d.category == 1
end
end
if !hasPhysical && ev.include?(:ATTACK)
if !hasPhysical && ev.include?(:ATTACK) && rand(100) < 80
# No physical attack, but emphasizes Attack
next if rand(100) < 80
next
end
if !hasSpecial && ev.include?(:SPECIAL_ATTACK)
if !hasSpecial && ev.include?(:SPECIAL_ATTACK) && rand(100) < 80
# No special attack, but emphasizes Special Attack
next if rand(100) < 80
next
end
r = rand(10)
next if r > 6 && totalbasedamage > 180

View File

@@ -184,15 +184,15 @@ class PlayerRating
# https://www.smogon.com/forums/threads/make-sense-of-your-shoddy-battle-rating.55764/
otherRating = 1500.0
otherDeviation = 350.0
s = Math.sqrt(100000.0 + (@deviation * @deviation) + (otherDeviation * otherDeviation))
s = Math.sqrt(100_000.0 + (@deviation * @deviation) + (otherDeviation * otherDeviation))
g = 10.0**((otherRating - @rating) * 0.79 / s)
@estimatedRating = (1.0 / (1.0 + g)) * 100.0 # Percent chance that I win against opponent
else
# GLIXARE method
rds = @deviation * @deviation
sqr = Math.sqrt(15.905694331435 * (rds + 221781.21786254))
sqr = Math.sqrt(15.905694331435 * (rds + 221_781.21786254))
inner = (1500.0 - @rating) * Math::PI / sqr
@estimatedRating = ((10000.0 / (1.0 + (10.0**inner))) + 0.5) / 100.0
@estimatedRating = ((10_000.0 / (1.0 + (10.0**inner))) + 0.5) / 100.0
end
return @estimatedRating
end
@@ -296,7 +296,7 @@ class PlayerRating
h2 += 0.5 * squVariance * e * (squDevplusVar - e) / (squD * d)
x1 = x0
x0 -= h1 / h2
break if ((x1 - x0).abs < 0.000001)
break if (x1 - x0).abs < 0.000001
}
return Math.exp(x0 / 2.0)
end
@@ -373,13 +373,7 @@ end
#===============================================================================
def pbRuledBattle(team1, team2, rule)
decision = 0
if rand(100) != 0
party1 = []
party2 = []
team1.length.times { |i| party1.push(team1[i]) }
team2.length.times { |i| party2.push(team2[i]) }
decision = pbDecideWinner(party1, party2, team1.rating, team2.rating)
else
if rand(100) == 0
level = rule.ruleset.suggestedLevel
t_type = GameData::TrainerType.keys.first
trainer1 = NPCTrainer.new("PLAYER1", t_type)
@@ -420,6 +414,12 @@ def pbRuledBattle(team1, team2, rule)
p.heal
p.item = items2[i]
end
else
party1 = []
party2 = []
team1.length.times { |i| party1.push(team1[i]) }
team2.length.times { |i| party2.push(team2[i]) }
decision = pbDecideWinner(party1, party2, team1.rating, team2.rating)
end
case decision
when 1 # Team 1 wins