Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .devcontainer/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
env
echo `pwd`

# Ruby requirements. Why won't mise install these for me?
sudo apt update && sudo apt install -y zlib1g-dev libssl-dev libffi-dev libyaml-dev

curl https://mise.run | sh
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
mise install
46 changes: 46 additions & 0 deletions public/examples/deathknight/frost.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

# ---
# title: 'Death Knight: Frost (11.2)'
# ---

title 'Frost Death Knight WhackAura'
load spec: :frost_death_knight
hide_ooc!

dynamic_group 'Frost DK Rotation' do
offset y: -100

action_usable 'Obliterate', if_stacks: { 'Killing Machine' => '>= 2' } do
glow!
end

action_usable 'Howling Blast', requires: { auras: ['Rime'] } do
glow!
end

action_usable 'Frost Strike', if_stacks: { 'Razorice' => '>= 5' }
action_usable 'Frost Strike'
action_usable 'Obliterate', if_stacks: { 'Killing Machine' => '1' }
action_usable 'Obliterate'
action_usable 'Empower Rune Weapon'
end

dynamic_group 'Frost DK AoE' do
offset y: -140

action_usable 'Frostscythe', if_stacks: { 'Killing Machine' => '>= 1' }
action_usable 'Glacial Advance'
end

dynamic_group 'Frost DK Cooldowns' do
offset y: -40

action_usable 'Pillar of Frost' do
glow!
end
action_usable "Reaper's Mark"
action_usable "Frostwyrm's Fury"
action_usable 'Breath of Sindragosa'
action_usable 'Abomination Limb'
end
14 changes: 14 additions & 0 deletions public/examples/mage/frost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
hide_ooc!

dynamic_group 'Frost Mage WhackAuras' do
icon 'Ray of Frost' do
action_usable! do
aura 'Cryopathy' do
stacks '>= 2' do
glow!
end
end
end
end

icon 'Ring of Fire' do
action_usable!
end

action_usable 'Comet Storm'
action_usable 'Glacial Spike' do
glow!
Expand Down
7 changes: 6 additions & 1 deletion public/examples/paladin/retribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
scale 0.8
action_usable 'Wake of Ashes'
action_usable 'Judgement'
action_usable 'Blade of Justice'
icon 'Blade of Justice' do
action_usable
action_usable spell_count: '>= 2' do
glow!
end
end
action_usable 'Final Verdict'
action_usable 'Bladestorm'
action_usable 'Divine Toll'
Expand Down
30 changes: 25 additions & 5 deletions public/examples/priest/shadow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,37 @@
load spec: :shadow_priest
hide_ooc!

dynamic_group 'WhackAuras' do
dynamic_group 'Shadow Stay Big' do
scale 0.6
offset y: -40, x: 80

action_usable 'Void Eruption'
action_usable 'Power Infusion'
action_usable 'Shadowfiend'
end

dynamic_group 'Shadow Stay Small' do
scale 0.6
offset y: -40, x: -80

action_usable 'Psyfiend'
action_usable 'Void Torrent'
action_usable 'Halo'
end

dynamic_group 'Shadow WhackAuras' do
scale 0.8
offset y: -70

debuff_missing 'Shadow Word: Pain'
debuff_missing 'Vampiric Touch'

action_usable 'Shadow Crash' do
glow!
end
action_usable 'Mind Blast'
action_usable 'Void Torrent'
action_usable 'Mindbender'
action_usable 'Halo'
action_usable 'Void Eruption'
action_usable 'Shadow Word: Death'
action_usable 'Shadow Crash'
action_usable 'Devouring Plague'
action_usable 'Mind Flay: Insanity'
end
49 changes: 29 additions & 20 deletions public/examples/warrior/arms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,41 @@
# title: 'Warrior: Arms'
# ---

title 'Arms Warrior'
load spec: :arms_warrior
hide_ooc!

dynamic_group 'Arms WhackAuras' do
action_usable 'Colossus Smash'
# action_usable 'Warbreaker'
action_usable 'Execute'
dynamic_group 'Arms Stay Big' do
scale 0.7
offset y: -40, x: 60

