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 requires assistance (alias for help?).
-
#bandit? ⇒ Boolean
Checks if the task type is a bandit task.
-
#count ⇒ Integer
Returns the number associated with the task.
-
#creature ⇒ Symbol?
Returns the creature requirement for the task.
-
#creature? ⇒ Boolean
Checks if the task type is one of the creature types.
-
#critter ⇒ Symbol?
Returns the creature requirement for the task (alias for creature).
-
#critter? ⇒ Boolean
Checks if the task has a creature requirement.
-
#cull? ⇒ Boolean
Checks if the task type is a cull task.
-
#dangerous? ⇒ Boolean
Checks if the task type is a dangerous task.
-
#done? ⇒ Boolean
Checks if the task is done.
-
#escort? ⇒ Boolean
Checks if the task type is an escort task.
-
#gem? ⇒ Boolean
Checks if the task type is a gem task.
-
#group? ⇒ Boolean
Checks if the task is a group task (alias for help?).
-
#guard? ⇒ Boolean
Checks if the task type is a guard task.
-
#heirloom? ⇒ Boolean
Checks if the task type is a heirloom task.
-
#heirloom_found? ⇒ Boolean
Checks if the task type is a found heirloom task.
-
#help? ⇒ Boolean
Checks if the task description indicates help is needed.
-
#herb? ⇒ Boolean
Checks if the task type is a herb task.
-
#initialize(options = {}) ⇒ Task
constructor
Initializes a new task with the given options.
-
#kind ⇒ Symbol
Returns the type of the task (alias for task).
-
#location ⇒ String
Returns the location requirement for the task.
-
#loot_heirloom? ⇒ Boolean
Checks if the task is a loot heirloom task.
-
#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 task.
-
#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 a search heirloom task.
-
#skin? ⇒ Boolean
Checks if the task type is a skin task.
-
#spawned? ⇒ Boolean
Checks if the task has spawned.
-
#task ⇒ Symbol
Returns the type of the task.
-
#triggered? ⇒ Boolean
Checks if the task has been triggered (spawned).
Constructor Details
#initialize(options = {}) ⇒ Task
Initializes a new task with the given options.
16 17 18 19 20 21 |
# File 'documented/gemstone/bounty/task.rb', line 16 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.
286 287 288 289 290 291 292 |
# File 'documented/gemstone/bounty/task.rb', line 286 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.
22 23 24 |
# File 'documented/gemstone/bounty/task.rb', line 22 def description @description end |
#requirements ⇒ Object
Returns the value of attribute requirements.
22 23 24 |
# File 'documented/gemstone/bounty/task.rb', line 22 def requirements @requirements end |
#town ⇒ Object
Returns the value of attribute town.
22 23 24 |
# File 'documented/gemstone/bounty/task.rb', line 22 def town @town end |
#type ⇒ Object
Returns the value of attribute type.
22 23 24 |
# File 'documented/gemstone/bounty/task.rb', line 22 def type @type end |
Instance Method Details
#any? ⇒ Boolean
Checks if there are any tasks.
213 214 215 |
# File 'documented/gemstone/bounty/task.rb', line 213 def any? !none? end |
#assigned? ⇒ Boolean
Checks if the task is assigned.
240 241 242 |
# File 'documented/gemstone/bounty/task.rb', line 240 def assigned? type.to_s.end_with?("assignment") end |
#assist? ⇒ Boolean
Checks if the task requires assistance (alias for help?).
267 268 269 |
# File 'documented/gemstone/bounty/task.rb', line 267 def assist? help? end |
#bandit? ⇒ Boolean
Checks if the task type is a bandit task.
77 78 79 |
# File 'documented/gemstone/bounty/task.rb', line 77 def bandit? type.to_s.start_with?("bandit") end |
#count ⇒ Integer
Returns the number associated with the task.
39 |
# File 'documented/gemstone/bounty/task.rb', line 39 def count; number; end |
#creature ⇒ Symbol?
Returns the creature requirement for the task.
45 46 47 |
# File 'documented/gemstone/bounty/task.rb', line 45 def creature requirements[:creature] end |
#creature? ⇒ Boolean
Checks if the task type is one of the creature types.
85 86 87 88 89 |
# File 'documented/gemstone/bounty/task.rb', line 85 def creature? [ :creature_assignment, :cull, :dangerous, :dangerous_spawned, :rescue, :heirloom ].include?(type) end |
#critter ⇒ Symbol?
Returns the creature requirement for the task (alias for creature).
53 54 55 |
# File 'documented/gemstone/bounty/task.rb', line 53 def critter requirements[:creature] end |
#critter? ⇒ Boolean
Checks if the task has a creature requirement.
61 62 63 |
# File 'documented/gemstone/bounty/task.rb', line 61 def critter? !!requirements[:creature] end |
#cull? ⇒ Boolean
Checks if the task type is a cull task.
95 96 97 |
# File 'documented/gemstone/bounty/task.rb', line 95 def cull? type.to_s.start_with?("cull") end |
#dangerous? ⇒ Boolean
Checks if the task type is a dangerous task.
103 104 105 |
# File 'documented/gemstone/bounty/task.rb', line 103 def dangerous? type.to_s.start_with?("dangerous") end |
#done? ⇒ Boolean
Checks if the task is done.
187 188 189 190 191 |
# File 'documented/gemstone/bounty/task.rb', line 187 def done? [ :failed, :guard, :taskmaster, :heirloom_found ].include?(type) end |
#escort? ⇒ Boolean
Checks if the task type is an escort task.
111 112 113 |
# File 'documented/gemstone/bounty/task.rb', line 111 def escort? type.to_s.start_with?("escort") end |
#gem? ⇒ Boolean
Checks if the task type is a gem task.
119 120 121 |
# File 'documented/gemstone/bounty/task.rb', line 119 def gem? type.to_s.start_with?("gem") end |
#group? ⇒ Boolean
Checks if the task is a group task (alias for help?).
275 276 277 |
# File 'documented/gemstone/bounty/task.rb', line 275 def group? help? end |
#guard? ⇒ Boolean
Checks if the task type is a guard task.
229 230 231 232 233 234 |
# File 'documented/gemstone/bounty/task.rb', line 229 def guard? [ :guard, :bandit_assignment, :creature_assignment, :heirloom_assignment, :heirloom_found, :rescue_assignment ].include?(type) end |
#heirloom? ⇒ Boolean
Checks if the task type is a heirloom task.
127 128 129 |
# File 'documented/gemstone/bounty/task.rb', line 127 def heirloom? type.to_s.start_with?("heirloom") end |
#heirloom_found? ⇒ Boolean
Checks if the task type is a found heirloom task.
177 178 179 180 181 |
# File 'documented/gemstone/bounty/task.rb', line 177 def heirloom_found? [ :heirloom_found ].include?(type) end |
#help? ⇒ Boolean
Checks if the task description indicates help is needed.
259 260 261 |
# File 'documented/gemstone/bounty/task.rb', line 259 def help? description.start_with?("You have been tasked to help") end |
#herb? ⇒ Boolean
Checks if the task type is a herb task.
135 136 137 |
# File 'documented/gemstone/bounty/task.rb', line 135 def herb? type.to_s.start_with?("herb") end |
#kind ⇒ Symbol
Returns the type of the task (alias for task).
34 |
# File 'documented/gemstone/bounty/task.rb', line 34 def kind; type; end |
#location ⇒ String
Returns the location requirement for the task.
69 70 71 |
# File 'documented/gemstone/bounty/task.rb', line 69 def location requirements[:area] || town end |
#loot_heirloom? ⇒ Boolean
Checks if the task is a loot heirloom task.
168 169 170 171 |
# File 'documented/gemstone/bounty/task.rb', line 168 def loot_heirloom? [:heirloom].include?(type) && requirements[:action] == "loot" end |
#none? ⇒ Boolean
Checks if there are no tasks.
221 222 223 |
# File 'documented/gemstone/bounty/task.rb', line 221 def none? [:none, nil].include?(type) end |
#ready? ⇒ Boolean
Checks if the task is ready to be executed.
248 249 250 251 252 253 |
# File 'documented/gemstone/bounty/task.rb', line 248 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 task.
143 144 145 |
# File 'documented/gemstone/bounty/task.rb', line 143 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.
300 301 302 |
# File 'documented/gemstone/bounty/task.rb', line 300 def respond_to_missing?(symbol, include_private = false) requirements&.keys&.include?(symbol) || super end |
#search_heirloom? ⇒ Boolean
Checks if the task is a search heirloom task.
159 160 161 162 |
# File 'documented/gemstone/bounty/task.rb', line 159 def search_heirloom? [:heirloom].include?(type) && requirements[:action] == "search" end |
#skin? ⇒ Boolean
Checks if the task type is a skin task.
151 152 153 |
# File 'documented/gemstone/bounty/task.rb', line 151 def skin? type.to_s.start_with?("skin") end |
#spawned? ⇒ Boolean
Checks if the task has spawned.
197 198 199 200 201 |
# File 'documented/gemstone/bounty/task.rb', line 197 def spawned? [ :dangerous_spawned, :escort, :rescue_spawned ].include?(type) end |
#task ⇒ Symbol
Returns the type of the task.
29 |
# File 'documented/gemstone/bounty/task.rb', line 29 def task; type; end |
#triggered? ⇒ Boolean
Checks if the task has been triggered (spawned).
207 |
# File 'documented/gemstone/bounty/task.rb', line 207 def triggered?; spawned?; end |