mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 06:34:59 +00:00
Moved some global metadata values to class Player, added battle points property
This commit is contained in:
@@ -2,15 +2,32 @@
|
||||
# Trainer class for the player
|
||||
#===============================================================================
|
||||
class Player < Trainer
|
||||
# @param value [Integer] new character ID
|
||||
attr_writer :character_ID
|
||||
# @return [Integer] the player's outfit
|
||||
attr_accessor :outfit
|
||||
# @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
|
||||
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
|
||||
# @return [Boolean] whether the Pokégear has been obtained
|
||||
attr_accessor :has_pokegear
|
||||
# @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
|
||||
|
||||
def inspect
|
||||
str = self.to_s.chop
|
||||
@@ -19,32 +36,59 @@ class Player < Trainer
|
||||
return str
|
||||
end
|
||||
|
||||
# @return [Integer] the character ID of the player
|
||||
def character_ID
|
||||
@character_ID = $PokemonGlobal.playerID || 0 if !@character_ID
|
||||
return @character_ID
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
ret = 0
|
||||
@badges.each { |b| ret += 1 if b }
|
||||
return ret
|
||||
return @badges.count { |badge| badge == true }
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
# (see Pokedex#seen?)
|
||||
# Shorthand for +self.pokedex.seen?+.
|
||||
def seen?(species)
|
||||
return @pokedex.seen?(species)
|
||||
end
|
||||
alias hasSeen? seen?
|
||||
|
||||
# (see Pokedex#owned?)
|
||||
# Shorthand for +self.pokedex.owned?+.
|
||||
def owned?(species)
|
||||
return @pokedex.owned?(species)
|
||||
end
|
||||
alias hasOwned? owned?
|
||||
|
||||
#=============================================================================
|
||||
|
||||
@@ -54,9 +98,14 @@ class Player < Trainer
|
||||
@outfit = 0
|
||||
@badges = [false] * 8
|
||||
@money = Settings::INITIAL_MONEY
|
||||
@coins = 0
|
||||
@battle_points = 0
|
||||
@soot = 0
|
||||
@pokedex = Pokedex.new
|
||||
@pokegear = false
|
||||
@has_pokedex = false
|
||||
@has_pokegear = false
|
||||
@has_running_shoes = false
|
||||
@seen_storage_creator = false
|
||||
@mystery_gift_unlocked = false
|
||||
@mystery_gifts = []
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Player
|
||||
class Player < Trainer
|
||||
# Represents the player's Pokédex.
|
||||
class Pokedex
|
||||
# @return [Array<Integer>] an array of accessible Dexes
|
||||
@@ -105,6 +105,9 @@ class Player
|
||||
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
|
||||
@@ -125,7 +128,7 @@ class Player
|
||||
def set_shadow_pokemon_owned(species)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return if species_id.nil?
|
||||
@owned[species_id] = true
|
||||
@owned_shadow[species_id] = true
|
||||
self.refresh_accessible_dexes
|
||||
end
|
||||
|
||||
@@ -137,6 +140,14 @@ class Player
|
||||
return @owned[species_id] == true
|
||||
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)
|
||||
species_id = GameData::Species.try_get(species)&.species
|
||||
return false if species_id.nil?
|
||||
return @owned_shadow[species_id] == true
|
||||
end
|
||||
|
||||
# Returns the amount of owned Pokémon.
|
||||
# If a region ID is given, returns the amount of owned Pokémon
|
||||
# in that region.
|
||||
@@ -217,12 +228,6 @@ class Player
|
||||
return @unlocked_dexes.length
|
||||
end
|
||||
|
||||
# Shorthand for +self.accessible_dexes.length+.
|
||||
# @return [Integer] amount of accessible Dexes
|
||||
def accessible_dexes_count
|
||||
return @accessible_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
|
||||
|
||||
@@ -26,6 +26,7 @@ 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
|
||||
|
||||
@@ -33,6 +34,9 @@ class Player < Trainer
|
||||
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)
|
||||
@@ -91,10 +95,14 @@ class PokeBattle_Trainer
|
||||
trainer.seen.each_with_index { |value, i| ret.pokedex.set_seen(i) if value }
|
||||
trainer.owned.each_with_index { |value, i| ret.pokedex.set_owned(i) if value }
|
||||
trainer.formseen.each_with_index do |value, i|
|
||||
ret.pokedex.seen_forms[GameData::Species.get(i).species] = [value[0].clone, value[1].clone] if value
|
||||
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|
|
||||
ret.pokedex.set_last_form_seen(GameData::Species.get(i).species, value[0], value[1]) if value
|
||||
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|
|
||||
@@ -102,7 +110,7 @@ class PokeBattle_Trainer
|
||||
end
|
||||
end
|
||||
ret.has_pokedex = trainer.pokedex
|
||||
ret.pokegear = trainer.pokegear
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user