action_usable 'Avatar'
action_usable 'Bladestorm'
# TODO: cleave instead of MS display when more than N targets?
# action_usable 'Cleave'
# action_usable 'Whirlwind'
end

dynamic_group 'Arms Stay Small' do
scale 0.7
offset y: -40, x: -60

action_usable 'Recklessness'
action_usable 'Thunderous Roar'
action_usable 'Colossus Smash'
end

# TODO: add `stacks` to glow! instead
# Min-maxing OP>MS is not recommended.
# action_usable 'Mortal Strike', if_stacks: { 'Overpower' => 2 } do
# glow!
# end
# action_usable 'Overpower' do
# glow! charges: 2
# end
dynamic_group 'Arms WhackAuras' do
scale 0.8
offset y: -80

action_usable 'Skullsplitter'
action_usable 'Colossus Smash'
action_usable 'Execute' do
glow! # todo: glow on sudden death only
end
action_usable 'Bladestorm'
action_usable 'Wrecking Throw'
action_usable 'Cleave'

action_usable ['Mortal Strike', 'Overpower']
action_usable 'Thunder Clap', requires: { target_debuffs_missing: ['Rend'] }
action_usable 'Rend', requires: { target_debuffs_missing: ['Rend'] }
action_usable 'Sweeping Strikes'
action_usable 'Avatar' do
glow!
end
end
end
21 changes: 21 additions & 0 deletions public/examples/warrior/protection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,28 @@
load spec: :protection_warrior
hide_ooc!

dynamic_group 'Prot Stay Big' do
scale 0.7
offset y: -40, x: 60

action_usable 'Avatar'
action_usable "Champion's Spear"
action_usable 'Shield Wall'
action_usable 'Last Stand'
end

dynamic_group 'Prot Stay Small' do
scale 0.7
offset y: -40, x: -60

action_usable 'Thunderous Roar'
action_usable 'Demolish'
end

dynamic_group 'Prot WhackAuras' do
scale 0.8
offset y: -80

