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

Allow players to set their own Blessing assignments by whispering #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
73 changes: 73 additions & 0 deletions PallyPower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function PallyPower:OnEnable()
self:ScanCooldowns()
self:RegisterEvent("CHAT_MSG_ADDON")
self:RegisterEvent("CHAT_MSG_SYSTEM")
self:RegisterEvent("CHAT_MSG_WHISPER")
self:RegisterEvent("ZONE_CHANGED")
self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
Expand Down Expand Up @@ -1618,6 +1619,78 @@ function PallyPower:CHAT_MSG_SYSTEM(event, text)
end
end

-- set normal bless using whispering e.g. "/w paladin !BOK" will set Bless of King for the player who whisp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add a message filter (cf. ChatFrame_AddMessageEventFilter) to hide these whispers and the auto-replies

function PallyPower:CHAT_MSG_WHISPER(event, text, a, b, c, wguid)
if text then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text cannot be nil

text = string.upper(text)
local blessID, blessName

if sfind(text, "!WISDOM") then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use text:find("^%s*!WISDOM") to only match at start of string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also localization concerns once again, what about players not playing in english?

blessID = 1
elseif sfind(text, "!MIGHT") or sfind(text, "!BOM") then
blessID = 2
elseif sfind(text, "!KING") or sfind(text, "!BOK") then
blessID = 3
elseif sfind(text, "!SALVATION") or sfind(text, "!BOS") or sfind(text, "!SALV") then
blessID = 4
elseif sfind(text, "!LIGHT") or sfind(text, "!BOL") then
blessID = 5
elseif sfind(text, "!SANCTUARY") or sfind(text, "!SANCT") then
blessID = 6
elseif sfind(text, "!BLESSINFO") or sfind(text, "!PP") then
blessID = 99
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, no; find a clean way to handle this special case that doesn't involve a magic blessing id

else
blessID = 0
end

blessName = PallyPower.IDToBless[blessID]

if blessID > 0 then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return out

local playerGuid = UnitGUID(wguid)
-- self:Print(playerGuid)

if playerGuid then
local localizedClass, englishClass, localizedRace, englishRace, sex, playerName, realm = GetPlayerInfoByGUID(playerGuid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we almost definitely already have this data somewhere; check the roster functions


if blessID == 99 then
local normalBlessText, normalBlessID
for pally in pairs(AllPallys) do

if PallyPower_Assignments[pally][PallyPower.ClassToID[englishClass]] then
-- self:Print(PallyPower_Assignments[pally][PallyPower.ClassToID[englishClass]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of your debug comments please

-- self:Print(GetNormalBlessings(pally, PallyPower.ClassToID[englishClass], playerName))
normalBlessID = GetNormalBlessings(pally, PallyPower.ClassToID[englishClass], playerName)
-- self:Print(normalBlessID)
if normalBlessID then
-- self:Print(normalBlessID)
normalBlessText = " (single bless: " .. PallyPower.IDToBless[tonumber(normalBlessID)] .. ") "
else
normalBlessText = ""
end

SendChatMessage(pally .. " -> " .. PallyPower.IDToBless[PallyPower_Assignments[pally][PallyPower.ClassToID[englishClass]]] .. normalBlessText, "WHISPER", "Common", playerName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg3 = nil for default language, don't hardcode Common, this won't work for horde

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also do we need a separate chat message for each paladin in the raid? concatenate this into a single reply, otherwise you'll quickly get spam filtered if many raiders use this (and you have lots of paladins in vanilla)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this line of code is very unreadable, split it up

end

end
-- self:Print(PallyPower_Assignments[PallyPower.player][PallyPower.ClassToID[englishClass]])
return false
end
-- self:Print(text)
-- self:Print(PallyPower.player)
-- self:Print(englishClass)
-- self:Print(PallyPower.ClassToID[englishClass])

SetNormalBlessings(PallyPower.player, PallyPower.ClassToID[englishClass], playerName, blessID)

self:Print(playerName .. " has now assigned " .. blessName .. " bless (small)")
SendChatMessage("You have now assigned " .. blessName .. " bless (small)", "WHISPER", "Common", playerName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before, don't hardcode arg3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also localization concerns here

else
self:Print("Player not found. Is he/she in your group?")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a player is shown this message, what are they supposed to do about it?

either silently discard or error reply to the sender, don't show anything to user

end -- end playerGuid
end -- end BlessID > 0
end --end text != nil
end

function PallyPower:UNIT_SPELLCAST_SUCCEEDED(event, unitTarget, castGUID, spellID)
if select(2, UnitClass(unitTarget)) == "PALADIN" then
for _, spells in pairs(self.Cooldowns) do
Expand Down
10 changes: 10 additions & 0 deletions PallyPowerValues.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ PallyPower.ClassToID = PallyPower.isBCC and {
["PET"] = 9
}

PallyPower.IDToBless = {
[0] = "NONE",
[1] = "WISDOM",
[2] = "MIGHT",
[3] = "KING",
[4] = "SALVATION",
[5] = "LIGHT",
[6] = "SANCTUARY",
}
icyz marked this conversation as resolved.
Show resolved Hide resolved

PallyPower.ClassIcons = PallyPower.isBCC and {
[1] = "Interface\\Icons\\ClassIcon_Warrior",
[2] = "Interface\\Icons\\ClassIcon_Rogue",
Expand Down