Class: Lich::Common::Char

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

Overview

Represents a character in the Lich game. This class provides various methods to access character attributes.

Examples:

Accessing character name

character_name = Char.name

Class Method Summary collapse

Class Method Details

.cheString?

Returns the ‘che’ attribute of the character if applicable.

Examples:

che_value = Char.che

Returns:

  • (String, nil)

    The character’s ‘che’ value or nil if not applicable.



291
292
293
# File 'documented/attributes/char.rb', line 291

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

.citizenshipString?

Returns the citizenship of the character if applicable.

Examples:

citizenship = Char.citizenship

Returns:

  • (String, nil)

    The character’s citizenship or nil if not applicable.



273
274
275
# File 'documented/attributes/char.rb', line 273

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

.citizenship=(_val) ⇒ void

Deprecated.

Updating via Char.citizenship is no longer supported.

This method returns an undefined value.

Sets the citizenship of the character (deprecated).

Examples:

Char.citizenship = "New Citizenship"

Parameters:

  • _val (Object)

    The value to set.



283
284
285
# File 'documented/attributes/char.rb', line 283

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

.dump_infovoid

Deprecated.

Char.dump_info is no longer used.

This method returns an undefined value.

Dumps character information (deprecated).

Examples:

Char.dump_info


210
211
212
# File 'documented/attributes/char.rb', line 210

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

.encumbranceString

Returns the encumbrance text of the character.

Examples:

encumbrance = Char.encumbrance

Returns:

  • (String)

    The character’s encumbrance text.



48
49
50
# File 'documented/attributes/char.rb', line 48

def Char.encumbrance
  XMLData.encumbrance_text
end

.healthInteger

Returns the current health of the character.

Examples:

health = Char.health

Returns:

  • (Integer)

    The character’s health value.



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

def Char.health
  XMLData.health
end

.infovoid

Deprecated.

Char.info is no longer supported.

This method returns an undefined value.

Provides character information (deprecated).

Examples:

Char.info


256
257
258
# File 'documented/attributes/char.rb', line 256

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

.init(_blah) ⇒ void

Deprecated.

Char.init is no longer used.

This method returns an undefined value.

Initializes the character (deprecated).

Examples:

Char.init(some_value)

Parameters:

  • _blah (Object)

    Unused parameter.



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

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

.load_info(_string) ⇒ void

Deprecated.

Char.load_info is no longer used.

This method returns an undefined value.

Loads character information (deprecated).

Examples:

Char.load_info(some_string)

Parameters:

  • _string (String)

    Unused parameter.



220
221
222
# File 'documented/attributes/char.rb', line 220

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

.manaInteger

Returns the current mana of the character.

Examples:

mana = Char.mana

Returns:

  • (Integer)

    The character’s mana value.



72
73
74
# File 'documented/attributes/char.rb', line 72

def Char.mana
  XMLData.mana
end

.max_healthInteger

Returns the maximum health of the character.

Examples:

max_health = Char.max_health

Returns:

  • (Integer)

    The character’s maximum health value.



96
97
98
99
# File 'documented/attributes/char.rb', line 96

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

.max_manaInteger

Returns the maximum mana of the character.

Examples:

max_mana = Char.max_mana

Returns:

  • (Integer)

    The character’s maximum mana value.



115
116
117
# File 'documented/attributes/char.rb', line 115

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

.max_spiritInteger

Returns the maximum spirit of the character.

Examples:

max_spirit = Char.max_spirit

Returns:

  • (Integer)

    The character’s maximum spirit value.



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

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

.max_staminaInteger

Returns the maximum stamina of the character.

Examples:

max_stamina = Char.max_stamina

Returns:

  • (Integer)

    The character’s maximum stamina value.



151
152
153
# File 'documented/attributes/char.rb', line 151

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

.maxhealthInteger

Deprecated.

Use Char.max_health instead.

Returns the maximum health of the character (deprecated).

Examples:

max_health = Char.maxhealth

Returns:

  • (Integer)

    The character’s maximum health value.



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

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

.maxmanaInteger

Deprecated.

Use Char.max_mana instead.

Returns the maximum mana of the character (deprecated).

Examples:

max_mana = Char.maxmana

Returns:

  • (Integer)

    The character’s maximum mana value.



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

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

.maxspiritInteger

Deprecated.

