Class: Lich::Gemstone::ReadyList

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

Overview

Represents a ready list for managing equipped items in the Lich game. This class provides methods to check, reset, and validate the items in the ready list.

Examples:

Creating a ready list

ready_list = Lich::Gemstone::ReadyList

Constant Summary collapse

ORIGINAL_READY_LIST =

The original list of ready items. This constant defines the default items that can be included in the ready list.

[:shield, :weapon, :secondary_weapon, :ranged_weapon, :ammo_bundle, :ammo2_bundle, :sheath, :secondary_sheath, :wand]
ORIGINAL_STORE_LIST =

The original list of store items. This constant defines the default items that can be included in the store list.

[:shield, :weapon, :secondary_weapon, :ranged_weapon, :ammo_bundle, :wand]

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:

Checking the ready list

ready_list.check(silent: true)

Parameters:

  • silent (Boolean) (defaults to: false)

    If true, suppresses output.

  • quiet (Boolean) (defaults to: false)

    If true, uses a quiet output pattern.



117
118
119
120
121
122
123
124
125
126
# File 'documented/gemstone/readylist.rb', line 117

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

.checked=(value) ⇒ Boolean

Sets the checked status of the ready list.

Parameters:

  • value (Boolean)

    The new checked status.

Returns:

  • (Boolean)

    The updated checked status.



71
72
73
# File 'documented/gemstone/readylist.rb', line 71

def checked=(value)
  @checked = value
end

.checked?Boolean

Checks if the ready list has been validated.

Returns:

  • (Boolean)

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



64
65
66
# File 'documented/gemstone/readylist.rb', line 64

def checked?
  @checked
end

.ready_listHash

Returns the current ready list.

Returns:

  • (Hash)

    The hash representing the ready list with item types as keys and their values.



52
53
54
# File 'documented/gemstone/readylist.rb', line 52

def ready_list
  @ready_list
end

.reset(all: false) ⇒ void

This method returns an undefined value.

Resets the ready and store lists.

Examples:

Resetting the ready list

ready_list.reset(all: true)

Parameters:

  • all (Boolean) (defaults to: false)

    If true, resets all items, otherwise only resets original items.



99
100
101
102
103
104
105
106
107
108
109
# File 'documented/gemstone/readylist.rb', line 99

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_listHash

Returns the current store list.

Returns:

  • (Hash)

    The hash representing the store list with item types as keys and their values.



58
59
60
# File 'documented/gemstone/readylist.rb', line 58

def store_list
  @store_list
end

.valid?(all: false) ⇒ Boolean

Note:

This method requires that the ready list has been checked before validation.

Validates the items in the ready list.

Examples:

Validating the ready list

is_valid = ready_list.valid?(all: true)

Parameters:

  • all (Boolean) (defaults to: false)

    If true, validates all items, otherwise only validates original ready items.

Returns:

  • (Boolean)

    True if all relevant items are valid, false otherwise.



81
82
83
84
85
86
87
88
89
90
91
92
# File 'documented/gemstone/readylist.rb', line 81

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.include?(value.id) || GameObj.left_hand.id.include?(value.id)
      @checked = false
      return false
    end
  end
  return true
end