mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 06:04:59 +00:00
Remove Scripts folder to convert to submodule
This commit is contained in:
@@ -1,242 +0,0 @@
|
||||
#===============================================================================
|
||||
# Basic trainer class (use a child class rather than this one)
|
||||
#===============================================================================
|
||||
class Trainer
|
||||
attr_accessor :trainer_type
|
||||
attr_accessor :name
|
||||
attr_accessor :id
|
||||
attr_accessor :language
|
||||
attr_accessor :party
|
||||
attr_accessor :quests
|
||||
attr_accessor :sprite_override
|
||||
attr_accessor :custom_appearance
|
||||
attr_accessor :lowest_difficulty
|
||||
attr_accessor :selected_difficulty
|
||||
attr_accessor :game_mode
|
||||
|
||||
def inspect
|
||||
str = super.chop
|
||||
party_str = @party.map { |p| p.species_data.species }.inspect
|
||||
str << format(' %s @party=%s>', self.full_name, party_str)
|
||||
return str
|
||||
end
|
||||
|
||||
def full_name
|
||||
return _INTL("{1} {2}", trainer_type_name, @name)
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
# Portion of the ID which is visible on the Trainer Card
|
||||
def public_ID(id = nil)
|
||||
return id ? id & 0xFFFF : @id & 0xFFFF
|
||||
end
|
||||
|
||||
# Other portion of the ID
|
||||
def secret_ID(id = nil)
|
||||
return id ? id >> 16 : @id >> 16
|
||||
end
|
||||
|
||||
# Random ID other than this Trainer's ID
|
||||
def make_foreign_ID
|
||||
loop do
|
||||
ret = rand(2 ** 16) | rand(2 ** 16) << 16
|
||||
return ret if ret != @id
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def trainer_type_name
|
||||
return GameData::TrainerType.get(@trainer_type).name;
|
||||
end
|
||||
|
||||
def base_money
|
||||
return GameData::TrainerType.get(@trainer_type).base_money;
|
||||
end
|
||||
|
||||
def gender
|
||||
return GameData::TrainerType.get(@trainer_type).gender;
|
||||
end
|
||||
|
||||
def male?
|
||||
return GameData::TrainerType.get(@trainer_type).male?;
|
||||
end
|
||||
|
||||
def female?
|
||||
return GameData::TrainerType.get(@trainer_type).female?;
|
||||
end
|
||||
|
||||
def skill_level
|
||||
if $game_switches[SWITCH_GAME_DIFFICULTY_HARD]
|
||||
return 100
|
||||
end
|
||||
return GameData::TrainerType.get(@trainer_type).skill_level;
|
||||
end
|
||||
|
||||
def skill_code
|
||||
return GameData::TrainerType.get(@trainer_type).skill_code;
|
||||
end
|
||||
|
||||
def has_skill_code?(code)
|
||||
c = skill_code
|
||||
return c && c != "" && c[/#{code}/]
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def pokemon_party
|
||||
return @party.find_all { |p| p && !p.egg? }
|
||||
end
|
||||
|
||||
def able_party
|
||||
return @party.find_all { |p| p && !p.egg? && !p.fainted? }
|
||||
end
|
||||
|
||||
def party_count
|
||||
return @party.length
|
||||
end
|
||||
|
||||
def pokemon_count
|
||||
ret = 0
|
||||
@party.each { |p| ret += 1 if p && !p.egg? }
|
||||
return ret
|
||||
end
|
||||
|
||||
def able_pokemon_count
|
||||
ret = 0
|
||||
@party.each { |p| ret += 1 if p && !p.egg? && !p.fainted? }
|
||||
return ret
|
||||
end
|
||||
|
||||
def
|
||||
highest_level_pokemon_in_party
|
||||
max_level = 0
|
||||
for pokemon in @party
|
||||
if pokemon.level > max_level
|
||||
max_level = pokemon.level
|
||||
end
|
||||
end
|
||||
return max_level
|
||||
end
|
||||
|
||||
def party_full?
|
||||
return party_count >= Settings::MAX_PARTY_SIZE
|
||||
end
|
||||
|
||||
# Returns true if there are no usable Pokémon in the player's party.
|
||||
def all_fainted?
|
||||
return able_pokemon_count == 0
|
||||
end
|
||||
|
||||
def first_party
|
||||
return @party[0]
|
||||
end
|
||||
|
||||
def first_pokemon
|
||||
return pokemon_party[0]
|
||||
end
|
||||
|
||||
def first_able_pokemon
|
||||
return able_party[0]
|
||||
end
|
||||
|
||||
def last_party
|
||||
return (@party.length > 0) ? @party[@party.length - 1] : nil
|
||||
end
|
||||
|
||||
def last_pokemon
|
||||
p = pokemon_party
|
||||
return (p.length > 0) ? p[p.length - 1] : nil
|
||||
end
|
||||
|
||||
def last_able_pokemon
|
||||
p = able_party
|
||||
return (p.length > 0) ? p[p.length - 1] : nil
|
||||
end
|
||||
|
||||
def remove_pokemon_at_index(index)
|
||||
return false if index < 0 || index >= party_count
|
||||
have_able = false
|
||||
@party.each_with_index do |pkmn, i|
|
||||
have_able = true if i != index && pkmn.able?
|
||||
break if have_able
|
||||
end
|
||||
return false if !have_able
|
||||
@party.delete_at(index)
|
||||
return true
|
||||
end
|
||||
|
||||
# Checks whether the trainer would still have an unfainted Pokémon if the
|
||||
# Pokémon given by _index_ were removed from the party.
|
||||
def has_other_able_pokemon?(index)
|
||||
@party.each_with_index { |pkmn, i| return true if i != index && pkmn.able? }
|
||||
return false
|
||||
end
|
||||
|
||||
# Returns true if there is a Pokémon of the given species in the trainer's
|
||||
# party. You may also specify a particular form it should be.
|
||||
def has_species?(species, form = -1)
|
||||
return pokemon_party.any? { |p| p && p.isSpecies?(species) && (form < 0 || p.form == form) }
|
||||
end
|
||||
|
||||
def has_species_or_fusion?(species, form = -1)
|
||||
return pokemon_party.any? { |p| p && p.isSpecies?(species) || p.isFusionOf(species) }
|
||||
end
|
||||
|
||||
# Returns whether there is a fatefully met Pokémon of the given species in the
|
||||
# trainer's party.
|
||||
def has_fateful_species?(species)
|
||||
return pokemon_party.any? { |p| p && p.isSpecies?(species) && p.obtain_method == 4 }
|
||||
end
|
||||
|
||||
# Returns whether there is a Pokémon with the given type in the trainer's
|
||||
# party.
|
||||
def has_pokemon_of_type?(type)
|
||||
return false if !GameData::Type.exists?(type)
|
||||
type = GameData::Type.get(type).id
|
||||
return pokemon_party.any? { |p| p && p.hasType?(type) }
|
||||
end
|
||||
|
||||
# Checks whether any Pokémon in the party knows the given move, and returns
|
||||
# the first Pokémon it finds with that move, or nil if no Pokémon has that move.
|
||||
def get_pokemon_with_move(move)
|
||||
pokemon_party.each { |pkmn| return pkmn if pkmn.hasMove?(move) }
|
||||
return nil
|
||||
end
|
||||
|
||||
# Fully heal all Pokémon in the party.
|
||||
def heal_party
|
||||
@party.each { |pkmn| pkmn.heal }
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def initialize(name, trainer_type, sprite_override=nil, custom_appearance=nil)
|
||||
@trainer_type = GameData::TrainerType.get(trainer_type).id
|
||||
@name = name
|
||||
@id = rand(2 ** 16) | rand(2 ** 16) << 16
|
||||
@language = pbGetLanguage
|
||||
@party = []
|
||||
@sprite_override = sprite_override
|
||||
@custom_appearance = custom_appearance
|
||||
@lowest_difficulty=2 #On hard by default, lowered whenever the player selects another difficulty
|
||||
@selected_difficulty=2 #On hard by default, lowered whenever the player selects another difficulty
|
||||
@game_mode =0 #classic
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Trainer class for NPC trainers
|
||||
#===============================================================================
|
||||
class NPCTrainer < Trainer
|
||||
attr_accessor :items
|
||||
attr_accessor :lose_text
|
||||
|
||||
def initialize(name, trainer_type, sprite_override=nil,custom_appearance=nil)
|
||||
super
|
||||
@items = []
|
||||
@lose_text = nil
|
||||
end
|
||||
end
|
||||
@@ -1,145 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
#
|
||||
|
||||
def getTrainersDataMode
|
||||
mode = GameData::Trainer
|
||||
if $game_switches && $game_switches[SWITCH_MODERN_MODE]
|
||||
mode = GameData::TrainerModern
|
||||
elsif $game_switches && $game_switches[SWITCH_EXPERT_MODE]
|
||||
mode = GameData::TrainerExpert
|
||||
end
|
||||
return mode
|
||||
end
|
||||
|
||||
def pbLoadTrainer(tr_type, tr_name, tr_version = 0)
|
||||
tr_type_data = GameData::TrainerType.try_get(tr_type)
|
||||
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
|
||||
tr_type = tr_type_data.id
|
||||
trainer_data = getTrainersDataMode.try_get(tr_type, tr_name, tr_version)
|
||||
if !trainer_data
|
||||
trainer_data = GameData::Trainer.try_get(tr_type, tr_name, tr_version)
|
||||
end
|
||||
return (trainer_data) ? trainer_data.to_trainer : nil
|
||||
end
|
||||
|
||||
def pbNewTrainer(tr_type, tr_name, tr_version, save_changes = true)
|
||||
party = []
|
||||
for i in 0...Settings::MAX_PARTY_SIZE
|
||||
if i == 0
|
||||
pbMessage(_INTL("Please enter the first Pokémon.", i))
|
||||
else
|
||||
break if !pbConfirmMessage(_INTL("Add another Pokémon?"))
|
||||
end
|
||||
loop do
|
||||
species = pbChooseSpeciesList
|
||||
if species
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(1, GameData::GrowthRate.max_level)
|
||||
params.setDefaultValue(10)
|
||||
level = pbMessageChooseNumber(_INTL("Set the level for {1} (max. #{params.maxNumber}).",
|
||||
GameData::Species.get(species).name), params)
|
||||
party.push([species, level])
|
||||
break
|
||||
else
|
||||
break if i > 0
|
||||
pbMessage(_INTL("This trainer must have at least 1 Pokémon!"))
|
||||
end
|
||||
end
|
||||
end
|
||||
trainer = [tr_type, tr_name, [], party, tr_version]
|
||||
if save_changes
|
||||
trainer_hash = {
|
||||
:id_number => getTrainersDataMode::DATA.keys.length / 2,
|
||||
:trainer_type => tr_type,
|
||||
:name => tr_name,
|
||||
:version => tr_version,
|
||||
:pokemon => []
|
||||
}
|
||||
party.each do |pkmn|
|
||||
trainer_hash[:pokemon].push({
|
||||
:species => pkmn[0],
|
||||
:level => pkmn[1]
|
||||
})
|
||||
end
|
||||
# Add trainer's data to records
|
||||
trainer_hash[:id] = [trainer_hash[:trainer_type], trainer_hash[:name], trainer_hash[:version]]
|
||||
getTrainersDataMode.register(trainer_hash)
|
||||
getTrainersDataMode.save
|
||||
pbConvertTrainerData
|
||||
pbMessage(_INTL("The Trainer's data was added to the list of battles and in PBS/trainers.txt."))
|
||||
end
|
||||
return trainer
|
||||
end
|
||||
|
||||
def pbConvertTrainerData
|
||||
tr_type_names = []
|
||||
GameData::TrainerType.each { |t| tr_type_names[t.id_number] = t.real_name }
|
||||
MessageTypes.setMessages(MessageTypes::TrainerTypes, tr_type_names)
|
||||
Compiler.write_trainer_types
|
||||
Compiler.write_trainers
|
||||
end
|
||||
|
||||
def pbTrainerTypeCheck(trainer_type)
|
||||
return true if !$DEBUG
|
||||
return true if GameData::TrainerType.exists?(trainer_type)
|
||||
if pbConfirmMessage(_INTL("Add new trainer type {1}?", trainer_type.to_s))
|
||||
pbTrainerTypeEditorNew(trainer_type.to_s)
|
||||
end
|
||||
pbMapInterpreter.command_end if pbMapInterpreter
|
||||
return false
|
||||
end
|
||||
|
||||
# Called from trainer events to ensure the trainer exists
|
||||
def pbTrainerCheck(tr_type, tr_name, max_battles, tr_version = 0)
|
||||
return true if !$DEBUG
|
||||
# Check for existence of trainer type
|
||||
pbTrainerTypeCheck(tr_type)
|
||||
tr_type_data = GameData::TrainerType.try_get(tr_type)
|
||||
return false if !tr_type_data
|
||||
tr_type = tr_type_data.id
|
||||
# Check for existence of trainer with given ID number
|
||||
return true if getTrainersDataMode.exists?(tr_type, tr_name, tr_version)
|
||||
# Add new trainer
|
||||
if pbConfirmMessage(_INTL("Add new trainer variant {1} (of {2}) for {3} {4}?",
|
||||
tr_version, max_battles, tr_type.to_s, tr_name))
|
||||
pbNewTrainer(tr_type, tr_name, tr_version)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbGetFreeTrainerParty(tr_type, tr_name)
|
||||
tr_type_data = GameData::TrainerType.try_get(tr_type)
|
||||
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
|
||||
tr_type = tr_type_data.id
|
||||
for i in 0...256
|
||||
return i if !getTrainersDataMode.try_get(tr_type, tr_name, i)
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
def pbMissingTrainer(tr_type, tr_name, tr_version)
|
||||
tr_type_data = GameData::TrainerType.try_get(tr_type)
|
||||
raise _INTL("Trainer type {1} does not exist.", tr_type) if !tr_type_data
|
||||
tr_type = tr_type_data.id
|
||||
if !$DEBUG
|
||||
#raise _INTL("Can't find trainer ({1}, {2}, ID {3})", tr_type.to_s, tr_name, tr_version)
|
||||
message = ""
|
||||
if $game_switches[SWITCH_MODERN_MODE]
|
||||
message << "[MODERN MODE] "
|
||||
end
|
||||
message << "This trainer appears to be missing from the game. Please report this on the game's Discord channel whenever you get a chance."
|
||||
pbMessage(message)
|
||||
return 1
|
||||
end
|
||||
message = ""
|
||||
if tr_version != 0
|
||||
message = _INTL("Add new trainer ({1}, {2}, ID {3})?", tr_type.to_s, tr_name, tr_version)
|
||||
else
|
||||
message = _INTL("Add new trainer ({1}, {2})?", tr_type.to_s, tr_name)
|
||||
end
|
||||
cmd = pbMessage(message, [_INTL("Yes"), _INTL("No")], 2)
|
||||
pbNewTrainer(tr_type, tr_name, tr_version) if cmd == 0
|
||||
return cmd
|
||||
end
|
||||
@@ -1,84 +0,0 @@
|
||||
#===============================================================================
|
||||
# Walking charset, for use in text entry screens and load game screen
|
||||
#===============================================================================
|
||||
class TrainerWalkingCharSprite < SpriteWrapper
|
||||
def initialize(charset,viewport=nil,trainer=nil)
|
||||
super(viewport)
|
||||
@animbitmap = nil
|
||||
@trainer=trainer
|
||||
self.charset = charset
|
||||
@animframe = 0 # Current pattern
|
||||
@frame = 0 # Frame counter
|
||||
self.animspeed = 5 # Animation speed (frames per pattern)
|
||||
end
|
||||
|
||||
|
||||
def charset=(value)
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap = nil
|
||||
|
||||
outfit_bitmap = _INTL("Graphics/Characters/players/outfits/{1}_{2}",value,$Trainer.outfit) if $Trainer && $Trainer.outfit
|
||||
|
||||
@trainer = $Trainer if !@trainer
|
||||
if $Trainer
|
||||
meta=GameData::Metadata.get_player($Trainer.character_ID)
|
||||
isPlayerCharacter = value == pbGetPlayerCharset(meta,1,nil,true)
|
||||
end
|
||||
isPlayerCharacter = true if $scene.is_a?(Scene_Intro) #
|
||||
|
||||
bitmapFileName = sprintf("Graphics/Characters/%s",value)
|
||||
@charset = pbResolveBitmap(bitmapFileName)
|
||||
if @charset
|
||||
@animbitmap = AnimatedBitmap.new(@charset)
|
||||
if isPlayerCharacter #Display clothed player on continue screen
|
||||
@animbitmap.bitmap = generateClothedBitmapStatic(@trainer)
|
||||
@animbitmap.bitmap.blt(0, 0, outfit_bitmap, outfit_bitmap.rect) if pbResolveBitmap(outfit_bitmap)
|
||||
else
|
||||
@animbitmap.bitmap.blt(0, 0, outfit_bitmap, outfit_bitmap.rect) if pbResolveBitmap(outfit_bitmap)
|
||||
end
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
self.src_rect.set(0,0,self.bitmap.width/4,self.bitmap.height/4)
|
||||
else
|
||||
self.bitmap = nil
|
||||
end
|
||||
end
|
||||
|
||||
def altcharset=(value) # Used for box icon in the naming screen
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap = nil
|
||||
@charset = pbResolveBitmap(value)
|
||||
if @charset
|
||||
@animbitmap = AnimatedBitmap.new(@charset)
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
self.src_rect.set(0,0,self.bitmap.width/4,self.bitmap.height)
|
||||
else
|
||||
self.bitmap = nil
|
||||
end
|
||||
end
|
||||
|
||||
def animspeed=(value)
|
||||
@frameskip = value*Graphics.frame_rate/40
|
||||
end
|
||||
|
||||
def dispose
|
||||
@animbitmap.dispose if @animbitmap
|
||||
super
|
||||
end
|
||||
|
||||
def update
|
||||
@updating = true
|
||||
super
|
||||
if @animbitmap
|
||||
@animbitmap.update
|
||||
self.bitmap = @animbitmap.bitmap
|
||||
end
|
||||
|
||||
@frame += 1
|
||||
if @frame>=@frameskip
|
||||
@animframe = (@animframe+1)%4
|
||||
self.src_rect.x = @animframe*@animbitmap.bitmap.width/4
|
||||
@frame -= @frameskip
|
||||
end
|
||||
@updating = false
|
||||
end
|
||||
end
|
||||
@@ -1,391 +0,0 @@
|
||||
#===============================================================================
|
||||
# Trainer class for the player
|
||||
#===============================================================================
|
||||
class Player < Trainer
|
||||
# @return [Integer] the character ID of the player
|
||||
attr_accessor :character_ID
|
||||
# @return [Integer] the player's outfit
|
||||
attr_accessor :outfit #old - unused
|
||||
|
||||
attr_accessor :skin_tone
|
||||
attr_accessor :clothes
|
||||
attr_accessor :hat
|
||||
attr_accessor :hat2
|
||||
|
||||
attr_accessor :hair
|
||||
attr_accessor :hair_color
|
||||
attr_accessor :hat_color
|
||||
attr_accessor :hat2_color
|
||||
|
||||
attr_accessor :clothes_color
|
||||
attr_accessor :unlocked_clothes
|
||||
attr_accessor :unlocked_hats
|
||||
attr_accessor :unlocked_hairstyles
|
||||
attr_accessor :unlocked_card_backgrounds
|
||||
|
||||
attr_accessor :dyed_hats
|
||||
attr_accessor :dyed_clothes
|
||||
|
||||
attr_accessor :favorite_hat
|
||||
attr_accessor :favorite_hat2
|
||||
|
||||
attr_accessor :favorite_clothes
|
||||
|
||||
attr_accessor :last_worn_outfit
|
||||
attr_accessor :last_worn_hat
|
||||
attr_accessor :last_worn_hat2
|
||||
|
||||
attr_accessor :surfing_pokemon
|
||||
|
||||
|
||||
attr_accessor :card_background
|
||||
attr_accessor :unlocked_card_backgrounds
|
||||
|
||||
attr_accessor :seen_qmarks_sprite
|
||||
|
||||
|
||||
# @return [Array<Boolean>] the player's Gym Badges (true if owned)
|
||||
attr_accessor :badges
|
||||
# @return [Integer] the player's money
|
||||
attr_reader :money
|
||||
# @return [Integer] the player's Game Corner coins
|
||||
attr_reader :coins
|
||||
# @return [Integer] the player's battle points
|
||||
attr_reader :battle_points
|
||||
# @return [Integer] the player's soot
|
||||
attr_reader :soot
|
||||
# @return [Pokedex] the player's Pokédex
|
||||
attr_reader :pokedex
|
||||
# @return [Boolean] whether the Pokédex has been obtained
|
||||
attr_accessor :has_pokedex
|
||||
# @return [Boolean] whether the Pokégear has been obtained
|
||||
attr_accessor :has_pokegear
|
||||
# @return [Boolean] whether the player has running shoes (i.e. can run)
|
||||
attr_accessor :has_running_shoes
|
||||
# @return [Boolean] whether the creator of the Pokémon Storage System has been seen
|
||||
attr_accessor :seen_storage_creator
|
||||
# @return [Boolean] whether Mystery Gift can be used from the load screen
|
||||
attr_accessor :mystery_gift_unlocked
|
||||
# @return [Array<Array>] downloaded Mystery Gift data
|
||||
attr_accessor :mystery_gifts
|
||||
attr_accessor :beat_league
|
||||
attr_accessor :new_game_plus_unlocked
|
||||
attr_accessor :new_game_plus
|
||||
def trainer_type
|
||||
if @trainer_type.is_a?(Integer)
|
||||
@trainer_type = GameData::Metadata.get_player(@character_ID || 0)[0]
|
||||
end
|
||||
return @trainer_type
|
||||
end
|
||||
|
||||
# Sets the player's money. It can not exceed {Settings::MAX_MONEY}.
|
||||
# @param value [Integer] new money value
|
||||
def money=(value)
|
||||
validate value => Integer
|
||||
@money = value.clamp(0, Settings::MAX_MONEY)
|
||||
end
|
||||
|
||||
def last_worn_outfit
|
||||
if !@last_worn_outfit
|
||||
if pbGet(VAR_TRAINER_GENDER) == GENDER_MALE
|
||||
@last_worn_outfit = DEFAULT_OUTFIT_MALE
|
||||
else
|
||||
@last_worn_outfit = DEFAULT_OUTFIT_FEMALE
|
||||
end
|
||||
end
|
||||
return @last_worn_outfit
|
||||
end
|
||||
|
||||
|
||||
def last_worn_hat(is_secondary=false)
|
||||
return is_secondary ? @last_worn_hat2 : @last_worn_hat
|
||||
end
|
||||
|
||||
|
||||
def set_last_worn_hat(value, is_secondary=false)
|
||||
if is_secondary
|
||||
@last_worn_hat = value
|
||||
else
|
||||
@last_worn_hat = value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def last_worn_hat2
|
||||
return @last_worn_hat2
|
||||
end
|
||||
|
||||
# Sets the player's coins amount. It can not exceed {Settings::MAX_COINS}.
|
||||
# @param value [Integer] new coins value
|
||||
def coins=(value)
|
||||
validate value => Integer
|
||||
@coins = value.clamp(0, Settings::MAX_COINS)
|
||||
end
|
||||
|
||||
def outfit=(value)
|
||||
@outfit=value
|
||||
end
|
||||
|
||||
def favorite_hat(is_secondary=false)
|
||||
return is_secondary ? @favorite_hat2 : @favorite_hat
|
||||
end
|
||||
|
||||
|
||||
#todo change to set_favorite_hat(value,is_secondary=false)
|
||||
def set_favorite_hat(value,is_secondary=false)
|
||||
if is_secondary
|
||||
@favorite_hat=value
|
||||
else
|
||||
@favorite_hat2=value
|
||||
end
|
||||
end
|
||||
|
||||
def hat_color(is_secondary=false)
|
||||
return is_secondary ? @hat2_color : @hat_color
|
||||
end
|
||||
def hat(is_secondary=false)
|
||||
return is_secondary ? @hat2 : @hat
|
||||
end
|
||||
|
||||
def set_hat(value, is_secondary=false)
|
||||
if value.is_a?(Symbol)
|
||||
value = HATS[value].id
|
||||
end
|
||||
if is_secondary
|
||||
@hat2= value
|
||||
else
|
||||
@hat=value
|
||||
end
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
|
||||
#todo : refactor to always use set_hat instead
|
||||
def hat=(value)
|
||||
if value.is_a?(Symbol)
|
||||
value = HATS[value].id
|
||||
end
|
||||
@hat=value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
#todo : refactor to always use set_hat instead
|
||||
def hat2=(value)
|
||||
if value.is_a?(Symbol)
|
||||
value = HATS[value].id
|
||||
end
|
||||
@hat2=value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def hair=(value)
|
||||
if value.is_a?(Symbol)
|
||||
value = HAIRSTYLES[value].id
|
||||
end
|
||||
@hair=value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def clothes=(value)
|
||||
if value.is_a?(Symbol)
|
||||
value = OUTFITS[value].id
|
||||
end
|
||||
@clothes=value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def clothes_color=(value)
|
||||
@clothes_color=value
|
||||
$Trainer.dyed_clothes= {} if !$Trainer.dyed_clothes
|
||||
$Trainer.dyed_clothes[@clothes] = value if value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def set_hat_color(value, is_secondary=false)
|
||||
if is_secondary
|
||||
@hat2_color=value
|
||||
else
|
||||
@hat_color=value
|
||||
end
|
||||
$Trainer.dyed_hats= {} if !$Trainer.dyed_hats
|
||||
worn_hat = is_secondary ? @hat2 : @hat
|
||||
$Trainer.dyed_hats[worn_hat] = value if value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
|
||||
def hat_color=(value)
|
||||
@hat_color=value
|
||||
$Trainer.dyed_hats= {} if !$Trainer.dyed_hats
|
||||
worn_hat = @hat
|
||||
$Trainer.dyed_hats[worn_hat] = value if value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def hat2_color=(value)
|
||||
@hat2_color=value
|
||||
$Trainer.dyed_hats= {} if !$Trainer.dyed_hats
|
||||
worn_hat = @hat2
|
||||
$Trainer.dyed_hats[worn_hat] = value if value
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def unlock_clothes(outfitID,silent=false)
|
||||
update_global_clothes_list()
|
||||
outfit = $PokemonGlobal.clothes_data[outfitID]
|
||||
@unlocked_clothes = [] if !@unlocked_clothes
|
||||
@unlocked_clothes << outfitID if !@unlocked_clothes.include?(outfitID)
|
||||
|
||||
if !silent
|
||||
filename = getTrainerSpriteOutfitFilename(outfitID)
|
||||
name= outfit ? outfit.name : outfitID
|
||||
unlock_outfit_animation(filename,name)
|
||||
end
|
||||
end
|
||||
|
||||
def unlock_hat(hatID,silent=false)
|
||||
update_global_hats_list()
|
||||
|
||||
hat = $PokemonGlobal.hats_data[hatID]
|
||||
@unlocked_hats = [] if !@unlocked_hats
|
||||
@unlocked_hats << hatID if !@unlocked_hats.include?(hatID)
|
||||
|
||||
|
||||
if !silent
|
||||
filename = getTrainerSpriteHatFilename(hatID)
|
||||
name= hat ? hat.name : hatID
|
||||
unlock_outfit_animation(filename,name)
|
||||
end
|
||||
end
|
||||
|
||||
def unlock_hair(hairID,silent=false)
|
||||
update_global_hairstyles_list()
|
||||
|
||||
hairstyle = $PokemonGlobal.hairstyles_data[hairID]
|
||||
if hairID.is_a?(Symbol)
|
||||
hairID = HAIRSTYLES[hairID].id
|
||||
end
|
||||
@unlocked_hairstyles = [] if !@unlocked_hairstyles
|
||||
@unlocked_hairstyles << hairID if !@unlocked_hairstyles.include?(hairID)
|
||||
|
||||
if !silent
|
||||
filename = getTrainerSpriteHairFilename("2_" + hairID)
|
||||
name= hairstyle ? hairstyle.name : hairID
|
||||
unlock_outfit_animation(filename,name)
|
||||
end
|
||||
end
|
||||
|
||||
def unlock_outfit_animation(filepath,name,color=2)
|
||||
outfit_preview = PictureWindow.new(filepath)
|
||||
outfit_preview.x = Graphics.width/4
|
||||
musicEffect= "Key item get"
|
||||
pbMessage(_INTL("{1} obtained \\C[{2}]{3}\\C[0]!\\me[{4}]",$Trainer.name,color,name,musicEffect))
|
||||
outfit_preview.dispose
|
||||
end
|
||||
|
||||
def surfing_pokemon=(species)
|
||||
@surfing_pokemon = species
|
||||
end
|
||||
|
||||
|
||||
def skin_tone=(value)
|
||||
@skin_tone=value
|
||||
$scene.reset_player_sprite
|
||||
#$scene.spritesetGlobal.playersprite.updateCharacterBitmap
|
||||
end
|
||||
|
||||
def beat_league=(value)
|
||||
@beat_league = value
|
||||
end
|
||||
def new_game_plus_unlocked=(value)
|
||||
@new_game_plus_unlocked = value
|
||||
end
|
||||
# Sets the player's Battle Points amount. It can not exceed
|
||||
# {Settings::MAX_BATTLE_POINTS}.
|
||||
# @param value [Integer] new Battle Points value
|
||||
def battle_points=(value)
|
||||
validate value => Integer
|
||||
@battle_points = value.clamp(0, Settings::MAX_BATTLE_POINTS)
|
||||
end
|
||||
|
||||
# Sets the player's soot amount. It can not exceed {Settings::MAX_SOOT}.
|
||||
# @param value [Integer] new soot value
|
||||
def soot=(value)
|
||||
validate value => Integer
|
||||
@soot = value.clamp(0, Settings::MAX_SOOT)
|
||||
end
|
||||
|
||||
# @return [Integer] the number of Gym Badges owned by the player
|
||||
def badge_count
|
||||
return @badges.count { |badge| badge == true }
|
||||
end
|
||||
|
||||
|
||||
def new_game_plus=(value)
|
||||
@new_game_plus = value
|
||||
end
|
||||
#=============================================================================
|
||||
|
||||
# (see Pokedex#seen?)
|
||||
# Shorthand for +self.pokedex.seen?+.
|
||||
def seen?(species)
|
||||
return @pokedex.seen?(species)
|
||||
end
|
||||
|
||||
# (see Pokedex#owned?)
|
||||
# Shorthand for +self.pokedex.owned?+.
|
||||
def owned?(species)
|
||||
return @pokedex.owned?(species)
|
||||
end
|
||||
|
||||
def can_change_outfit()
|
||||
return false if isOnPinkanIsland()
|
||||
return true
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
def initialize(name, trainer_type)
|
||||
super
|
||||
@character_ID = -1
|
||||
@outfit = 0
|
||||
@hat = 0
|
||||
@hat2 = 0
|
||||
|
||||
@hair = 0
|
||||
@clothes = 0
|
||||
@hair_color = 0
|
||||
@skin_tone = 0
|
||||
@badges = [false] * 8
|
||||
@money = Settings::INITIAL_MONEY
|
||||
@coins = 0
|
||||
@battle_points = 0
|
||||
@soot = 0
|
||||
@pokedex = Pokedex.new
|
||||
@has_pokedex = false
|
||||
@has_pokegear = false
|
||||
@has_running_shoes = false
|
||||
@seen_storage_creator = false
|
||||
@mystery_gift_unlocked = false
|
||||
@mystery_gifts = []
|
||||
@beat_league = false
|
||||
@new_game_plus_unlocked = false
|
||||
@new_game_plus = false
|
||||
@surfing_pokemon = nil
|
||||
@last_worn_outfit = nil
|
||||
@last_worn_hat = nil
|
||||
@last_worn_hat2 = nil
|
||||
|
||||
@dyed_hats = {}
|
||||
@dyed_clothes = {}
|
||||
|
||||
@favorite_hat = nil
|
||||
@favorite_hat2 =nil
|
||||
@favorite_clothes = nil
|
||||
|
||||
@card_background = Settings::DEFAULT_TRAINER_CARD_BG
|
||||
@unlocked_card_backgrounds = [@card_background]
|
||||
|
||||
@seen_qmarks_sprite = false
|
||||
end
|
||||
end
|
||||
@@ -1,487 +0,0 @@
|
||||
class Player < Trainer
|
||||
# Represents the player's Pokédex.
|
||||
class Pokedex
|
||||
# @return [Array<Integer>] an array of accessible Dexes
|
||||
# @see #refresh_accessible_dexes
|
||||
attr_reader :accessible_dexes
|
||||
|
||||
def inspect
|
||||
str = super.chop
|
||||
str << format(' seen: %d, owned: %d>', self.seen_count, self.owned_count)
|
||||
return str
|
||||
end
|
||||
|
||||
# Creates an empty Pokédex.
|
||||
def initialize
|
||||
@unlocked_dexes = []
|
||||
0.upto(pbLoadRegionalDexes.length) do |i|
|
||||
@unlocked_dexes[i] = (i == 0)
|
||||
end
|
||||
self.clear
|
||||
end
|
||||
|
||||
# Clears the Pokédex.
|
||||
def clear
|
||||
@seen = {} #deprecated
|
||||
@owned = {} #deprecated
|
||||
@seen_standard = initStandardDexArray()
|
||||
@seen_fusion = initFusionDexArray()
|
||||
@seen_triple = {}
|
||||
|
||||
@owned_standard = initStandardDexArray()
|
||||
@owned_fusion = initFusionDexArray()
|
||||
@owned_triple = {}
|
||||
|
||||
@seen_forms = {}
|
||||
@last_seen_forms = {}
|
||||
@owned_shadow = {}
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
def initStandardDexArray()
|
||||
dex_array = []
|
||||
(0..NB_POKEMON).each { |poke|
|
||||
if poke == 0
|
||||
dex_array << nil
|
||||
end
|
||||
dex_array << false
|
||||
}
|
||||
return dex_array
|
||||
end
|
||||
|
||||
def initFusionDexArray()
|
||||
head_array = []
|
||||
(0..NB_POKEMON).each { |head|
|
||||
body_array = []
|
||||
if head == 0
|
||||
head_array << nil
|
||||
end
|
||||
(0..NB_POKEMON).each { |body|
|
||||
if body == 0
|
||||
body_array << nil
|
||||
end
|
||||
body_array << false
|
||||
}
|
||||
head_array << body_array
|
||||
}
|
||||
return head_array
|
||||
end
|
||||
|
||||
def resync_pokedex
|
||||
echoln "syncing pokedex"
|
||||
@seen_standard = resync_standard_pokedex_array(@seen_standard)
|
||||
@owned_standard = resync_standard_pokedex_array(@owned_standard)
|
||||
|
||||
@seen_fusion = resync_fused_pokedex_array(@seen_fusion)
|
||||
@owned_fusion = resync_fused_pokedex_array(@owned_fusion)
|
||||
end
|
||||
|
||||
def resync_fused_pokedex_array(original_dex_array)
|
||||
new_dex = initFusionDexArray()
|
||||
(0..NB_POKEMON).each do |head_id|
|
||||
(0..NB_POKEMON).each do |body_id|
|
||||
if original_dex_array[head_id]
|
||||
new_dex[head_id][body_id] = original_dex_array[head_id][body_id] if original_dex_array[head_id][body_id]
|
||||
end
|
||||
end
|
||||
end
|
||||
return new_dex
|
||||
end
|
||||
|
||||
def resync_standard_pokedex_array(original_dex_array)
|
||||
new_dex = initStandardDexArray()
|
||||
(0..NB_POKEMON).each do |pokemon_id|
|
||||
new_dex[pokemon_id] = original_dex_array[pokemon_id] if original_dex_array[pokemon_id]
|
||||
end
|
||||
return new_dex
|
||||
end
|
||||
|
||||
def isTripleFusion(num)
|
||||
return isTripleFusion?(num)
|
||||
end
|
||||
|
||||
def isTripleFusion?(num)
|
||||
return num >= Settings::ZAPMOLCUNO_NB
|
||||
end
|
||||
|
||||
def isFusion(num)
|
||||
return num > Settings::NB_POKEMON && !isTripleFusion(num)
|
||||
end
|
||||
|
||||
def resyncPokedexIfNumberOfPokemonChanged()
|
||||
if @seen_standard.length < NB_POKEMON || @seen_fusion.length < NB_POKEMON
|
||||
resync_pokedex()
|
||||
end
|
||||
end
|
||||
|
||||
def verify_dex_is_correct_length(current_dex)
|
||||
|
||||
expected_length = 509 + 2
|
||||
return current_dex.length == expected_length
|
||||
end
|
||||
|
||||
def set_seen_fusion(species)
|
||||
bodyId = getBodyID(species)
|
||||
headId = getHeadID(species, bodyId)
|
||||
@seen_fusion[headId][bodyId] = true
|
||||
end
|
||||
|
||||
def set_seen_normalDex(species)
|
||||
dex_num = getDexNumberForSpecies(species)
|
||||
@seen_standard[dex_num] = true
|
||||
end
|
||||
|
||||
def set_seen_triple(species)
|
||||
if species.is_a?(Pokemon)
|
||||
species_id = species.species
|
||||
else
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
end
|
||||
return if species_id.nil?
|
||||
@seen_triple[species_id] = true
|
||||
end
|
||||
|
||||
def set_seen(species, should_refresh_dexes = true)
|
||||
try_resync_pokedex()
|
||||
dexNum = getDexNumberForSpecies(species)
|
||||
if isTripleFusion(dexNum)
|
||||
set_seen_triple(species)
|
||||
elsif isFusion(dexNum)
|
||||
set_seen_fusion(species)
|
||||
else
|
||||
set_seen_normalDex(species)
|
||||
end
|
||||
self.refresh_accessible_dexes if should_refresh_dexes
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] species to check
|
||||
# @return [Boolean] whether the species is seen
|
||||
|
||||
def seen_fusion?(species)
|
||||
bodyId = getBodyID(species)
|
||||
headId = getHeadID(species, bodyId)
|
||||
return @seen_fusion[headId][bodyId]
|
||||
end
|
||||
|
||||
# def seen_normalDex?(species)
|
||||
# species_id = GameData::Species.try_get(species)&.species
|
||||
# return false if species_id.nil?
|
||||
# return @seen[species_id] == true
|
||||
# end
|
||||
def seen_normalDex?(species)
|
||||
return @seen_standard[getDexNumberForSpecies(species)]
|
||||
end
|
||||
|
||||
def seen_triple?(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return false if species_id.nil?
|
||||
return @seen_triple[species_id]
|
||||
end
|
||||
|
||||
def seen?(species)
|
||||
return false if !species
|
||||
try_resync_pokedex()
|
||||
num = getDexNumberForSpecies(species)
|
||||
if isTripleFusion(num)
|
||||
return seen_triple?(species)
|
||||
elsif isFusion(num)
|
||||
return seen_fusion?(species)
|
||||
else
|
||||
return seen_normalDex?(species)
|
||||
end
|
||||
end
|
||||
|
||||
def seen_form?(species, gender, form)
|
||||
return false
|
||||
# species_id = GameData::Species.try_get(species)&.species
|
||||
# return false if species_id.nil?
|
||||
# @seen_forms[species_id] ||= [[], []]
|
||||
# return @seen_forms[species_id][gender][form] == true
|
||||
end
|
||||
|
||||
# Returns the amount of seen Pokémon.
|
||||
# If a region ID is given, returns the amount of seen Pokémon
|
||||
# in that region.
|
||||
# @param dex [Integer] region ID
|
||||
def seen_count(dex = -1)
|
||||
try_resync_pokedex()
|
||||
return count_dex(@seen_standard, @seen_fusion) + @owned_triple.size
|
||||
end
|
||||
|
||||
# Returns whether there are any seen Pokémon.
|
||||
# If a region is given, returns whether there are seen Pokémon
|
||||
# in that region.
|
||||
# @param region [Integer] region ID
|
||||
# @return [Boolean] whether there are any seen Pokémon
|
||||
def seen_any?(dex = -1)
|
||||
return seen_count >= 1
|
||||
end
|
||||
|
||||
# Returns the amount of seen forms for the given species.
|
||||
# @param species [Symbol, GameData::Species] Pokémon species
|
||||
# @return [Integer] amount of seen forms
|
||||
def seen_forms_count(species)
|
||||
return 0
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] Pokémon species
|
||||
def last_form_seen(species)
|
||||
@last_seen_forms[species] ||= []
|
||||
return @last_seen_forms[species][0] || 0, @last_seen_forms[species][1] || 0
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] Pokémon species
|
||||
# @param gender [Integer] gender (0=male, 1=female, 2=genderless)
|
||||
# @param form [Integer] form number
|
||||
def set_last_form_seen(species, gender = 0, form = 0)
|
||||
@last_seen_forms[species] = [gender, form]
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# Sets the given species as owned in the Pokédex.
|
||||
# @param species [Symbol, GameData::Species] species to set as owned
|
||||
# @param should_refresh_dexes [Boolean] whether Dex accessibility should be recalculated
|
||||
def set_owned_fusion(species)
|
||||
try_resync_pokedex()
|
||||
bodyId = getBodyID(species)
|
||||
headId = getHeadID(species, bodyId)
|
||||
@owned_fusion[headId][bodyId] = true
|
||||
end
|
||||
|
||||
def set_owned_triple(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return if species_id.nil?
|
||||
@owned_triple[species_id] = true
|
||||
end
|
||||
|
||||
def set_owned_normalDex(species)
|
||||
try_resync_pokedex()
|
||||
@owned_standard[getDexNumberForSpecies(species)] = true
|
||||
end
|
||||
|
||||
def set_owned(species, should_refresh_dexes = true)
|
||||
dexNum = getDexNumberForSpecies(species)
|
||||
if isTripleFusion(dexNum)
|
||||
set_owned_triple(species)
|
||||
elsif isFusion(dexNum)
|
||||
set_owned_fusion(species)
|
||||
else
|
||||
set_owned_normalDex(species)
|
||||
end
|
||||
self.refresh_accessible_dexes if should_refresh_dexes
|
||||
end
|
||||
|
||||
# Sets the given species as owned in the Pokédex.
|
||||
# @param species [Symbol, GameData::Species] species to set as owned
|
||||
def set_shadow_pokemon_owned(species)
|
||||
return
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] species to check
|
||||
# @return [Boolean] whether the species is owned
|
||||
def owned_fusion?(species)
|
||||
bodyId = getBodyID(species)
|
||||
headId = getHeadID(species, bodyId)
|
||||
|
||||
# p headId
|
||||
# p @owned_fusion[headId]
|
||||
# if !@owned_fusion[headId]
|
||||
# print "syncing"
|
||||
# @seen_fusion = initFusionDexArray(true)
|
||||
# end
|
||||
# p @owned_fusion[headId]
|
||||
|
||||
return @owned_fusion[headId][bodyId] == true
|
||||
end
|
||||
|
||||
def owned_triple?(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return false if species_id.nil?
|
||||
return @owned_triple[species_id]
|
||||
end
|
||||
|
||||
def owned?(species)
|
||||
try_resync_pokedex()
|
||||
num = getDexNumberForSpecies(species)
|
||||
if isTripleFusion(num)
|
||||
return owned_triple?(species)
|
||||
elsif isFusion(num)
|
||||
return owned_fusion?(species)
|
||||
else
|
||||
return owned_normalDex?(species)
|
||||
end
|
||||
end
|
||||
|
||||
def owned_normalDex?(species)
|
||||
return @owned_standard[getDexNumberForSpecies(species)]
|
||||
end
|
||||
|
||||
# @param species [Symbol, GameData::Species] species to check
|
||||
# @return [Boolean] whether a Shadow Pokémon of the species is owned
|
||||
def owned_shadow_pokemon?(species)
|
||||
return
|
||||
end
|
||||
|
||||
# Returns the amount of owned Pokémon.
|
||||
# If a region ID is given, returns the amount of owned Pokémon
|
||||
# in that region.
|
||||
# @param region [Integer] region ID
|
||||
def owned_count(dex = -1)
|
||||
return count_dex(@owned_standard, @owned_fusion) + @owned_triple.size
|
||||
end
|
||||
|
||||
def count_dex(standardList, fusedList)
|
||||
owned_standard = count_true(standardList)
|
||||
owned_fused = 0
|
||||
fusedList.each { |head_poke_list|
|
||||
if head_poke_list != nil
|
||||
owned_fused += count_true(head_poke_list)
|
||||
end
|
||||
}
|
||||
return owned_standard + owned_fused
|
||||
end
|
||||
|
||||
def count_true(list)
|
||||
count = 0
|
||||
list.each { |owned|
|
||||
if owned
|
||||
count += 1
|
||||
end
|
||||
}
|
||||
return count
|
||||
end
|
||||
|
||||
def dex_sync_needed?()
|
||||
# p NB_POKEMON
|
||||
# p @owned_standard.length
|
||||
|
||||
return @owned_standard == nil || @owned_fusion == nil || @owned_triple == nil ||
|
||||
!verify_dex_is_correct_length(@owned_standard) || !verify_dex_is_correct_length(@seen_fusion)
|
||||
|
||||
end
|
||||
|
||||
#todo:
|
||||
# loop on @owned and @seen and add the pokemon in @owned_standard/fusion @seen_standard/fusion
|
||||
# then clear @owned and @seen
|
||||
def try_resync_pokedex()
|
||||
resyncPokedexIfNumberOfPokemonChanged
|
||||
#
|
||||
# if dex_sync_needed?()
|
||||
# print "syncing"
|
||||
# init_new_pokedex_if_needed()
|
||||
# @seen.each { |pokemon|
|
||||
# set_seen(pokemon[0])
|
||||
# }
|
||||
# @owned.each { |pokemon|
|
||||
# set_owned(pokemon[0])
|
||||
# }
|
||||
# self.refresh_accessible_dexes
|
||||
# @seen = {} #deprecated
|
||||
# @owned = {} #deprecated
|
||||
# end
|
||||
#self.clear
|
||||
end
|
||||
|
||||
def resync_boxes_to_pokedex
|
||||
$PokemonStorage.boxes.each { |box|
|
||||
box.pokemon.each { |pokemon|
|
||||
if pokemon != nil
|
||||
if !pokemon.egg?
|
||||
set_owned(pokemon.species)
|
||||
set_seen(pokemon.species)
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def init_new_pokedex_if_needed()
|
||||
@seen_standard = initStandardDexArray() # if @seen_standard == nil
|
||||
@seen_fusion = initFusionDexArray() # if @seen_fusion == nil
|
||||
@seen_triple = {} if @seen_triple == nil
|
||||
|
||||
@owned_standard = initStandardDexArray() # if @owned_standard == nil
|
||||
@owned_fusion = initFusionDexArray() # if @owned_fusion == nil
|
||||
@owned_triple = {} if @owned_triple == nil
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# @param pkmn [Pokemon, Symbol, GameData::Species] Pokemon to register as seen
|
||||
# @param gender [Integer] gender to register (0=male, 1=female, 2=genderless)
|
||||
# @param form [Integer] form to register
|
||||
def register(species, gender = 0, form = 0, should_refresh_dexes = true)
|
||||
set_seen(species, should_refresh_dexes)
|
||||
end
|
||||
|
||||
# @param pkmn [Pokemon] Pokemon to register as most recently seen
|
||||
def register_last_seen(pkmn)
|
||||
return
|
||||
# validate pkmn => Pokemon
|
||||
# species_data = pkmn.species_data
|
||||
# form = species_data.pokedex_form
|
||||
# form = 0 if species_data.form_name.nil? || species_data.form_name.empty?
|
||||
# @last_seen_forms[pkmn.species] = [pkmn.gender, form]
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
# Unlocks the given Dex, -1 being the National Dex.
|
||||
# @param dex [Integer] Dex ID (-1 is the National Dex)
|
||||
def unlock(dex)
|
||||
validate dex => Integer
|
||||
dex = @unlocked_dexes.length - 1 if dex < 0 || dex > @unlocked_dexes.length - 1
|
||||
@unlocked_dexes[dex] = true
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# Locks the given Dex, -1 being the National Dex.
|
||||
# @param dex [Integer] Dex ID (-1 is the National Dex)
|
||||
def lock(dex)
|
||||
validate dex => Integer
|
||||
dex = @unlocked_dexes.length - 1 if dex < 0 || dex > @unlocked_dexes.length - 1
|
||||
@unlocked_dexes[dex] = false
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
# @param dex [Integer] Dex ID (-1 is the National Dex)
|
||||
# @return [Boolean] whether the given Dex is unlocked
|
||||
def unlocked?(dex)
|
||||
return dex == 0
|
||||
# validate dex => Integer
|
||||
# dex = @unlocked_dexes.length - 1 if dex == -1
|
||||
# return @unlocked_dexes[dex] == true
|
||||
end
|
||||
|
||||
# @return [Integer] the number of defined Dexes (including the National Dex)
|
||||
def dexes_count
|
||||
return @unlocked_dexes.length
|
||||
end
|
||||
|
||||
# Decides which Dex lists are able to be viewed (i.e. they are unlocked and
|
||||
# have at least 1 seen species in them), and saves all accessible Dex region
|
||||
# numbers into {#accessible_dexes}. National Dex comes after all regional
|
||||
# Dexes.
|
||||
# If the Dex list shown depends on the player's location, this just decides
|
||||
# if a species in the current region has been seen - doesn't look at other
|
||||
# regions.
|
||||
def refresh_accessible_dexes
|
||||
@accessible_dexes = []
|
||||
if self.unlocked?(0) && self.seen_any?
|
||||
@accessible_dexes.push(-1)
|
||||
end
|
||||
end
|
||||
|
||||
#===========================================================================
|
||||
|
||||
private
|
||||
|
||||
# @param hash [Hash]
|
||||
# @param region [Integer]
|
||||
# @return [Integer]
|
||||
def count_species(hash, region = -1)
|
||||
return hash.size()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,194 +0,0 @@
|
||||
#===============================================================================
|
||||
# Deprecated
|
||||
#===============================================================================
|
||||
class Trainer
|
||||
deprecated_method_alias :fullname, :full_name, removal_in: 'v20'
|
||||
deprecated_method_alias :publicID, :public_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :secretID, :secret_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :getForeignID, :make_foreign_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :trainerTypeName, :trainer_type_name, removal_in: 'v20'
|
||||
deprecated_method_alias :isMale?, :male?, removal_in: 'v20'
|
||||
deprecated_method_alias :isFemale?, :female?, removal_in: 'v20'
|
||||
deprecated_method_alias :moneyEarned, :base_money, removal_in: 'v20'
|
||||
deprecated_method_alias :skill, :skill_level, removal_in: 'v20'
|
||||
deprecated_method_alias :skillCode, :skill_code, removal_in: 'v20'
|
||||
deprecated_method_alias :hasSkillCode, :has_skill_code?, removal_in: 'v20'
|
||||
deprecated_method_alias :pokemonParty, :pokemon_party, removal_in: 'v20'
|
||||
deprecated_method_alias :ablePokemonParty, :able_party, removal_in: 'v20'
|
||||
deprecated_method_alias :partyCount, :party_count, removal_in: 'v20'
|
||||
deprecated_method_alias :pokemonCount, :pokemon_count, removal_in: 'v20'
|
||||
deprecated_method_alias :ablePokemonCount, :able_pokemon_count, removal_in: 'v20'
|
||||
deprecated_method_alias :firstParty, :first_party, removal_in: 'v20'
|
||||
deprecated_method_alias :firstPokemon, :first_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :firstAblePokemon, :first_able_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :lastParty, :last_party, removal_in: 'v20'
|
||||
deprecated_method_alias :lastPokemon, :last_pokemon, removal_in: 'v20'
|
||||
deprecated_method_alias :lastAblePokemon, :last_able_pokemon, removal_in: 'v20'
|
||||
end
|
||||
|
||||
class Player < Trainer
|
||||
class Pokedex
|
||||
# @deprecated Use {seen?} or {set_seen} instead. This alias is slated to be removed in v20.
|
||||
attr_reader :seen_forms
|
||||
end
|
||||
|
||||
deprecated_method_alias :numbadges, :badge_count, removal_in: 'v20'
|
||||
deprecated_method_alias :metaID, :character_ID, removal_in: 'v20'
|
||||
deprecated_method_alias :mysterygiftaccess, :mystery_gift_unlocked, removal_in: 'v20'
|
||||
deprecated_method_alias :mysterygift, :mystery_gifts, removal_in: 'v20'
|
||||
deprecated_method_alias :hasSeen?, :seen?, removal_in: 'v20'
|
||||
deprecated_method_alias :hasOwned?, :owned?, removal_in: 'v20'
|
||||
deprecated_method_alias :pokegear, :has_pokegear, removal_in: 'v20'
|
||||
|
||||
# @deprecated Use {Player::Pokedex#set_seen} instead. This alias is slated to be removed in v20.
|
||||
def setSeen(species)
|
||||
Deprecation.warn_method('Player#setSeen', 'v20', 'Player::Pokedex#set_seen(species)')
|
||||
return @pokedex.set_seen(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#set_owned} instead. This alias is slated to be removed in v20.
|
||||
def setOwned(species)
|
||||
Deprecation.warn_method('Player#setOwned', 'v20', 'Player::Pokedex#set_owned(species)')
|
||||
return @pokedex.set_owned(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#seen_count} instead. This alias is slated to be removed in v20.
|
||||
def pokedexSeen(dex = -1)
|
||||
Deprecation.warn_method('Player#pokedexSeen', 'v20', 'Player::Pokedex#seen_count')
|
||||
return @pokedex.seen_count(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#owned_count} instead. This alias is slated to be removed in v20.
|
||||
def pokedexOwned(dex = -1)
|
||||
Deprecation.warn_method('Player#pokedexOwned', 'v20', 'Player::Pokedex#owned_count')
|
||||
return @pokedex.owned_count(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#seen_forms_count} instead. This alias is slated to be removed in v20.
|
||||
def numFormsSeen(species)
|
||||
Deprecation.warn_method('Player#numFormsSeen', 'v20', 'Player::Pokedex#seen_forms_count')
|
||||
return @pokedex.seen_forms_count(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#clear} instead. This alias is slated to be removed in v20.
|
||||
def clearPokedex
|
||||
Deprecation.warn_method('Player#clearPokedex', 'v20', 'Player::Pokedex#clear')
|
||||
return @pokedex.clear
|
||||
end
|
||||
end
|
||||
|
||||
# @deprecated Use {Player} instead. PokeBattle_Trainer is slated to be removed in v20.
|
||||
class PokeBattle_Trainer
|
||||
attr_reader :trainertype, :name, :id, :metaID, :outfit, :language
|
||||
attr_reader :party, :badges, :money
|
||||
attr_reader :seen, :owned, :formseen, :formlastseen, :shadowcaught
|
||||
attr_reader :pokedex, :pokegear
|
||||
attr_reader :mysterygiftaccess, :mysterygift
|
||||
|
||||
def self.convert(trainer)
|
||||
validate trainer => self
|
||||
ret = Player.new(trainer.name, trainer.trainertype)
|
||||
ret.id = trainer.id
|
||||
ret.character_ID = trainer.metaID if trainer.metaID
|
||||
ret.outfit = trainer.outfit if trainer.outfit
|
||||
ret.language = trainer.language if trainer.language
|
||||
trainer.party.each { |p| ret.party.push(PokeBattle_Pokemon.convert(p)) }
|
||||
ret.badges = trainer.badges.clone
|
||||
ret.money = trainer.money
|
||||
trainer.seen.each_with_index { |value, i| ret.pokedex.set_seen(i, false) if value }
|
||||
trainer.owned.each_with_index { |value, i| ret.pokedex.set_owned(i, false) if value }
|
||||
trainer.formseen.each_with_index do |value, i|
|
||||
species_id = GameData::Species.try_get(i)&.species
|
||||
next if species_id.nil? || value.nil?
|
||||
ret.pokedex.seen_forms[species_id] = [value[0].clone, value[1].clone] if value
|
||||
end
|
||||
trainer.formlastseen.each_with_index do |value, i|
|
||||
species_id = GameData::Species.try_get(i)&.species
|
||||
next if species_id.nil? || value.nil?
|
||||
ret.pokedex.set_last_form_seen(species_id, value[0], value[1]) if value
|
||||
end
|
||||
if trainer.shadowcaught
|
||||
trainer.shadowcaught.each_with_index do |value, i|
|
||||
ret.pokedex.set_shadow_pokemon_owned(i) if value
|
||||
end
|
||||
end
|
||||
ret.pokedex.refresh_accessible_dexes
|
||||
ret.has_pokedex = trainer.pokedex
|
||||
ret.has_pokegear = trainer.pokegear
|
||||
ret.mystery_gift_unlocked = trainer.mysterygiftaccess if trainer.mysterygiftaccess
|
||||
ret.mystery_gifts = trainer.mysterygift.clone if trainer.mysterygift
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#remove_pokemon_at_index} instead. This alias is slated to be removed in v20.
|
||||
def pbRemovePokemonAt(index)
|
||||
Deprecation.warn_method('pbRemovePokemonAt', 'v20', 'Player#remove_pokemon_at_index')
|
||||
return $Trainer.remove_pokemon_at_index(index)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_other_able_pokemon?} instead. This alias is slated to be removed in v20.
|
||||
def pbCheckAble(index)
|
||||
Deprecation.warn_method('pbCheckAble', 'v20', 'Player#has_other_able_pokemon?')
|
||||
return $Trainer.has_other_able_pokemon?(index)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#all_fainted?} instead. This alias is slated to be removed in v20.
|
||||
def pbAllFainted
|
||||
Deprecation.warn_method('pbAllFainted', 'v20', 'Player#all_fainted?')
|
||||
return $Trainer.all_fainted?
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_species?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasSpecies?(species, form = -1)
|
||||
Deprecation.warn_method('pbHasSpecies?', 'v20', 'Player#has_species?')
|
||||
return $Trainer.has_species?(species, form)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_fateful_species?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasFatefulSpecies?(species)
|
||||
Deprecation.warn_method('pbHasFatefulSpecies?', 'v20', 'Player#has_fateful_species?')
|
||||
return $Trainer.has_fateful_species?(species)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#has_pokemon_of_type?} instead. This alias is slated to be removed in v20.
|
||||
def pbHasType?(type)
|
||||
Deprecation.warn_method('pbHasType?', 'v20', 'Player#has_pokemon_of_type?')
|
||||
return $Trainer.has_pokemon_of_type?(type)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#get_pokemon_with_move} instead. This alias is slated to be removed in v20.
|
||||
def pbCheckMove(move)
|
||||
Deprecation.warn_method('pbCheckMove', 'v20', 'Player#get_pokemon_with_move')
|
||||
return $Trainer.get_pokemon_with_move(move)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player#heal_party} instead. This alias is slated to be removed in v20.
|
||||
def pbHealAll
|
||||
Deprecation.warn_method('pbHealAll', 'v20', 'Player#heal_party')
|
||||
$Trainer.heal_party
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#unlock} instead. This alias is slated to be removed in v20.
|
||||
def pbUnlockDex(dex=-1)
|
||||
Deprecation.warn_method('pbUnlockDex', 'v20', '$Trainer.pokedex.unlock(dex)')
|
||||
$Trainer.pokedex.unlock(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#lock} instead. This alias is slated to be removed in v20.
|
||||
def pbLockDex(dex=-1)
|
||||
Deprecation.warn_method('pbLockDex', 'v20', '$Trainer.pokedex.lock(dex)')
|
||||
$Trainer.pokedex.lock(dex)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#register} instead. This alias is slated to be removed in v20.
|
||||
def pbSeenForm(species, gender = 0, form = 0)
|
||||
Deprecation.warn_method('pbSeenForm', 'v20', '$Trainer.pokedex.register(species, gender, form)')
|
||||
$Trainer.pokedex.register(species, gender, form)
|
||||
end
|
||||
|
||||
# @deprecated Use {Player::Pokedex#register_last_seen} instead. This alias is slated to be removed in v20.
|
||||
def pbUpdateLastSeenForm(pkmn)
|
||||
Deprecation.warn_method('Player#pokedexSeen', 'v20', '$Trainer.pokedex.register_last_seen(pkmn)')
|
||||
$Trainer.pokedex.register_last_seen(pkmn)
|
||||
end
|
||||
Reference in New Issue
Block a user