Class: Lich::Gemstone::ReadyList

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

Overview

Represents a list of ready items in the game.

Class Method Summary collapse

Class Method Details

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

This method returns an undefined value.

Checks the current settings of the ready list.

Examples:

Lich::Gemstone::ReadyList.check(silent: true)

Parameters:

  • silent (Boolean) (defaults to: false)

    whether to suppress output (default: false).

  • quiet (Boolean) (defaults to: false)

    whether to suppress output and use a different start pattern (default: false).



84
85
86
87
88
89
90
91
92
# File 'lib/gemstone/readylist.rb', line 84

def check(silent: false, quiet: false)
  if quiet
    start_pattern = /<output class="mono"\/>/
  else
    start_pattern = /Your current settings are:/
  end
  Lich::Util.issue_command("ready list", start_pattern, silent: silent, quiet: quiet)
  @checked = true
end

.checked=(value) ⇒ Boolean

Sets the checked state of the ready list.

Examples:

Lich::Gemstone::ReadyList.checked = true

Parameters:

  • value (Boolean)

    the new checked state.

Returns:

  • (Boolean)

    the new checked state.



46
47
48
# File 'lib/gemstone/readylist.rb', line 46

def checked=(value)
  @checked = value
end

.checked?Boolean

Checks if the ready list has been validated.

Examples:

Lich::Gemstone::ReadyList.checked?

Returns:

  • (Boolean)

    true if the ready list has been checked, false otherwise.



37
38
39
# File 'lib/gemstone/readylist.rb', line 37

def checked?
  @checked
end

.ready_listHash

Returns the current ready list.

Examples:

Lich::Gemstone::ReadyList.ready_list

Returns:

  • (Hash)

    the current state of the ready list.



29
30
31
# File 'lib/gemstone/readylist.rb', line 29

def ready_list
  @ready_list
end

.resetvoid

This method returns an undefined value.

Resets the ready list and its checked state.

Examples:

Lich::Gemstone::ReadyList.reset


71
72
73
74
75
76
# File 'lib/gemstone/readylist.rb', line 71

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

.valid?Boolean

Note:

If any item is invalid, the checked state will be reset to false.

Validates the items in the ready list.

Examples:

Lich::Gemstone::ReadyList.valid?

Returns:

  • (Boolean)

    true if all items are valid, false otherwise.



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gemstone/readylist.rb', line 55

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