Skip to content

Commit

Permalink
Merge pull request #38 from prowley/alts
Browse files Browse the repository at this point in the history
Alts
  • Loading branch information
prowley authored Oct 12, 2020
2 parents c67c2c6 + 7190d2d commit 2130504
Show file tree
Hide file tree
Showing 13 changed files with 707 additions and 142 deletions.
21 changes: 21 additions & 0 deletions Locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ L["Summoning %p, please click the portal"] = true
L["raidinfo"] = "Summons are available. Type %t for summons, -%t to cancel, %t to reset to requested on summon failure"
L["clickersnag"] = "Need more clickers at %l, %z"
L["clicknag"] = "Click the summoning portal!"
L["You are in the summon queue. Whisper me an alt name if you don't want to wait online."] = true
L["You are near the top of the summon queue. Get online now."] = true

-- summon.lua
L["Warlock"] = true
Expand All @@ -34,6 +36,7 @@ L["requested"] = true
L["Buffed"] = true
L["B"] = true
L["Prioritized"] = true
L["P"] = true
L["Last"] = true
L["L"] = true
L["Normal"] = true
Expand All @@ -48,6 +51,7 @@ L["summoned"] = true
L["Location: %subzone, %zone"] = true
L["Destination: %subzone, %zone"] = true
L["Next"] = true
L["Alt:"] = true

-- optionsgui.lua
L["Raid summon instructions"] = true
Expand Down Expand Up @@ -119,6 +123,23 @@ L["Use AddOn Broadcast Communications"] = true
L["broadcastdesc"] = "Get and send summoning status updates. Gives you notifications of summon status changes, and helps to keep the summoning list alive through relogs. Makes the Next button more effective with multiple warlock summoners i.e. please don't turn this off."
L["Version Details"] = true
L["SteaSummon version %s\n\nWoW client\nversion: %v\nbuild: %b\ndate: %d\ntocversion: %t"] = true
L["Alt Support"] = true
L["Alt Character Options"] = true
L["altdesc"] = "These options allow players to log on another character while waiting for their summon to be ready."
L["Enable only when player buffed"] = true
L["altbuffeddesc"] = "Alt support only triggers the instructional whisper when the player is buffed (all players can still use alt support)"
L["Enable only when the queue spot reaches"] = true
L["qspotdesc"] = "Alt support only triggers the instructional whisper when the player is at or lower in the queue than this value"
L["Whisper alts when they reach this queue spot"] = true
L["Automatically register your characters for alt support"] = true
L["These are the characters you might be on when your summon is ready"] = true
L["qspotreadydesc"] = "Alt support only triggers ready whisper when the player reaches this spot in the queue"
L["When out of online players to summon, whisper this many extra alts"] = true
L["qspotboostreadydesc"] = "Raise players from their alts to keep summons going"
L["Whisper instructional text"] = true
L["a sentence that is whispered to instruct the player how to add an alt for their summon"] = true
L["Whisper summon ready text"] = true
L["a sentence that is whispered to tell an alt their summon is ready"] = true

-- gossip.lua
L["There is a newer version available."] = true
Expand Down
5 changes: 3 additions & 2 deletions SteaSummon.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
## Title: SteaSummon
## Notes: One button summoning, shared summoning list...
## Author: Stea
## Version: 0.57
## Version: 0.58
## SavedVariablesPerCharacter: SteaSummonSave, SteaDEBUG
## x-SteaSummon-Protocol-version: 0.4
## x-SteaSummon-Protocol-version: 0.5

Libs\embeds.xml
Locale\Locales.xml
Expand All @@ -19,6 +19,7 @@ raid.lua
summon.lua
monitor.lua
chat.lua
alt.lua
events.lua
main.lua

131 changes: 131 additions & 0 deletions alt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
local _, addonData = ...

local summon
local util
local chat
local gossip

