Class: Lich::Gemstone::Scars

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

Overview

Represents the scars of a character in the game.

This class provides methods to access and manipulate the scar data for various body parts of a character.

See Also:

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

{
  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

Class Method Details

.all_scarsHash

Retrieves the scar levels for all body parts.

Returns:

  • (Hash)

    a hash containing the scar levels for all body parts.



109
110
111
112
113
114
115
116
117
# File 'documented/gemstone/scars.rb', line 109

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

.armsObject



64
65
66
67
68
69
70
71
72
# File 'documented/gemstone/scars.rb', line 64

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



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

def left_arm; leftArm; end

.left_eyeObject



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

def left_eye; leftEye; end

.left_footObject



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

def left_foot; leftFoot; end

.left_handObject



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

def left_hand; leftHand; end

.left_legObject



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

def left_leg; leftLeg; end

.limbsObject



74
75
76
77
78
79
80
81
82
83
84
# File 'documented/gemstone/scars.rb', line 74

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

.partString?

Define methods for each body part and its aliases Defines methods for each body part and its aliases. Each method retrieves the scar data for the corresponding body part.

Returns:

  • (String, nil)

    the scar data for the specified body part, or nil if not found.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'documented/gemstone/scars.rb', line 39

BODY_PARTS.each do |part, aliases|
  # Define the primary method
  define_method(part) do
    fix_injury_mode('both') # continue to use 'both' (_injury2) for now

    XMLData.injuries[part.to_s] && XMLData.injuries[part.to_s]['scar']
  end

  # Define shorthand alias methods
  aliases.each do |ali|
    alias_method ali, part
  end
end

.right_armObject



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

def right_arm; rightArm; end

.right_eyeObject



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

def right_eye; rightEye; end

.right_footObject



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

def right_foot; rightFoot; end

.right_handObject



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

def right_hand; rightHand; end

.right_legObject



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

def right_leg; rightLeg; end

.scar_level(part) ⇒ String?

Retrieves the scar level for a specific body part.

Parameters:

  • part (Symbol)

    the body part to retrieve the scar level for

Returns:

  • (String, nil)

    the scar level for the specified body part, or nil if not found.



101
102
103
104
# File 'documented/gemstone/scars.rb', line 101

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

.torsoObject



86
87
88
89
90
91
92
93
94
95
# File 'documented/gemstone/scars.rb', line 86

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