action_usable 'Revenge'
action_usable 'Shield Slam'
action_usable 'Shield Block'
Expand Down
14 changes: 9 additions & 5 deletions public/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"/examples/shaman/elemental.rb": {
"title": "Shaman: Elemental"
},
"/examples/priest/shadow.rb": {
"title": "Priest: Shadow"
},
"/examples/rogue/outlaw.rb": {
"title": "Rogue: Outlaw"
},
"/examples/priest/shadow.rb": {
"title": "Priest: Shadow"
},
"/examples/paladin/retribution.rb": {
"title": "Paladin: Retribution"
},
Expand All @@ -35,6 +35,9 @@
},
"/examples/demonhunter/havoc.rb": {
"title": "Demon Hunter: Havoc"
},
"/examples/deathknight/frost.rb": {
"title": "Death Knight: Frost (11.2)"
}
},
"examples": [
Expand All @@ -43,13 +46,14 @@
"/examples/warrior/arms.rb",
"/examples/shaman/restoration.rb",
"/examples/shaman/elemental.rb",
"/examples/priest/shadow.rb",
"/examples/rogue/outlaw.rb",
"/examples/priest/shadow.rb",
"/examples/paladin/retribution.rb",
"/examples/paladin/protection.rb",
"/examples/mage/frost.rb",
"/examples/hunter/beastmastery.rb",
"/examples/demonhunter/havoc.rb"
"/examples/demonhunter/havoc.rb",
"/examples/deathknight/frost.rb"
],
"lua": [
"/lua/inspect.lua",
Expand Down
60 changes: 46 additions & 14 deletions public/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@
class Node # rubocop:disable Style/Documentation,Metrics/ClassLength
include Casting::Client
delegate_missing_methods
attr_accessor :uid, :children, :controlled_children, :parent, :triggers, :actions, :type, :options
attr_accessor :uid, :children, :controlled_children, :parent, :triggers, :trigger_options, :actions, :type, :options
attr_reader :conditions

def initialize(id: nil, type: nil, parent: nil, triggers: [], actions: { start: [], init: [], finish: [] }, &block) # rubocop:disable Metrics/MethodLength
def initialize(id: nil, type: nil, parent: nil, triggers: [], trigger_options: nil, actions: { start: [], init: [], finish: [] }, &block) # rubocop:disable Metrics/MethodLength,Metrics/ParameterLists,Layout/LineLength
@uid = Digest::SHA1.hexdigest([id, parent, triggers, actions].to_json)[0..10]
@id = "#{id} (#{@uid})"
@id = id
@parent = parent
@children = []
@controlled_children = []
@triggers = triggers
@trigger_options = trigger_options || {
disjunctive: 'any',
activeTriggerMode: -10
}
@actions = actions
@conditions = []
@type = type
Expand Down Expand Up @@ -138,7 +142,9 @@ def make_triggers(requires, if_missing: [], if_stacks: {}, triggers: []) # ruboc
end

def map_triggers(triggers)
Hash[*triggers.each_with_index.to_h { |trigger, index| [index + 1, trigger.as_json] }.flatten]
Hash[*triggers.each_with_index.to_h do |trigger, index|
[index + 1, trigger.as_json]
end.flatten].merge(trigger_options)
end

def load(spec: nil) # rubocop:disable Metrics/MethodLength
Expand Down Expand Up @@ -182,8 +188,9 @@ def dynamic_group(name, **kwargs, &block)
end

def icon(*args, **kwargs, &block)
kwargs = { parent: self, type: type }.merge(kwargs)
icon = WeakAura::Icon.new(*args, **kwargs, &block)
args = { id: args[0] } if args[0].is_a?(String)
kwargs = { parent: self, type: type }.merge(args).merge(kwargs)
icon = WeakAura::Icon.new(**kwargs, &block)
add_node(icon)
end

Expand All @@ -195,7 +202,7 @@ def add_node(node)
node
end

def glow!(options = {}) # rubocop:disable Metrics/MethodLength
def glow!(**options) # rubocop:disable Metrics/MethodLength
raise 'glow! only supports a single check, use multiple `glow!` calls for multiple checks.' if options.keys.size > 1

check = []
Expand All @@ -208,15 +215,16 @@ def glow!(options = {}) # rubocop:disable Metrics/MethodLength
end

if options[:charges]
charges_value, charges_op = parse_operator(options[:charges])
check = {
"variable": 'charges',
"op": '==',
"value": options[:charges].to_s,
"trigger": 1
'variable' => 'charges',
'op' => charges_op,
'value' => charges_value.to_s,
'trigger' => 1
}
end

@conditions ||= {}
@conditions ||= []
@conditions << {
check: check,
changes: [
Expand All @@ -228,8 +236,28 @@ def glow!(options = {}) # rubocop:disable Metrics/MethodLength
}
end

def aura(name, **options, &block)
# Adds an aura trigger for conditional logic
options[:parent_node] = self
trigger = Trigger::Auras.new(aura_names: name, **options)
triggers << trigger

# Executes block in context of trigger for nested conditions
trigger.instance_eval(&block) if block_given?
trigger
end

def parse_operator(value)
return [value, '=='] if value.is_a?(Integer)

value_str = value.to_s
operator = value_str.match(/^[<>!=]+/)&.[](0) || '=='
parsed_value = value_str.gsub(/^[<>!=]+\s*/, '').to_i
[parsed_value, operator]
end

def hide_ooc! # rubocop:disable Metrics/MethodLength
@conditions ||= {}
@conditions ||= []
@conditions << {
check: {
trigger: -1,
Expand All @@ -245,7 +273,11 @@ def hide_ooc! # rubocop:disable Metrics/MethodLength
end

def as_json
{ load: load, triggers: triggers, actions: actions, conditions: conditions,
{ id: "#{id} (#{@uid})",
load: load,
triggers: triggers.is_a?(Hash) ? triggers : map_triggers(triggers),
actions: actions,
conditions: conditions,
tocversion: TOC_VERSION }
end
end
Loading