local alt = {
me = "",
playersInConversation = {},

init = function(self)
addonData.debug:registerCategory("alt")
self.me, _ = UnitName("player")
summon = addonData.summon
util = addonData.util
chat = addonData.chat
gossip = addonData.gossip
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

if upTo == nil then
upTo = summon.numwaiting
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:recAltWhispered(rec) == "" and #summon:recAlts(rec) > 0 then
db("alt", "offline with alts")
for _,alt in pairs(summon:recAlts(rec)) do
db("alt", "whispering", alt)
chat:whisper(SteaSummonSave.altGetOnlineWhisper, alt)
summon:recAltWhispered(rec, summon:recAltWhispered(rec) .. alt .. ",")
gossip:altWhispered(summon:recPlayer(rec), alt)
end
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)
local idx = summon:findWaitingPlayerIdx(player)

if gossip.netList[player] then
--return -- addon users can configure if they want alts
end

if SteaSummonSave.altbuffed and #summon:recBuffs(summon.waiting[idx]) == 0 then
return
end

if SteaSummonSave.initialQspot <= idx then
-- we need to talk
chat:whisper(SteaSummonSave.altWhisper, player)
end
end,
}

addonData.alt = alt
17 changes: 15 additions & 2 deletions buffs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,33 @@ buffs = {
local out = ""
local spacer = ""
for _,v in pairs(buffs) do
if #v then
if #v > 0 then
db("buffs", v[1])
out = out .. spacer .. v[1] .. "~" .. v[2]
spacer = "&"
end
end
db("buffs", "buffs marshalled", out)
return out
end,

unmarshallBuffs = function(self, marshalled)
local out = {}
db("buffs", "unmarshalling", marshalled)
if not marshalled or marshalled == "" then
return out
end

local tmpOut = { strsplit("&", marshalled) }
for i,v in pairs(tmpOut) do
out[i] = { strsplit("~", tmpOut[i]) }
if not (v == nil or v == "") then
db("buffs", "unmarshalling", v)
out[i] = { strsplit("~", v) }
end

db("buffs", "buff unmarshalled", out[i][1], out[i][2])
end

return out
end,
}
Expand Down
2 changes: 2 additions & 0 deletions chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ local chat = {
if IsInGroup(player) or (player == me and settings:debug()) then
gossip:add(player, event == "CHAT_MSG_WHISPER" )
end
elseif event == "CHAT_MSG_WHISPER" then
addonData.alt:whispered(player, msg)
end
end
end,
Expand Down
10 changes: 10 additions & 0 deletions debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ local debug = {
if not SteaDEBUG or not SteaDEBUG.log then
self:reset()
end
if SteaDEBUG.loglength == nil then
SteaDEBUG.loglength = 3000
end

if #SteaDEBUG.log > SteaDEBUG.loglength then
for i = #SteaDEBUG.log, SteaDEBUG.loglength, -1 do
table.remove(SteaDEBUG.log)
end
end

local f = CreateFrame("Frame", "DBFrame", UIParent, "AnimatedShineTemplate")
f:SetPoint("CENTER")
Expand Down Expand Up @@ -166,6 +175,7 @@ local debug = {
SteaDEBUG = {}
SteaDEBUG.log = {}
SteaDEBUG.on = false
SteaDEBUG.loglength = 3000
end,

show = function(self, show)
Expand Down
3 changes: 3 additions & 0 deletions events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ function loaded(_, event, ...)
addonData.chat:init()
addonData.util:init()
addonData.buffs:init()
addonData.alt:init()

-- wait to set up debug categories until all categories are registered
-- otherwise the category or its children may not be registered for chat debug messages
addonData.debug:chatCat("summon.waitlist")
addonData.debug:chatCat("summon.spellcast")
addonData.debug:chatCat("summon.display")
addonData.debug:chatCat("gossip")
addonData.debug:chatCat("raid")
addonData.debug:chatCat("alt")
addonData.debug:chatCat("buffs")
addonData.debug:chatCatSwitch(true) -- strictly this is unnecessary, but I want to see the output

Expand Down
Loading

0 comments on commit 2130504

Please sign in to comment.