Class: PFM::GameState

Inherits:
Object show all
Defined in:
docs/01450_Systems_00000_General_00010_GameState.rb,
docs/02000_Nuri_Yuri.rb,
docs/01450_Systems_00101_Dex.rb,
docs/01450_Systems_00103_Bag.rb,
docs/01450_Systems_09000_GTS.rb,
docs/01450_Systems_00203_Shop.rb,
docs/01450_Systems_99991_Wild.rb,
docs/01450_Systems_08000_Quest.rb,
docs/01450_Systems_00104_Trainer.rb,
docs/01450_Systems_00105_Options.rb,
docs/01450_Systems_00200_Storage.rb,
docs/01450_Systems_00201_Daycare.rb,
docs/01450_Systems_00202_Environment.rb,
docs/01450_Systems_08001_Mining_Game.rb,
docs/01450_Systems_00300_Hall_of_fame.rb,
docs/01450_Systems_99990_Global_Systems.rb

Overview

The game informations and Party management

The global object is stored in PFM.game_state

Author:

  • Nuri Yuri

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(battle = false, starting_language = 'en') ⇒ GameState

Create a new Pokemon Party

Parameters:

  • battle (Boolean) (defaults to: false)

    if its a party of a NPC battler

  • starting_language (String) (defaults to: 'en')

    the lang id of the game described by this object



169
170
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 169

def initialize(battle = false, starting_language = 'en')
end

Instance Attribute Details

#actorsArray<PFM::Pokemon>

The Pokemon of the Player

Returns:



32
33
34
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 32

def actors
  @actors
end

#bagPFM::Bag

The bag of the player

Returns:



126
127
128
# File 'docs/01450_Systems_00103_Bag.rb', line 126

def bag
  @bag
end

#berriesHash

The in game berry data

Returns:

  • (Hash)


164
165
166
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 164

def berries
  @berries
end

#daycarePFM::Daycare

The daycare management object

Returns:



240
241
242
# File 'docs/01450_Systems_00201_Daycare.rb', line 240

def daycare
  @daycare
end

#envPFM::Environment

The environment informations

Returns:



281
282
283
# File 'docs/01450_Systems_00202_Environment.rb', line 281

def env
  @env
end

#game_actorsGame_Actors

The $game_actors

Returns:



97
98
99
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 97

def game_actors
  @game_actors
end

#game_mapGame_Map

The $game_map

Returns:



113
114
115
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 113

def game_map
  @game_map
end

#game_partyGame_Party

The $game_party

Returns:



104
105
106
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 104

def game_party
  @game_party
end

#game_playerGame_Player

The $game_player

Returns:



120
121
122
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 120

def game_player
  @game_player
end

#game_screenGame_Screen

The $game_screen

Returns:



90
91
92
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 90

def game_screen
  @game_screen
end

#game_self_switchesGame_SelfSwitches

The $game_self_switches

Returns:



69
70
71
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 69

def game_self_switches
  @game_self_switches
end

#game_self_variablesGame_SelfVariables

The $game_self_variables

Returns:



76
77
78
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 76

def game_self_variables
  @game_self_variables
end

#game_switchesGame_Switches

The $game_switches

Returns:



59
60
61
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 59

def game_switches
  @game_switches
end

#game_systemGame_System

The $game_system

Returns:



83
84
85
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 83

def game_system
  @game_system
end

#game_tempGame_Temp

The $game_temp

Returns:



127
128
129
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 127

def game_temp
  @game_temp
end

#game_variablesGame_Variables

The $game_variables

Returns:



49
50
51
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 49

def game_variables
  @game_variables
end

#hall_of_famePFM::Hall_of_Fame

The list of the victory in the Pokemon League

Returns:



22
23
24
# File 'docs/01450_Systems_00300_Hall_of_fame.rb', line 22

def hall_of_fame
  @hall_of_fame
end

#honey_treesArray<Hash{ Symbol => Integer}> (readonly)

Access to the honey tree information

Returns:

  • (Array<Hash{ Symbol => Integer}>)


85
86
87
# File 'docs/01450_Systems_99990_Global_Systems.rb', line 85

def honey_trees
  @honey_trees
end

#level_max_limitInteger

Maximum level an allied Pokemon can reach

Returns:

  • (Integer)


159
160
161
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 159

def level_max_limit
  @level_max_limit
end

#mining_gamePFM::MiningGame

