Class: Lich::Gemstone::Bounty::Task
- Inherits:
-
Object
- Object
- Lich::Gemstone::Bounty::Task
- Defined in:
- documented/gemstone/bounty/task.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#requirements ⇒ Object
Returns the value of attribute requirements.
-
#town ⇒ Object
Returns the value of attribute town.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#any? ⇒ Boolean
Checks if there are any tasks.
-
#assigned? ⇒ Boolean
Checks if the task is assigned.
-
#assist? ⇒ Boolean
Checks if the task is an assist task.
-
#bandit? ⇒ Boolean
Checks if the task type is a bandit type.
-
#count ⇒ Integer
Returns the number associated with the task.
-
#creature ⇒ String?
Returns the creature requirement for the task.
-
#creature? ⇒ Boolean
Checks if the task type is one of the creature types.
-
#critter ⇒ String?
Returns the creature requirement for the task.
-
#critter? ⇒ Boolean
Checks if there is a creature requirement for the task.
-
#cull? ⇒ Boolean
Checks if the task type is a cull type.
-
#dangerous? ⇒ Boolean
Checks if the task type is a dangerous type.
-
#done? ⇒ Boolean
Checks if the task is marked as done.
-
#escort? ⇒ Boolean
Checks if the task type is an escort type.
-
#gem? ⇒ Boolean
Checks if the task type is a gem type.
-
#group? ⇒ Boolean
Checks if the task is a group task.
-
#guard? ⇒ Boolean
Checks if the task type is a guard type.
-
#heirloom? ⇒ Boolean
Checks if the task type is an heirloom type.
-
#heirloom_found? ⇒ Boolean
Checks if the task type indicates that an heirloom has been found.
-
#help? ⇒ Boolean
Checks if the task description indicates a help task.
-
#herb? ⇒ Boolean
Checks if the task type is an herb type.
-
#initialize(options = {}) ⇒ Task
constructor
Initializes a new Task instance.
-
#kind ⇒ String
Returns the type of the task.
-
#location ⇒ String
Returns the location requirement for the task.
-
#loot_heirloom? ⇒ Boolean
Checks if the task is to loot an heirloom.
-
#method_missing(symbol, *args, &blk) ⇒ Object
Handles calls to methods that are not defined.
-
#none? ⇒ Boolean
Checks if there are no tasks.
-
#ready? ⇒ Boolean
Checks if the task is ready to be executed.
-
#rescue? ⇒ Boolean
Checks if the task type is a rescue type.
-
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Checks if the object responds to a missing method.
-
#search_heirloom? ⇒ Boolean
Checks if the task is to search for an heirloom.
-
#skin? ⇒ Boolean
Checks if the task type is a skin type.
-
#spawned? ⇒ Boolean
Checks if the task has spawned.
-
#task ⇒ String
Returns the type of the task.
-
#triggered? ⇒ Boolean
Checks if the task has been triggered.
Constructor Details
#initialize(options = {}) ⇒ Task
Initializes a new Task instance.
15 16 17 18 19 20 |
# File 'documented/gemstone/bounty/task.rb', line 15 def initialize( = {}) @description = [:description] @type = [:type] @requirements = [:requirements] || {} @town = [:town] || @requirements[:town] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &blk) ⇒ Object
Handles calls to methods that are not defined.
219 220 221 222 223 224 225 |
# File 'documented/gemstone/bounty/task.rb', line 219 def method_missing(symbol, *args, &blk) if requirements&.keys&.include?(symbol) requirements[symbol] else super end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
21 22 23 |
# File 'documented/gemstone/bounty/task.rb', line 21 def description @description end |
#requirements ⇒ Object
Returns the value of attribute requirements.
21 22 23 |
# File 'documented/gemstone/bounty/task.rb', line 21 def requirements @requirements end |
#town ⇒ Object
Returns the value of attribute town.
21 22 23 |
# File 'documented/gemstone/bounty/task.rb', line 21 def town @town end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'documented/gemstone/bounty/task.rb', line 21 def type @type end |
Instance Method Details
#any? ⇒ Boolean
Checks if there are any tasks.
163 164 165 |
# File 'documented/gemstone/bounty/task.rb', line 163 def any? !none? end |
#assigned? ⇒ Boolean
Checks if the task is assigned.
184 185 186 |
# File 'documented/gemstone/bounty/task.rb', line 184 def assigned? type.to_s.end_with?("assignment") end |
#assist? ⇒ Boolean
Checks if the task is an assist task.
205 206 207 |
# File 'documented/gemstone/bounty/task.rb', line 205 def assist? help? end |
#bandit? ⇒ Boolean
Checks if the task type is a bandit type.
59 60 61 |
# File 'documented/gemstone/bounty/task.rb', line 59 def bandit? type.to_s.start_with?("bandit") end |
#count ⇒ Integer
Returns the number associated with the task.
31 |
# File 'documented/gemstone/bounty/task.rb', line 31 def count; number; end |
#creature ⇒ String?
Returns the creature requirement for the task.
35 36 37 |
# File 'documented/gemstone/bounty/task.rb', line 35 def creature requirements[:creature] end |
#creature? ⇒ Boolean
Checks if the task type is one of the creature types.
65 66 67 68 69 |
# File 'documented/gemstone/bounty/task.rb', line 65 def creature? [ :creature_assignment, :cull, :dangerous, :dangerous_spawned, :rescue, :heirloom ].include?(type) end |
#critter ⇒ String?
Returns the creature requirement for the task.
41 42 43 |
# File 'documented/gemstone/bounty/task.rb', line 41 def critter requirements[:creature] end |
#critter? ⇒ Boolean
Checks if there is a creature requirement for the task.
47 48 49 |
# File 'documented/gemstone/bounty/task.rb', line 47 def critter? !!requirements[:creature] end |
#cull? ⇒ Boolean
Checks if the task type is a cull type.
73 74 75 |
# File 'documented/gemstone/bounty/task.rb', line 73 def cull? type.to_s.start_with?("cull") end |
#dangerous? ⇒ Boolean
Checks if the task type is a dangerous type.
79 80 81 |
# File 'documented/gemstone/bounty/task.rb', line 79 def dangerous? type.to_s.start_with?("dangerous") end |
#done? ⇒ Boolean
Checks if the task is marked as done.
143 144 145 146 147 |
# File 'documented/gemstone/bounty/task.rb', line 143 def done? [ :failed, :guard, :taskmaster, :heirloom_found ].include?(type) end |
#escort? ⇒ Boolean
Checks if the task type is an escort type.
85 86 87 |
# File 'documented/gemstone/bounty/task.rb', line 85 def escort? type.to_s.start_with?("escort") end |
#gem? ⇒ Boolean
Checks if the task type is a gem type.
91 92 93 |
# File 'documented/gemstone/bounty/task.rb', line 91 def gem? type.to_s.start_with?("gem") end |
#group? ⇒ Boolean
Checks if the task is a group task.
211 212 213 |
# File 'documented/gemstone/bounty/task.rb', line 211 def group? help? end |
#guard? ⇒ Boolean
Checks if the task type is a guard type.
175 176 177 178 179 180 |
# File 'documented/gemstone/bounty/task.rb', line 175 def guard? [ :guard, :bandit_assignment, :creature_assignment, :heirloom_assignment, :heirloom_found, :rescue_assignment ].include?(type) end |
#heirloom? ⇒ Boolean
Checks if the task type is an heirloom type.
97 98 99 |
# File 'documented/gemstone/bounty/task.rb', line 97 def heirloom? type.to_s.start_with?("heirloom") end |
#heirloom_found? ⇒ Boolean
Checks if the task type indicates that an heirloom has been found.
135 136 137 138 139 |
# File 'documented/gemstone/bounty/task.rb', line 135 def heirloom_found? [ :heirloom_found ].include?(type) end |
#help? ⇒ Boolean
Checks if the task description indicates a help task.
199 200 201 |
# File 'documented/gemstone/bounty/task.rb', line 199 def help? description.start_with?("You have been tasked to help") end |
#herb? ⇒ Boolean
Checks if the task type is an herb type.
103 104 105 |
# File 'documented/gemstone/bounty/task.rb', line 103 def herb? type.to_s.start_with?("herb") end |
#kind ⇒ String
Returns the type of the task.
28 |
# File 'documented/gemstone/bounty/task.rb', line 28 def kind; type; end |
#location ⇒ String
Returns the location requirement for the task.
53 54 55 |
# File 'documented/gemstone/bounty/task.rb', line 53 def location requirements[:area] || town end |
#loot_heirloom? ⇒ Boolean
Checks if the task is to loot an heirloom.
128 129 130 131 |
# File 'documented/gemstone/bounty/task.rb', line 128 def loot_heirloom? [:heirloom].include?(type) && requirements[:action] == "loot" end |
#none? ⇒ Boolean
Checks if there are no tasks.
169 170 171 |
# File 'documented/gemstone/bounty/task.rb', line 169 def none? [:none, nil].include?(type) end |
#ready? ⇒ Boolean
Checks if the task is ready to be executed.
190 191 192 193 194 195 |
# File 'documented/gemstone/bounty/task.rb', line 190 def ready? [ :bandit_assignment, :escort_assignment, :bandit, :cull, :dangerous, :escort, :gem, :heirloom, :herb, :rescue, :skin ].include?(type) end |
#rescue? ⇒ Boolean
Checks if the task type is a rescue type.
109 110 111 |
# File 'documented/gemstone/bounty/task.rb', line 109 def rescue? type.to_s.start_with?("rescue") end |
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Checks if the object responds to a missing method.
231 232 233 |
# File 'documented/gemstone/bounty/task.rb', line 231 def respond_to_missing?(symbol, include_private = false) requirements&.keys&.include?(symbol) || super end |
#search_heirloom? ⇒ Boolean
Checks if the task is to search for an heirloom.
121 122 123 124 |
# File 'documented/gemstone/bounty/task.rb', line 121 def search_heirloom? [:heirloom].include?(type) && requirements[:action] == "search" end |
#skin? ⇒ Boolean
Checks if the task type is a skin type.
115 116 117 |
# File 'documented/gemstone/bounty/task.rb', line 115 def skin? type.to_s.start_with?("skin") end |
#spawned? ⇒ Boolean
Checks if the task has spawned.
151 152 153 154 155 |
# File 'documented/gemstone/bounty/task.rb', line 151 def spawned? [ :dangerous_spawned, :escort, :rescue_spawned ].include?(type) end |
#task ⇒ String
Returns the type of the task.
25 |
# File 'documented/gemstone/bounty/task.rb', line 25 def task; type; end |
#triggered? ⇒ Boolean
Checks if the task has been triggered.
159 |
# File 'documented/gemstone/bounty/task.rb', line 159 def triggered?; spawned?; end |