Class: PFM::GameState
- Defined in:
- scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb,
scripts/01450 Systems/09000 GTS/09000 GTS.rb,
scripts/01450 Systems/00103 Bag/00001 PFM/00300 Bag.rb,
scripts/01450 Systems/00203 Shop/00001 PFM/00700 Shop.rb,
scripts/01450 Systems/00101 Dex/00001 PFM/00100 Pokedex.rb,
scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb,
scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb,
scripts/01450 Systems/00105 Options/00001 PFM/00500 Options.rb,
scripts/01450 Systems/00201 Daycare/00001 PFM/01100 Daycare.rb,
scripts/01450 Systems/99991 Wild/00100 Wild Battle (manager).rb,
scripts/01450 Systems/00200 Storage/00001 PFM_Storage/00001 Main.rb,
scripts/02000 Nuri Yuri/00001 DynamicLight/00003 DL PokemonParty.rb,
scripts/01450 Systems/08000 Quest/00001 PFM_Quest/00001 PFM Quests.rb,
scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb,
scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb,
scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb,
scripts/01450 Systems/08001 Mining Game/00020 PFM_Mining_Game/00001 MiningGame.rb
Overview
The game informations and Party management
The global object is stored in PFM.game_state
Constant Summary collapse
- ON_INITIALIZE =
Constant containing all the proc to call when creating a new GameState object (for battle)
{}
- ON_PLAYER_INITIALIZE =
Constant containing all the proc to call when creating a new GameState object (for the player)
{}
- ON_EXPAND_GLOBAL_VARIABLES =
Constant containing all the proc to call when expanding the global variables
{}
- FASTER_HATCH_ABILITIES =
Abilities that increase the hatch speed
%i[magma_armor flame_body steam_engine]
Instance Attribute Summary collapse
-
#actors ⇒ Array<PFM::Pokemon>
The Pokemon of the Player.
-
#bag ⇒ PFM::Bag
The bag of the player.
-
#berries ⇒ Hash
The in game berry data.
-
#daycare ⇒ PFM::Daycare
The daycare management object.
-
#env ⇒ PFM::Environment
The environment informations.
-
#game_actors ⇒ Game_Actors
The $game_actors.
-
#game_map ⇒ Game_Map
The $game_map.
-
#game_party ⇒ Game_Party
The $game_party.
-
#game_player ⇒ Game_Player
The $game_player.
-
#game_screen ⇒ Game_Screen
The $game_screen.
-
#game_self_switches ⇒ Game_SelfSwitches
The $game_self_switches.
-
#game_self_variables ⇒ Game_SelfVariables
The $game_self_variables.
-
#game_switches ⇒ Game_Switches
The $game_switches.
-
#game_system ⇒ Game_System
The $game_system.
-
#game_temp ⇒ Game_Temp
The $game_temp.
-
#game_variables ⇒ Game_Variables
The $game_variables.
-
#hall_of_fame ⇒ PFM::Hall_of_Fame
The list of the victory in the Pokemon League.
-
#honey_trees ⇒ Array<Hash{ Symbol => Integer}>
readonly
Access to the honey tree information.
-
#level_max_limit ⇒ Integer
Maximum level an allied Pokemon can reach.
-
#mining_game ⇒ PFM::MiningGame
Stats and booleans relative to the Mining Game.
-
#nuri_yuri_dynamic_light
Access to the information of the current dynamic light state (Battle / Save).
-
#nuzlocke ⇒ Nuzlocke
The nuzlocke logic.
-
#online_pokemon
Returns the value of attribute online_pokemon.
-
#options ⇒ PFM::Options
The game options.
-
#pathfinding_requests ⇒ Array<Object>
The pathfinding requests.
-
#pokedex ⇒ PFM::Pokedex
The Pokedex of the player.
-
#quests ⇒ PFM::Quests
The player quests informations.
-
#repel_count ⇒ Integer
(also: #get_repel_count)
The number of steps the repel will work.
-
#shop ⇒ PFM::Shop
The list of the limited shops.
-
#steps ⇒ Integer
The number of steps the player did.
-
#storage ⇒ PFM::Storage
The PC storage of the player.
-
#tint_time_set ⇒ Symbol?
Name of the time set to use (nil = default).
-
#trainer ⇒ PFM::Trainer
The informations about the player and the game.
-
#user_data ⇒ Hash
readonly
User data.
-
#wild_battle ⇒ PFM::Wild_Battle
The information about the Wild Battle.
Class Method Summary collapse
-
.on_expand_global_variables(name, &block)
Add a new proc on global variable expand.
-
.on_initialize(name, &block)
Add a new proc on initialize (for battle).
-
.on_player_initialize(name, &block)
Add a new proc on player initialize (for the player).
Instance Method Summary collapse
-
#add_money(n)
Add money.
-
#add_pokemon(pkmn) ⇒ Boolean, Integer
Add a Pokemon to the pary (also update the Pokedex Informations).
-
#alive? ⇒ Boolean
Is the party able to start a battle ?.
- #battle_starting_update
-
#can_learn?(id, index = false)
Checks if one Pokemon of the party can learn the requested skill.
-
#can_learn_index(id) ⇒ Integer, false
Return the index of the Pokemon who can learn the specified skill.
-
#can_learn_or_learnt?(id, index = false)
Checks if one Pokemon of the party can learn or has learnt the requested skill.
-
#can_learn_or_learnt_index(id) ⇒ Integer, false
Return the index of the Pokemon who can learn or has learn the specified skill.
-
#cant_process_event_tasks? ⇒ Boolean
Tell if EventTasks can't process.
-
#contain_enough_selectable_pokemon?(arr = []) ⇒ Boolean
(also: #has_enough_selectable_pokemon?)
Check if the player has enough Pokemon to choose in its party Doesn't count banned Pokemon.
-
#contain_matching_pokemon?(id, level = nil, form = nil, shiny = nil, index: false) ⇒ Boolean, Integer
(also: #has_pokemon?)
Check if the player has a specific Pokemon in its party.
-
#contain_pokemon_with_the_ability?(id, index = false) ⇒ Boolean, Integer
(also: #has_ability?)
Check if the party has a Pokemon with a specific ability.
-
#contain_pokemon_with_the_skill?(id, index = false) ⇒ Boolean, Integer
(also: #has_skill?)
Check if the party has a Pokemon with a specific skill.
-
#dead? ⇒ Boolean
Is the party not able to start a battle ?.
-
#empty? ⇒ Boolean
Is the party empty ?.
-
#expand_global_var
Expand the global variable with the instance variables of the object.
-
#find_pokemon(criteria) ⇒ PFM::Pokemon?
Return the Pokemon that match the specific criteria.
-
#first_pokemon_alive_index
Index of the first pokemon alive in the party.
-
#full? ⇒ Boolean
Is the party full ?.
-
#hatch_check_update
Update the remaining steps of all the Egg to hatch.
-
#heal_party
Heal the pokemon in the Party.
-
#increase_steps ⇒ Array
Increase the @step and manage events that trigger each steps.
-
#initialize(battle = false, starting_language = 'en') ⇒ GameState
constructor
Create a new Pokemon Party.
-
#load_parameters
Load some parameters (audio volume & text).
-
#lose_money(n)
Lose money.
-
#loyalty_update
Update the loyalty process of the pokemon.
-
#max_level ⇒ Integer
Return the maximum level of the Pokemon in the Party.
-
#money ⇒ Integer
Return the money the player has.
-
#money=(v)
Change the money the player has.
-
#online_id ⇒ Integer
Retrieve the online ID of the trainer.
-
#poison_update
Update the processing of the poison event.
-
#pokemon_ability_index(id) ⇒ Integer, false
Get the index of the Pokemon that has the specified ability.
-
#pokemon_alive(max = @actors.size)
Number of pokemon alive in the party.
-
#pokemon_index(id, level = nil, form = nil, shiny = nil) ⇒ Integer, false
Find a specific Pokemon index in the party.
-
#pokemon_skill_index(id) ⇒ Integer, false
Get the index of the Pokemon that has the specified skill.
-
#raw_online_id ⇒ Integer?
The raw_online_id doesn't have the checksum to get a new ID, this is used for when you do new game.
-
#remove_pokemon(var, by_id = false, all = false)
Remove a pokemon from the party.
-
#repel_update
Update the processing of the repel.
-
#size ⇒ Integer
Return the size of the party.
-
#specific_alive?(id) ⇒ Boolean
Test if a specific Pokémon is able to fight or not.
-
#switch_pokemon(first, second)
Switch pokemon in the party.
Constructor Details
#initialize(battle = false, starting_language = 'en') ⇒ GameState
Create a new Pokemon Party
213 214 215 216 217 218 219 220 221 222 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 213 def initialize(battle = false, starting_language = 'en') @starting_language = starting_language ON_INITIALIZE.each_value do |block| instance_exec(&block) if block end return if battle game_state_initialize rmxp_boot unless $tester end |
Instance Attribute Details
#actors ⇒ Array<PFM::Pokemon>
The Pokemon of the Player
39 40 41 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 39 def actors @actors end |
#bag ⇒ PFM::Bag
The bag of the player
189 190 191 |
# File 'scripts/01450 Systems/00103 Bag/00001 PFM/00300 Bag.rb', line 189 def bag @bag end |
#berries ⇒ Hash
The in game berry data
207 208 209 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 207 def berries @berries end |
#daycare ⇒ PFM::Daycare
The daycare management object
516 517 518 |
# File 'scripts/01450 Systems/00201 Daycare/00001 PFM/01100 Daycare.rb', line 516 def daycare @daycare end |
#env ⇒ PFM::Environment
The environment informations
420 421 422 |
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 420 def env @env end |
#game_actors ⇒ Game_Actors
The $game_actors
121 122 123 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 121 def game_actors @game_actors end |
#game_map ⇒ Game_Map
The $game_map
141 142 143 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 141 def game_map @game_map end |
#game_party ⇒ Game_Party
The $game_party
130 131 132 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 130 def game_party @game_party end |
#game_player ⇒ Game_Player
The $game_player
150 151 152 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 150 def game_player @game_player end |
#game_screen ⇒ Game_Screen
The $game_screen
112 113 114 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 112 def game_screen @game_screen end |
#game_self_switches ⇒ Game_SelfSwitches
The $game_self_switches
85 86 87 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 85 def game_self_switches @game_self_switches end |
#game_self_variables ⇒ Game_SelfVariables
The $game_self_variables
94 95 96 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 94 def game_self_variables @game_self_variables end |
#game_switches ⇒ Game_Switches
The $game_switches
73 74 75 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 73 def game_switches @game_switches end |
#game_system ⇒ Game_System
The $game_system
103 104 105 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 103 def game_system @game_system end |
#game_temp ⇒ Game_Temp
The $game_temp
159 160 161 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 159 def game_temp @game_temp end |
#game_variables ⇒ Game_Variables
The $game_variables
61 62 63 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 61 def game_variables @game_variables end |
#hall_of_fame ⇒ PFM::Hall_of_Fame
The list of the victory in the Pokemon League
36 37 38 |
# File 'scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb', line 36 def hall_of_fame @hall_of_fame end |
#honey_trees ⇒ Array<Hash{ Symbol => Integer}> (readonly)
Access to the honey tree information
140 141 142 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 140 def honey_trees @honey_trees end |
#level_max_limit ⇒ Integer
Maximum level an allied Pokemon can reach
201 202 203 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 201 def level_max_limit @level_max_limit end |
#mining_game ⇒ PFM::MiningGame
Stats and booleans relative to the Mining Game
44 45 46 |
# File 'scripts/01450 Systems/08001 Mining Game/00020 PFM_Mining_Game/00001 MiningGame.rb', line 44 def mining_game @mining_game end |
#nuri_yuri_dynamic_light
Access to the information of the current dynamic light state (Battle / Save)
4 5 6 |
# File 'scripts/02000 Nuri Yuri/00001 DynamicLight/00003 DL PokemonParty.rb', line 4 def nuri_yuri_dynamic_light @nuri_yuri_dynamic_light end |
#nuzlocke ⇒ Nuzlocke
The nuzlocke logic
168 169 170 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 168 def nuzlocke @nuzlocke end |
#online_pokemon
Returns the value of attribute online_pokemon.
962 963 964 |
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 962 def online_pokemon @online_pokemon end |
#options ⇒ PFM::Options
The game options
115 116 117 |
# File 'scripts/01450 Systems/00105 Options/00001 PFM/00500 Options.rb', line 115 def @options end |
#pathfinding_requests ⇒ Array<Object>
The pathfinding requests
181 182 183 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 181 def pathfinding_requests @pathfinding_requests end |
#pokedex ⇒ PFM::Pokedex
The Pokedex of the player
342 343 344 |
# File 'scripts/01450 Systems/00101 Dex/00001 PFM/00100 Pokedex.rb', line 342 def pokedex @pokedex end |
#quests ⇒ PFM::Quests
The player quests informations
361 362 363 |
# File 'scripts/01450 Systems/08000 Quest/00001 PFM_Quest/00001 PFM Quests.rb', line 361 def quests @quests end |
#repel_count ⇒ Integer Also known as: get_repel_count
The number of steps the repel will work
51 52 53 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 51 def repel_count @repel_count end |
#shop ⇒ PFM::Shop
The list of the limited shops
224 225 226 |
# File 'scripts/01450 Systems/00203 Shop/00001 PFM/00700 Shop.rb', line 224 def shop @shop end |
#steps ⇒ Integer
The number of steps the player did
56 57 58 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 56 def steps @steps end |
#storage ⇒ PFM::Storage
The PC storage of the player
262 263 264 |
# File 'scripts/01450 Systems/00200 Storage/00001 PFM_Storage/00001 Main.rb', line 262 def storage @storage end |
#tint_time_set ⇒ Symbol?
Name of the time set to use (nil = default)
187 188 189 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 187 def tint_time_set @tint_time_set end |
#trainer ⇒ PFM::Trainer
The informations about the player and the game
192 193 194 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 192 def trainer @trainer end |
#user_data ⇒ Hash (readonly)
User data
191 192 193 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 191 def user_data @user_data end |
#wild_battle ⇒ PFM::Wild_Battle
The information about the Wild Battle
306 307 308 |
# File 'scripts/01450 Systems/99991 Wild/00100 Wild Battle (manager).rb', line 306 def wild_battle @wild_battle end |
Class Method Details
.on_expand_global_variables(name, &block)
Add a new proc on global variable expand
32 33 34 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 32 def (name, &block) ON_EXPAND_GLOBAL_VARIABLES[name] = block end |
.on_initialize(name, &block)
Add a new proc on initialize (for battle)
18 19 20 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 18 def on_initialize(name, &block) ON_INITIALIZE[name] = block end |
.on_player_initialize(name, &block)
Add a new proc on player initialize (for the player)
25 26 27 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 25 def on_player_initialize(name, &block) ON_PLAYER_INITIALIZE[name] = block end |
Instance Method Details
#add_money(n)
Add money
373 374 375 376 377 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 373 def add_money(n) return lose_money(-n) if n < 0 $game_party.gold += n end |
#add_pokemon(pkmn) ⇒ Boolean, Integer
Add a Pokemon to the pary (also update the Pokedex Informations)
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 66 def add_pokemon(pkmn) unless pkmn.egg? @pokedex.mark_seen(pkmn.id, pkmn.form, forced: true) @pokedex.mark_captured(pkmn.id) @pokedex.increase_creature_fought(pkmn.id) @pokedex.increase_creature_caught_count(pkmn.id) end if full? return @storage.current_box if @storage.store(pkmn) return false else @actors << pkmn return true end end |
#alive? ⇒ Boolean
Is the party able to start a battle ?
29 30 31 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 29 def alive? return !dead? end |
#battle_starting_update
270 271 272 273 274 275 276 277 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 270 def battle_starting_update return if cant_process_event_tasks? encounter_count = $game_player.encounter_count if !$game_system.encounter_disabled && ((@steps % encounter_count) == 0) && @wild_battle.available? $game_system.map_interpreter.launch_common_event(1) unless $game_system.map_interpreter.running? end end |
#can_learn?(id) ⇒ Boolean #can_learn?(id, index) ⇒ Integer, false
Checks if one Pokemon of the party can learn the requested skill.
232 233 234 235 236 237 238 239 240 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 232 def can_learn?(id, index = false) id = data_move(id).id if id.is_a?(Symbol) @actors.each_with_index do |pokemon, i| if pokemon&.can_learn?(id) return index ? i : true end end return false end |
#can_learn_index(id) ⇒ Integer, false
Return the index of the Pokemon who can learn the specified skill
245 246 247 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 245 def can_learn_index(id) can_learn?(id, true) end |
#can_learn_or_learnt?(id) ⇒ Boolean #can_learn_or_learnt?(id, index) ⇒ Integer, false
Checks if one Pokemon of the party can learn or has learnt the requested skill.
258 259 260 261 262 263 264 265 266 267 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 258 def can_learn_or_learnt?(id, index = false) id = data_move(id).id if id.is_a?(Symbol) @actors.each_with_index do |pokemon, i| next unless pokemon if pokemon.can_learn?(id) != false return index ? i : true end end return false end |
#can_learn_or_learnt_index(id) ⇒ Integer, false
Return the index of the Pokemon who can learn or has learn the specified skill
272 273 274 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 272 def can_learn_or_learnt_index(id) can_learn_or_learnt?(id, true) end |
#cant_process_event_tasks? ⇒ Boolean
Tell if EventTasks can't process
339 340 341 342 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 339 def cant_process_event_tasks? return ($game_player.move_route_forcing || $game_system.map_interpreter.running? || $game_temp. || $game_player.sliding) end |
#contain_enough_selectable_pokemon?(arr = []) ⇒ Boolean Also known as: has_enough_selectable_pokemon?
Check if the player has enough Pokemon to choose in its party Doesn't count banned Pokemon
136 137 138 139 140 141 142 143 144 145 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 136 def contain_enough_selectable_pokemon?(arr = []) if arr.any? count = @actors.count { |pokemon| !arr.include?(pokemon.id) } else count = $actors.size end return false unless $game_variables[Yuki::Var::Max_Pokemon_Select].between(1, size) return $game_variables[Yuki::Var::Max_Pokemon_Select] <= count end |
#contain_matching_pokemon?(id, level = nil, form = nil, shiny = nil, index: false) ⇒ Boolean, Integer Also known as: has_pokemon?
Check if the player has a specific Pokemon in its party
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 117 def contain_matching_pokemon?(id, level = nil, form = nil, shiny = nil, index: false) id = data_creature(id).id if id.is_a?(Symbol) @actors.each_with_index do |pokemon, i| next unless pokemon.id == id bool = true bool &&= pokemon.level == level if level bool &&= pokemon.form == form if form bool &&= pokemon.shiny == shiny unless shiny.nil? next unless bool return i if index return true end return false end |
#contain_pokemon_with_the_ability?(id, index = false) ⇒ Boolean, Integer Also known as: has_ability?
Check if the party has a Pokemon with a specific ability
205 206 207 208 209 210 211 212 213 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 205 def contain_pokemon_with_the_ability?(id, index = false) id = data_ability(id).id if id.is_a?(Symbol) @actors.each_with_index do |pokemon, i| if pokemon&.ability == id return index ? i : true end end return false end |
#contain_pokemon_with_the_skill?(id, index = false) ⇒ Boolean, Integer Also known as: has_skill?
Check if the party has a Pokemon with a specific skill
180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 180 def contain_pokemon_with_the_skill?(id, index = false) id = data_move(id).id if id.is_a?(Symbol) @actors.each_with_index do |pokemon, i| next unless pokemon pokemon.skills_set.each do |skill| if skill&.id == id return index ? i : true end end end return false end |
#dead? ⇒ Boolean
Is the party not able to start a battle ?
23 24 25 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 23 def dead? return empty? || @actors.all?(&:dead?) end |
#empty? ⇒ Boolean
Is the party empty ?
11 12 13 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 11 def empty? return @actors.empty? end |
#expand_global_var
Expand the global variable with the instance variables of the object
252 253 254 255 256 257 258 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 252 def PFM.game_state = self $pokemon_party = self ON_EXPAND_GLOBAL_VARIABLES.each_value do |block| instance_exec(&block) if block end end |
#find_pokemon(criteria) ⇒ PFM::Pokemon?
Return the Pokemon that match the specific criteria
279 280 281 282 283 284 285 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 279 def find_pokemon(criteria) @actors.find do |pokemon| criteria.each do |property, value| break(false) unless pokemon.send(property) == value end end end |
#first_pokemon_alive_index
Index of the first pokemon alive in the party
44 45 46 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 44 def first_pokemon_alive_index return @actors.index { |pokemon| !pokemon.dead? } end |
#full? ⇒ Boolean
Is the party full ?
17 18 19 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 17 def full? return @actors.size == 6 end |
#hatch_check_update
Update the remaining steps of all the Egg to hatch
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 308 def hatch_check_update return if cant_process_event_tasks? amca = FASTER_HATCH_ABILITIES.include?(@actors[0]&.ability_db_symbol || :__undef__) @actors.each do |pokemon| next unless pokemon.step_remaining > 0 pokemon.step_remaining -= 1 pokemon.step_remaining -= 1 if amca && (pokemon.step_remaining > 0) if pokemon.step_remaining == 0 pokemon.egg_finish $scene.delay_display_call(:display_egg_hatch, pokemon) end end end |
#heal_party
Heal the pokemon in the Party
159 160 161 162 163 164 165 166 167 168 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 159 def heal_party @actors.each do |pokemon| next unless pokemon pokemon.cure pokemon.hp = pokemon.max_hp pokemon.skills_set.each do |skill| skill&.pp = skill.ppmax end end end |
#increase_steps ⇒ Array
Increase the @step and manage events that trigger each steps
346 347 348 349 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 346 def increase_steps @steps += 1 $game_party.steps = @steps end |
#load_parameters
Load some parameters (audio volume & text)
389 390 391 392 393 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 389 def load_parameters Audio.music_volume = @options.music_volume Audio.sfx_volume = @options.sfx_volume Studio::Text.load end |
#lose_money(n)
Lose money
381 382 383 384 385 386 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 381 def lose_money(n) return add_money(-n) if n < 0 $game_party.gold -= n $game_party.gold = 0 if $game_party.gold < 0 end |
#loyalty_update
Update the loyalty process of the pokemon
325 326 327 328 329 330 331 332 333 334 335 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 325 def loyalty_update return unless (@steps - (@steps / 128) * 128) == 0 && rand(2) == 0 return if cant_process_event_tasks? @actors.each do |pokemon| value = pokemon.loyalty < 200 ? 2 : 1 value *= 2 if data_item(pokemon.captured_with).db_symbol == :luxury_ball value *= 1.5 if pokemon.item_db_symbol == :soothe_bell pokemon.loyalty += value.floor end end |
#max_level ⇒ Integer
Return the maximum level of the Pokemon in the Party
172 173 174 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 172 def max_level @actors.max_by(&:level)&.level || 0 end |
#money ⇒ Integer
Return the money the player has
361 362 363 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 361 def money return $game_party.gold end |
#money=(v)
Change the money the player has
367 368 369 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 367 def money=(v) $game_party.gold = v.to_i end |
#online_id ⇒ Integer
Retrieve the online ID of the trainer
966 967 968 969 970 971 972 973 974 975 |
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 966 def online_id if @online_id.nil? id = GTS::Core.obtain_online_id raise('GTS Error: Cannot get Online ID for GTS!') if id == 0 raise('GTS Error: Cannot set Online ID for GTS!') unless GTS::Core.register_online_id(id) @online_id = id end return @online_id end |
#poison_update
Update the processing of the poison event
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 280 def poison_update return unless (@steps - (@steps / 8) * 8) == 0 return if cant_process_event_tasks? psn_event = false @actors.each do |pokemon| next unless pokemon.poisoned? || pokemon.toxic? next if pokemon.ability_db_symbol == :immunity $scene.delay_display_call(:display_poison_animation) unless psn_event psn_event = true pokemon.hp -= (pokemon.toxic? ? 2 : 1) if pokemon.hp <= 0 && $game_switches[::Yuki::Sw::OW_Poison] $scene.delay_display_call(:display_poison_faint, pokemon) end next unless pokemon.hp <= 1 && !$game_switches[::Yuki::Sw::OW_Poison] pokemon.hp = 1 pokemon.cure $scene.delay_display_call(:display_poison_end, pokemon) end nuzlocke.clear_dead_pokemon if nuzlocke.enabled? end |
#pokemon_ability_index(id) ⇒ Integer, false
Get the index of the Pokemon that has the specified ability
219 220 221 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 219 def pokemon_ability_index(id) has_ability?(id, true) end |
#pokemon_alive(max = @actors.size)
Number of pokemon alive in the party
35 36 37 38 39 40 41 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 35 def pokemon_alive(max = @actors.size) alive = 0 max.times do |i| alive += 1 if @actors[i] && !@actors[i].dead? end return alive end |
#pokemon_index(id, level = nil, form = nil, shiny = nil) ⇒ Integer, false
Find a specific Pokemon index in the party
154 155 156 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 154 def pokemon_index(id, level = nil, form = nil, shiny = nil) has_pokemon?(id, level, form, shiny, index: true) end |
#pokemon_skill_index(id) ⇒ Integer, false
Get the index of the Pokemon that has the specified skill
197 198 199 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 197 def pokemon_skill_index(id) has_skill?(id, true) end |
#raw_online_id ⇒ Integer?
The raw_online_id doesn't have the checksum to get a new ID, this is used for when you do new game.
980 981 982 |
# File 'scripts/01450 Systems/09000 GTS/09000 GTS.rb', line 980 def raw_online_id @online_id end |
#remove_pokemon(var, by_id = false, all = false)
Remove a pokemon from the party
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 87 def remove_pokemon(var, by_id = false, all = false) var = data_creature(var).id if var.is_a?(Symbol) if by_id @actors.each_with_index do |pokemon, index| if pokemon.id == var @actors[index] = nil break unless all end end else @actors[var] = nil end @actors.compact! end |
#repel_update
Update the processing of the repel
261 262 263 264 265 266 267 268 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00200 Accessors.rb', line 261 def repel_update return if cant_process_event_tasks? if @repel_count > 0 @repel_count -= 1 $scene.delay_display_call(:display_repel_check) if @repel_count == 0 end end |
#size ⇒ Integer
Return the size of the party
5 6 7 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 5 def size return @actors.size end |
#specific_alive?(id) ⇒ Boolean
Test if a specific Pokémon is able to fight or not
55 56 57 58 59 60 61 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 55 def specific_alive?(id) if block_given? return @actors.any? { |pokemon| !pokemon.dead? && (pokemon.id == id || !id) && yield(pokemon) } else return @actors.any? { |pokemon| !pokemon.dead? && pokemon.id == id } end end |
#switch_pokemon(first, second)
Switch pokemon in the party
105 106 107 108 |
# File 'scripts/01450 Systems/00000 General/00010 GameState/00201 Management.rb', line 105 def switch_pokemon(first, second) @actors[first], @actors[second] = @actors[second], @actors[first] @actors.compact! end |