Class: PFM::Trainer
- Defined in:
- scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb
Overview
The actor trainer data informations
Main object stored in $trainer and PFM.game_state.trainer
Constant Summary collapse
- TIME_FORMAT =
Time format
'%02d:%02d'
Instance Attribute Summary collapse
-
#badges ⇒ Array<Boolean>
The badges this trainer object has collected.
-
#current_version ⇒ Integer
The current version de PSDK (update management).
-
#game_state ⇒ PFM::GameState
Get the game state responsive of the whole game state.
-
#game_version ⇒ Integer
The game version in which this object has been saved or created.
-
#id_boy ⇒ Integer
The internal ID of the trainer as a boy.
-
#id_girl ⇒ Integer
The internal ID of the trainer as a girl.
-
#name_boy ⇒ String
Name of the trainer as a boy (Default to Palbolsky).
-
#name_girl ⇒ String
Name of the trainer as a girl (Default to Yuri).
-
#play_time ⇒ Integer
The time the player has played as this Trainer object.
-
#playing_girl ⇒ Boolean
If the player is playing the girl trainer.
-
#region ⇒ Integer
The ID of the current region in which the trainer is.
-
#start_time ⇒ Integer
The time in second when the Trainer object has been created (computer time).
Instance Method Summary collapse
-
#badge_counter ⇒ Integer
Return the number of badges the trainer got.
-
#badge_obtained?(badge_num, region = 1) ⇒ Boolean
(also: #has_badge?)
Has the player got the badge ?.
-
#define_gender(playing_girl)
(also: #set_gender)
Set the gender of the trainer.
-
#id ⇒ Integer
Return the id of the trainer.
-
#initialize(game_state = PFM.game_state) ⇒ Trainer
constructor
Create a new Trainer.
-
#load_time
Load the time counter with the current time.
-
#name ⇒ String
Return the name of the trainer.
-
#name=(value)
Change the name of the trainer.
-
#play_time_text ⇒ String
Return the play time text (without updating it).
-
#redefine_var
Redefine some variable RMXP uses with the right values.
-
#set_badge(badge_num, region = 1, value = true)
Set the got state of a badge.
-
#time_counter ⇒ Integer
Return the time counter (current time - time counter).
-
#update_play_time ⇒ Integer
Update the play time and reload the time counter.
Constructor Details
#initialize(game_state = PFM.game_state) ⇒ Trainer
Create a new Trainer
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 48 def initialize(game_state = PFM.game_state) @name_boy = default_male_name @name_girl = default_female_name @game_state = game_state game_state.game_switches[Yuki::Sw::Gender] = @playing_girl = false game_state.game_variables[Yuki::Var::Player_ID] = @id_boy = rand(0x3FFFFFFF) @id_girl = (@id_boy ^ 0x28F4AB4C) @start_time = Time.new.to_i @play_time = 0 @badges = Array.new(6 * 8, false) @region = 0 @game_version = Configs.infos.game_version @current_version = PSDK_Version rescue 0 @time_counter = 0 load_time end |
Instance Attribute Details
#badges ⇒ Array<Boolean>
The badges this trainer object has collected
32 33 34 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 32 def badges @badges end |
#current_version ⇒ Integer
The current version de PSDK (update management). It's saved like game_version
41 42 43 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 41 def current_version @current_version end |
#game_state ⇒ PFM::GameState
Get the game state responsive of the whole game state
44 45 46 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 44 def game_state @game_state end |
#game_version ⇒ Integer
The game version in which this object has been saved or created
38 39 40 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 38 def game_version @game_version end |
#id_boy ⇒ Integer
The internal ID of the trainer as a boy
20 21 22 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 20 def id_boy @id_boy end |
#id_girl ⇒ Integer
The internal ID of the trainer as a girl. It's equal to id_boy ^ 0x28F4AB4C
23 24 25 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 23 def id_girl @id_girl end |
#name_boy ⇒ String
Name of the trainer as a boy (Default to Palbolsky)
11 12 13 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 11 def name_boy @name_boy end |
#name_girl ⇒ String
Name of the trainer as a girl (Default to Yuri)
14 15 16 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 14 def name_girl @name_girl end |
#play_time ⇒ Integer
The time the player has played as this Trainer object
29 30 31 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 29 def play_time @play_time end |
#playing_girl ⇒ Boolean
If the player is playing the girl trainer
17 18 19 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 17 def @playing_girl end |
#region ⇒ Integer
The ID of the current region in which the trainer is
35 36 37 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 35 def region @region end |
#start_time ⇒ Integer
The time in second when the Trainer object has been created (computer time)
26 27 28 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 26 def start_time @start_time end |
Instance Method Details
#badge_counter ⇒ Integer
Return the number of badges the trainer got
117 118 119 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 117 def badge_counter @badges.count { |badge| badge == true } end |
#badge_obtained?(badge_num, region = 1) ⇒ Boolean Also known as: has_badge?
Has the player got the badge ?
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 141 def badge_obtained?(badge_num, region = 1) region -= 1 badge_num -= 1 if (region * 8) >= @badges.size log_error('Le jeu ne prévoit pas de badge pour cette région. PSDK_ERR n°000_006') elsif badge_num < 0 || badge_num > 7 log_error('Le numéro de badge indiqué est invalide, il doit être entre 1 et 8. PSDK_ERR n°000_007') else return @badges[(region * 8) + badge_num] end return false end |
#define_gender(playing_girl) Also known as: set_gender
Set the gender of the trainer
157 158 159 160 161 162 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 157 def define_gender() @playing_girl = game_state.game_switches[Yuki::Sw::Gender] = game_state.game_variables[Yuki::Var::Player_ID] = id game_state.game_actors[1].name = name end |
#id ⇒ Integer
Return the id of the trainer
84 85 86 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 84 def id return @playing_girl ? @id_girl : @id_boy end |
#load_time
Load the time counter with the current time
96 97 98 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 96 def load_time @time_counter = Time.new.to_i end |
#name ⇒ String
Return the name of the trainer
67 68 69 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 67 def name return @playing_girl ? @name_girl : @name_boy end |
#name=(value)
Change the name of the trainer
73 74 75 76 77 78 79 80 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 73 def name=(value) if @playing_girl @name_girl = value else @name_boy = value end game_state.game_actors[1].name = value end |
#play_time_text ⇒ String
Return the play time text (without updating it)
167 168 169 170 171 172 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 167 def play_time_text time = @play_time hours = time / 3600 minutes = (time - 3600 * hours) / 60 return format(TIME_FORMAT, hours, minutes) end |
#redefine_var
Redefine some variable RMXP uses with the right values
89 90 91 92 93 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 89 def redefine_var game_state.game_variables[Yuki::Var::Player_ID] = id game_state.game_actors[1].name = name # redefinir les badges end |
#set_badge(badge_num, region = 1, value = true)
Set the got state of a badge
125 126 127 128 129 130 131 132 133 134 135 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 125 def set_badge(badge_num, region = 1, value = true) region -= 1 badge_num -= 1 if (region * 8) >= @badges.size log_error('Le jeu ne prévoit pas de badge pour cette région. PSDK_ERR n°000_006') elsif badge_num < 0 || badge_num > 7 log_error('Le numéro de badge indiqué est invalide, il doit être entre 1 et 8. PSDK_ERR n°000_007') else @badges[(region * 8) + badge_num] = value end end |
#time_counter ⇒ Integer
Return the time counter (current time - time counter)
102 103 104 105 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 102 def time_counter counter = Time.new.to_i - @time_counter return counter < 0 ? 0 : counter end |
#update_play_time ⇒ Integer
Update the play time and reload the time counter
109 110 111 112 113 |
# File 'scripts/01450 Systems/00104 Trainer/00001 PFM/00400 Trainer.rb', line 109 def update_play_time @play_time += time_counter load_time return @play_time end |