def pbHasType?(type)
if type.is_a?(Symbol) || type.is_a?(String)
type = getConst(PBTypes,type)
end
return false if type==nil || type<0
ret = (self.type1==type || self.type2==type)
ret |= (@effects[PBEffects::Type3]==type) if @effects[PBEffects::Type3]>=0
return ret
end
def pbHasPrimaryType?(type)
ret=false
if type.is_a?(Symbol) || type.is_a?(String)
ret=isConst?(self.type1,PBTypes,type.to_sym)
if @effects[PBEffects::Type3]>=0
ret=isConst?(@effects[PBEffects::Type3],PBTypes,type.to_sym)
end
end
return ret
end
Since the def for it is this one:
Code:def pbHasType?(type) if type.is_a?(Symbol) || type.is_a?(String) type = getConst(PBTypes,type) end return false if type==nil || type<0 ret = (self.type1==type || self.type2==type) ret |= (@effects[PBEffects::Type3]==type) if @effects[PBEffects::Type3]>=0 return ret end
We have other code to get the primary type:
Code:def pbHasPrimaryType?(type) ret=false if type.is_a?(Symbol) || type.is_a?(String) ret=isConst?(self.type1,PBTypes,type.to_sym) if @effects[PBEffects::Type3]>=0 ret=isConst?(@effects[PBEffects::Type3],PBTypes,type.to_sym) end end return ret end
################################################################################
# Types
################################################################################
# Returns whether this Pokémon has the specified type.
def hasType?(type)
if type.is_a?(String) || type.is_a?(Symbol)
return isConst?(self.type1,PBTypes,type) || isConst?(self.type2,PBTypes,type)
else
return self.type1==type || self.type2==type
end
end
# Returns this Pokémon's first type.
def type1
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,self.fSpecies,8)
ret=dexdata.fgetb
dexdata.close
return ret
end
# Returns this Pokémon's second type.
def type2
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,self.fSpecies,9)
ret=dexdata.fgetb
dexdata.close
return ret
end
We have other code to get the primary type:
Code:def pbHasPrimaryType?(type) ret=false if type.is_a?(Symbol) || type.is_a?(String) ret=isConst?(self.type1,PBTypes,type.to_sym) if @effects[PBEffects::Type3]>=0 ret=isConst?(@effects[PBEffects::Type3],PBTypes,type.to_sym) end end return ret end
pbSet(VAR_ID, $Trainer.party[0].type1)
if onactive && @battle.pbIsOpposing?(self.index) && self.species==PBSpecies::STARTERSPECIES
if opponent.is_a?(Array) # Double battle
if self.index == 1 && opponent[0].trainertype == PBTrainers::RIVALNAME
self.type1 = pbGet(VAR_ID)
elsif self.index == 3 && opponent[1].trainertype == PBTrainers::RIVALNAME
self.type1 = pbGet(VAR_ID)
end
elsif opponent.is_a?(PokeBattle_Trainer) && opponent.trainertype == PBTrainers::RIVALNAME # Single battle
self.type1 = pbGet(VAR_ID)
end
end
def pbHasType1?(type)
for i in $Trainer.party
return true if i.type1 == type
end
return false
end
Well, you can just loop through each Pokemon in the player's party and see if any of their type1's match the type you're checking:
Code:def pbHasType1?(type) for i in $Trainer.party return true if i.type1 == type end return false end
# Returns true if there is a Pokémon with the type1 in the player's party.
def pbHasType1?(type)
if type.is_a?(String) || type.is_a?(Symbol)
type = getID(PBTypes,type)
end
for i in $Trainer.party
return true if i.type1 == type
end
return false
end
# Returns true if there is a Pokémon with the type2 in the player's party.
def pbHasType2?(type)
if type.is_a?(String) || type.is_a?(Symbol)
type = getID(PBTypes,type)
end
for i in $Trainer.party
return true if i.type2 == type
end
return false
end