Renamed class PlayerTrainer to class Player, implemented class Player#Pokedex

This commit is contained in:
Maruno17
2021-04-11 20:45:44 +01:00
parent dcd0fe8b21
commit e49ddde198
32 changed files with 637 additions and 475 deletions

View File

@@ -186,126 +186,3 @@ class NPCTrainer < Trainer
@lose_text = nil
end
end
#===============================================================================
# Trainer class for the player
#===============================================================================
class PlayerTrainer < Trainer
attr_writer :character_ID
attr_accessor :outfit
attr_accessor :badges
attr_reader :money
attr_accessor :seen
attr_accessor :owned
attr_accessor :seen_forms
attr_accessor :last_seen_forms
attr_accessor :owned_shadow
attr_accessor :pokedex # Whether the Pokédex was obtained
attr_accessor :pokegear # Whether the Pokégear was obtained
attr_accessor :mystery_gift_unlocked # Whether MG can be used from load screen
attr_accessor :mystery_gifts # Variable that stores downloaded MG data
def character_ID
@character_ID = $PokemonGlobal.playerID || 0 if !@character_ID
return @character_ID
end
def money=(value)
@money = value.clamp(0, Settings::MAX_MONEY)
end
def badge_count
ret = 0
@badges.each { |b| ret += 1 if b }
return ret
end
#=============================================================================
def seen?(species)
species_data = GameData::Species.try_get(species)
return (species_data) ? @seen[species_data.species] : false
end
alias hasSeen? seen?
def owned?(species)
species_data = GameData::Species.try_get(species)
return (species_data) ? @owned[species_data.species] : false
end
alias hasOwned? owned?
def set_seen(species)
species_data = GameData::Species.try_get(species)
@seen[species_data.species] = true if species_data
end
def set_owned(species)
species_data = GameData::Species.try_get(species)
@owned[species_data.species] = true if species_data
end
def seen_count(region = -1)
ret = 0
if region == -1
GameData::Species.each { |s| ret += 1 if s.form == 0 && @seen[s.species] }
else
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && @seen[s] }
end
return ret
end
def seen_any?(region = -1)
if region == -1
GameData::Species.each { |s| return true if s.form == 0 && @seen[s.species] }
else
pbAllRegionalSpecies(region).each { |s| return true if s && @seen[s] }
end
return false
end
def owned_count(region = -1)
ret = 0
if region == -1
GameData::Species.each { |s| ret += 1 if s.form == 0 && @owned[s.species] }
else
pbAllRegionalSpecies(region).each { |s| ret += 1 if s && @owned[s] }
end
return ret
end
def seen_forms_count(species)
species_data = GameData::Species.try_get(species)
return 0 if !species_data
species = species_data.species
ret = 0
@seen_forms[species] = [[], []] if !@seen_forms[species]
array = @seen_forms[species]
for i in 0...[array[0].length, array[1].length].max
ret += 1 if array[0][i] || array[1][i]
end
return ret
end
def clear_pokedex
@seen = {}
@owned = {}
@seen_forms = {}
@last_seen_forms = {}
@owned_shadow = {}
end
#=============================================================================
def initialize(name, trainer_type)
super
@character_ID = nil
@outfit = 0
@badges = [false] * 8
@money = Settings::INITIAL_MONEY
clear_pokedex
@pokegear = false
@pokedex = false
@mystery_gift_unlocked = false
@mystery_gifts = []
end
end