Class: Lich::Gemstone::ReadyList
- Inherits:
-
Object
- Object
- Lich::Gemstone::ReadyList
- Defined in:
- documented/gemstone/readylist.rb
Overview
Entries are stored as GameObj instances; ReadyList.valid? confirms all stored items remain in inventory, containers, or hands.
Tracks equipped items and storage locations from the "ready list" command in GemStone IV.
Maintains two parallel lists: a ready list of currently equipped items (shields, weapons, wands, etc.) and a store list of items staged for retrieval from storage. Use ReadyList.check to sync state from the game server, then read individual entries via accessor methods like weapon or store_weapon.
Constant Summary collapse
- ORIGINAL_READY_LIST =
Standard game-provided ready list entry types.
Represents the default equipment slots GemStone IV tracks: shields, primary/secondary weapons, ranged weapons, ammo bundles, sheaths, and wands.
[:shield, :weapon, :secondary_weapon, :ranged_weapon, :ammo_bundle, :ammo2_bundle, :sheath, :secondary_sheath, :wand]
- ORIGINAL_STORE_LIST =
Standard game-provided store list entry types.
Subset of ORIGINAL_READY_LIST used for tracking items awaiting retrieval from storage. Excludes ammo2_bundle, sheath, and secondary_sheath.
[:shield, :weapon, :secondary_weapon, :ranged_weapon, :ammo_bundle, :wand]
Class Method Summary collapse
-
.check(silent: false, quiet: false) ⇒ void
Syncs ready list state from the game server by parsing "ready list" command output.
-
.checked=(value) ⇒ Boolean
private
Sets the checked state flag.
-
.checked? ⇒ Boolean
Returns true if ReadyList.check has successfully synced state from the game server.
-
.ready_list ⇒ Hash{Symbol => GameObj, nil}
Returns the internal hash mapping equipment slot names to GameObj instances.
-
.reset(all: false) ⇒ void
Clears all stored entries and sets checked state to false.
-
.store_list ⇒ Hash{Symbol => GameObj, nil}
Returns the internal hash mapping storage slot names to GameObj instances.
-
.valid?(all: false) ⇒ Boolean
Verifies that all stored equipment items still exist in inventory, containers, or hands.
Class Method Details
.check(silent: false, quiet: false) ⇒ void
This method returns an undefined value.
Syncs ready list state from the game server by parsing "ready list" command output.
Waits for roundtime, issues the "ready list" command, and reads equipment assignments from the server response. Parses the response to extract item IDs and slot types, populating ready_list and store_list. Sets checked? to true only if the response contains "Your current settings are:", indicating a valid ready list from the server.
168 169 170 171 172 173 174 175 176 177 |
# File 'documented/gemstone/readylist.rb', line 168 def check(silent: false, quiet: false) if quiet start_pattern = /<output class="mono"\/>|^You are a ghost!/ else start_pattern = /Your current settings are:|^You are a ghost!/ end waitrt? results = Lich::Util.issue_command("ready list", start_pattern, silent: silent, quiet: quiet) @checked = results.any? { |line| line.match?(/Your current settings are:/) } end |
.checked=(value) ⇒ Boolean
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.
Sets the checked state flag.
100 101 102 |
# File 'documented/gemstone/readylist.rb', line 100 def checked=(value) @checked = value end |
.checked? ⇒ Boolean
Returns true if check has successfully synced state from the game server.
91 92 93 |
# File 'documented/gemstone/readylist.rb', line 91 def checked? @checked end |
.ready_list ⇒ Hash{Symbol => GameObj, nil}
Returns the internal hash mapping equipment slot names to GameObj instances.
72 73 74 |
# File 'documented/gemstone/readylist.rb', line 72 def ready_list @ready_list end |
.reset(all: false) ⇒ void
This method returns an undefined value.
Clears all stored entries and sets checked state to false.
Sets checked= to false, then nilifies entries in ready_list and store_list.
142 143 144 145 146 147 148 149 150 151 152 |
# File 'documented/gemstone/readylist.rb', line 142 def reset(all: false) @checked = false @ready_list.each do |key, _value| next unless all || ORIGINAL_READY_LIST.include?(key) @ready_list[key] = nil end @store_list.each do |key, _value| next unless all || ORIGINAL_STORE_LIST.include?(key) @store_list[key] = nil end end |
.store_list ⇒ Hash{Symbol => GameObj, nil}
Returns the internal hash mapping storage slot names to GameObj instances.
83 84 85 |
# File 'documented/gemstone/readylist.rb', line 83 def store_list @store_list end |
.valid?(all: false) ⇒ Boolean
Verifies that all stored equipment items still exist in inventory, containers, or hands.
Confirms checked? is true, then iterates the ready list verifying each non-wand entry either has a nil value or the GameObj (by id) still appears in GameObj.inv, GameObj.containers, GameObj.right_hand, or GameObj.left_hand. Wand entries are excluded from validation. Sets checked= to false if any item is missing.
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'documented/gemstone/readylist.rb', line 119 def valid?(all: false) # check if existing ready items are valid or not return false unless checked? @ready_list.each do |key, value| next unless all || ORIGINAL_READY_LIST.include?(key) unless key.eql?(:wand) || value.nil? || GameObj.inv.map(&:id).include?(value.id) || GameObj.containers.values.flatten.map(&:id).include?(value.id) || GameObj.right_hand.id.eql?(value.id) || GameObj.left_hand.id.eql?(value.id) @checked = false return false end end return true end |