Fix challenge min length (#180)

* Fix challenge min length

Challenge min length wasn't working when combined with PokemonRule/TeamRule.
This commit is contained in:
FL
2022-05-29 15:18:38 -03:00
committed by GitHub
parent 9f09851db9
commit 22018012c7

View File

@@ -148,7 +148,7 @@ class PokemonRuleSet
def canRegisterTeam?(team) def canRegisterTeam?(team)
return false if !team || team.length < self.minTeamLength return false if !team || team.length < self.minTeamLength
return false if team.length > self.maxTeamLength return false if team.length > self.maxTeamLength
teamNumber = [self.maxLength, team.length].min teamNumber = self.minTeamLength
team.each do |pkmn| team.each do |pkmn|
return false if !isPokemonValid?(pkmn) return false if !isPokemonValid?(pkmn)
end end
@@ -175,7 +175,7 @@ class PokemonRuleSet
# team rules and subset rules. Not all Pokemon in the team have to be valid. # team rules and subset rules. Not all Pokemon in the team have to be valid.
def hasValidTeam?(team) def hasValidTeam?(team)
return false if !team || team.length < self.minTeamLength return false if !team || team.length < self.minTeamLength
teamNumber = [self.maxLength, team.length].min teamNumber = self.minTeamLength
validPokemon = [] validPokemon = []
team.each do |pkmn| team.each do |pkmn|
validPokemon.push(pkmn) if isPokemonValid?(pkmn) validPokemon.push(pkmn) if isPokemonValid?(pkmn)