Class: Lich::Gemstone::StowList
- Inherits:
-
Object
- Object
- Lich::Gemstone::StowList
- Defined in:
- documented/gemstone/stowlist.rb
Overview
Represents a list of items to stow in the Lich game. This class manages the stow list and provides methods to check, reset, and validate the stow targets.
Constant Summary collapse
- ORIGINAL_STOW_LIST =
The original list of stowable item types.
[: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 stow list and updates the checked status.
-
.checked=(value) ⇒ Boolean
Sets the checked status of the stow list.
-
.checked? ⇒ Boolean
Checks if the stow list has been validated.
-
.reset(all: false) ⇒ Object
Resets the stow list entries to nil.
-
.stow_list ⇒ Hash
Returns the current stow list.
-
.valid?(all: false) ⇒ Boolean
Validates the stow list entries.
Class Method Details
.check(silent: false, quiet: false) ⇒ void
This method will set the checked status to true after execution.
This method returns an undefined value.
Checks the stow list and updates the checked status.
92 93 94 95 96 97 98 99 100 101 |
# File 'documented/gemstone/stowlist.rb', line 92 def check(silent: false, quiet: false) if quiet start_pattern = /<output class="mono"\/>/ else start_pattern = /You have the following containers set as stow targets:/ end waitrt? Lich::Util.issue_command("stow list", start_pattern, silent: silent, quiet: quiet) @checked = true end |
.checked=(value) ⇒ Boolean
Sets the checked status of the stow list.
54 55 56 |
# File 'documented/gemstone/stowlist.rb', line 54 def checked=(value) @checked = value end |
.checked? ⇒ Boolean
Checks if the stow list has been validated.
47 48 49 |
# File 'documented/gemstone/stowlist.rb', line 47 def checked? @checked end |
.reset(all: false) ⇒ Object
Resets the stow list entries to nil.
77 78 79 80 81 82 83 |
# File 'documented/gemstone/stowlist.rb', line 77 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 ⇒ Hash
Returns the current stow list.
41 42 43 |
# File 'documented/gemstone/stowlist.rb', line 41 def stow_list @stow_list end |
.valid?(all: false) ⇒ Boolean
This method requires that the stow list has been checked.
Validates the stow list entries.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'documented/gemstone/stowlist.rb', line 62 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 |