mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-12 07:35:00 +00:00
Rearranged OrgBattle scripts
This commit is contained in:
@@ -0,0 +1,382 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonChallengeRules
|
||||
attr_reader :ruleset
|
||||
attr_reader :battletype
|
||||
attr_reader :levelAdjustment
|
||||
|
||||
def initialize(ruleset = nil)
|
||||
@ruleset = (ruleset) ? ruleset : PokemonRuleSet.new
|
||||
@battletype = BattleTower.new
|
||||
@levelAdjustment = nil
|
||||
@battlerules = []
|
||||
end
|
||||
|
||||
def copy
|
||||
ret = PokemonChallengeRules.new(@ruleset.copy)
|
||||
ret.setBattleType(@battletype)
|
||||
ret.setLevelAdjustment(@levelAdjustment)
|
||||
for rule in @battlerules
|
||||
ret.addBattleRule(rule)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def setRuleset(rule)
|
||||
@ruleset = rule
|
||||
return self
|
||||
end
|
||||
|
||||
def setBattleType(rule)
|
||||
@battletype = rule
|
||||
return self
|
||||
end
|
||||
|
||||
def setLevelAdjustment(rule)
|
||||
@levelAdjustment = rule
|
||||
return self
|
||||
end
|
||||
|
||||
def number
|
||||
return self.ruleset.number
|
||||
end
|
||||
|
||||
def setNumber(number)
|
||||
self.ruleset.setNumber(number)
|
||||
return self
|
||||
end
|
||||
|
||||
def setDoubleBattle(value)
|
||||
if value
|
||||
self.ruleset.setNumber(4)
|
||||
self.addBattleRule(DoubleBattle.new)
|
||||
else
|
||||
self.ruleset.setNumber(3)
|
||||
self.addBattleRule(SingleBattle.new)
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
def adjustLevels(party1, party2)
|
||||
return @levelAdjustment.adjustLevels(party1, party2) if @levelAdjustment
|
||||
return nil
|
||||
end
|
||||
|
||||
def unadjustLevels(party1, party2, adjusts)
|
||||
@levelAdjustment.unadjustLevels(party1, party2, adjusts) if @levelAdjustment && adjusts
|
||||
end
|
||||
|
||||
def adjustLevelsBilateral(party1,party2)
|
||||
if @levelAdjustment && @levelAdjustment.type == LevelAdjustment::BothTeams
|
||||
return @levelAdjustment.adjustLevels(party1, party2)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def unadjustLevelsBilateral(party1,party2,adjusts)
|
||||
if @levelAdjustment && adjusts && @levelAdjustment.type == LevelAdjustment::BothTeams
|
||||
@levelAdjustment.unadjustLevels(party1, party2, adjusts)
|
||||
end
|
||||
end
|
||||
|
||||
def addPokemonRule(rule)
|
||||
self.ruleset.addPokemonRule(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
def addLevelRule(minLevel,maxLevel,totalLevel)
|
||||
self.addPokemonRule(MinimumLevelRestriction.new(minLevel))
|
||||
self.addPokemonRule(MaximumLevelRestriction.new(maxLevel))
|
||||
self.addSubsetRule(TotalLevelRestriction.new(totalLevel))
|
||||
self.setLevelAdjustment(TotalLevelAdjustment.new(minLevel, maxLevel, totalLevel))
|
||||
return self
|
||||
end
|
||||
|
||||
def addSubsetRule(rule)
|
||||
self.ruleset.addSubsetRule(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
def addTeamRule(rule)
|
||||
self.ruleset.addTeamRule(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
def addBattleRule(rule)
|
||||
@battlerules.push(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
def createBattle(scene, trainer1, trainer2)
|
||||
battle = @battletype.pbCreateBattle(scene, trainer1, trainer2)
|
||||
for p in @battlerules
|
||||
p.setRule(battle)
|
||||
end
|
||||
return battle
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Stadium Cups rules
|
||||
#===============================================================================
|
||||
def pbPikaCupRules(double)
|
||||
ret = PokemonChallengeRules.new
|
||||
ret.addPokemonRule(StandardRestriction.new)
|
||||
ret.addLevelRule(15, 20, 50)
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SleepClause.new)
|
||||
ret.addBattleRule(FreezeClause.new)
|
||||
ret.addBattleRule(SelfKOClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
ret.setNumber(3)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbPokeCupRules(double)
|
||||
ret = PokemonChallengeRules.new
|
||||
ret.addPokemonRule(StandardRestriction.new)
|
||||
ret.addLevelRule(50, 55, 155)
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SleepClause.new)
|
||||
ret.addBattleRule(FreezeClause.new)
|
||||
ret.addBattleRule(SelfdestructClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
ret.setNumber(3)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbPrimeCupRules(double)
|
||||
ret = PokemonChallengeRules.new
|
||||
ret.setLevelAdjustment(OpenLevelAdjustment.new(GameData::GrowthRate.max_level))
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SleepClause.new)
|
||||
ret.addBattleRule(FreezeClause.new)
|
||||
ret.addBattleRule(SelfdestructClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbFancyCupRules(double)
|
||||
ret = PokemonChallengeRules.new
|
||||
ret.addPokemonRule(StandardRestriction.new)
|
||||
ret.addLevelRule(25, 30, 80)
|
||||
ret.addPokemonRule(HeightRestriction.new(2))
|
||||
ret.addPokemonRule(WeightRestriction.new(20))
|
||||
ret.addPokemonRule(BabyRestriction.new)
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SleepClause.new)
|
||||
ret.addBattleRule(FreezeClause.new)
|
||||
ret.addBattleRule(PerishSongClause.new)
|
||||
ret.addBattleRule(SelfdestructClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
ret.setNumber(3)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbLittleCupRules(double)
|
||||
ret = PokemonChallengeRules.new
|
||||
ret.addPokemonRule(StandardRestriction.new)
|
||||
ret.addPokemonRule(UnevolvedFormRestriction.new)
|
||||
ret.setLevelAdjustment(EnemyLevelAdjustment.new(5))
|
||||
ret.addPokemonRule(MaximumLevelRestriction.new(5))
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SleepClause.new)
|
||||
ret.addBattleRule(FreezeClause.new)
|
||||
ret.addBattleRule(SelfdestructClause.new)
|
||||
ret.addBattleRule(PerishSongClause.new)
|
||||
ret.addBattleRule(SonicBoomClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbStrictLittleCupRules(double)
|
||||
ret = PokemonChallengeRules.new
|
||||
ret.addPokemonRule(StandardRestriction.new)
|
||||
ret.addPokemonRule(UnevolvedFormRestriction.new)
|
||||
ret.setLevelAdjustment(EnemyLevelAdjustment.new(5))
|
||||
ret.addPokemonRule(MaximumLevelRestriction.new(5))
|
||||
ret.addPokemonRule(LittleCupRestriction.new)
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addBattleRule(SleepClause.new)
|
||||
ret.addBattleRule(EvasionClause.new)
|
||||
ret.addBattleRule(OHKOClause.new)
|
||||
ret.addBattleRule(SelfKOClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
ret.setNumber(3)
|
||||
return ret
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Battle Frontier rules
|
||||
#===============================================================================
|
||||
def pbBattleTowerRules(double, openlevel)
|
||||
ret = PokemonChallengeRules.new
|
||||
if openlevel
|
||||
ret.setLevelAdjustment(OpenLevelAdjustment.new(60))
|
||||
else
|
||||
ret.setLevelAdjustment(CappedLevelAdjustment.new(50))
|
||||
end
|
||||
ret.addPokemonRule(StandardRestriction.new)
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SoulDewBattleClause.new)
|
||||
ret.setDoubleBattle(double)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbBattlePalaceRules(double, openlevel)
|
||||
return pbBattleTowerRules(double, openlevel).setBattleType(BattlePalace.new)
|
||||
end
|
||||
|
||||
def pbBattleArenaRules(openlevel)
|
||||
return pbBattleTowerRules(false, openlevel).setBattleType(BattleArena.new)
|
||||
end
|
||||
|
||||
def pbBattleFactoryRules(double, openlevel)
|
||||
ret = PokemonChallengeRules.new
|
||||
if openlevel
|
||||
ret.setLevelAdjustment(FixedLevelAdjustment.new(100))
|
||||
ret.addPokemonRule(MaximumLevelRestriction.new(100))
|
||||
else
|
||||
ret.setLevelAdjustment(FixedLevelAdjustment.new(50))
|
||||
ret.addPokemonRule(MaximumLevelRestriction.new(50))
|
||||
end
|
||||
ret.addTeamRule(SpeciesClause.new)
|
||||
ret.addPokemonRule(BannedSpeciesRestriction.new(:UNOWN))
|
||||
ret.addTeamRule(ItemClause.new)
|
||||
ret.addBattleRule(SoulDewBattleClause.new)
|
||||
ret.setDoubleBattle(double).setNumber(0)
|
||||
return ret
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Other Interesting Rulesets
|
||||
#===============================================================================
|
||||
=begin
|
||||
# Official Species Restriction
|
||||
.addPokemonRule(BannedSpeciesRestriction.new(
|
||||
:MEWTWO, :MEW,
|
||||
:LUGIA, :HOOH, :CELEBI,
|
||||
:KYOGRE, :GROUDON, :RAYQUAZA, :JIRACHI, :DEOXYS,
|
||||
:DIALGA, :PALKIA, :GIRATINA, :MANAPHY, :PHIONE,
|
||||
:DARKRAI, :SHAYMIN, :ARCEUS))
|
||||
.addBattleRule(SoulDewBattleClause.new)
|
||||
|
||||
# New Official Species Restriction
|
||||
.addPokemonRule(BannedSpeciesRestriction.new(
|
||||
:MEW,
|
||||
:CELEBI,
|
||||
:JIRACHI, :DEOXYS,
|
||||
:MANAPHY, :PHIONE, :DARKRAI, :SHAYMIN, :ARCEUS))
|
||||
.addBattleRule(SoulDewBattleClause.new)
|
||||
|
||||
# Pocket Monsters Stadium
|
||||
PokemonChallengeRules.new
|
||||
.addPokemonRule(SpeciesRestriction.new(
|
||||
:VENUSAUR, :CHARIZARD, :BLASTOISE, :BEEDRILL, :FEAROW,
|
||||
:PIKACHU, :NIDOQUEEN, :NIDOKING, :DUGTRIO, :PRIMEAPE,
|
||||
:ARCANINE, :ALAKAZAM, :MACHAMP, :GOLEM, :MAGNETON,
|
||||
:CLOYSTER, :GENGAR, :ONIX, :HYPNO, :ELECTRODE,
|
||||
:EXEGGUTOR, :CHANSEY, :KANGASKHAN, :STARMIE, :SCYTHER,
|
||||
:JYNX, :PINSIR, :TAUROS, :GYARADOS, :LAPRAS,
|
||||
:DITTO, :VAPOREON, :JOLTEON, :FLAREON, :AERODACTYL,
|
||||
:SNORLAX, :ARTICUNO, :ZAPDOS, :MOLTRES, :DRAGONITE
|
||||
))
|
||||
|
||||
# 1999 Tournament Rules
|
||||
PokemonChallengeRules.new
|
||||
.addTeamRule(SpeciesClause.new)
|
||||
.addPokemonRule(ItemsDisallowedClause.new)
|
||||
.addBattleRule(SleepClause.new)
|
||||
.addBattleRule(FreezeClause.new)
|
||||
.addBattleRule(SelfdestructClause.new)
|
||||
.setDoubleBattle(false)
|
||||
.setLevelRule(1, 50, 150)
|
||||
.addPokemonRule(BannedSpeciesRestriction.new(
|
||||
:VENUSAUR, :DUGTRIO, :ALAKAZAM, :GOLEM, :MAGNETON,
|
||||
:GENGAR, :HYPNO, :ELECTRODE, :EXEGGUTOR, :CHANSEY,
|
||||
:KANGASKHAN, :STARMIE, :JYNX, :TAUROS, :GYARADOS,
|
||||
:LAPRAS, :DITTO, :VAPOREON, :JOLTEON, :SNORLAX,
|
||||
:ARTICUNO, :ZAPDOS, :DRAGONITE, :MEWTWO, :MEW))
|
||||
|
||||
# 2005 Tournament Rules
|
||||
PokemonChallengeRules.new
|
||||
.addPokemonRule(BannedSpeciesRestriction.new(
|
||||
:DRAGONITE, :MEW, :MEWTWO,
|
||||
:TYRANITAR, :LUGIA, :CELEBI, :HOOH,
|
||||
:GROUDON, :KYOGRE, :RAYQUAZA, :JIRACHI, :DEOXYS))
|
||||
.setDoubleBattle(true)
|
||||
.addLevelRule(1, 50, 200)
|
||||
.addTeamRule(ItemClause.new)
|
||||
.addPokemonRule(BannedItemRestriction.new(:SOULDEW, :ENIGMABERRY))
|
||||
.addBattleRule(SleepClause.new)
|
||||
.addBattleRule(FreezeClause.new)
|
||||
.addBattleRule(SelfdestructClause.new)
|
||||
.addBattleRule(PerishSongClause.new)
|
||||
|
||||
# 2008 Tournament Rules
|
||||
PokemonChallengeRules.new
|
||||
.addPokemonRule(BannedSpeciesRestriction.new(
|
||||
:MEWTWO, :MEW,
|
||||
:TYRANITAR, :LUGIA, :HOOH, :CELEBI,
|
||||
:GROUDON, :KYOGRE, :RAYQUAZA, :JIRACHI, :DEOXYS,
|
||||
:PALKIA, :DIALGA, :PHIONE, :MANAPHY, :ROTOM, :SHAYMIN, :DARKRAI))
|
||||
.setDoubleBattle(true)
|
||||
.addLevelRule(1, 50, 200)
|
||||
.addTeamRule(NicknameClause.new)
|
||||
.addTeamRule(ItemClause.new)
|
||||
.addBattleRule(SoulDewBattleClause.new)
|
||||
|
||||
# 2010 Tournament Rules
|
||||
PokemonChallengeRules.new
|
||||
.addPokemonRule(BannedSpeciesRestriction.new(
|
||||
:MEW,
|
||||
:CELEBI,
|
||||
:JIRACHI, :DEOXYS,
|
||||
:PHIONE, :MANAPHY, :SHAYMIN, :DARKRAI, :ARCEUS))
|
||||
.addSubsetRule(RestrictedSpeciesSubsetRestriction.new(
|
||||
:MEWTWO,
|
||||
:LUGIA, :HOOH,
|
||||
:GROUDON, :KYOGRE, :RAYQUAZA,
|
||||
:PALKIA, :DIALGA, :GIRATINA))
|
||||
.setDoubleBattle(true)
|
||||
.addLevelRule(1, 100, 600)
|
||||
.setLevelAdjustment(CappedLevelAdjustment.new(50))
|
||||
.addTeamRule(NicknameClause.new)
|
||||
.addTeamRule(ItemClause.new)
|
||||
.addPokemonRule(SoulDewClause.new)
|
||||
|
||||
# Pokemon Colosseum -- Anything Goes
|
||||
PokemonChallengeRules.new
|
||||
.addLevelRule(1, 100, 600)
|
||||
.addBattleRule(SleepClause.new)
|
||||
.addBattleRule(FreezeClause.new)
|
||||
.addBattleRule(SelfdestructClause.new)
|
||||
.addBattleRule(PerishSongClause.new)
|
||||
|
||||
# Pokemon Colosseum -- Max Lv. 50
|
||||
PokemonChallengeRules.new
|
||||
.addLevelRule(1, 50, 300)
|
||||
.addTeamRule(SpeciesClause.new)
|
||||
.addTeamRule(ItemClause.new)
|
||||
.addBattleRule(SleepClause.new)
|
||||
.addBattleRule(FreezeClause.new)
|
||||
.addBattleRule(SelfdestructClause.new)
|
||||
.addBattleRule(PerishSongClause.new)
|
||||
|
||||
# Pokemon Colosseum -- Max Lv. 100
|
||||
PokemonChallengeRules.new
|
||||
.addLevelRule(1, 100, 600)
|
||||
.addTeamRule(SpeciesClause.new)
|
||||
.addTeamRule(ItemClause.new)
|
||||
.addBattleRule(SleepClause.new)
|
||||
.addBattleRule(FreezeClause.new)
|
||||
.addBattleRule(SelfdestructClause.new)
|
||||
.addBattleRule(PerishSongClause.new)
|
||||
=end
|
||||
@@ -0,0 +1,324 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonRuleSet
|
||||
def initialize(number = 0)
|
||||
@pokemonRules = []
|
||||
@teamRules = []
|
||||
@subsetRules = []
|
||||
@minLength = 1
|
||||
@number = number
|
||||
end
|
||||
|
||||
def copy
|
||||
ret = PokemonRuleSet.new(@number)
|
||||
for rule in @pokemonRules
|
||||
ret.addPokemonRule(rule)
|
||||
end
|
||||
for rule in @teamRules
|
||||
ret.addTeamRule(rule)
|
||||
end
|
||||
for rule in @subsetRules
|
||||
ret.addSubsetRule(rule)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def minLength
|
||||
return (@minLength) ? @minLength : self.maxLength
|
||||
end
|
||||
|
||||
def maxLength
|
||||
return (@number < 0) ? 6 : @number
|
||||
end
|
||||
alias number maxLength
|
||||
|
||||
def minTeamLength
|
||||
return [1, self.minLength].max
|
||||
end
|
||||
|
||||
def maxTeamLength
|
||||
return [6, self.maxLength].max
|
||||
end
|
||||
|
||||
# Returns the length of a valid subset of a Pokemon team.
|
||||
def suggestedNumber
|
||||
return self.maxLength
|
||||
end
|
||||
|
||||
# Returns a valid level to assign to each member of a valid Pokemon team.
|
||||
def suggestedLevel
|
||||
minLevel = 1
|
||||
maxLevel = GameData::GrowthRate.max_level
|
||||
num = self.suggestedNumber
|
||||
for rule in @pokemonRules
|
||||
if rule.is_a?(MinimumLevelRestriction)
|
||||
minLevel = rule.level
|
||||
elsif rule.is_a?(MaximumLevelRestriction)
|
||||
maxLevel = rule.level
|
||||
end
|
||||
end
|
||||
totalLevel = maxLevel * num
|
||||
for rule in @subsetRules
|
||||
totalLevel = rule.level if rule.is_a?(TotalLevelRestriction)
|
||||
end
|
||||
return [maxLevel, minLevel].max if totalLevel >= maxLevel * num
|
||||
return [totalLevel / self.suggestedNumber, minLevel].max
|
||||
end
|
||||
|
||||
def setNumberRange(minValue, maxValue)
|
||||
@minLength = [1, minValue].max
|
||||
@number = [maxValue, 6].min
|
||||
return self
|
||||
end
|
||||
|
||||
def setNumber(value)
|
||||
return setNumberRange(value, value)
|
||||
end
|
||||
|
||||
# This rule checks either:
|
||||
# - the entire team to determine whether a subset of the team meets the rule, or
|
||||
# - whether the entire team meets the rule. If the condition holds for the
|
||||
# entire team, the condition must also hold for any possible subset of the
|
||||
# team with the suggested number.
|
||||
# Examples of team rules:
|
||||
# - No two Pokemon can be the same species.
|
||||
# - No two Pokemon can hold the same items.
|
||||
def addTeamRule(rule)
|
||||
@teamRules.push(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
# This rule checks:
|
||||
# - the entire team to determine whether a subset of the team meets the rule, or
|
||||
# - a list of Pokemon whose length is equal to the suggested number. For an
|
||||
# entire team, the condition must hold for at least one possible subset of
|
||||
# the team, but not necessarily for the entire team.
|
||||
# A subset rule is "number-dependent", that is, whether the condition is likely
|
||||
# to hold depends on the number of Pokemon in the subset.
|
||||
# Example of a subset rule:
|
||||
# - The combined level of X Pokemon can't exceed Y.
|
||||
def addSubsetRule(rule)
|
||||
@teamRules.push(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
def addPokemonRule(rule)
|
||||
@pokemonRules.push(rule)
|
||||
return self
|
||||
end
|
||||
|
||||
def clearTeamRules
|
||||
@teamRules.clear
|
||||
return self
|
||||
end
|
||||
|
||||
def clearSubsetRules
|
||||
@subsetRules.clear
|
||||
return self
|
||||
end
|
||||
|
||||
def clearPokemonRules
|
||||
@pokemonRules.clear
|
||||
return self
|
||||
end
|
||||
|
||||
def isPokemonValid?(pkmn)
|
||||
return false if !pkmn
|
||||
for rule in @pokemonRules
|
||||
return false if !rule.isValid?(pkmn)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def hasRegistrableTeam?(list)
|
||||
return false if !list || list.length < self.minTeamLength
|
||||
pbEachCombination(list, self.maxTeamLength) { |comb|
|
||||
return true if canRegisterTeam?(comb)
|
||||
}
|
||||
return false
|
||||
end
|
||||
|
||||
# Returns true if the team's length is greater or equal to the suggested number
|
||||
# and is 6 or less, the team as a whole meets the requirements of any team
|
||||
# rules, and at least one subset of the team meets the requirements of any
|
||||
# subset rules. Each Pokemon in the team must be valid.
|
||||
def canRegisterTeam?(team)
|
||||
return false if !team || team.length < self.minTeamLength
|
||||
return false if team.length > self.maxTeamLength
|
||||
teamNumber = [self.maxLength, team.length].min
|
||||
for pkmn in team
|
||||
return false if !isPokemonValid?(pkmn)
|
||||
end
|
||||
for rule in @teamRules
|
||||
return false if !rule.isValid?(team)
|
||||
end
|
||||
if @subsetRules.length > 0
|
||||
pbEachCombination(team, teamNumber) { |comb|
|
||||
isValid = true
|
||||
for rule in @subsetRules
|
||||
next if rule.isValid?(comb)
|
||||
isValid = false
|
||||
break
|
||||
end
|
||||
return true if isValid
|
||||
}
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
# Returns true if the team's length is greater or equal to the suggested number
|
||||
# and at least one subset of the team meets the requirements of any team rules
|
||||
# and subset rules. Not all Pokemon in the team have to be valid.
|
||||
def hasValidTeam?(team)
|
||||
return false if !team || team.length < self.minTeamLength
|
||||
teamNumber = [self.maxLength, team.length].min
|
||||
validPokemon = []
|
||||
for pkmn in team
|
||||
validPokemon.push(pkmn) if isPokemonValid?(pkmn)
|
||||
end
|
||||
return false if validPokemon.length < teamNumber
|
||||
if @teamRules.length > 0
|
||||
pbEachCombination(team, teamNumber) { |comb| return true if isValid?(comb) }
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
# Returns true if the team's length meets the subset length range requirements
|
||||
# and the team meets the requirements of any team rules and subset rules. Each
|
||||
# Pokemon in the team must be valid.
|
||||
def isValid?(team, error = nil)
|
||||
if team.length < self.minLength
|
||||
error.push(_INTL("Choose a Pokémon.")) if error && self.minLength == 1
|
||||
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
|
||||
return false
|
||||
end
|
||||
for pkmn in team
|
||||
next if isPokemonValid?(pkmn)
|
||||
if pkmn
|
||||
error.push(_INTL("This team is not allowed.", pkmn.name)) if error
|
||||
else
|
||||
error.push(_INTL("{1} is not allowed.", pkmn.name)) if error
|
||||
end
|
||||
return false
|
||||
end
|
||||
for rule in @teamRules
|
||||
next if rule.isValid?(team)
|
||||
error.push(rule.errorMessage) if error
|
||||
return false
|
||||
end
|
||||
for rule in @subsetRules
|
||||
next if rule.isValid?(team)
|
||||
error.push(rule.errorMessage) if error
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class StandardRules < PokemonRuleSet
|
||||
attr_reader :number
|
||||
|
||||
def initialize(number, level = nil)
|
||||
super(number)
|
||||
addPokemonRule(StandardRestriction.new)
|
||||
addPokemonRule(SpeciesClause.new)
|
||||
addPokemonRule(ItemClause.new)
|
||||
addPokemonRule(MaximumLevelRestriction.new(level)) if level
|
||||
end
|
||||
end
|
||||
|
||||
###########################################
|
||||
# Generation IV Cups
|
||||
###########################################
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class StandardCup < StandardRules
|
||||
def initialize
|
||||
super(3, 50)
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("Standard Cup")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class DoubleCup < StandardRules
|
||||
def initialize
|
||||
super(4, 50)
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("Double Cup")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class FancyCup < PokemonRuleSet
|
||||
def initialize
|
||||
super(3)
|
||||
addPokemonRule(StandardRestriction.new)
|
||||
addPokemonRule(MaximumLevelRestriction.new(30))
|
||||
addSubsetRule(TotalLevelRestriction.new(80))
|
||||
addPokemonRule(HeightRestriction.new(2))
|
||||
addPokemonRule(WeightRestriction.new(20))
|
||||
addPokemonRule(BabyRestriction.new)
|
||||
addPokemonRule(SpeciesClause.new)
|
||||
addPokemonRule(ItemClause.new)
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("Fancy Cup")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class LittleCup < PokemonRuleSet
|
||||
def initialize
|
||||
super(3)
|
||||
addPokemonRule(StandardRestriction.new)
|
||||
addPokemonRule(MaximumLevelRestriction.new(5))
|
||||
addPokemonRule(BabyRestriction.new)
|
||||
addPokemonRule(SpeciesClause.new)
|
||||
addPokemonRule(ItemClause.new)
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("Little Cup")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class LightCup < PokemonRuleSet
|
||||
def initialize
|
||||
super(3)
|
||||
addPokemonRule(StandardRestriction.new)
|
||||
addPokemonRule(MaximumLevelRestriction.new(50))
|
||||
addPokemonRule(WeightRestriction.new(99))
|
||||
addPokemonRule(BabyRestriction.new)
|
||||
addPokemonRule(SpeciesClause.new)
|
||||
addPokemonRule(ItemClause.new)
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("Light Cup")
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,393 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class StandardRestriction
|
||||
def isValid?(pkmn)
|
||||
return false if !pkmn || pkmn.egg?
|
||||
# Species with disadvantageous abilities are not banned
|
||||
pkmn.species_data.abilities.each do |a|
|
||||
return true if [:TRUANT, :SLOWSTART].include?(a)
|
||||
end
|
||||
# Certain named species are not banned
|
||||
return true if [:DRAGONITE, :SALAMENCE, :TYRANITAR].include?(pkmn.species)
|
||||
# Certain named species are banned
|
||||
return false if [:WYNAUT, :WOBBUFFET].include?(pkmn.species)
|
||||
# Species with total base stat 600 or more are banned
|
||||
bst = 0
|
||||
pkmn.baseStats.each_value { |s| bst += s }
|
||||
return false if bst >= 600
|
||||
# Is valid
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class HeightRestriction
|
||||
def initialize(maxHeightInMeters)
|
||||
@level = maxHeightInMeters
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
height = (pkmn.is_a?(Pokemon)) ? pkmn.height : GameData::Species.get(pkmn).height
|
||||
return height <= (@level * 10).round
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class WeightRestriction
|
||||
def initialize(maxWeightInKg)
|
||||
@level = maxWeightInKg
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
weight = (pkmn.is_a?(Pokemon)) ? pkmn.weight : GameData::Species.get(pkmn).weight
|
||||
return weight <= (@level * 10).round
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Unused
|
||||
#===============================================================================
|
||||
class NegativeExtendedGameClause
|
||||
def isValid?(pkmn)
|
||||
return false if pkmn.isSpecies?(:ARCEUS)
|
||||
return false if pkmn.hasItem?(:MICLEBERRY)
|
||||
return false if pkmn.hasItem?(:CUSTAPBERRY)
|
||||
return false if pkmn.hasItem?(:JABOCABERRY)
|
||||
return false if pkmn.hasItem?(:ROWAPBERRY)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
$babySpeciesData = {}
|
||||
|
||||
class BabyRestriction
|
||||
def isValid?(pkmn)
|
||||
if !$babySpeciesData[pkmn.species]
|
||||
$babySpeciesData[pkmn.species] = pkmn.species_data.get_baby_species
|
||||
end
|
||||
return pkmn.species == $babySpeciesData[pkmn.species]
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
$canEvolve = {}
|
||||
|
||||
class UnevolvedFormRestriction
|
||||
def isValid?(pkmn)
|
||||
if !$babySpeciesData[pkmn.species]
|
||||
$babySpeciesData[pkmn.species] = pkmn.species_data.get_baby_species
|
||||
end
|
||||
return false if pkmn.species != $babySpeciesData[pkmn.species]
|
||||
if $canEvolve[pkmn.species].nil?
|
||||
$canEvolve[pkmn.species] = (pkmn.species_data.get_evolutions(true).length > 0)
|
||||
end
|
||||
return $canEvolve[pkmn.species]
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
module NicknameChecker
|
||||
@@names = {}
|
||||
|
||||
def getName(species)
|
||||
n = @@names[species]
|
||||
return n if n
|
||||
n = GameData::Species.get(species).name
|
||||
@@names[species] = n.upcase
|
||||
return n
|
||||
end
|
||||
|
||||
def check(name, species)
|
||||
name = name.upcase
|
||||
return true if name == getName(species)
|
||||
return false if @@names.values.include?(name)
|
||||
GameData::Species.each do |species_data|
|
||||
next if species_data.species == species || species_data.form != 0
|
||||
return false if getName(species_data.id) == name
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# No two Pokemon can have the same nickname.
|
||||
# No nickname can be the same as the (real) name of another Pokemon character.
|
||||
#===============================================================================
|
||||
class NicknameClause
|
||||
def isValid?(team)
|
||||
for i in 0...team.length - 1
|
||||
for j in i + 1...team.length
|
||||
return false if team[i].name == team[j].name
|
||||
return false if !NicknameChecker.check(team[i].name, team[i].species)
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def errorMessage
|
||||
return _INTL("No identical nicknames.")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class NonEggRestriction
|
||||
def isValid?(pkmn)
|
||||
return pkmn && !pkmn.egg?
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class AblePokemonRestriction
|
||||
def isValid?(pkmn)
|
||||
return pkmn && pkmn.able?
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SpeciesRestriction
|
||||
def initialize(*specieslist)
|
||||
@specieslist = specieslist.clone
|
||||
end
|
||||
|
||||
def isSpecies?(species, specieslist)
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
return isSpecies?(pkmn.species, @specieslist)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BannedSpeciesRestriction
|
||||
def initialize(*specieslist)
|
||||
@specieslist = specieslist.clone
|
||||
end
|
||||
|
||||
def isSpecies?(species, specieslist)
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
return !isSpecies?(pkmn.species, @specieslist)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class RestrictedSpeciesRestriction
|
||||
def initialize(maxValue, *specieslist)
|
||||
@specieslist = specieslist.clone
|
||||
@maxValue = maxValue
|
||||
end
|
||||
|
||||
def isSpecies?(species, specieslist)
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(team)
|
||||
count = 0
|
||||
team.each do |pkmn|
|
||||
count += 1 if pkmn && isSpecies?(pkmn.species, @specieslist)
|
||||
end
|
||||
return count <= @maxValue
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class RestrictedSpeciesTeamRestriction < RestrictedSpeciesRestriction
|
||||
def initialize(*specieslist)
|
||||
super(4, *specieslist)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class RestrictedSpeciesSubsetRestriction < RestrictedSpeciesRestriction
|
||||
def initialize(*specieslist)
|
||||
super(2, *specieslist)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SameSpeciesClause
|
||||
def isValid?(team)
|
||||
species = []
|
||||
team.each do |pkmn|
|
||||
species.push(pkmn.species) if pkmn && !species.include?(pkmn.species)
|
||||
end
|
||||
return species.length == 1
|
||||
end
|
||||
|
||||
def errorMessage
|
||||
return _INTL("Pokémon must be the same species.")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SpeciesClause
|
||||
def isValid?(team)
|
||||
species = []
|
||||
team.each do |pkmn|
|
||||
next if !pkmn
|
||||
return false if species.include?(pkmn.species)
|
||||
species.push(pkmn.species)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def errorMessage
|
||||
return _INTL("Pokémon can't be the same species.")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class MinimumLevelRestriction
|
||||
attr_reader :level
|
||||
|
||||
def initialize(minLevel)
|
||||
@level = minLevel
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
return pkmn.level >= @level
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class MaximumLevelRestriction
|
||||
attr_reader :level
|
||||
|
||||
def initialize(maxLevel)
|
||||
@level = maxLevel
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
return pkmn.level <= @level
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class TotalLevelRestriction
|
||||
attr_reader :level
|
||||
|
||||
def initialize(level)
|
||||
@level = level
|
||||
end
|
||||
|
||||
def isValid?(team)
|
||||
totalLevel = 0
|
||||
team.each { |pkmn| totalLevel += pkmn.level if pkmn }
|
||||
return totalLevel <= @level
|
||||
end
|
||||
|
||||
def errorMessage
|
||||
return _INTL("The combined levels exceed {1}.", @level)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BannedItemRestriction
|
||||
def initialize(*itemlist)
|
||||
@itemlist = itemlist.clone
|
||||
end
|
||||
|
||||
def isSpecies?(item,itemlist)
|
||||
return itemlist.include?(item)
|
||||
end
|
||||
|
||||
def isValid?(pkmn)
|
||||
return !pkmn.item_id || !isSpecies?(pkmn.item_id, @itemlist)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class ItemsDisallowedClause
|
||||
def isValid?(pkmn)
|
||||
return !pkmn.hasItem?
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SoulDewClause
|
||||
def isValid?(pkmn)
|
||||
return !pkmn.hasItem?(:SOULDEW)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class ItemClause
|
||||
def isValid?(team)
|
||||
items = []
|
||||
team.each do |pkmn|
|
||||
next if !pkmn || !pkmn.hasItem?
|
||||
return false if items.include?(pkmn.item_id)
|
||||
items.push(pkmn.item_id)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def errorMessage
|
||||
return _INTL("No identical hold items.")
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class LittleCupRestriction
|
||||
def isValid?(pkmn)
|
||||
return false if pkmn.hasItem?(:BERRYJUICE)
|
||||
return false if pkmn.hasItem?(:DEEPSEATOOTH)
|
||||
return false if pkmn.hasMove?(:SONICBOOM)
|
||||
return false if pkmn.hasMove?(:DRAGONRAGE)
|
||||
return false if pkmn.isSpecies?(:SCYTHER)
|
||||
return false if pkmn.isSpecies?(:SNEASEL)
|
||||
return false if pkmn.isSpecies?(:MEDITITE)
|
||||
return false if pkmn.isSpecies?(:YANMA)
|
||||
return false if pkmn.isSpecies?(:TANGELA)
|
||||
return false if pkmn.isSpecies?(:MURKROW)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,227 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class LevelAdjustment
|
||||
BothTeams = 0
|
||||
EnemyTeam = 1
|
||||
MyTeam = 2
|
||||
BothTeamsDifferent = 3
|
||||
|
||||
def initialize(adjustment)
|
||||
@adjustment = adjustment
|
||||
end
|
||||
|
||||
def type
|
||||
@adjustment
|
||||
end
|
||||
|
||||
def self.getNullAdjustment(thisTeam, _otherTeam)
|
||||
ret = []
|
||||
thisTeam.each_with_index { |pkmn, i| ret[i] = pkmn.level }
|
||||
return ret
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, otherTeam)
|
||||
return self.getNullAdjustment(thisTeam, otherTeam)
|
||||
end
|
||||
|
||||
def getOldExp(team1, _team2)
|
||||
ret = []
|
||||
team1.each_with_index { |pkmn, i| ret[i] = pkmn.exp }
|
||||
return ret
|
||||
end
|
||||
|
||||
def unadjustLevels(team1, team2, adjustments)
|
||||
team1.each_with_index do |pkmn, i|
|
||||
next if !adjustments[0][i] || pkmn.exp == adjustments[0][i]
|
||||
pkmn.exp = adjustments[0][i]
|
||||
pkmn.calc_stats
|
||||
end
|
||||
team2.each_with_index do |pkmn, i|
|
||||
next if !adjustments[1][i] || pkmn.exp == adjustments[1][i]
|
||||
pkmn.exp = adjustments[1][i]
|
||||
pkmn.calc_stats
|
||||
end
|
||||
end
|
||||
|
||||
def adjustLevels(team1, team2)
|
||||
adj1 = nil
|
||||
adj2 = nil
|
||||
ret = [getOldExp(team1, team2), getOldExp(team2, team1)]
|
||||
if @adjustment == BothTeams || @adjustment == MyTeam
|
||||
adj1 = getAdjustment(team1, team2)
|
||||
elsif @adjustment == BothTeamsDifferent
|
||||
adj1 = getMyAdjustment(team1, team2)
|
||||
end
|
||||
if @adjustment == BothTeams || @adjustment == EnemyTeam
|
||||
adj2 = getAdjustment(team2, team1)
|
||||
elsif @adjustment == BothTeamsDifferent
|
||||
adj2 = getTheirAdjustment(team2, team1)
|
||||
end
|
||||
if adj1
|
||||
team1.each_with_index do |pkmn, i|
|
||||
next if pkmn.level == adj1[i]
|
||||
pkmn.level = adj1[i]
|
||||
pkmn.calc_stats
|
||||
end
|
||||
end
|
||||
if adj2
|
||||
team2.each_with_index do |pkmn, i|
|
||||
next if pkmn.level == adj2[i]
|
||||
pkmn.level = adj2[i]
|
||||
pkmn.calc_stats
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class FixedLevelAdjustment < LevelAdjustment
|
||||
def initialize(level)
|
||||
super(LevelAdjustment::BothTeams)
|
||||
@level = level.clamp(1, GameData::GrowthRate.max_level)
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, _otherTeam)
|
||||
ret = []
|
||||
thisTeam.each_with_index { |pkmn, i| ret[i] = @level }
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class TotalLevelAdjustment < LevelAdjustment
|
||||
def initialize(minLevel, maxLevel, totalLevel)
|
||||
super(LevelAdjustment::EnemyTeam)
|
||||
@minLevel = minLevel.clamp(1, GameData::GrowthRate.max_level)
|
||||
@maxLevel = maxLevel.clamp(1, GameData::GrowthRate.max_level)
|
||||
@totalLevel=totalLevel
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, _otherTeam)
|
||||
ret = []
|
||||
total = 0
|
||||
thisTeam.each_with_index do |pkmn, i|
|
||||
ret[i] = @minLevel
|
||||
total += @minLevel
|
||||
end
|
||||
loop do
|
||||
work = false
|
||||
thisTeam.each_with_index do |pkmn, i|
|
||||
next if ret[i] >= @maxLevel || total >= @totalLevel
|
||||
ret[i] += 1
|
||||
total += 1
|
||||
work = true
|
||||
end
|
||||
break if !work
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class CombinedLevelAdjustment < LevelAdjustment
|
||||
def initialize(my, their)
|
||||
super(LevelAdjustment::BothTeamsDifferent)
|
||||
@my = my
|
||||
@their = their
|
||||
end
|
||||
|
||||
def getMyAdjustment(myTeam,theirTeam)
|
||||
return @my.getAdjustment(myTeam, theirTeam) if @my
|
||||
return LevelAdjustment.getNullAdjustment(myTeam, theirTeam)
|
||||
end
|
||||
|
||||
def getTheirAdjustment(theirTeam,myTeam)
|
||||
return @their.getAdjustment(theirTeam, myTeam) if @their
|
||||
return LevelAdjustment.getNullAdjustment(theirTeam, myTeam)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SinglePlayerCappedLevelAdjustment < CombinedLevelAdjustment
|
||||
def initialize(level)
|
||||
super(CappedLevelAdjustment.new(level), FixedLevelAdjustment.new(level))
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class CappedLevelAdjustment < LevelAdjustment
|
||||
def initialize(level)
|
||||
super(LevelAdjustment::BothTeams)
|
||||
@level = level.clamp(1, GameData::GrowthRate.max_level)
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, _otherTeam)
|
||||
ret = []
|
||||
thisTeam.each_with_index { |pkmn, i| ret[i] = [pkmn.level, @level].min }
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Unused
|
||||
#===============================================================================
|
||||
class LevelBalanceAdjustment < LevelAdjustment
|
||||
def initialize(minLevel)
|
||||
super(LevelAdjustment::BothTeams)
|
||||
@minLevel = minLevel
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, _otherTeam)
|
||||
ret = []
|
||||
thisTeam.each_with_index do |pkmn, i|
|
||||
ret[i] = (113 - (pbBaseStatTotal(pkmn.species) * 0.072)).round
|
||||
end
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class EnemyLevelAdjustment < LevelAdjustment
|
||||
def initialize(level)
|
||||
super(LevelAdjustment::EnemyTeam)
|
||||
@level = level.clamp(1, GameData::GrowthRate.max_level)
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, _otherTeam)
|
||||
ret = []
|
||||
thisTeam.each_with_index { |pkmn, i| ret[i] = @level }
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class OpenLevelAdjustment < LevelAdjustment
|
||||
def initialize(minLevel = 1)
|
||||
super(LevelAdjustment::EnemyTeam)
|
||||
@minLevel = minLevel
|
||||
end
|
||||
|
||||
def getAdjustment(thisTeam, otherTeam)
|
||||
maxLevel = 1
|
||||
otherTeam.each do |pkmn|
|
||||
level = pkmn.level
|
||||
maxLevel = level if maxLevel < level
|
||||
end
|
||||
maxLevel = @minLevel if maxLevel < @minLevel
|
||||
ret = []
|
||||
thisTeam.each_with_index { |pkmn, i| ret[i] = maxLevel }
|
||||
return ret
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,97 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class BattleRule
|
||||
def setRule(battle); end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class DoubleBattle < BattleRule
|
||||
def setRule(battle); battle.setBattleMode("double"); end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SingleBattle < BattleRule
|
||||
def setRule(battle); battle.setBattleMode("single"); end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SoulDewBattleClause < BattleRule
|
||||
def setRule(battle); battle.rules["souldewclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SleepClause < BattleRule
|
||||
def setRule(battle); battle.rules["sleepclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class FreezeClause < BattleRule
|
||||
def setRule(battle); battle.rules["freezeclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class EvasionClause < BattleRule
|
||||
def setRule(battle); battle.rules["evasionclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class OHKOClause < BattleRule
|
||||
def setRule(battle); battle.rules["ohkoclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PerishSongClause < BattleRule
|
||||
def setRule(battle); battle.rules["perishsong"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SelfKOClause < BattleRule
|
||||
def setRule(battle); battle.rules["selfkoclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SelfdestructClause < BattleRule
|
||||
def setRule(battle); battle.rules["selfdestructclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SonicBoomClause < BattleRule
|
||||
def setRule(battle); battle.rules["sonicboomclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class ModifiedSleepClause < BattleRule
|
||||
def setRule(battle); battle.rules["modifiedsleepclause"] = true; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SkillSwapClause < BattleRule
|
||||
def setRule(battle); battle.rules["skillswapclause"] = true; end
|
||||
end
|
||||
Reference in New Issue
Block a user