Class: Lich::Gemstone::CharacterStatus

Inherits:
Object
  • Object
show all
Defined in:
documented/games.rb

Overview

Base class for character status tracking

Class Method Summary collapse

Class Method Details

.fix_injury_mode(mode = 'both') ⇒ void

This method returns an undefined value.

Sets the character's injury display mode (wounds, scars, or both).

Sends the _injury command and waits up to 7.5 seconds for XMLData.injury_mode to reflect the change.

Examples:

Lich::Gemstone::CharacterStatus.fix_injury_mode('scar')

Parameters:

  • mode (String) (defaults to: 'both')

    'scar'/'scars', 'wound'/'wounds', or 'both' (default)

Raises:

  • (ArgumentError)

    if mode is not one of the recognized values



1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
# File 'documented/games.rb', line 1549

def fix_injury_mode(mode = 'both') # Default mode 'both' handles wounds (precedence) then scars
  case mode
  when 'scar', 'scars'
    unless XMLData.injury_mode == 1
      Game._puts '_injury 1'
      150.times { sleep 0.05; break if XMLData.injury_mode == 1 }
    end
  when 'wound', 'wounds' # future proof leaving in place, but this will likely not be used
    unless XMLData.injury_mode == 0
      Game._puts '_injury 0'
      150.times { sleep 0.05; break if XMLData.injury_mode == 0 }
    end
  when 'both'
    unless XMLData.injury_mode == 2
      Game._puts '_injury 2'
      150.times { sleep 0.05; break if XMLData.injury_mode == 2 }
    end
  else
    raise ArgumentError, "Invalid mode: #{mode}. Use 'scar', 'wound', or 'both'."
  end
end

.method_missing(_method_name = nil) ⇒ nil

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Handles calls to unknown injury area methods on CharacterStatus.

Returns a formatted error message listing valid areas.

Returns:

  • (nil)

    (the result of the Lich::Messaging._respond call)



1577
1578
1579
1580
1581
# File 'documented/games.rb', line 1577

def method_missing(_method_name = nil)
  result = Lich::Messaging.mono(Lich::Messaging.msg_format("bold", "#{self.name.split('::').last}: Invalid area, try one of these: arms, limbs, torso, #{XMLData.injuries.keys.join(', ')}"))
  # the _respond method used in Lich::Messaging returns nil upon success
  return result
end