-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrategyEngine.lua
More file actions
200 lines (180 loc) · 8.17 KB
/
StrategyEngine.lua
File metadata and controls
200 lines (180 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
local _, ns = ...
local Constants = ns.Constants
local StrategyEngine = {}
-- Static per-archetype recommended actions.
local ARCHETYPE_ACTIONS = {
setup_burst = {
"Survive the setup window — pre-position defensives before the CC chain lands.",
"Trinket only the critical CC in the chain, not the opener.",
"Counter-pressure during their downtime between goes.",
},
sustained_caster = {
"Interrupt or kick key casts on cooldown to disrupt sustained pressure.",
"Maintain melee uptime or LoS to reduce free casting time.",
"Save burst for windows when their defenses are on cooldown.",
},
melee_pressure = {
"Kite during their offensive cooldowns — they rely on uptime.",
"Peel or CC them off your healer during their go windows.",
"Trade cooldowns efficiently — their pressure is constant, not bursty.",
},
skirmisher = {
"Track their mobility cooldowns — they re-engage aggressively.",
"Don't overcommit defensives to chip damage; wait for committed goes.",
"Control the pace — force them to play reactive instead of proactive.",
},
control_healer = {
"Coordinate CC chains on the healer during your go windows.",
"Purge or dispel key healing buffs before attempting a kill.",
"Pressure the DPS to force early healer cooldowns.",
},
reactive_healer = {
"Land kill attempts in CC windows when the healer can't react.",
"Apply sustained pressure to force throughput cooldowns early.",
"Swap to the healer if DPS is too defensively loaded.",
},
bruiser = {
"Avoid trading into them in prolonged 1v1 — they outlast most specs.",
"Focus on their teammates — bruisers struggle to peel at range.",
"Save burst for execute range where their tankiness matters less.",
},
sustained_ranged = {
"Close distance quickly — their damage drops in melee range.",
"Interrupt key shots and use LoS to reduce free damage.",
"Pressure hard during pet downtime if applicable.",
},
}
-- Fallback actions for unknown archetypes.
local DEFAULT_ACTIONS = {
"Track their major offensive cooldowns and respond with defensives.",
"Look for CC windows to set up your own kill attempts.",
"Play to your spec's strengths rather than reacting to theirs.",
}
-- ── Baseline threat score coefficients ───────────────────────────────────
-- Used to estimate threat when historicalFights < 3. Tune weights here.
local ARCHETYPE_THREAT_BONUS = {
setup_burst = 0.15,
melee_pressure = 0.10,
skirmisher = 0.08,
sustained_caster = 0.05,
sustained_ranged = 0.05,
control_healer = 0.05,
reactive_healer = 0.03,
bruiser = 0.00,
}
local TAG_THREAT_BONUS = {
frequent_cc = 0.10,
execute_risk = 0.08,
immunity_risk = 0.08,
control_pressure = 0.08,
mobility_heavy = 0.06,
purge_pressure = 0.04,
}
local THREAT_MELEE_BONUS = 0.05
local THREAT_CC_FAM_BONUS = 0.03
local THREAT_CC_FAM_CAP = 4
local THREAT_BASE = 0.45
local THREAT_MIN = 0.25
local THREAT_MAX = 0.90
local function ComputeBaselineThreatScore(specId)
local archetype = ns.StaticPvpData and ns.StaticPvpData.GetSpecArchetype
and ns.StaticPvpData.GetSpecArchetype(specId) or nil
if not archetype then return THREAT_BASE end
local score = THREAT_BASE
score = score + (ARCHETYPE_THREAT_BONUS[archetype.archetype] or 0)
for _, tag in ipairs(archetype.threatTags or {}) do
score = score + (TAG_THREAT_BONUS[tag] or 0)
end
if archetype.rangeBucket == "melee" then
score = score + THREAT_MELEE_BONUS
end
-- Count unique CC families from SeedArenaControl data.
local ccFamilies = ns.StaticPvpData and ns.StaticPvpData.GetCCFamiliesForSpec
and ns.StaticPvpData.GetCCFamiliesForSpec(specId) or {}
local familySet = {}
for _, entry in ipairs(ccFamilies) do
if type(entry) == "table" and entry.family then
familySet[entry.family] = true
end
end
local familyCount = 0
for _ in pairs(familySet) do familyCount = familyCount + 1 end
score = score + math.min(familyCount, THREAT_CC_FAM_CAP) * THREAT_CC_FAM_BONUS
return math.max(THREAT_MIN, math.min(THREAT_MAX, score))
end
function StrategyEngine.GetCounterGuide(specId, playerBuildHash, characterKey)
if not specId then return nil end
local store = ns.Addon:GetModule("CombatStore")
local archetype = ns.StaticPvpData and ns.StaticPvpData.GetSpecArchetype(specId) or nil
local ccFamilies = ns.StaticPvpData and ns.StaticPvpData.GetCCFamiliesForSpec(specId) or {}
local specSignature = store and store.GetSpecDamageSignature and store:GetSpecDamageSignature(specId) or {}
local buildEffectiveness = playerBuildHash and store and store.GetBuildEffectivenessVsSpec
and store:GetBuildEffectivenessVsSpec(playerBuildHash, specId) or nil
local bestBuild = store and store.GetBestBuildVsSpec and store:GetBestBuildVsSpec(specId) or nil
local winRateByMMR = store and store.GetSpecWinRateByMMRBand
and store:GetSpecWinRateByMMRBand(specId, characterKey) or {}
-- Historical win rate from spec aggregate.
local specWinRate = nil
local specFights = 0
if store and store.GetAggregateBucketByKey then
local bucket = store:GetAggregateBucketByKey("specs", specId, characterKey)
if bucket then
specFights = bucket.fights or 0
if specFights > 0 then
specWinRate = (bucket.wins or 0) / specFights
end
end
end
local baselineThreat = ComputeBaselineThreatScore(specId)
-- Top opponent spells (from specDamageSignatures).
local topSpellsFromOpponent = {}
for i, entry in ipairs(specSignature) do
if i > 5 then break end
topSpellsFromOpponent[i] = entry
end
-- Archetype-based recommended actions.
local archetypeKey = archetype and archetype.archetype or nil
local recommendedActions = ARCHETYPE_ACTIONS[archetypeKey] or DEFAULT_ACTIONS
-- Enrich with static counter tips from SeedCounterTips (if available).
local counterTips = ns.StaticPvpData and ns.StaticPvpData.GetCounterTips
and ns.StaticPvpData.GetCounterTips(specId) or nil
if counterTips then
-- Merge seed tips before archetype actions for richer output.
local merged = {}
for _, t in ipairs(counterTips.tips or {}) do
merged[#merged + 1] = t
end
for _, a in ipairs(recommendedActions) do
merged[#merged + 1] = a
end
recommendedActions = merged
end
return {
specId = specId,
archetypeLabel = archetype and archetype.archetype or "unknown",
specName = archetype and archetype.specName or nil,
classFile = archetype and archetype.classFile or nil,
rangeBucket = archetype and archetype.rangeBucket or "unknown",
threatTags = archetype and archetype.threatTags or {},
ccFamilies = ccFamilies,
topSpellsFromOpponent = topSpellsFromOpponent,
historicalWinRate = specWinRate,
historicalFights = specFights,
baselineThreatScore = baselineThreat, -- NEW
winRateByMMRBand = winRateByMMR,
bestBuildVsSpec = bestBuild,
currentBuildEffectiveness = buildEffectiveness,
recommendedActions = recommendedActions,
interruptPriority = counterTips and counterTips.interruptPriority or {},
safeWindows = counterTips and counterTips.safeWindows or {},
murlokWinRate = counterTips and counterTips.murlokWinRate or nil,
}
end
-- Convenience: check if enough data exists for a meaningful guide.
function StrategyEngine.HasSufficientData(specId, characterKey)
local store = ns.Addon:GetModule("CombatStore")
if not store or not store.GetAggregateBucketByKey then return false end
local bucket = store:GetAggregateBucketByKey("specs", specId, characterKey)
return bucket ~= nil and (bucket.fights or 0) >= 5
end
ns.Addon:RegisterModule("StrategyEngine", StrategyEngine)