Class: Lich::Gemstone::Scars

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

Overview

Scars class for tracking character scars

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

.abdomenScar

Returns the scar status of the abdomen.

Examples:

Scars.abdomen

Returns:

  • (Scar)

    the scar status of the abdomen



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

def Scars.abdomen;   fix_injury_mode; XMLData.injuries['abdomen']['scar'];   end

.absScar

Alias for abdomen.

Examples:

Scars.abs

Returns:

  • (Scar)

    the scar status of the abdomen



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

def Scars.abs;       fix_injury_mode; XMLData.injuries['abdomen']['scar'];   end

.all_scarsHash

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

Examples:

Scars.all_scars

Returns:

  • (Hash)

    A hash of all body parts and their corresponding scar levels.

Raises:

  • (StandardError)

    If there is an issue retrieving the data.



126
127
128
129
130
131
132
133
134
# File 'lib/gemstone/scars.rb', line 126

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:

Continues to use ‘both’ (_injury2) for now.

Retrieves the maximum scar level for arms (left arm, right arm, left hand, right hand).

Examples:

Scars.arms

Returns:

  • (Integer, nil)

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



993
994
995
996
# File 'lib/games.rb', line 993

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

.backScar

Returns the scar status of the back.

Examples:

Scars.back

Returns:

  • (Scar)

    the scar status of the back



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

def Scars.back;      fix_injury_mode; XMLData.injuries['back']['scar'];      end

.chestScar

Returns the scar status of the chest.

Examples:

Scars.chest

Returns:

  • (Scar)

    the scar status of the chest



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

def Scars.chest;     fix_injury_mode; XMLData.injuries['chest']['scar'];     end

.headScar

Returns the scar status of the head.

Examples:

Scars.head

Returns:

  • (Scar)

    the scar status of the head



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

def Scars.head;      fix_injury_mode; XMLData.injuries['head']['scar'];      end

.larmScar

Alias for leftArm.

Examples:

Scars.larm

Returns:

  • (Scar)

    the scar status of the left arm



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

def Scars.larm;      fix_injury_mode; XMLData.injuries['leftArm']['scar'];   end

.left_armObject



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

def left_arm; leftArm; end

.left_eyeObject

Alias snake_case methods for overachievers



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

def left_eye; leftEye; end

.left_footObject



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

def left_foot; leftFoot; end

.left_handObject



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

def left_hand; leftHand; end

.left_legObject



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

def left_leg; leftLeg; end

.leftArmScar

Returns the scar status of the left arm.

Examples:

Scars.leftArm

Returns:

  • (Scar)

    the scar status of the left arm



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

def Scars.leftArm;   fix_injury_mode; XMLData.injuries['leftArm']['scar'];   end

.leftEyeScar

Returns the scar status of the left eye.

Examples:

Scars.leftEye

Returns:

  • (Scar)

    the scar status of the left eye



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

def Scars.leftEye;   fix_injury_mode; XMLData.injuries['leftEye']['scar'];   end

.leftFootScar

Returns the scar status of the left foot.

Examples:

Scars.leftFoot

Returns:

  • (Scar)

    the scar status of the left foot



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

def Scars.leftFoot;  fix_injury_mode; XMLData.injuries['leftFoot']['scar'];  end

.leftHandScar

Returns the scar status of the left hand.

Examples:

Scars.leftHand

Returns:

  • (Scar)

    the scar status of the left hand



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

def Scars.leftHand;  fix_injury_mode; XMLData.injuries['leftHand']['scar'];  end

.leftLegScar

Returns the scar status of the left leg.

Examples:

Scars.lefgLeg

Returns:

  • (Scar)

    the scar status of the left leg



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

def Scars.leftLeg;   fix_injury_mode; XMLData.injuries['leftLeg']['scar'];   end

.leyeScar

Alias for leftEye.

Examples:

Scars.leye

Returns:

  • (Scar)

    the scar status of the left eye



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

def Scars.leye;      fix_injury_mode; XMLData.injuries['leftEye']['scar'];   end

.lhandScar

Alias for leftHand.

Examples:

Scars.lhand

Returns:

  • (Scar)

    the scar status of the left hand



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

def Scars.lhand;     fix_injury_mode; XMLData.injuries['leftHand']['scar'];  end

.limbsInteger?

Note:

Continues to use ‘both’ (_injury2) for now.

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

Examples:

Scars.limbs

Returns:

  • (Integer, nil)

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



1003
1004
1005
1006
# File 'lib/games.rb', line 1003

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

.llegScar

Alias for leftLeg.

Examples:

Scars.lleg

Returns:

  • (Scar)

    the scar status of the left leg



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

def Scars.lleg;      fix_injury_mode; XMLData.injuries['leftLeg']['scar'];   end

