mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
More tweaks from the Rubocop overlord
This commit is contained in:
@@ -203,7 +203,7 @@ class PBPokemon
|
||||
def createPokemon(level, iv, trainer)
|
||||
pkmn = Pokemon.new(@species, level, trainer, false)
|
||||
pkmn.item = @item
|
||||
pkmn.personalID = rand(2**16) | rand(2**16) << 16
|
||||
pkmn.personalID = rand(2**16) | (rand(2**16) << 16)
|
||||
pkmn.nature = nature
|
||||
pkmn.happiness = 0
|
||||
pkmn.moves.push(Pokemon::Move.new(self.convertMove(@move1)))
|
||||
|
||||
@@ -7,21 +7,21 @@ def pbBattleChallengeTrainer(win_count, bttrainers)
|
||||
# This table's start points and lengths are based on a bttrainers size of 300.
|
||||
# They are scaled based on the actual size of bttrainers later.
|
||||
table = [ # Each value is [minimum win count, range start point, range length]
|
||||
[ 0, 0, 100], # 0-100
|
||||
[ 6, 80, 40], # 80-120
|
||||
[ 7, 80, 40], # 80-120
|
||||
[13, 120, 20], # 120-140
|
||||
[14, 100, 40], # 100-140
|
||||
[20, 140, 20], # 140-160
|
||||
[21, 120, 40], # 120-160
|
||||
[27, 160, 20], # 160-180
|
||||
[28, 140, 40], # 140-180
|
||||
[34, 180, 20], # 180-200
|
||||
[35, 160, 40], # 160-200
|
||||
[41, 200, 20], # 200-220
|
||||
[42, 180, 40], # 180-220
|
||||
[48, 220, 40], # 220-260
|
||||
[49, 200, 100] # 200-300 - This line is used for all higher win_counts
|
||||
[ 0, 0, 100], # 0-100
|
||||
[ 6, 80, 40], # 80-120
|
||||
[ 7, 80, 40], # 80-120
|
||||
[13, 120, 20], # 120-140
|
||||
[14, 100, 40], # 100-140
|
||||
[20, 140, 20], # 140-160
|
||||
[21, 120, 40], # 120-160
|
||||
[27, 160, 20], # 160-180
|
||||
[28, 140, 40], # 140-180
|
||||
[34, 180, 20], # 180-200
|
||||
[35, 160, 40], # 160-200
|
||||
[41, 200, 20], # 200-220
|
||||
[42, 180, 40], # 180-220
|
||||
[48, 220, 40], # 220-260
|
||||
[49, 200, 100] # 200-300 - This line is used for all higher win_counts
|
||||
]
|
||||
slot = nil
|
||||
table.each { |val| slot = val if val[0] <= win_count && (!slot || slot[0] < val[0]) }
|
||||
@@ -99,25 +99,25 @@ def pbBattleFactoryPokemon(rules, win_count, swap_count, rentals)
|
||||
# Group 1 is 0 - 173. Group 2 is 174 - 371. Group 3 is 372 - 881.
|
||||
if level == GameData::GrowthRate.max_level # Open Level (Level 100)
|
||||
table = [
|
||||
[372, 491], # Group 3 (first quarter)
|
||||
[492, 610], # Group 3 (second quarter)
|
||||
[611, 729], # Group 3 (third quarter)
|
||||
[730, 849], # Group 3 (fourth quarter)
|
||||
[372, 881], # All of Group 3
|
||||
[372, 881], # All of Group 3
|
||||
[372, 881], # All of Group 3
|
||||
[372, 881] # This line is used for all higher sets (all of Group 3)
|
||||
[372, 491], # Group 3 (first quarter)
|
||||
[492, 610], # Group 3 (second quarter)
|
||||
[611, 729], # Group 3 (third quarter)
|
||||
[730, 849], # Group 3 (fourth quarter)
|
||||
[372, 881], # All of Group 3
|
||||
[372, 881], # All of Group 3
|
||||
[372, 881], # All of Group 3
|
||||
[372, 881] # This line is used for all higher sets (all of Group 3)
|
||||
]
|
||||
else
|
||||
table = [
|
||||
[ 0, 173], # Group 1
|
||||
[174, 272], # Group 2 (first half)
|
||||
[273, 371], # Group 2 (second half)
|
||||
[372, 491], # Group 3 (first quarter)
|
||||
[492, 610], # Group 3 (second quarter)
|
||||
[611, 729], # Group 3 (third quarter)
|
||||
[730, 849], # Group 3 (fourth quarter)
|
||||
[372, 881] # This line is used for all higher sets (all of Group 3)
|
||||
[ 0, 173], # Group 1
|
||||
[174, 272], # Group 2 (first half)
|
||||
[273, 371], # Group 2 (second half)
|
||||
[372, 491], # Group 3 (first quarter)
|
||||
[492, 610], # Group 3 (second quarter)
|
||||
[611, 729], # Group 3 (third quarter)
|
||||
[730, 849], # Group 3 (fourth quarter)
|
||||
[372, 881] # This line is used for all higher sets (all of Group 3)
|
||||
]
|
||||
end
|
||||
pokemonNumbers[0] = table[set][0] * btpokemon.length / 881
|
||||
|
||||
@@ -229,12 +229,10 @@ class BattleSwapScreen
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
elsif @scene.pbConfirm(_INTL("Quit swapping?"))
|
||||
# Canceled
|
||||
if @scene.pbConfirm(_INTL("Quit swapping?"))
|
||||
@scene.pbEndScene
|
||||
return false
|
||||
end
|
||||
@scene.pbEndScene
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,9 +52,10 @@ class PokemonRuleSet
|
||||
maxLevel = GameData::GrowthRate.max_level
|
||||
num = self.suggestedNumber
|
||||
for rule in @pokemonRules
|
||||
if rule.is_a?(MinimumLevelRestriction)
|
||||
case rule
|
||||
when MinimumLevelRestriction
|
||||
minLevel = rule.level
|
||||
elsif rule.is_a?(MaximumLevelRestriction)
|
||||
when MaximumLevelRestriction
|
||||
maxLevel = rule.level
|
||||
end
|
||||
end
|
||||
@@ -203,8 +204,8 @@ class PokemonRuleSet
|
||||
next if isPokemonValid?(pkmn)
|
||||
if pkmn
|
||||
error.push(_INTL("{1} is not allowed.", pkmn.name)) if error
|
||||
else
|
||||
error.push(_INTL("This team is not allowed.")) if error
|
||||
elsif error
|
||||
error.push(_INTL("This team is not allowed."))
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
@@ -5,14 +5,14 @@ class BugContestState
|
||||
attr_reader :timer
|
||||
|
||||
CONTESTANT_NAMES = [
|
||||
_INTL("Bug Catcher Ed"),
|
||||
_INTL("Bug Catcher Benny"),
|
||||
_INTL("Bug Catcher Josh"),
|
||||
_INTL("Camper Barry"),
|
||||
_INTL("Cool Trainer Nick"),
|
||||
_INTL("Lass Abby"),
|
||||
_INTL("Picnicker Cindy"),
|
||||
_INTL("Youngster Samuel")
|
||||
_INTL("Bug Catcher Ed"),
|
||||
_INTL("Bug Catcher Benny"),
|
||||
_INTL("Bug Catcher Josh"),
|
||||
_INTL("Camper Barry"),
|
||||
_INTL("Cool Trainer Nick"),
|
||||
_INTL("Lass Abby"),
|
||||
_INTL("Picnicker Cindy"),
|
||||
_INTL("Youngster Samuel")
|
||||
]
|
||||
TIME_ALLOWED = Settings::BUG_CONTEST_TIME
|
||||
|
||||
@@ -30,7 +30,7 @@ class BugContestState
|
||||
def expired?
|
||||
return false if !undecided?
|
||||
return false if TIME_ALLOWED <= 0
|
||||
curtime = @timer + TIME_ALLOWED * Graphics.frame_rate
|
||||
curtime = @timer + (TIME_ALLOWED * Graphics.frame_rate)
|
||||
curtime = [curtime - Graphics.frame_count, 0].max
|
||||
return (curtime <= 0)
|
||||
end
|
||||
|
||||
@@ -68,15 +68,15 @@ end
|
||||
|
||||
def pbArrangeByTier(pokemonlist, rule)
|
||||
tiers = [
|
||||
withRestr(rule, 0, 500, 0),
|
||||
withRestr(rule, 380, 500, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 580, 680, 1),
|
||||
withRestr(rule, 500, 680, 0),
|
||||
withRestr(rule, 580, 680, 2)
|
||||
withRestr(rule, 0, 500, 0),
|
||||
withRestr(rule, 380, 500, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 400, 555, 0),
|
||||
withRestr(rule, 580, 680, 1),
|
||||
withRestr(rule, 500, 680, 0),
|
||||
withRestr(rule, 580, 680, 2)
|
||||
]
|
||||
tierPokemon = []
|
||||
tiers.length.times do
|
||||
|
||||
@@ -196,15 +196,15 @@ def pbRandomPokemonFromRule(rules, trainer)
|
||||
$legalMovesLevel = level
|
||||
$legalMoves[species] = pbGetLegalMoves2(species, level) if !$legalMoves[species]
|
||||
itemlist = [
|
||||
:ORANBERRY, :SITRUSBERRY, :ADAMANTORB, :BABIRIBERRY,
|
||||
:BLACKSLUDGE, :BRIGHTPOWDER, :CHESTOBERRY, :CHOICEBAND,
|
||||
:CHOICESCARF, :CHOICESPECS, :CHOPLEBERRY, :DAMPROCK,
|
||||
:DEEPSEATOOTH, :EXPERTBELT, :FLAMEORB, :FOCUSSASH,
|
||||
:FOCUSBAND, :HEATROCK, :LEFTOVERS, :LIFEORB, :LIGHTBALL,
|
||||
:LIGHTCLAY, :LUMBERRY, :OCCABERRY, :PETAYABERRY, :SALACBERRY,
|
||||
:SCOPELENS, :SHEDSHELL, :SHELLBELL, :SHUCABERRY, :LIECHIBERRY,
|
||||
:SILKSCARF, :THICKCLUB, :TOXICORB, :WIDELENS, :YACHEBERRY,
|
||||
:HABANBERRY, :SOULDEW, :PASSHOBERRY, :QUICKCLAW, :WHITEHERB
|
||||
:ORANBERRY, :SITRUSBERRY, :ADAMANTORB, :BABIRIBERRY,
|
||||
:BLACKSLUDGE, :BRIGHTPOWDER, :CHESTOBERRY, :CHOICEBAND,
|
||||
:CHOICESCARF, :CHOICESPECS, :CHOPLEBERRY, :DAMPROCK,
|
||||
:DEEPSEATOOTH, :EXPERTBELT, :FLAMEORB, :FOCUSSASH,
|
||||
:FOCUSBAND, :HEATROCK, :LEFTOVERS, :LIFEORB, :LIGHTBALL,
|
||||
:LIGHTCLAY, :LUMBERRY, :OCCABERRY, :PETAYABERRY, :SALACBERRY,
|
||||
:SCOPELENS, :SHEDSHELL, :SHELLBELL, :SHUCABERRY, :LIECHIBERRY,
|
||||
:SILKSCARF, :THICKCLUB, :TOXICORB, :WIDELENS, :YACHEBERRY,
|
||||
:HABANBERRY, :SOULDEW, :PASSHOBERRY, :QUICKCLAW, :WHITEHERB
|
||||
]
|
||||
# Most used: Leftovers, Life Orb, Choice Band, Choice Scarf, Focus Sash
|
||||
item = nil
|
||||
|
||||
@@ -146,7 +146,7 @@ class PlayerRatingElo
|
||||
|
||||
def winChancePercent
|
||||
return @estimatedRating if @estimatedRating
|
||||
x = (1 + 10.0**((@rating - 1600.0) / 400.0))
|
||||
x = (1 + (10.0**((@rating - 1600.0) / 400.0)))
|
||||
@estimatedRating = (x == 0 ? 1.0 : 1.0 / x)
|
||||
return @estimatedRating
|
||||
end
|
||||
@@ -156,7 +156,7 @@ class PlayerRatingElo
|
||||
stake = 0
|
||||
matches.length.times do
|
||||
score = (match.score == -1) ? 0.5 : match.score
|
||||
e = (1 + 10.0**((@rating - match.opponentRating) / 400.0))
|
||||
e = (1 + (10.0**((@rating - match.opponentRating) / 400.0)))
|
||||
stake += match.kValue * (score - e)
|
||||
end
|
||||
@rating += stake
|
||||
@@ -184,7 +184,7 @@ 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(100000.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
|
||||
@@ -192,7 +192,7 @@ class PlayerRating
|
||||
rds = @deviation * @deviation
|
||||
sqr = Math.sqrt(15.905694331435 * (rds + 221781.21786254))
|
||||
inner = (1500.0 - @rating) * Math::PI / sqr
|
||||
@estimatedRating = (10000.0 / (1.0 + (10.0**inner)) + 0.5) / 100.0
|
||||
@estimatedRating = ((10000.0 / (1.0 + (10.0**inner))) + 0.5) / 100.0
|
||||
end
|
||||
return @estimatedRating
|
||||
end
|
||||
@@ -202,7 +202,7 @@ class PlayerRating
|
||||
deviation = deviation2
|
||||
rating = rating2
|
||||
if matches.length == 0
|
||||
setDeviation2(Math.sqrt(deviation * deviation + volatility * volatility))
|
||||
setDeviation2(Math.sqrt((deviation * deviation) + (volatility * volatility)))
|
||||
return
|
||||
end
|
||||
g = []
|
||||
@@ -228,10 +228,10 @@ class PlayerRating
|
||||
end
|
||||
volatility = getUpdatedVolatility(volatility, deviation, variance, sum, system)
|
||||
# Update deviation
|
||||
t = deviation * deviation + volatility * volatility
|
||||
deviation = 1.0 / Math.sqrt(1.0 / t + 1.0 / variance)
|
||||
t = (deviation * deviation) + (volatility * volatility)
|
||||
deviation = 1.0 / Math.sqrt((1.0 / t) + (1.0 / variance))
|
||||
# Update rating
|
||||
rating = rating + deviation * deviation * sum
|
||||
rating = rating + (deviation * deviation * sum)
|
||||
setRating2(rating)
|
||||
setDeviation2(deviation)
|
||||
setVolatility2(volatility)
|
||||
@@ -254,7 +254,7 @@ class PlayerRating
|
||||
def getGFactor(deviation)
|
||||
# deviation is not yet in glicko2
|
||||
deviation /= 173.7178
|
||||
return 1.0 / Math.sqrt(1.0 + (3.0 * deviation * deviation) / (Math::PI * Math::PI))
|
||||
return 1.0 / Math.sqrt(1.0 + ((3.0 * deviation * deviation) / (Math::PI * Math::PI)))
|
||||
end
|
||||
|
||||
def getEFactor(rating, opponentRating, g)
|
||||
@@ -291,8 +291,8 @@ class PlayerRating
|
||||
d = squDevplusVar + e
|
||||
squD = d * d
|
||||
i = improvement / d
|
||||
h1 = -(x0 - a) / squSystem - 0.5 * e * i * i
|
||||
h2 = -1.0 / squSystem - 0.5 * e * squDevplusVar / squD
|
||||
h1 = (-(x0 - a) / squSystem) - (0.5 * e * i * i)
|
||||
h2 = (-1.0 / squSystem) - (0.5 * e * squDevplusVar / squD)
|
||||
h2 += 0.5 * squVariance * e * (squDevplusVar - e) / (squD * d)
|
||||
x1 = x0
|
||||
x0 -= h1 / h2
|
||||
|
||||
Reference in New Issue
Block a user