Class: Lich::Gemstone::StowList

Inherits:
Object
  • Object
show all
Defined in:
lib/gemstone/stowlist.rb

Overview

Represents a list of items that can be stowed.

Class Method Summary collapse

Class Method Details

.check(silent: false, quiet: false) ⇒ void

This method returns an undefined value.

Checks the stow list and issues a command to the game.

Examples:

StowList.check(silent: true)

Parameters:

  • silent (Boolean) (defaults to: false)

    whether to suppress output (default: false).

  • quiet (Boolean) (defaults to: false)

    whether to suppress the initial message (default: false).



95
96
97
98
99
100
101
102
103
# File 'lib/gemstone/stowlist.rb', line 95

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
  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.

Parameters:

  • value (Boolean)

    the new checked status.

Returns:

  • (Boolean)

    the value that was set.



56
57
58
# File 'lib/gemstone/stowlist.rb', line 56

def checked=(value)
  @checked = value
end

.checked?Boolean

Checks if the stow list has been checked.

Returns:

  • (Boolean)

    true if checked, false otherwise.



48
49
50
# File 'lib/gemstone/stowlist.rb', line 48

def checked?
  @checked
end

.resetvoid

This method returns an undefined value.

Resets the stow list and its checked status.

Examples:

StowList.reset


81
82
83
84
85
86
# File 'lib/gemstone/stowlist.rb', line 81

def reset
  @checked = false
  @stow_list.each_key do |key|
    @stow_list[key] = nil
  end
end

.stow_listHash

Returns the entire stow list.

Returns:

  • (Hash)

    the stow list containing all entries.



41
42
43
# File 'lib/gemstone/stowlist.rb', line 41

def stow_list
  @stow_list
end

.valid?Boolean

Note:

This method will set @checked to false if any entry is invalid.

Validates the stow list entries against the game inventory.

Returns:

  • (Boolean)

    true if all entries are valid, false otherwise.



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/gemstone/stowlist.rb', line 64

def valid?
  # check if existing containers are valid or not
  return false unless checked?
  @stow_list.each_value do |value|
    unless value.nil? || GameObj.inv.map(&:id).include?(value.id)
      @checked = false
      return false
    end
  end
  return true
end