Class: Lich::Gemstone::Bounty::Task
- Inherits:
-
Object
- Object
- Lich::Gemstone::Bounty::Task
- Defined in:
- lib/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 type ends with “assignment”.
-
#assist? ⇒ Boolean
Checks if the task is an assist task (alias for help?).
-
#bandit? ⇒ Boolean
Checks if the task type starts with “bandit”.
-
#count ⇒ nil
Returns the number of tasks (not implemented).
-
#creature ⇒ Symbol?
Returns the creature requirement for the task.
-
#creature? ⇒ Boolean
Checks if the task type is one of the creature-related types.
-
#critter ⇒ Symbol?
Returns the creature requirement for the task (alias for creature).
-
#critter? ⇒ Boolean
Checks if a creature is required for the task.
-
#cull? ⇒ Boolean
Checks if the task type starts with “cull”.
-
#dangerous? ⇒ Boolean
Checks if the task type starts with “dangerous”.
-
#done? ⇒ Boolean
Checks if the task is done based on its type.
-
#escort? ⇒ Boolean
Checks if the task type starts with “escort”.
-
#gem? ⇒ Boolean
Checks if the task type starts with “gem”.
-
#group? ⇒ Boolean
Checks if the task is a group task (alias for help?).
-
#guard? ⇒ Boolean
Checks if the task type is one of the guard-related types.
-
#heirloom? ⇒ Boolean
Checks if the task type starts with “heirloom”.
-
#heirloom_found? ⇒ Boolean
Checks if the task type is “heirloom_found”.
-
#help? ⇒ Boolean
Checks if the description indicates a help task.
-
#herb? ⇒ Boolean
Checks if the task type starts with “herb”.
-
#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 area requirement or the town associated with the task.
-
#loot_heirloom? ⇒ Boolean
Checks if the task is a loot action for an heirloom.
-
#method_missing(symbol, *args, &blk) ⇒ Object
Handles missing methods by returning the corresponding requirement if it exists.
-
#none? ⇒ Boolean
Checks if there are no tasks.
-
#ready? ⇒ Boolean
Checks if the task is ready based on its type.
-
#rescue? ⇒ Boolean
Checks if the task type starts with “rescue”.
-
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Checks if the method is missing and if it corresponds to a requirement.
-
#search_heirloom? ⇒ Boolean
Checks if the task is a search action for an heirloom.
-
#skin? ⇒ Boolean
Checks if the task type starts with “skin”.
-
#spawned? ⇒ Boolean
Checks if the task type is one of the spawned types.
-
#task ⇒ Symbol
Returns the type of the task.
-
#triggered? ⇒ Boolean
Checks if the task has been triggered (alias for spawned?).
Constructor Details
#initialize(options = {}) ⇒ Task
Initializes a new Task with the given options.
13 14 15 16 17 18 |
# File 'lib/gemstone/bounty/task.rb', line 13 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 missing methods by returning the corresponding requirement if it exists.
254 255 256 257 258 259 260 |
# File 'lib/gemstone/bounty/task.rb', line 254 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.
20 21 22 |
# File 'lib/gemstone/bounty/task.rb', line 20 def description @description end |
#requirements ⇒ Object
Returns the value of attribute requirements.
20 21 22 |
# File 'lib/gemstone/bounty/task.rb', line 20 def requirements @requirements end |
#town ⇒ Object
Returns the value of attribute town.
20 21 22 |
# File 'lib/gemstone/bounty/task.rb', line 20 def town @town end |
#type ⇒ Object
Returns the value of attribute type.
20 21 22 |
# File 'lib/gemstone/bounty/task.rb', line 20 def type @type end |
Instance Method Details
#any? ⇒ Boolean
Checks if there are any tasks.
188 189 190 |
# File 'lib/gemstone/bounty/task.rb', line 188 def any? !none? end |
#assigned? ⇒ Boolean
Checks if the task type ends with “assignment”.
212 213 214 |
# File 'lib/gemstone/bounty/task.rb', line 212 def assigned? type.to_s.end_with?("assignment") end |
#assist? ⇒ Boolean
Checks if the task is an assist task (alias for help?).
236 237 238 |
# File 'lib/gemstone/bounty/task.rb', line 236 def assist? help? end |
#bandit? ⇒ Boolean
Checks if the task type starts with “bandit”.
68 69 70 |
# File 'lib/gemstone/bounty/task.rb', line 68 def bandit? type.to_s.start_with?("bandit") end |
#count ⇒ nil
Returns the number of tasks (not implemented).
35 |
# File 'lib/gemstone/bounty/task.rb', line 35 def count; number; end |
#creature ⇒ Symbol?
Returns the creature requirement for the task.
40 41 42 |
# File 'lib/gemstone/bounty/task.rb', line 40 def creature requirements[:creature] end |
#creature? ⇒ Boolean
Checks if the task type is one of the creature-related types.
75 76 77 78 79 |
# File 'lib/gemstone/bounty/task.rb', line 75 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).
47 48 49 |
# File 'lib/gemstone/bounty/task.rb', line 47 def critter requirements[:creature] end |
#critter? ⇒ Boolean
Checks if a creature is required for the task.
54 55 56 |
# File 'lib/gemstone/bounty/task.rb', line 54 def critter? !!requirements[:creature] end |
#cull? ⇒ Boolean
Checks if the task type starts with “cull”.
84 85 86 |
# File 'lib/gemstone/bounty/task.rb', line 84 def cull? type.to_s.start_with?("cull") end |
#dangerous? ⇒ Boolean
Checks if the task type starts with “dangerous”.
91 92 93 |
# File 'lib/gemstone/bounty/task.rb', line 91 def dangerous? type.to_s.start_with?("dangerous") end |
#done? ⇒ Boolean
Checks if the task is done based on its type.
165 166 167 168 169 |
# File 'lib/gemstone/bounty/task.rb', line 165 def done? [ :failed, :guard, :taskmaster, :heirloom_found ].include?(type) end |
#escort? ⇒ Boolean
Checks if the task type starts with “escort”.
98 99 100 |
# File 'lib/gemstone/bounty/task.rb', line 98 def escort? type.to_s.start_with?("escort") end |
#gem? ⇒ Boolean
Checks if the task type starts with “gem”.
105 106 107 |
# File 'lib/gemstone/bounty/task.rb', line 105 def gem? type.to_s.start_with?("gem") end |
#group? ⇒ Boolean
Checks if the task is a group task (alias for help?).
243 244 245 |
# File 'lib/gemstone/bounty/task.rb', line 243 def group? help? end |
#guard? ⇒ Boolean
Checks if the task type is one of the guard-related types.
202 203 204 205 206 207 |
# File 'lib/gemstone/bounty/task.rb', line 202 def guard? [ :guard, :bandit_assignment, :creature_assignment, :heirloom_assignment, :heirloom_found, :rescue_assignment ].include?(type) end |
#heirloom? ⇒ Boolean
Checks if the task type starts with “heirloom”.
112 113 114 |
# File 'lib/gemstone/bounty/task.rb', line 112 def heirloom? type.to_s.start_with?("heirloom") end |
#heirloom_found? ⇒ Boolean
Checks if the task type is “heirloom_found”.
156 157 158 159 160 |
# File 'lib/gemstone/bounty/task.rb', line 156 def heirloom_found? [ :heirloom_found ].include?(type) end |
#help? ⇒ Boolean
Checks if the description indicates a help task.
229 230 231 |
# File 'lib/gemstone/bounty/task.rb', line 229 def help? description.start_with?("You have been tasked to help") end |
#herb? ⇒ Boolean
Checks if the task type starts with “herb”.
119 120 121 |
# File 'lib/gemstone/bounty/task.rb', line 119 def herb? type.to_s.start_with?("herb") end |
#kind ⇒ Symbol
Returns the type of the task (alias for task).
30 |
# File 'lib/gemstone/bounty/task.rb', line 30 def kind; type; end |
#location ⇒ String
Returns the area requirement or the town associated with the task.
61 62 63 |
# File 'lib/gemstone/bounty/task.rb', line 61 def location requirements[:area] || town end |
#loot_heirloom? ⇒ Boolean
Checks if the task is a loot action for an heirloom.
148 149 150 151 |
# File 'lib/gemstone/bounty/task.rb', line 148 def loot_heirloom? [:heirloom].include?(type) && requirements[:action] == "loot" end |
#none? ⇒ Boolean
Checks if there are no tasks.
195 196 197 |
# File 'lib/gemstone/bounty/task.rb', line 195 def none? [:none, nil].include?(type) end |
#ready? ⇒ Boolean
Checks if the task is ready based on its type.
219 220 221 222 223 224 |
# File 'lib/gemstone/bounty/task.rb', line 219 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 starts with “rescue”.
126 127 128 |
# File 'lib/gemstone/bounty/task.rb', line 126 def rescue? type.to_s.start_with?("rescue") end |
#respond_to_missing?(symbol, include_private = false) ⇒ Boolean
Checks if the method is missing and if it corresponds to a requirement.
267 268 269 |
# File 'lib/gemstone/bounty/task.rb', line 267 def respond_to_missing?(symbol, include_private = false) requirements&.keys&.include?(symbol) || super end |
#search_heirloom? ⇒ Boolean
Checks if the task is a search action for an heirloom.
140 141 142 143 |
# File 'lib/gemstone/bounty/task.rb', line 140 def search_heirloom? [:heirloom].include?(type) && requirements[:action] == "search" end |
#skin? ⇒ Boolean
Checks if the task type starts with “skin”.
133 134 135 |
# File 'lib/gemstone/bounty/task.rb', line 133 def skin? type.to_s.start_with?("skin") end |
#spawned? ⇒ Boolean
Checks if the task type is one of the spawned types.
174 175 176 177 178 |
# File 'lib/gemstone/bounty/task.rb', line 174 def spawned? [ :dangerous_spawned, :escort, :rescue_spawned ].include?(type) end |
#task ⇒ Symbol
Returns the type of the task.
25 |
# File 'lib/gemstone/bounty/task.rb', line 25 def task; type; end |
#triggered? ⇒ Boolean
Checks if the task has been triggered (alias for spawned?).
183 |
# File 'lib/gemstone/bounty/task.rb', line 183 def triggered?; spawned?; end |