class PokeBattle_Trainer
##########
# Trainer's initial money
INITIALMONEY=2000
MAXMONEY=999999
##########
attr_reader(:name)
attr_accessor(:id)
attr_accessor(:trainertype)
attr_accessor(:badges)
attr_accessor(:seen)
attr_accessor(:money)
attr_accessor(:owned)
attr_accessor(:party)
attr_accessor(:pokedex) # Whether the Pokédex was obtained
attr_accessor(:pokegear)
def money=(value)
@money=[[value,MAXMONEY].min,0].max
end
def trainerTypeName # Name of this trainer type (localized)
return PBTrainers.getName(@trainertype) rescue _INTL("PKMN Trainer")
end
def moneyEarned # Money won when trainer is defeated
ret=0
pbRgssOpen("Data/trainernames.dat","rb"){|f|
trainernames=Marshal.load(f)
return 30 if !trainernames[@trainertype]
ret=trainernames[@trainertype][3]
}
return ret
end
def gender
ret=2 # 2 = gender unknown
pbRgssOpen("Data/trainernames.dat","rb"){|f|
trainernames=Marshal.load(f)
if !trainernames[trainertype]
ret=2
else
ret=trainernames[trainertype][7]
ret=2 if !ret
end
}
return ret
end
def pokemonParty
return @party.find_all {|item| item && !item.egg? }
end
def pokemonCount
ret=0
for i in
[email protected]
ret+=1 if @party
&& !@party.egg?
end
return ret
end
def ablePokemonCount
ret=0
for i in [email protected]
ret+=1 if @party && !@party.egg? && @party.hp>0
end
return ret
end
def fullname
return _INTL("{1} {2}",self.trainerTypeName,@name)
end
def numbadges # Number of badges
ret=0
for i in [email protected]
ret+=1 if @badges
end
return ret
end
def publicID(id) # Portion of the ID which is visible on the Trainer Card
return id&0xFFFF
end
def pokedexSeen # Number of Pokémon seen
ret=0
for i in 0..PBSpecies.maxValue
ret+=1 if @seen
end
return ret
end
def pokedexOwned # Number of Pokémon owned
ret=0
for i in 0..PBSpecies.maxValue
ret+=1 if @owned
end
return ret
end
def setForeignID(other)
@id=other.getForeignID
end
def getForeignID # Random ID other than this Trainer's ID
fid=0
loop do
fid=rand(256)
fid|=rand(256)<<8
fid|=rand(256)<<16
fid|=rand(256)<<24
break if fid!=@id
end
return fid
end
def initialize(name,trainertype)
@name=name
@trainertype=trainertype
@id=rand(256)
@id|=rand(256)<<8
@id|=rand(256)<<16
@id|=rand(256)<<24
@seen=[]
@owned=[]
@badges=[]
@pokedex=false
@pokegear=false
for i in 0..PBSpecies.maxValue
@seen=false
@owned=false
end
for i in 0..7
@badges=false
end
@money=INITIALMONEY
@party=[]
end
end