Class: Lich::Gemstone::Wounds

Inherits:
Gemstone::CharacterStatus
  • Object
show all
Defined in:
lib/gemstone/wounds.rb,
lib/games.rb

Overview

Wounds class for tracking character 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

{
  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

.abdomenWound

Returns the wound status of the abdomen.

Examples:

Wounds.abdomen

Returns:

  • (Wound)

    the wound status of the abdomen



644
# File 'lib/games.rb', line 644

def Wounds.abdomen;   fix_injury_mode; XMLData.injuries['abdomen']['wound'];   end

.absWound

Alias for abdomen.

Examples:

Wounds.abs

Returns:

  • (Wound)

    the wound status of the abdomen



651
# File 'lib/games.rb', line 651

def Wounds.abs;       fix_injury_mode; XMLData.injuries['abdomen']['wound'];   end

.all_woundsHash

Helper method to get all wound levels

Examples:

Wounds.all_wounds

Returns:

  • (Hash)

    a hash of all body parts and their corresponding wound levels

Raises:

  • (StandardError)

    if there is an issue accessing XMLData



127
128
129
130
# File 'lib/gemstone/wounds.rb', line 127

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

.armsString?

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

Examples:

Wounds.arms

Returns:

  • (String, nil)

    the maximum wound level for arms or nil if not present

Raises:

  • (StandardError)

    if there is an issue accessing XMLData



770
771
772
773
# File 'lib/games.rb', line 770

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

.backWound

Returns the wound status of the back.

Examples:

Wounds.back

Returns:

  • (Wound)

    the wound status of the back



630
# File 'lib/games.rb', line 630

def Wounds.back;      fix_injury_mode; XMLData.injuries['back']['wound'];      end

.chestWound

Returns the wound status of the chest.

Examples:

Wounds.chest

Returns:

  • (Wound)

    the wound status of the chest



637
# File 'lib/games.rb', line 637

def Wounds.chest;     fix_injury_mode; XMLData.injuries['chest']['wound'];     end

.headWound

Returns the wound status of the head.

Examples:

Wounds.head

Returns:

  • (Wound)

    the wound status of the head



616
# File 'lib/games.rb', line 616

def Wounds.head;      fix_injury_mode; XMLData.injuries['head']['wound'];      end

.larmWound

Alias for leftArm.

Examples:

Wounds.larm

Returns:

  • (Wound)

    the wound status of the left arm



665
# File 'lib/games.rb', line 665

def Wounds.larm;      fix_injury_mode; XMLData.injuries['leftArm']['wound'];   end

.left_armObject



53
# File 'lib/gemstone/wounds.rb', line 53

def left_arm; leftArm; end

.left_eyeObject

Alias snake_case methods for overachievers



51
# File 'lib/gemstone/wounds.rb', line 51

def left_eye; leftEye; end

.left_footObject



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

def left_foot; leftFoot; end

.left_handObject



55
# File 'lib/gemstone/wounds.rb', line 55

def left_hand; leftHand; end

.left_legObject



57
# File 'lib/gemstone/wounds.rb', line 57

def left_leg; leftLeg; end

.leftArmWound

Returns the wound status of the left arm.

Examples:

Wounds.leftArm

Returns:

  • (Wound)

    the wound status of the left arm



658
# File 'lib/games.rb', line 658

def Wounds.leftArm;   fix_injury_mode; XMLData.injuries['leftArm']['wound'];   end

.leftEyeWound

Returns the wound status of the left eye.

Examples:

Wounds.leftEye

Returns:

  • (Wound)

    the wound status of the left eye



588
# File 'lib/games.rb', line 588

def Wounds.leftEye;   fix_injury_mode; XMLData.injuries['leftEye']['wound'];   end

.leftFootWound

Returns the wound status of the left foot.

Examples:

Wounds.leftFoot

Returns:

  • (Wound)

    the wound status of the left foot



742
# File 'lib/games.rb', line 742

def Wounds.leftFoot;  fix_injury_mode; XMLData.injuries['leftFoot']['wound'];  end

.leftHandWound

Returns the wound status of the left hand.

Examples:

Wounds.leftHand

Returns:

  • (Wound)

    the wound status of the left hand



700
# File 'lib/games.rb', line 700

def Wounds.leftHand;  fix_injury_mode; XMLData.injuries['leftHand']['wound'];  end

.leftLegWound

Returns the wound status of the left leg.

Examples:

Wounds.leftLeg

Returns:

  • (Wound)

    the wound status of the left leg



714
# File 'lib/games.rb', line 714

def Wounds.leftLeg;   fix_injury_mode; XMLData.injuries['leftLeg']['wound'];   end

.leyeWound

Alias for leftEye.

Examples:

Wounds.leye

Returns:

  • (Wound)

    the wound status of the left eye



595
# File 'lib/games.rb', line 595

def Wounds.leye;      fix_injury_mode; XMLData.injuries['leftEye']['wound'];   end

.lhandWound

Alias for leftHand.

Examples:

Wounds.lhand

Returns:

  • (Wound)

    the wound status of the left hand



707
# File 'lib/games.rb', line 707

def Wounds.lhand;     fix_injury_mode; XMLData.injuries['leftHand']['wound'];  end

.limbsString?

Retrieves the maximum wound level for all limbs.

Examples:

Wounds.limbs

Returns:

  • (String, nil)

    the maximum wound level for limbs or nil if not present

Raises:

  • (StandardError)

    if there is an issue accessing XMLData



780
781
782
783
# File 'lib/games.rb', line 780

def Wounds.limbs
  fix_injury_mode
  [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

.llegWound

Alias for leftLeg.

Examples:

Wounds.lleg

Returns:

  • (Wound)

    the wound status of the left leg



721
# File 'lib/games.rb', line 721

def Wounds.lleg;      fix_injury_mode; XMLData.injuries['leftLeg']['wound'];   end

.method_missing(_arg = nil) ⇒ nil

Handles invalid area requests for wounds.

Parameters:

  • _arg (nil) (defaults to: nil)

    ignored parameter

Returns:

  • (nil)


799
800
801
802
# File 'lib/games.rb', line 799

def Wounds.method_missing(_arg = nil)
  echo "Wounds: Invalid area, try one of these: arms, limbs, torso, #{XMLData.injuries.keys.join(', ')}"
  nil
end

.neckWound

Returns the wound status of the neck.

Examples:

Wounds.neck

Returns:

  • (Wound)

    the wound status of the neck



623
# File 'lib/games.rb', line 623

def Wounds.neck;      fix_injury_mode; XMLData.injuries['neck']['wound'];      end

.nervesWound

Returns the wound status of the nerves.

Examples:

Wounds.nerves

Returns:

  • (Wound)

    the wound status of the nerves



763
# File 'lib/games.rb', line 763

def Wounds.nerves;    fix_injury_mode; XMLData.injuries['nsys']['wound'];      end

.nsysWound

Returns the wound status of the nervous system.

Examples:

Wounds.nsys

Returns:

  • (Wound)

    the wound status of the nervous system



756
# File 'lib/games.rb', line 756

def Wounds.nsys;      fix_injury_mode; XMLData.injuries['nsys']['wound'];      end

.partString?

Define methods for each body part and its aliases Retrieves the wound for the body part.

Examples:

Wounds.leftEye

Returns:

  • (String, nil)

    the wound level for the body part or nil if not present

Raises:

  • (StandardError)

    if there is an issue accessing XMLData



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gemstone/wounds.rb', line 36

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]['wound']
  end

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

.rarmWound

Alias for rightArm.

Examples:

Wounds.rarm

Returns:

  • (Wound)

    the wound status of the right arm



679
# File 'lib/games.rb', line 679

def Wounds.rarm;      fix_injury_mode; XMLData.injuries['rightArm']['wound'];  end

.reyeWound

Alias for rightEye.

Examples:

Wounds.reye

Returns:

  • (Wound)

    the wound status of the right eye



609
# File 'lib/games.rb', line 609

def Wounds.reye;      fix_injury_mode; XMLData.injuries['rightEye']['wound'];  end

.rhandWound

Alias for rightHand.

Examples:

Wounds.rhand

Returns:

  • (Wound)

    the wound status of the right hand



693
# File 'lib/games.rb', line 693

def Wounds.rhand;     fix_injury_mode; XMLData.injuries['rightHand']['wound']; end

.right_armObject



54
# File 'lib/gemstone/wounds.rb', line 54

def right_arm; rightArm; end

.right_eyeObject



52
# File 'lib/gemstone/wounds.rb', line 52

def right_eye; rightEye; end

.right_footObject



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

def right_foot; rightFoot; end

.right_handObject



56
# File 'lib/gemstone/wounds.rb', line 56

def right_hand; rightHand; end

.right_legObject



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

def right_leg; rightLeg; end

.rightArmWound

Returns the wound status of the right arm.

Examples:

Wounds.rightArm

Returns:

  • (Wound)

    the wound status of the right arm



672
# File 'lib/games.rb', line 672

def Wounds.rightArm;  fix_injury_mode; XMLData.injuries['rightArm']['wound'];  end

.rightEyeWound

Returns the wound status of the right eye.

Examples:

Wounds.rightEye

Returns:

  • (Wound)

    the wound status of the right eye



602
# File 'lib/games.rb', line 602

def Wounds.rightEye;  fix_injury_mode; XMLData.injuries['rightEye']['wound'];  end

.rightFootWound

Returns the wound status of the right foot.

Examples:

Wounds.rightFoot

Returns:

  • (Wound)

    the wound status of the right foot



749
# File 'lib/games.rb', line 749

def Wounds.rightFoot; fix_injury_mode; XMLData.injuries['rightFoot']['wound']; end

.rightHandWound

Returns the wound status of the right hand.

Examples:

Wounds.rightHand

Returns:

  • (Wound)

    the wound status of the right hand



686
# File 'lib/games.rb', line 686

def Wounds.rightHand; fix_injury_mode; XMLData.injuries['rightHand']['wound']; end

.rightLegWound

Returns the wound status of the right leg.

Examples:

Wounds.rightLeg

Returns:

  • (Wound)

    the wound status of the right leg



728
# File 'lib/games.rb', line 728

def Wounds.rightLeg;  fix_injury_mode; XMLData.injuries['rightLeg']['wound'];  end

.rlegWound

Alias for rightLeg.

Examples:

Wounds.rleg

Returns:

  • (Wound)

    the wound status of the right leg



735
# File 'lib/games.rb', line 735

def Wounds.rleg;      fix_injury_mode; XMLData.injuries['rightLeg']['wound'];  end

.torsoString?

Retrieves the maximum wound level for the torso.

Examples:

Wounds.torso

Returns:

  • (String, nil)

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

Raises:

  • (StandardError)

    if there is an issue accessing XMLData



790
791
792
793
# File 'lib/games.rb', line 790

def Wounds.torso
  fix_injury_mode
  [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) ⇒ String?

Helper method to get wound level for any body part

Examples:

Wounds.wound_level(:leftArm)

Parameters:

  • part (Symbol)

    the body part to check

Returns:

  • (String, nil)

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

Raises:

  • (StandardError)

    if there is an issue accessing XMLData



117
118
119
120
# File 'lib/gemstone/wounds.rb', line 117

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