mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-12 07:35:00 +00:00
Created and implemented GameData::Species
This commit is contained in:
@@ -1,26 +1,22 @@
|
||||
def pbBaseStatTotal(species)
|
||||
baseStats = pbGetSpeciesData(species,0,SpeciesData::BASE_STATS)
|
||||
baseStats = GameData::Species.get(species).base_stats
|
||||
ret = 0
|
||||
baseStats.each { |s| ret += s }
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbBalancedLevelFromBST(species)
|
||||
return (113-(pbBaseStatTotal(species)*0.072)).round
|
||||
return (113 - (pbBaseStatTotal(species) * 0.072)).round
|
||||
end
|
||||
|
||||
def pbTooTall?(pkmn,maxHeightInMeters)
|
||||
species = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn
|
||||
form = (pkmn.is_a?(Pokemon)) ? pkmn.form : 0
|
||||
height = pbGetSpeciesData(species,form,SpeciesData::HEIGHT)
|
||||
return height>(maxHeightInMeters*10).round
|
||||
def pbTooTall?(pkmn, maxHeightInMeters)
|
||||
height = (pkmn.is_a?(Pokemon)) ? pkmn.height : GameData::Species.get(pkmn).height
|
||||
return height > (maxHeightInMeters * 10).round
|
||||
end
|
||||
|
||||
def pbTooHeavy?(pkmn,maxWeightInKg)
|
||||
species = (pkmn.is_a?(Pokemon)) ? pkmn.species : pkmn
|
||||
form = (pkmn.is_a?(Pokemon)) ? pkmn.form : 0
|
||||
weight = pbGetSpeciesData(species,form,SpeciesData::WEIGHT)
|
||||
return weight>(maxWeightInKg*10).round
|
||||
def pbTooHeavy?(pkmn, maxWeightInKg)
|
||||
weight = (pkmn.is_a?(Pokemon)) ? pkmn.weight : GameData::Species.get(pkmn).weight
|
||||
return weight > (maxWeightInKg * 10).round
|
||||
end
|
||||
|
||||
|
||||
@@ -287,10 +283,7 @@ class SpeciesRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBSpecies,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
@@ -310,10 +303,7 @@ class BannedSpeciesRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBSpecies,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
@@ -328,17 +318,17 @@ end
|
||||
|
||||
|
||||
class BannedItemRestriction
|
||||
def initialize(*specieslist)
|
||||
@specieslist=specieslist.clone
|
||||
def initialize(*itemlist)
|
||||
@itemlist=itemlist.clone
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
return specieslist.any? { |s| species == s }
|
||||
def isSpecies?(item,itemlist)
|
||||
return itemlist.include?(item)
|
||||
end
|
||||
|
||||
def isValid?(pokemon)
|
||||
count=0
|
||||
if pokemon.item && isSpecies?(pokemon.item,@specieslist)
|
||||
if pokemon.item && isSpecies?(pokemon.item,@itemlist)
|
||||
count+=1
|
||||
end
|
||||
return count==0
|
||||
@@ -354,10 +344,7 @@ class RestrictedSpeciesRestriction
|
||||
end
|
||||
|
||||
def isSpecies?(species,specieslist)
|
||||
for s in specieslist
|
||||
return true if isConst?(species,PBSpecies,s)
|
||||
end
|
||||
return false
|
||||
return specieslist.include?(species)
|
||||
end
|
||||
|
||||
def isValid?(team)
|
||||
@@ -390,29 +377,22 @@ end
|
||||
|
||||
|
||||
class StandardRestriction
|
||||
def isValid?(pokemon)
|
||||
return false if !pokemon || pokemon.egg?
|
||||
def isValid?(pkmn)
|
||||
return false if !pkmn || pkmn.egg?
|
||||
# Species with disadvantageous abilities are not banned
|
||||
abilities = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::ABILITIES)
|
||||
abilities = [abilities] if !abilities.is_a?(Array)
|
||||
abilities.each do |a|
|
||||
return true if [:TRUANT, :SLOWSTART].include?(a)
|
||||
pkmn.species_data.abilities.each do |a|
|
||||
return true if [:TRUANT, :SLOWSTART].include?(a[0])
|
||||
end
|
||||
# Certain named species are not banned
|
||||
speciesWhitelist = [:DRAGONITE,:SALAMENCE,:TYRANITAR]
|
||||
for i in speciesWhitelist
|
||||
return true if pokemon.isSpecies?(i)
|
||||
end
|
||||
speciesWhitelist = [:DRAGONITE, :SALAMENCE, :TYRANITAR]
|
||||
return true if speciesWhitelist.include?(pkmn.species)
|
||||
# Certain named species are banned
|
||||
speciesBlacklist = [:WYNAUT,:WOBBUFFET]
|
||||
for i in speciesBlacklist
|
||||
return false if pokemon.isSpecies?(i)
|
||||
end
|
||||
speciesBlacklist = [:WYNAUT, :WOBBUFFET]
|
||||
return false if speciesBlacklist.include?(pkmn.species)
|
||||
# Species with total base stat 600 or more are banned
|
||||
baseStats = pbGetSpeciesData(pokemon.species,pokemon.form,SpeciesData::BASE_STATS)
|
||||
bst = 0
|
||||
baseStats.each { |s| bst += s }
|
||||
return false if bst>=600
|
||||
pkmn.baseStats.each { |s| bst += s }
|
||||
return false if bst >= 600
|
||||
# Is valid
|
||||
return true
|
||||
end
|
||||
@@ -632,28 +612,23 @@ end
|
||||
|
||||
|
||||
module NicknameChecker
|
||||
@@names={}
|
||||
@@namesMaxValue=0
|
||||
@@names = {}
|
||||
|
||||
def getName(species)
|
||||
n=@@names[species]
|
||||
n = @@names[species]
|
||||
return n if n
|
||||
n=PBSpecies.getName(species)
|
||||
@@names[species]=n.upcase
|
||||
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)
|
||||
if @@names.values.include?(name)
|
||||
return false
|
||||
end
|
||||
for i in @@namesMaxValue..PBSpecies.maxValue
|
||||
if i!=species
|
||||
n=getName(i)
|
||||
return false if n==name
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user