.method_missing(_arg = nil) ⇒ nil

Note:

This method provides feedback on valid areas to check for scars.

Handles calls to undefined methods for the Scars class.

Examples:

Scars.invalid_method

Parameters:

  • _arg (nil) (defaults to: nil)

    an optional argument that is ignored.

Returns:

  • (nil)

    always returns nil.



1025
1026
1027
1028
# File 'lib/games.rb', line 1025

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

.neckScar

Returns the scar status of the neck.

Examples:

Scars.neck

Returns:

  • (Scar)

    the scar status of the neck



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

def Scars.neck;      fix_injury_mode; XMLData.injuries['neck']['scar'];      end

.nervesInteger

Retrieves the scar value for the nerves area after fixing the injury mode.

Examples:

Scars.nerves

Returns:

  • (Integer)

    the scar value for the nerves area.



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

def Scars.nerves;    fix_injury_mode; XMLData.injuries['nsys']['scar'];      end

.nsysInteger

Retrieves the scar value for the nsys area after fixing the injury mode.

Examples:

Scars.nsys

Returns:

  • (Integer)

    the scar value for the nsys area.



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

def Scars.nsys;      fix_injury_mode; XMLData.injuries['nsys']['scar'];      end

.partHash?

Note:

Continues to use ‘both’ (_injury2) for now.

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

Examples:

Scars.leftEye

Returns:

  • (Hash, nil)

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



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/gemstone/scars.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]['scar']
  end

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

.rarmScar

Alias for rightArm.

Examples:

Scars.rarm

Returns:

  • (Scar)

    the scar status of the right arm



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

def Scars.rarm;      fix_injury_mode; XMLData.injuries['rightArm']['scar'];  end

.reyeScar

Alias for rightEye.

Examples:

Scars.reye

Returns:

  • (Scar)

    the scar status of the right eye



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

def Scars.reye;      fix_injury_mode; XMLData.injuries['rightEye']['scar'];  end

.rhandScar

Alias for rightHand.

Examples:

Scars.rhand

Returns:

  • (Scar)

    the scar status of the right hand



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

def Scars.rhand;     fix_injury_mode; XMLData.injuries['rightHand']['scar']; end

.right_armObject



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

def right_arm; rightArm; end

.right_eyeObject



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

def right_eye; rightEye; end

.right_footObject



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

def right_foot; rightFoot; end

.right_handObject



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

def right_hand; rightHand; end

.right_legObject



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

def right_leg; rightLeg; end

.rightArmScar

Returns the scar status of the right arm.

Examples:

Scars.rightArm

Returns:

  • (Scar)

    the scar status of the right arm



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

def Scars.rightArm;  fix_injury_mode; XMLData.injuries['rightArm']['scar'];  end

.rightEyeScar

Returns the scar status of the right eye.

Examples:

Scars.rightEye

Returns:

  • (Scar)

    the scar status of the right eye



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

def Scars.rightEye;  fix_injury_mode; XMLData.injuries['rightEye']['scar'];  end

.rightFootScar

Returns the scar status of the right foot.

Examples:

Scars.rightFoot

Returns:

  • (Scar)

    the scar status of the right foot



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

def Scars.rightFoot; fix_injury_mode; XMLData.injuries['rightFoot']['scar']; end

.rightHandScar

Returns the scar status of the right hand.

Examples:

Scars.rightHand

Returns:

  • (Scar)

    the scar status of the right hand



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

def Scars.rightHand; fix_injury_mode; XMLData.injuries['rightHand']['scar']; end

.rightLegScar

Returns the scar status of the right leg.

Examples:

Scars.rightLeg

Returns:

  • (Scar)

    the scar status of the right leg



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

def Scars.rightLeg;  fix_injury_mode; XMLData.injuries['rightLeg']['scar'];  end

.rlegScar

Alias for rightLeg.

Examples:

Scars.rleg

Returns:

  • (Scar)

    the scar status of the right leg



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

def Scars.rleg;      fix_injury_mode; XMLData.injuries['rightLeg']['scar'];  end

.scar_level(part) ⇒ Integer?

Note:

Continues to use ‘both’ (_injury2) for now.

Helper method to get scar level for any body part.

Examples:

Scars.scar_level(:leftArm)

Parameters:

  • part (Symbol)

    The body part to retrieve the scar level for.

Returns:

  • (Integer, nil)

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



116
117
118
119
# File 'lib/gemstone/scars.rb', line 116

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

.torsoInteger?

Note:

Continues to use ‘both’ (_injury2) for now.

Retrieves the maximum scar level for the torso (chest, abdomen, back, eyes).

Examples:

Scars.torso

Returns:

  • (Integer, nil)

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



1013
1014
1015
1016
# File 'lib/games.rb', line 1013

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