Stats and booleans relative to the Mining Game

Returns:



359
360
361
# File 'docs/01450_Systems_08001_Mining_Game.rb', line 359

def mining_game
  @mining_game
end

#nuri_yuri_dynamic_light

Access to the information of the current dynamic light state (Battle / Save)



181
182
183
# File 'docs/02000_Nuri_Yuri.rb', line 181

def nuri_yuri_dynamic_light
  @nuri_yuri_dynamic_light
end

#nuzlockeNuzlocke

The nuzlocke logic

Returns:



134
135
136
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 134

def nuzlocke
  @nuzlocke
end

#online_pokemon

Returns the value of attribute online_pokemon.



296
297
298
# File 'docs/01450_Systems_09000_GTS.rb', line 296

def online_pokemon
  @online_pokemon
end

#optionsPFM::Options

The game options

Returns:



76
77
78
# File 'docs/01450_Systems_00105_Options.rb', line 76

def options
  @options
end

#pathfinding_requestsArray<Object>

The pathfinding requests

Returns:



143
144
145
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 143

def pathfinding_requests
  @pathfinding_requests
end

#pokedexPFM::Pokedex

The Pokedex of the player

Returns:



156
157
158
# File 'docs/01450_Systems_00101_Dex.rb', line 156

def pokedex
  @pokedex
end

#questsPFM::Quests

The player quests informations

Returns:



362
363
364
# File 'docs/01450_Systems_08000_Quest.rb', line 362

def quests
  @quests
end

#repel_countInteger Also known as: get_repel_count

The number of steps the repel will work

Returns:

  • (Integer)


41
42
43
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 41

def repel_count
  @repel_count
end

#shopPFM::Shop

The list of the limited shops

Returns:



81
82
83
# File 'docs/01450_Systems_00203_Shop.rb', line 81

def shop
  @shop
end

#stepsInteger

The number of steps the player did

Returns:

  • (Integer)


45
46
47
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 45

def steps
  @steps
end

#storagePFM::Storage

The PC storage of the player

Returns:



197
198
199
# File 'docs/01450_Systems_00200_Storage.rb', line 197

def storage
  @storage
end

#tint_time_setSymbol?

Name of the time set to use (nil = default)

Returns:

  • (Symbol, nil)


148
149
150
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 148

def tint_time_set
  @tint_time_set
end

#trainerPFM::Trainer

The informations about the player and the game

Returns:



114
115
116
# File 'docs/01450_Systems_00104_Trainer.rb', line 114

def trainer
  @trainer
end

#user_dataHash (readonly)

User data

Returns:

  • (Hash)


151
152
153
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 151

def user_data
  @user_data
end

#wild_battlePFM::Wild_Battle

The information about the Wild Battle

Returns:



285
286
287
# File 'docs/01450_Systems_99991_Wild.rb', line 285

def wild_battle
  @wild_battle
end

Class Method Details

.on_expand_global_variables(name, &block)

Add a new proc on global variable expand

Parameters:

  • name (Symbol)

    name of the block to add

  • block (Proc)

    proc to execute with the GameState context



27
28
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 27

def on_expand_global_variables(name, &block)
end

.on_initialize(name, &block)

Add a new proc on initialize (for battle)

Parameters:

  • name (Symbol)

    name of the block to add

  • block (Proc)

    proc to execute with the GameState context



17
18
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 17

def on_initialize(name, &block)
end

.on_player_initialize(name, &block)

Add a new proc on player initialize (for the player)

Parameters:

  • name (Symbol)

    name of the block to add

  • block (Proc)

    proc to execute with the GameState context



22
23
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 22

def on_player_initialize(name, &block)
end

Instance Method Details

#add_money(n)

Add money

Parameters:

  • n (Integer)

    amount of money to add



224
225
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 224

def add_money(n)
end

#add_pokemon(pkmn) ⇒ Boolean, Integer

Add a Pokemon to the pary (also update the Pokedex Informations)

Parameters:

Returns:

  • (Boolean, Integer)

    Box index if stored in a box, false if failed, true if stored in the Party



273
274
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 273

def add_pokemon(pkmn)
end

#alive?Boolean

Is the party able to start a battle ?

Returns:

  • (Boolean)


252
253
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 252

def alive?
end

#battle_starting_update

Note:

this methods calls common event 1 if a battle must start