Use Char.max_spirit instead.

Returns the maximum spirit of the character (deprecated).

Examples:

max_spirit = Char.maxspirit

Returns:

  • (Integer)

    The character’s maximum spirit value.



142
143
144
145
# File 'documented/attributes/char.rb', line 142

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

.maxstaminaInteger

Deprecated.

Use Char.max_stamina instead.

Returns the maximum stamina of the character (deprecated).

Examples:

max_stamina = Char.maxstamina

Returns:

  • (Integer)

    The character’s maximum stamina value.



160
161
162
163
# File 'documented/attributes/char.rb', line 160

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

.method_missing(meth, *args) ⇒ Object

Handles missing methods for the character.

Examples:

result = Char.some_missing_method

Parameters:

  • meth (Symbol)

    The missing method name.

  • args (Array)

    Arguments for the missing method.

Returns:

  • (Object)

    The result of the method call if found, otherwise raises NoMethodError.



240
241
242
243
244
245
246
247
248
249
# File 'documented/attributes/char.rb', line 240

def Char.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

.nameString

Returns the name of the character.

Examples:

name = Char.name

Returns:

  • (String)

    The character’s name.



24
25
26
# File 'documented/attributes/char.rb', line 24

def Char.name
  XMLData.name
end

.percent_encumbranceInteger

Returns the percentage of the character’s encumbrance.

Examples:

encumbrance_percentage = Char.percent_encumbrance

Returns:

  • (Integer)

    The percentage value of the character’s encumbrance.



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

def Char.percent_encumbrance
  XMLData.encumbrance_value
end

.percent_healthInteger

Returns the percentage of the character’s health.

Examples:

health_percentage = Char.percent_health

Returns:

  • (Integer)

    The percentage value of the character’s health.



169
170
171
# File 'documented/attributes/char.rb', line 169

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

.percent_manaInteger

Returns the percentage of the character’s mana.

Examples:

mana_percentage = Char.percent_mana

Returns:

  • (Integer)

    The percentage value of the character’s mana.



177
178
179
180
181
182
183
# File 'documented/attributes/char.rb', line 177

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

.percent_spiritInteger

Returns the percentage of the character’s spirit.

Examples:

spirit_percentage = Char.percent_spirit

Returns:

  • (Integer)

    The percentage value of the character’s spirit.



189
190
191
# File 'documented/attributes/char.rb', line 189

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

.percent_staminaInteger

Returns the percentage of the character’s stamina.

Examples:

stamina_percentage = Char.percent_stamina

Returns:

  • (Integer)

    The percentage value of the character’s stamina.



197
198
199
200
201
202
203
# File 'documented/attributes/char.rb', line 197

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

.percent_stanceInteger

Returns the percentage of the character’s stance.

Examples:

stance_percentage = Char.percent_stance

Returns:

  • (Integer)

    The percentage value of the character’s stance.



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

def Char.percent_stance
  XMLData.stance_value
end

.respond_to?(m, *args) ⇒ Boolean

Checks if the character responds to a method.

Examples:

supports_method = Char.respond_to?(:some_method)

Parameters:

  • m (Symbol)

    The method name to check.

  • args (Array)

    Additional arguments for the method.

Returns:

  • (Boolean)

    True if the method is supported, false otherwise.



230
231
232
# File 'documented/attributes/char.rb', line 230

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

.skillsvoid

Deprecated.

Char.skills is no longer supported.

This method returns an undefined value.

Provides character skills information (deprecated).

Examples:

Char.skills


265
266
267
# File 'documented/attributes/char.rb', line 265

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

.spiritInteger

Returns the current spirit of the character.

Examples:

spirit = Char.spirit

Returns:

  • (Integer)

    The character’s spirit value.



80
81
82
# File 'documented/attributes/char.rb', line 80

def Char.spirit
  XMLData.spirit
end

.staminaInteger

Returns the current stamina of the character.

Examples:

stamina = Char.stamina

Returns:

  • (Integer)

    The character’s stamina value.



88
89
90
# File 'documented/attributes/char.rb', line 88

def Char.stamina
  XMLData.stamina
end

.stanceString

Returns the current stance of the character.

Examples:

stance = Char.stance

Returns:

  • (String)

    The character’s stance text.



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

def Char.stance
  XMLData.stance_text
end