Class: Lich::Common::Char

Inherits:
Object
  • Object
show all
Defined in:
documented/attributes/char.rb

Overview

Represents a character in the game.

This class provides methods to access various character attributes.

See Also:

Class Method Summary collapse

Class Method Details

.che ⇒ String?

Returns the 'che' attribute of the character if applicable.

Returns:

  • (String, nil) —

    the character's 'che' value or nil



248
249
250
# File 'documented/attributes/char.rb', line 248

def self.che
  Infomon.get('che') if XMLData.game =~ /^GS/
end

.citizenship ⇒ String?

Returns the citizenship of the character if applicable.

Returns:

  • (String, nil) —

    the character's citizenship or nil



232
233
234
# File 'documented/attributes/char.rb', line 232

def self.citizenship
  Infomon.get('citizenship') if XMLData.game =~ /^GS/
end

.citizenship=(_val) ⇒ void

Deprecated.

This method returns an undefined value.

Sets the citizenship of the character (deprecated).

This method is no longer supported and should be updated in scripts.

Parameters:

  • _val (String) —

    the new citizenship value



242
243
244
# File 'documented/attributes/char.rb', line 242

def self.citizenship=(_val)
  echo "Updating via Char.citizenship is no longer supported. Update or fix your script."
end

.dump_info ⇒ void

Deprecated.

This method returns an undefined value.

Dumps character information (deprecated).

This method is no longer used and should be updated in scripts.



175
176
177
# File 'documented/attributes/char.rb', line 175

def self.dump_info
  echo "Char.dump_info is no longer used. Update or fix your script."
end

.encumbrance ⇒ String

Returns the current encumbrance of the character.

Returns:

  • (String) —

    the character's encumbrance text



39
40
41
# File 'documented/attributes/char.rb', line 39

def self.encumbrance
  XMLData.encumbrance_text
end

.health ⇒ Integer

Returns the current health of the character.

Returns:

  • (Integer) —

    the character's health



51
52
53
# File 'documented/attributes/char.rb', line 51

def self.health
  XMLData.health
end

.info ⇒ void

Deprecated.

This method returns an undefined value.

Returns character information (deprecated).

This method is no longer supported and should be updated in scripts.



217
218
219
# File 'documented/attributes/char.rb', line 217

def self.info
  echo "Char.info is no longer supported. Update or fix your script."
end

.init(_blah) ⇒ void

Deprecated.

This method returns an undefined value.

Initializes the character (deprecated).

This method is no longer used and should be updated in scripts.

Parameters:

  • _blah (Object) —

    unused parameter



15
16
17
# File 'documented/attributes/char.rb', line 15

def self.init(_blah)
  echo 'Char.init is no longer used. Update or fix your script.'
end

.load_info(_string) ⇒ void

Deprecated.

This method returns an undefined value.

Loads character information (deprecated).

This method is no longer used and should be updated in scripts.

Parameters:

  • _string (String) —

    unused parameter



185
186
187
# File 'documented/attributes/char.rb', line 185

def self.load_info(_string)
  echo "Char.load_info is no longer used. Update or fix your script."
end

.mana ⇒ Integer

Returns the current mana of the character.

Returns:

  • (Integer) —

    the character's mana



57
58
59
# File 'documented/attributes/char.rb', line 57

def self.mana
  XMLData.mana
end

.max_health ⇒ Integer

Returns the maximum health of the character.

Returns:

  • (Integer) —

    the character's maximum health



75
76
77
78
# File 'documented/attributes/char.rb', line 75

def self.max_health
  # Object.module_eval { XMLData.max_health }
  XMLData.max_health
end

.max_mana ⇒ Integer

Returns the maximum mana of the character.

Returns:

  • (Integer) —

    the character's maximum mana



92
93
94
# File 'documented/attributes/char.rb', line 92

def self.max_mana
  Object.module_eval { XMLData.max_mana }
end

.max_spirit ⇒ Integer

Returns the maximum spirit of the character.

Returns:

  • (Integer) —

    the character's maximum spirit



108
109
110
# File 'documented/attributes/char.rb', line 108

def self.max_spirit
  Object.module_eval { XMLData.max_spirit }
end

.max_stamina ⇒ Integer

Returns the maximum stamina of the character.

Returns:

  • (Integer) —

    the character's maximum stamina



124
125
126
# File 'documented/attributes/char.rb', line 124

def self.max_stamina
  Object.module_eval { XMLData.max_stamina }
end

.maxhealth ⇒ Integer

Deprecated.

Returns the maximum health of the character (deprecated).

This method is deprecated; use #max_health instead.

Returns:

  • (Integer) —

    the character's maximum health



85
86
87
88
# File 'documented/attributes/char.rb', line 85

def self.maxhealth
  Lich.deprecated("Char.maxhealth", "Char.max_health", caller[0], fe_log: true)
  Char.max_health
end

.maxmana ⇒ Integer

Deprecated.

Returns the maximum mana of the character (deprecated).

This method is deprecated; use #max_mana instead.

Returns:

  • (Integer) —

    the character's maximum mana



101
102
103
104
# File 'documented/attributes/char.rb', line 101

def self.maxmana
  Lich.deprecated("Char.maxmana", "Char.max_mana", caller[0], fe_log: true)
  Char.max_mana
