Class: PFM::Hall_of_Fame

Inherits:
Object show all
Defined in:
scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb

Overview

Class describing the Hall_of_Fame logic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game_state = PFM.game_state) ⇒ Hall_of_Fame

Create a new hall of fame

Parameters:

  • game_state (PFM::GameState) (defaults to: PFM.game_state)

    variable responsive of containing the whole game state for easier access



13
14
15
16
# File 'scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb', line 13

def initialize(game_state = PFM.game_state)
  @player_victory = []
  @game_state = game_state
end

Instance Attribute Details

#game_statePFM::GameState

Get the game state responsive of the whole game state

Returns:



9
10
11
# File 'scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb', line 9

def game_state
  @game_state
end

#player_victoryArray

Array containing every victory of the player

Returns:

  • (Array)


6
7
8
# File 'scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb', line 6

def player_victory
  @player_victory
end

Instance Method Details

#register_victory(mode = :league)

Register a win in the Pokemon League for the player

Parameters:

  • mode (Symbol) (defaults to: :league)

    the symbol designing the type of victory : possible victory are :league and :title_defense



20
21
22
23
24
25
26
27
28
29
30
# File 'scripts/01450 Systems/00300 Hall of fame/00001 PFM/02000 Hall_of_Fame.rb', line 20

def register_victory(mode = :league)
  pokemon_array = []
  @game_state.actors.each { |pkm| pokemon_array << pkm.clone }
  victory = {
    mode: mode,
    team: pokemon_array,
    play_time: PFM.game_state.trainer.play_time_text,
    entry_date: Time.new
  }
  @player_victory << victory
end