Class: Lich::Gemstone::StowList
- Inherits:
-
Object
- Object
- Lich::Gemstone::StowList
- Defined in:
- documented/gemstone/stowlist.rb
Overview
Represents a list of items that can be stowed.
This class manages the stow list entries and their states.
Constant Summary collapse
- ORIGINAL_STOW_LIST =
[:box, :gem, :herb, :skin, :wand, :scroll, :potion, :trinket, :reagent, :lockpick, :treasure, :forageable, :collectible, :default]
Class Method Summary collapse
-
.check(silent: false, quiet: false) ⇒ void
Checks the current stow list status and updates the checked state.
- .checked=(value) ⇒ Object
- .checked? ⇒ Boolean
-
.reset(all: false) ⇒ void
Resets the stow list entries to nil.
- .stow_list ⇒ Object
-
.valid?(all: false) ⇒ Boolean
Checks if the stow list entries are valid.
Class Method Details
.check(silent: false, quiet: false) ⇒ void
This method returns an undefined value.
Checks the current stow list status and updates the checked state.
82 83 84 85 86 87 88 89 90 91 |
# File 'documented/gemstone/stowlist.rb', line 82 def check(silent: false, quiet: false) if quiet start_pattern = /<output class="mono"\/>|^You are a ghost!/ else start_pattern = /You have the following containers set as stow targets:|^You are a ghost!/ end waitrt? results = Lich::Util.issue_command("stow list", start_pattern, silent: silent, quiet: quiet) @checked = results.any? { |line| line.match?(/You have the following containers set as stow targets/) } end |
.checked=(value) ⇒ Object
44 45 46 |
# File 'documented/gemstone/stowlist.rb', line 44 def checked=(value) @checked = value end |
.checked? ⇒ Boolean
40 41 42 |
# File 'documented/gemstone/stowlist.rb', line 40 def checked? @checked end |
.reset(all: false) ⇒ void
This method returns an undefined value.
Resets the stow list entries to nil.
69 70 71 72 73 74 75 |
# File 'documented/gemstone/stowlist.rb', line 69 def reset(all: false) @checked = false @stow_list.each do |key, _value| next unless all || ORIGINAL_STOW_LIST.include?(key) @stow_list[key] = nil end end |
.stow_list ⇒ Object
36 37 38 |
# File 'documented/gemstone/stowlist.rb', line 36 def stow_list @stow_list end |
.valid?(all: false) ⇒ Boolean
Checks if the stow list entries are valid.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'documented/gemstone/stowlist.rb', line 52 def valid?(all: false) # check if existing containers are valid or not return false unless checked? @stow_list.each do |key, value| next unless all || ORIGINAL_STOW_LIST.include?(key) unless value.nil? || GameObj.inv.map(&:id).include?(value.id) @checked = false return false end end return true end |