Class: Lich::Gemstone::CharacterStatus

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

Overview

Base class for character status tracking Base class for character status tracking Provides methods to manage character injuries and statuses

Examples:

Using CharacterStatus

CharacterStatus.fix_injury_mode("scar")

Direct Known Subclasses

Scars, Wounds

Class Method Summary collapse

Class Method Details

.fix_injury_mode(mode = 'both') ⇒ void

This method returns an undefined value.

Fixes the injury mode for the character

Examples:

CharacterStatus.fix_injury_mode("scar")

Parameters:

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

    The mode to set (‘scar’, ‘wound’, or ‘both’)

Raises:

  • (ArgumentError)

    If an invalid mode is provided



697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
# File 'documented/games.rb', line 697

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) ⇒ String

Handles missing methods for character status

Examples:

result = CharacterStatus.new.some_invalid_method

Parameters:

  • _method_name (Symbol) (defaults to: nil)

    The name of the missing method

Returns:

  • (String)

    A message indicating the invalid area



724
725
726
727
728
# File 'documented/games.rb', line 724

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