-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComm.lua
More file actions
133 lines (117 loc) · 4.45 KB
/
Comm.lua
File metadata and controls
133 lines (117 loc) · 4.45 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
local _, ns = ...
local PREFIX = ns.PREFIX
local state = ns.state
local Print = ns.Print
function ns.BroadcastMeasure(measure)
if not IsInGroup() then return end
local channel = IsInRaid() and "RAID" or "PARTY"
C_ChatInfo.SendAddonMessage(PREFIX, "MEASURE:" .. tostring(measure or 0), channel)
end
function ns.SendPing()
if not IsInGroup() then return end
state.activePlayers = {}
state.lastPingTime = GetTime()
local channel = IsInRaid() and "RAID" or "PARTY"
C_ChatInfo.SendAddonMessage(PREFIX, "PING", channel)
Print("Sent version check to group...")
end
function ns.SendPong()
if not IsInGroup() then return end
local channel = IsInRaid() and "RAID" or "PARTY"
C_ChatInfo.SendAddonMessage(PREFIX, "PONG:" .. ns.VERSION, channel)
end
function ns.HandleAddonMessage(message, sender)
local action, value = strsplit(":", message)
if action == "MEASURE" then
local n = tonumber(value)
if n == 0 then n = nil end
ns.SetMeasure(n, true)
ns.UpdatePlayerPanel()
ns.ValidateTarget()
elseif action == "OVERRIDE" then
local measure, slot, token = select(2, strsplit(":", message))
measure = tonumber(measure)
slot = tonumber(slot)
if measure and slot and token then
BeledarOrchestraDB.Overrides = BeledarOrchestraDB.Overrides or {}
BeledarOrchestraDB.Overrides[measure] = BeledarOrchestraDB.Overrides[measure] or {}
BeledarOrchestraDB.Overrides[measure][slot] = token
ns.UpdateAssignmentGrid()
ns.UpdatePlayerPanel()
ns.ValidateTarget()
end
elseif action == "CLEAR_OVERRIDES" then
BeledarOrchestraDB.Overrides = {}
ns.UpdateAssignmentGrid()
ns.UpdatePlayerPanel()
ns.ValidateTarget()
elseif action == "CLEAR_MEASURE" then
local m = tonumber(value)
if m and BeledarOrchestraDB.Overrides then
BeledarOrchestraDB.Overrides[m] = nil
ns.UpdateAssignmentGrid()
ns.UpdatePlayerPanel()
ns.ValidateTarget()
end
elseif action == "PING" then
ns.SendPong()
elseif action == "PONG" then
local name = Ambiguate(sender, "none")
state.activePlayers[name] = value or "Unknown"
elseif action == "PERFORMED" then
local measure, slot = select(2, strsplit(":", message))
measure = tonumber(measure)
slot = tonumber(slot)
if measure == state.currentMeasure and slot then
state.performedEmotes[slot] = true
ns.UpdateAssignmentGrid()
end
elseif action == "DANCE_MOVING" then
local measure, slot = select(2, strsplit(":", message))
measure = tonumber(measure)
slot = tonumber(slot)
if measure == state.currentMeasure and slot then
state.danceMoving[slot] = true
ns.UpdateAssignmentGrid()
end
elseif action == "DANCE_STOPPED" then
local measure, slot = select(2, strsplit(":", message))
measure = tonumber(measure)
slot = tonumber(slot)
if measure == state.currentMeasure and slot then
state.danceComplete[slot] = true
ns.UpdateAssignmentGrid()
end
elseif action == "RETRY" then
local m = tonumber(value)
if m == state.currentMeasure then
state.performedEmotes = {}
state.danceMoving = {}
state.danceComplete = {}
state.measureLocked = false
state.measureStarted = false
state.countdownEndTime = nil
ns.frame:UnregisterEvent("PLAYER_STARTED_MOVING")
ns.frame:UnregisterEvent("PLAYER_STOPPED_MOVING")
ns.UpdateAssignmentGrid()
ns.UpdatePlayerPanel()
ns.ValidateTarget()
end
elseif action == "START" then
local m, dur = select(2, strsplit(":", message))
m = tonumber(m)
dur = tonumber(dur) or state.countdownDuration
if m == state.currentMeasure then
state.countdownEndTime = GetTime() + dur
state.measureStarted = false
state.measureLocked = false
state.performedEmotes = {}
state.danceMoving = {}
state.danceComplete = {}
ns.frame:UnregisterEvent("PLAYER_STARTED_MOVING")
ns.frame:UnregisterEvent("PLAYER_STOPPED_MOVING")
ns.UpdatePlayerPanel()
ns.UpdateAssignmentGrid()
end
end
end