Update section to detect if a wild battle must start



187
188
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 187

def battle_starting_update
end

#can_learn?(id) ⇒ Boolean #can_learn?(id, index) ⇒ Integer, false

Checks if one Pokemon of the party can learn the requested skill.

Overloads:

  • #can_learn?(id) ⇒ Boolean

    Parameters:

    • id (Integer, Symbol)

      the id of the skill in the database

    Returns:

    • (Boolean)
  • #can_learn?(id, index) ⇒ Integer, false

    Returns the position of the first pokemon that meets conditions

    Parameters:

    • id (Integer, Symbol)

      the id of the skill in the database

    • index (true)

      indicating to return the index

    Returns:

    • (Integer, false)


350
351
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 350

def can_learn?(id, index = false)
end

#can_learn_index(id) ⇒ Integer, false

Return the index of the Pokemon who can learn the specified skill

Parameters:

  • id (Integer, Symbol)

    the id of the skill in the database

Returns:

  • (Integer, false)


355
356
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 355

def can_learn_index(id)
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.

Overloads:

  • #can_learn_or_learnt?(id) ⇒ Boolean

    Parameters:

    • id (Integer, Symbol)

      the id of the skill in the database

    Returns:

    • (Boolean)
  • #can_learn_or_learnt?(id, index) ⇒ Integer, false

    Returns the position of the first pokemon that meets conditions

    Parameters:

    • id (Integer, Symbol)

      the id of the skill in the database

    • index (true)

      indicating to return the index

    Returns:

    • (Integer, false)


366
367
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 366

