-
Notifications
You must be signed in to change notification settings - Fork 4
/
alt.lua
145 lines (122 loc) · 3.75 KB
/
alt.lua
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
local _, addonData = ...
local summon
local util
local chat
local gossip
local monitor
local alt = {
me = "",
playersInConversation = {},
-- TODO: add whisper alt function for the summon buttons
init = function(self)
addonData.debug:registerCategory("alt")
self.me, _ = UnitName("player")
summon = addonData.summon
util = addonData.util
chat = addonData.chat
gossip = addonData.gossip
monitor = addonData.monitor
monitor:create(15, self.listWhisper)
end,
newPlayer = function(self, player)
if player == self.me then
for _,v in pairs(SteaSummonSave.alttoons) do
db("alt", "mytoon:", v)
end
if #SteaSummonSave.alttoons > 0 then
db("alt", "adding my own toons as alts")
gossip:alts(player, SteaSummonSave.alttoons)
end
return
end
end,
listWhisper = function(_, upTo, boost)
-- maybe some convos get triggered
local i = 1
local boosted = 0
-- don't whisper if we can't summon
if summon.numwaiting == 0 or not summon:summonsReady() then
return
end
if upTo == nil and boost ~= nil then
upTo = summon.numwaiting
elseif upTo == nil then
upTo = SteaSummonSave.qspot
end
db("alt", "checking list for offlines with alts")
while(i <= summon.numwaiting and i <= upTo) do
local rec = summon.waiting[i]
local player = summon:recPlayer(rec)
db("alt", "player", player)
if summon:recStatus(rec) == "offline" and #summon:recAlts(rec) > 0
and (summon:recAltWhispered(rec) == "x" or summon:recAltWhispered(rec) > 59) then
db("alt", "offline with alts")
for _,alt in pairs(summon:recAlts(rec)) do
db("alt", "whispering", alt)
gossip:chatThis("raisealt", alt)
end
summon:recAltWhispered(rec, 0)
gossip:altWhispered(summon:recPlayer(rec), 0)
boosted = boosted + 1
if boost and boosted == boost then
break
end
end
i = i + 1
end
end,
listShorter = function(self)
local upTo = SteaSummonSave.qspot
if upTo == 0 or upTo == 41 then
return
end
self:listWhisper(upTo)
end,
listBoost = function(self)
local boost = SteaSummonSave.qboost
if boost == 0 then
return
end
self:listWhisper(nil, boost)
end,
whispered = function(_, player, text)
db("alt", "whispered", text, "from", player)
local wait = summon:findWaitingPlayer(player)
if not wait or summon:recStatus(wait) ~= "requested" then
-- filter out thank yous and such (because the world is asynchronous)
-- and random whispers, because the whole world is not in your raid
return
end
-- let's see if this is a single word or a list of words
local alts = {}
local words = util:multiLineToTable(text, ",")
for _, v in pairs(words) do
local alt = strtrim(v)
if string.find(v, " ") then
-- probably indicates something other than an alt or list of alts
-- otoh, failure conditions include lmao, plz, and other drivel, let's hope those aren't real toons
db("alt", "spaces found")
return
end
table.insert(alts, alt)
end
if #alts > 0 then
-- probably have an alt list, or some very angry people called plz and lmao
gossip:alts(player, alts)
end
end,
askForAlts = function(_, player)
if summon.zone == "" then
return -- don't whisper people if not indicating we are going to summon
end
local idx = summon:findWaitingPlayerIdx(player)
if SteaSummonSave.altbuffed and #summon:recBuffs(summon.waiting[idx]) == 0 then
return
end
if SteaSummonSave.initialQspot <= idx then
-- we need to talk
gossip:chatThis("alt", player)
end
end,
}
addonData.alt = alt