Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spell_count to ActionUsable trigger #13

Merged
merged 4 commits into from
Sep 21, 2024
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
20 changes: 20 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "weakauras",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tools]
ruby = "latest"
node = "latest"
ruby = "latest"
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
source 'https://rubygems.org'

gem 'ruby_wasm', github: 'ruby/ruby.wasm'
# gem 'ruby_wasm', github: 'ruby/ruby.wasm'
gem 'ruby-lsp'

group :development do
gem 'rubocop'
end

group :test do
gem 'debug'
gem 'guard'
gem 'guard-rspec', require: false
gem 'rspec'
Expand Down
33 changes: 26 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
GIT
remote: https://github.com/ruby/ruby.wasm.git
revision: 0bab190cd87d533096ad98eefd3132b93fbe9068
specs:
ruby_wasm (2.4.1)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
casting (1.0.2)
coderay (1.1.3)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
deep_merge (1.2.2)
diff-lcs (1.5.1)
docile (1.4.0)
Expand All @@ -30,12 +27,17 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
io-console (0.7.2)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.1)
json_pure (2.7.1)
language_server-protocol (3.17.0.3)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
lumberjack (1.2.10)
method_source (1.1.0)
nenv (0.3.0)
Expand All @@ -46,15 +48,24 @@ GEM
parser (3.3.0.2)
ast (~> 2.4.1)
racc
prism (1.0.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
psych (5.1.2)
stringio
racc (1.7.3)
rainbow (3.1.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.5.3)
logger
rdoc (6.7.0)
psych (>= 4.0.0)
regexp_parser (2.9.0)
reline (0.5.10)
io-console (~> 0.5)
rexml (3.2.6)
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand Down Expand Up @@ -82,6 +93,11 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
ruby-lsp (0.18.1)
language_server-protocol (~> 3.17.0)
prism (~> 1.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-progressbar (1.13.0)
shellany (0.0.1)
simplecov (0.22.0)
Expand All @@ -90,6 +106,8 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sorbet-runtime (0.5.11577)
stringio (3.1.1)
thor (1.3.1)
unicode-display_width (2.5.0)

Expand All @@ -99,13 +117,14 @@ PLATFORMS

DEPENDENCIES
casting
debug
deep_merge
guard
guard-rspec
json_pure
rspec
rubocop
ruby_wasm!
ruby-lsp
simplecov

BUNDLED WITH
Expand Down
19 changes: 19 additions & 0 deletions public/examples/mage/frost.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# ---
# title: 'Mage: Frost'
# ---

title 'Mage: Frost'
load spec: :frost_mage
hide_ooc!

dynamic_group 'Frost Mage WhackAuras' do
action_usable 'Comet Storm'
action_usable 'Glacial Spike' do
glow!
end
action_usable 'Shifting Power'
action_usable 'Frozen Orb'
action_usable({ spell_name: 'Flurry', spell_count: 1 })
end
16 changes: 13 additions & 3 deletions public/examples/warrior/fury.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
# title: 'Warrior: Fury'
# ---

title 'Warrior: Fury'
load spec: :fury_warrior
hide_ooc!

dynamic_group 'Fury WhackAuras' do
offset y: -100
action_usable 'Bloodthirst'
action_usable 'Raging Blow'
action_usable 'Rampage', if_missing: ['Enrage'] do
action_usable 'Rampage'
action_usable 'Execute', if_stacks: { 'Ashen Juggernaut' => '>= 2' } do
glow!
end
action_usable 'Rampage', requires: { auras: ['Enrage'] }
action_usable 'Execute'
action_usable 'Execute', if_stacks: { 'Ashen Juggernaut' => '< 2' }
action_usable 'Bladestorm'
action_usable 'Thunderous Roar'
action_usable "Odyn's Fury"
action_usable 'Whirlwind', if_missing: ['Whirlwind']
end

dynamic_group 'Fury Offensive Cooldowns' do
offset y: -40
action_usable 'Recklessness'
action_usable 'Avatar'
end
5 changes: 4 additions & 1 deletion public/node.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

TOC_VERSION = 110_002

WOW_SPECS = {
blood_deathknight: 250,
frost_deathknight: 251,
Expand Down Expand Up @@ -243,6 +245,7 @@
end

def as_json
{ load: load, triggers: triggers, actions: actions, conditions: conditions }
{ load: load, triggers: triggers, actions: actions, conditions: conditions,

Check warning on line 248 in public/node.rb

View check run for this annotation

Codecov / codecov/patch

public/node.rb#L248

Added line #L248 was not covered by tests
tocversion: TOC_VERSION }
end
end
1 change: 0 additions & 1 deletion public/weak_aura.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def as_json # rubocop:disable Metrics/MethodLength
},
internalVersion: 70,
yOffset: 99.999755859375,
tocversion: 100_200,
id: id,
borderOffset: 4,
frameStrata: 1,
Expand Down
1 change: 0 additions & 1 deletion public/weak_aura/dynamic_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def as_json # rubocop:disable Metrics/MethodLength
uid: uid,
constantFactor: 'RADIUS',
borderOffset: 4,
tocversion: 100_200,
id: id,
rotation: 0,
frameStrata: 1,
Expand Down
1 change: 0 additions & 1 deletion public/weak_aura/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def as_json # rubocop:disable Metrics/MethodLength
},
internalVersion: 70,
yOffset: 99.999755859375,
tocversion: 100_200,
id: id,
borderOffset: 4,
frameStrata: 1,
Expand Down
1 change: 0 additions & 1 deletion public/weak_aura/icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def as_json # rubocop:disable Metrics/MethodLength
1,
1
],
tocversion: 100_200,
id: id,
config: [],
alpha: 1,
Expand Down
8 changes: 8 additions & 0 deletions public/weak_aura/triggers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ def initialize(**options)
spell_name: options[:spell]
}.merge(options)
end