def can_learn_or_learnt?(id, index = 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

Parameters:

  • id (Integer, Symbol)

    the id of the skill in the database

Returns:

  • (Integer, false)


371
372
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 371

def can_learn_or_learnt_index(id)
end

#cant_process_event_tasks?Boolean

Tell if EventTasks can’t process

Returns:

  • (Boolean)


202
203
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 202

def cant_process_event_tasks?
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

Parameters:

  • arr (Array) (defaults to: [])

    ids of the banned Pokemon

Returns:

  • (Boolean)


299
300
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 299

def contain_enough_selectable_pokemon?(arr = [])
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

Parameters:

  • id (Integer, Symbol)

    id of the Pokemon in the database

  • level (Integer, nil) (defaults to: nil)

    the level required

  • form (Integer, nil) (defaults to: nil)

    the form of the Pokemon

  • shiny (Boolean, nil) (defaults to: nil)

    if the Pokemon should be shiny or not

  • index (Boolean) (defaults to: false)

    if you want an index when found

Returns:

  • (Boolean, Integer)

    if the Pokemon has been found



293
294
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 293

def contain_matching_pokemon?(id, level = nil, form = nil, shiny = nil, index: 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

Parameters:

  • id (Integer, Symbol)

    ID of the ability in the database

  • index (Boolean) (defaults to: false)

    if the method return the index of the Pokemon that has the ability

Returns:

  • (Boolean, Integer)


333
334
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 333

def contain_pokemon_with_the_ability?(id, index = 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

Parameters:

  • id (Integer, Symbol)

    ID of the skill in the database

  • index (Boolean) (defaults to: false)

    if the method return the index of the Pokemon that has the skill

Returns:

  • (Boolean, Integer)


321
322
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 321

def contain_pokemon_with_the_skill?(id, index = false)
end

#dead?Boolean

Is the party not able to start a battle ?

Returns:

  • (Boolean)


248
249
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 248

def dead?
end

#empty?Boolean

Is the party empty ?

Returns:

  • (Boolean)


240
241
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 240

def empty?
end

#expand_global_var

Expand the global variable with the instance variables of the object



180
181
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 180

def expand_global_var
end

#find_pokemon(criteria) ⇒ PFM::Pokemon?

Return the Pokemon that match the specific criteria

Parameters:

  • criteria (Hash)

    list of property linked to a value to check in order to find the Pokemon

Returns:



376
377
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 376

def find_pokemon(criteria)
end

#first_pokemon_alive_index

Index of the first pokemon alive in the party



259
260
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 259

def first_pokemon_alive_index
end

#full?Boolean

Is the party full ?

Returns:

  • (Boolean)


244
245
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 244

def full?
end

#hatch_check_update

Update the remaining steps of all the Egg to hatch



195
196
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 195

def hatch_check_update
end

#heal_party

Heal the pokemon in the Party



311
312
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 311

def heal_party
end

#increase_stepsArray

Increase the @step and manage events that trigger each steps

Returns:

  • (Array)

    informations about events that has been triggered.



206
207
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 206

def increase_steps
end

#load_parameters

Load some parameters (audio volume & text)



231
232
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 231

def load_parameters
end

#lose_money(n)

Lose money

Parameters:

  • n (Integer)

    amount of money to lose



228
229
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 228

def lose_money(n)
end

#loyalty_update

Update the loyalty process of the pokemon



198
199
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 198

def loyalty_update
end

#max_levelInteger

Return the maximum level of the Pokemon in the Party

Returns:

  • (Integer)


315
316
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 315

def max_level
end

#moneyInteger

Return the money the player has

Returns:

  • (Integer)


216
217
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 216

def money
end

#money=(v)

Change the money the player has

Parameters:

  • v (Integer)


220
221
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 220

def money=(v)
end

#online_idInteger

Retrieve the online ID of the trainer

Returns:

  • (Integer)


299
300
# File 'docs/01450_Systems_09000_GTS.rb', line 299

def online_id
end

#poison_update

Update the processing of the poison event



190
191
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 190

def poison_update
end

#pokemon_ability_index(id) ⇒ Integer, false

Get the index of the Pokemon that has the specified ability

Parameters:

  • id (Integer, Symbol)

    ID of the ability in the database

Returns:

  • (Integer, false)


339
340
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 339

def pokemon_ability_index(id)
end

#pokemon_alive(max = @actors.size)

Number of pokemon alive in the party

Parameters:

  • max (Integer) (defaults to: @actors.size)

    the number of Pokemon to check from the begining of the party



256
257
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 256

def pokemon_alive(max = @actors.size)
end

#pokemon_index(id, level = nil, form = nil, shiny = nil) ⇒ Integer, false

Find a specific Pokemon index in the party

Parameters:

  • id (Integer, Symbol)

    id of the Pokemon in the database

  • level (Integer, nil) (defaults to: nil)

    the level required

  • form (Integer, nil) (defaults to: nil)

    the form of the Pokemon

  • shiny (Boolean, nil) (defaults to: nil)

    if the Pokemon should be shiny or not

Returns:

  • (Integer, false)

    index of the Pokemon in the party



308
309
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 308

def pokemon_index(id, level = nil, form = nil, shiny = nil)
end

#pokemon_skill_index(id) ⇒ Integer, false

Get the index of the Pokemon that has the specified skill

Parameters:

  • id (Integer, Symbol)

    ID of the skill in the database

Returns:

  • (Integer, false)


327
328
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 327

def pokemon_skill_index(id)
end

#raw_online_idInteger?

The raw_online_id doesn’t have the checksum to get a new ID, this is used for when you do new game.

Returns:

  • (Integer, nil)


304
305
# File 'docs/01450_Systems_09000_GTS.rb', line 304

def raw_online_id
end

#remove_pokemon(var, by_id = false, all = false)

Remove a pokemon from the party

Parameters:

  • var (Integer, Symbol)

    the var value (index or id)

  • by_id (Boolean) (defaults to: false)

    if the pokemon are removed by their id

  • all (Boolean) (defaults to: false)

    if every pokemon that has the id are removed



279
280
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 279

def remove_pokemon(var, by_id = false, all = false)
end

#repel_update

Update the processing of the repel



183
184
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 183

def repel_update
end

#sizeInteger

Return the size of the party

Returns:

  • (Integer)


236
237
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 236

def size
end

#specific_alive?(id) ⇒ Boolean

Test if a specific Pokémon is able to fight or not

Examples:

Checking if Pikachu is alive in the party

PFM.game_state.specific_alive?(25)

Checking if alolan Meowth is alive in the party

PFM.game_state.specific_alive?(52) { |pokemon| pokemon.form == 1 }

Parameters:

  • id (Integer)

    ID of the Pokemon

Returns:

  • (Boolean)


268
269
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 268

def specific_alive?(id)
end

#switch_pokemon(first, second)

Switch pokemon in the party

Parameters:

  • first (Integer)

    index of the first pokemon to switch

  • second (Integer)

    index of the second pokemon to switch



284
285
# File 'docs/01450_Systems_00000_General_00010_GameState.rb', line 284

def switch_pokemon(first, second)
end