Class: Lich::Gemstone::Wounds

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

Overview

Wounds class for tracking character wounds Wounds class for tracking character wounds

This class provides methods to access and manage the wounds of a character in the game. It includes methods for individual body parts, composite wounds, and overall wound levels.

Examples:

Creating a Wounds instance

wounds = Lich::Gemstone::Wounds

Constant Summary collapse

BODY_PARTS =

Body part accessor methods XML from Simutronics drives the structure of the wound 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 wound naming for various body parts.

{
  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_woundsHash<Symbol, Integer>

Helper method to get all wound levels Returns a hash of all body parts and their corresponding wound levels.

Examples:

all_wounds = wounds.all_wounds

Returns:

  • (Hash<Symbol, Integer>)

    A hash mapping body parts to their wound levels.



131
132
133
134
# File 'documented/gemstone/wounds.rb', line 131

def all_wounds
  fix_injury_mode('both')
  XMLData.injuries.transform_values { |v| v['wound'] }
end

.armsInteger?

Composite wound methods Returns the maximum wound level for both arms and hands.

Examples:

max_wound = wounds.arms

Returns:

  • (Integer, nil)

    The maximum wound level for arms or nil if not present.



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

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

.left_armObject



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

def left_arm; leftArm; end

.left_eyeInteger?

Alias snake_case methods for overachievers Returns the wound level for the left eye using snake_case.

Examples:

wound_level = wounds.left_eye

Returns:

  • (Integer, nil)

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



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

def left_eye; leftEye; end

.left_footObject



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

def left_foot; leftFoot; end

.left_handObject



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

def left_hand; leftHand; end

.left_legObject



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

def left_leg; leftLeg; end

.limbsInteger?

Returns the maximum wound level for both arms, hands, and legs.

Examples:

max_wound = wounds.limbs

Returns:

  • (Integer, nil)

    The maximum wound level for limbs or nil if not present.



88
89
90
91
92
93
94
95
96
97
98
# File 'documented/gemstone/wounds.rb', line 88

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

.right_armObject



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

def right_arm; rightArm; end

.right_eyeObject



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

def right_eye; rightEye; end

.right_footObject



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

def right_foot; rightFoot; end

.right_handObject



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

def right_hand; rightHand; end

.right_legObject



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

def right_leg; rightLeg; end

.torsoInteger?

Returns the maximum wound level for the torso including eyes, chest, abdomen, and back.

Examples:

max_wound = wounds.torso

Returns:

  • (Integer, nil)

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



104
105
106
107
108
109
110
111
112
113
# File 'documented/gemstone/wounds.rb', line 104

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

.wound_level(part) ⇒ Integer?

Helper method to get wound level for any body part Returns the wound level for a specified body part.

Examples:

wound_level = wounds.wound_level(:leftEye)

Parameters:

  • part (Symbol)

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

Returns:

  • (Integer, nil)

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



121
122
123
124
# File 'documented/gemstone/wounds.rb', line 121

def wound_level(part)
  fix_injury_mode('both')
  XMLData.injuries[part.to_s] && XMLData.injuries[part.to_s]['wound']
end