def parse_count_operator(count, default_operator = '==')
return [count, default_operator] if count.is_a?(Integer)

operator = count.to_s.match(/^[<>!=]+/)&.[](0) || default_operator
count = count.to_s.gsub(/^[<>!=]+/, '').to_i
[count, operator]
end
end
end

Expand Down
55 changes: 38 additions & 17 deletions public/weak_aura/triggers/action_usable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,45 @@ def initialize(**_options)
end

def as_json # rubocop:disable Metrics/MethodLength
trigger = {
type: 'spell',
subeventSuffix: '_CAST_START',
spellName: options[:spell],
use_exact_spellName: !!options[:exact],
use_genericShowOn: true,
event: 'Action Usable',
names: [],
realSpellName: options[:spell_name],
use_spellName: true,
spellIds: [],
genericShowOn: 'showOnCooldown',
subeventPrefix: 'SPELL',
unit: 'player',
use_track: true,
debuffType: 'HELPFUL'
}

if options[:spell_count]
spell_count_operator = options[:spell_count].to_s.match(/[<>=]+/)&.[](0) || '=='
spell_count = if options[:spell_count].is_a?(Numeric)
options[:spell_count]
else
options[:spell_count]
.match(/[0-9]+/)&.[](0)
end.to_i

if spell_count
trigger
.merge!({
spellCount: spell_count,
use_spellCount: true,
spellCount_operator: spell_count_operator
})
end
end

{
trigger: {
type: 'spell',
subeventSuffix: '_CAST_START',
spellName: options[:spell],
use_exact_spellName: !!options[:exact],
use_genericShowOn: true,
event: 'Action Usable',
names: [],
realSpellName: options[:spell_name],
use_spellName: true,
spellIds: [],
genericShowOn: 'showOnCooldown',
subeventPrefix: 'SPELL',
unit: 'player',
use_track: true,
debuffType: 'HELPFUL'
}
trigger: trigger
}
end
end
Expand Down
17 changes: 17 additions & 0 deletions public/weak_aura/triggers/action_usable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require './spec/spec_helper'

RSpec.describe Trigger::ActionUsable do
it 'should accept spell_count and default to the equality operator' do
trigger = Trigger::ActionUsable.new(spell_count: 1).as_json[:trigger]
expect(trigger[:spellCount]).to eq(1)
expect(trigger[:spellCount_operator]).to eq('==')
end

it 'should accept spell_count w/ gte operator' do
trigger = Trigger::ActionUsable.new(spell_count: '>= 1').as_json[:trigger]
expect(trigger[:spellCount]).to eq(1)
expect(trigger[:spellCount_operator]).to eq('>=')
end
end
Loading
Loading