Module: Api::ActionExtension
- Included in:
- Action
- Defined in:
- lib/sc2ai/protocol/extensions/action.rb
Overview
Adds additional functionality and fixes quirks with color specifically pertaining to debug commands
Instance Method Summary collapse
-
#ability_id ⇒ Integer?
Finds ability_id for the action, if applicable.
-
#action_type ⇒ Class
Checks the action type and returns corresponding class.
-
#unit_tags ⇒ Array<Integer>
Finds unit tags for action, if applicable.
Instance Method Details
#ability_id ⇒ Integer?
Finds ability_id for the action, if applicable
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sc2ai/protocol/extensions/action.rb', line 43 def ability_id if action_type == Api::ActionRaw case action_raw.action when :unit_command # ActionRawUnitCommand return action_raw.unit_command.ability_id when :toggle_autocast # ActionRawToggleAutocast return action_raw.toggle_autocast.ability_id end elsif action_type == Api::ActionSpatial && action_ui.action == :unit_command # ActionSpatialUnitCommand return action_ui.unit_command.ability_id end nil end |
#action_type ⇒ Class
Checks the action type and returns corresponding class
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sc2ai/protocol/extensions/action.rb', line 6 def action_type @action_type ||= if has_action_raw? Api::ActionRaw elsif has_action_chat? Api::ActionChat elsif has_action_feature_layer? Api::ActionSpatial elsif has_action_ui? Api::ActionUI end end |
#unit_tags ⇒ Array<Integer>
Finds unit tags for action, if applicable
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sc2ai/protocol/extensions/action.rb', line 20 def = [] if action_type == Api::ActionRaw case action_raw.action when :unit_command # ActionRawUnitCommand = action_raw.unit_command. when :toggle_autocast # ActionRawToggleAutocast = action_raw.toggle_autocast. end # when Api::ActionSpatial # if action == :unit_command # ActionSpatialUnitCommand # # For spatial unit commands, one _could_ assume the errors came from # # the last selected allied units on the previous frame. # # Since we don't have bot access here, leaving this empty. # # tags = @bot.previous.all_units.owned.select(&:is_selected).tags # end end end |