end

.maxspirit ⇒ Integer

Deprecated.

Returns the maximum spirit of the character (deprecated).

This method is deprecated; use #max_spirit instead.

Returns:

  • (Integer) —

    the character's maximum spirit



117
118
119
120
# File 'documented/attributes/char.rb', line 117

def self.maxspirit
  Lich.deprecated("Char.maxspirit", "Char.max_spirit", caller[0], fe_log: true)
  Char.max_spirit
end

.maxstamina ⇒ Integer

Deprecated.

Returns the maximum stamina of the character (deprecated).

This method is deprecated; use #max_stamina instead.

Returns:

  • (Integer) —

    the character's maximum stamina



133
134
135
136
# File 'documented/attributes/char.rb', line 133

def self.maxstamina
  Lich.deprecated("Char.maxstamina", "Char.max_stamina", caller[0], fe_log: true)
  Char.max_stamina
end

.method_missing(meth, *args) ⇒ Object

Handles calls to methods that are not defined.

Parameters:

  • meth (Symbol) —

    the method name that was called

  • args (Array) —

    arguments passed to the method

Returns:

  • (Object) —

    the result of the method call or raises an error



201
202
203
204
205
206
207
208
209
210
# File 'documented/attributes/char.rb', line 201

def self.method_missing(meth, *args)
  polyfill = [Stats, Skills, Spellsong].find { |klass|
    klass.respond_to?(meth, *args)
  }
  if polyfill
    Lich.deprecated("Char.#{meth}", "#{polyfill}.#{meth}", caller[0])
    return polyfill.send(meth, *args)
  end
  super(meth, *args)
end

.name ⇒ String

Returns the name of the character.

Returns:

  • (String) —

    the character's name



21
22
23
# File 'documented/attributes/char.rb', line 21

def self.name
  XMLData.name
end

.percent_encumbrance ⇒ Integer

Returns the percentage of the character's encumbrance.

Returns:

  • (Integer) —

    the percentage of encumbrance



45
46
47
# File 'documented/attributes/char.rb', line 45

def self.percent_encumbrance
  XMLData.encumbrance_value
end

.percent_health ⇒ Integer

Returns the percentage of the character's health.

Returns:

  • (Integer) —

    the percentage of health



140
141
142
# File 'documented/attributes/char.rb', line 140

def self.percent_health
  ((XMLData.health.to_f / XMLData.max_health.to_f) * 100).to_i
end

.percent_mana ⇒ Integer

Returns the percentage of the character's mana.

Returns:

  • (Integer) —

    the percentage of mana



146
147
148
149
150
151
152
# File 'documented/attributes/char.rb', line 146

def self.percent_mana
  if XMLData.max_mana == 0
    100
  else
    ((XMLData.mana.to_f / XMLData.max_mana.to_f) * 100).to_i
  end
end

.percent_spirit ⇒ Integer

Returns the percentage of the character's spirit.

Returns:

  • (Integer) —

    the percentage of spirit



156
157
158
# File 'documented/attributes/char.rb', line 156

def self.percent_spirit
  ((XMLData.spirit.to_f / XMLData.max_spirit.to_f) * 100).to_i
end

.percent_stamina ⇒ Integer

Returns the percentage of the character's stamina.

Returns:

  • (Integer) —

    the percentage of stamina



162
163
164
165
166
167
168
# File 'documented/attributes/char.rb', line 162

def self.percent_stamina
  if XMLData.max_stamina == 0
    100
  else
    ((XMLData.stamina.to_f / XMLData.max_stamina.to_f) * 100).to_i
  end
end

.percent_stance ⇒ Integer

Returns the percentage of the character's stance.

Returns:

  • (Integer) —

    the percentage of stance



33
34
35
# File 'documented/attributes/char.rb', line 33

def self.percent_stance
  XMLData.stance_value
end

.respond_to?(m, *args) ⇒ Boolean

Checks if the character responds to a method.

Parameters:

  • m (Symbol) —

    the method name to check

  • args (Array) —

    additional arguments for the method

Returns:

  • (Boolean) —

    true if the method is supported



193
194
195
# File 'documented/attributes/char.rb', line 193

def self.respond_to?(m, *args)
  [Stats, Skills, Spellsong].any? { |k| k.respond_to?(m) } or super(m, *args)
end

.skills ⇒ void

Deprecated.

This method returns an undefined value.

Returns character skills (deprecated).

This method is no longer supported and should be updated in scripts.



226
227
228
# File 'documented/attributes/char.rb', line 226

def self.skills
  echo "Char.skills is no longer supported. Update or fix your script."
end

.spirit ⇒ Integer

Returns the current spirit of the character.

Returns:

  • (Integer) —

    the character's spirit



63
64
65
# File 'documented/attributes/char.rb', line 63

def self.spirit
  XMLData.spirit
end

.stamina ⇒ Integer

Returns the current stamina of the character.

Returns:

  • (Integer) —

    the character's stamina



69
70
71
# File 'documented/attributes/char.rb', line 69

def self.stamina
  XMLData.stamina
end

.stance ⇒ String

Returns the current stance of the character.

Returns:

  • (String) —

    the character's stance text



27
28
29
# File 'documented/attributes/char.rb', line 27

def self.stance
  XMLData.stance_text
end