Class: Lich::Gemstone::ReadyList

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

Overview

Represents a list of ready items and their storage in the game.

This class manages the items that a player can have ready for use, including weapons and shields, and provides methods to check their validity and reset the lists.

See Also:

  • #ready_list
  • #store_list

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

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

Note:

This method updates the checked state based on the results.

This method returns an undefined value.

Checks the current settings of the ready list in the game.

Parameters:

  • silent (Boolean) (defaults to: false)

    if true, suppresses output

  • quiet (Boolean) (defaults to: false)

    if true, uses a quieter output pattern



108
109
110
111
112
113
114
115
116
117
# File 'documented/gemstone/readylist.rb', line 108

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) ⇒ Object



62
63
64
# File 'documented/gemstone/readylist.rb', line 62

def checked=(value)
  @checked = value
end

.checked?Boolean

Returns:

  • (Boolean)


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

def checked?
  @checked
end

.ready_listObject



50
51
52
# File 'documented/gemstone/readylist.rb', line 50

def ready_list
  @ready_list
end

.reset(all: false) ⇒ void

This method returns an undefined value.

Resets the ready and store lists to nil.

Parameters:

  • all (Boolean) (defaults to: false)

    if true, resets all items regardless of original list



90
91
92
93
94
95
96
97
98
99
100
# File 'documented/gemstone/readylist.rb', line 90

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_listObject



54
55
56
# File 'documented/gemstone/readylist.rb', line 54

def store_list
  @store_list
end

.valid?(all: false) ⇒ Boolean

Note:

This method relies on the checked state being true.

Checks if the current ready items are valid.

Examples:

Check validity of ready items

ready_list.valid?

Parameters:

  • all (Boolean) (defaults to: false)

    if true, checks all items regardless of original list

Returns:

  • (Boolean)

    true if all checked items are valid, false otherwise



73
74
75
76
77
78
79
80
81
82
83
84
# File 'documented/gemstone/readylist.rb', line 73

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