Class: Lich::Gemstone::Scars

Inherits:
CharacterStatus show all
Defined in:
documented/gemstone/scars.rb

Overview

Scars class for tracking character scars Scars class for tracking character scars

This class provides methods to access and manage scars on various body parts of a character. It defines both primary and alias methods for body parts, as well as composite methods for groups of body parts.

Examples:

Accessing a character’s left eye scar

scars = Lich::Gemstone::Scars.new
scar_level = scars.leftEye

Constant Summary collapse

BODY_PARTS =

Body part accessor methods XML from Simutronics drives the structure of the scar naming (eg. leftEye) The following is a hash of the body parts and shorthand aliases created for more idiomatic Ruby A hash of body parts and their shorthand aliases. This constant drives the structure of the scar naming convention.

{
  leftEye: ['leye'],
  rightEye: ['reye'],
  head: [],
  neck: [],
  back: [],
  chest: [],
  abdomen: ['abs'],
  leftArm: ['larm'],
  rightArm: ['rarm'],
  rightHand: ['rhand'],
  leftHand: ['lhand'],
  leftLeg: ['lleg'],
  rightLeg: ['rleg'],
  leftFoot: ['lfoot'],
  rightFoot: ['rfoot'],
  nsys: ['nerves']
}.freeze

Class Method Summary collapse

Methods inherited from CharacterStatus

fix_injury_mode, method_missing

Class Method Details

.all_scarsHash

Note:

This method temporarily changes the injury mode to ‘scar’ to retrieve actual scar level data.

Helper method to get all scar levels Retrieves the scar levels for all body parts.

Examples:

all_scar_levels = scars.all_scars

Returns:

  • (Hash)

    A hash mapping body parts to their scar levels.



144
145
146
147
148
149
150
151
152
# File 'documented/gemstone/scars.rb', line 144

def all_scars
  begin
    fix_injury_mode('scar') # for this one call, we want to get actual scar level data
    result = XMLData.injuries.transform_values { |v| v['scar'] }
  ensure
    fix_injury_mode('both') # reset to both
  end
  return result
end

.armsInteger?

Note:

This method uses ‘both’ injury mode for consistency.

Composite scar methods Retrieves the maximum scar level for both arms and hands.

Examples:

max_scar = scars.arms

Returns:

  • (Integer, nil)

    The maximum scar level among the arms and hands or nil if not present.



79
80
81
82
83
84
85
86
87
# File 'documented/gemstone/scars.rb', line 79

def arms
  fix_injury_mode('both')
  [
    XMLData.injuries['leftArm']['scar'],
    XMLData.injuries['rightArm']['scar'],
    XMLData.injuries['leftHand']['scar'],
    XMLData.injuries['rightHand']['scar']
  ].max
end

.left_armObject



63
# File 'documented/gemstone/scars.rb', line 63

def left_arm; leftArm; end

.left_eyeInteger?

Note:

This method is an alias for leftEye.

Alias snake_case methods for overachievers Retrieves the scar level for the left eye using snake_case.

Examples:

scar_level = scars.left_eye

Returns:

  • (Integer, nil)

    The scar level for the left eye or nil if not present.



61
# File 'documented/gemstone/scars.rb', line 61

def left_eye; leftEye; end

.left_footObject



69
# File 'documented/gemstone/scars.rb', line 69

def left_foot; leftFoot; end

.left_handObject



65
# File 'documented/gemstone/scars.rb', line 65

def left_hand; leftHand; end

.left_legObject



67
# File 'documented/gemstone/scars.rb', line 67

def left_leg; leftLeg; end

.limbsInteger?

Note:

This method uses ‘both’ injury mode for consistency.

Retrieves the maximum scar level for all limbs (arms and legs).

Examples:

max_scar = scars.limbs

Returns:

  • (Integer, nil)

    The maximum scar level among all limbs or nil if not present.



95
96
97
98
99
100
101
102
103
104
105
# File 'documented/gemstone/scars.rb', line 95

def limbs
  fix_injury_mode('both')
  [
    XMLData.injuries['leftArm']['scar'],
    XMLData.injuries['rightArm']['scar'],
    XMLData.injuries['leftHand']['scar'],
    XMLData.injuries['rightHand']['scar'],
    XMLData.injuries['leftLeg']['scar'],
    XMLData.injuries['rightLeg']['scar']
  ].max
end

.right_armObject



64
# File 'documented/gemstone/scars.rb', line 64

def right_arm; rightArm; end

.right_eyeObject



62
# File 'documented/gemstone/scars.rb', line 62

def right_eye; rightEye; end

.right_footObject



70
# File 'documented/gemstone/scars.rb', line 70

def right_foot; rightFoot; end

.right_handObject



66
# File 'documented/gemstone/scars.rb', line 66

def right_hand; rightHand; end

.right_legObject



68
# File 'documented/gemstone/scars.rb', line 68

def right_leg; rightLeg; end

.scar_level(part) ⇒ Integer?

Note:

This method uses ‘both’ injury mode for consistency.

Helper method to get scar level for any body part Retrieves the scar level for a specified body part.

Examples:

scar_level = scars.scar_level(:leftEye)

Parameters:

  • part (Symbol)

    The body part to check (e.g., :leftEye).

Returns:

  • (Integer, nil)

    The scar level for the specified body part or nil if not present.



132
133
134
135
# File 'documented/gemstone/scars.rb', line 132

def scar_level(part)
  fix_injury_mode('both')
  XMLData.injuries[part.to_s] && XMLData.injuries[part.to_s]['scar']
end

.torsoInteger?

Note:

This method uses ‘both’ injury mode for consistency.

Retrieves the maximum scar level for the torso.

Examples:

max_scar = scars.torso

Returns:

  • (Integer, nil)

    The maximum scar level for the torso or nil if not present.



113
114
115
116
117
118
119
120
121
122
# File 'documented/gemstone/scars.rb', line 113

def torso
  fix_injury_mode('both')
  [
    XMLData.injuries['rightEye']['scar'],
    XMLData.injuries['leftEye']['scar'],
    XMLData.injuries['chest']['scar'],
    XMLData.injuries['abdomen']['scar'],
    XMLData.injuries['back']['scar']
  ].max
end