-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOnyfansLoot-Commands.lua
182 lines (173 loc) · 10.8 KB
/
OnyfansLoot-Commands.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
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
local util = OnyFansLoot.util
SLASH_OF1 = "/of"
SLASH_OF2 = "/onyfansloot"
SlashCmdList["OF"] = function(msg)
local regex = "(%a+) ?(.*)"
local msg1, msg2 = string.match(msg, regex)
if msg1 and msg1 == "export" then
local data = GetExportData(msg2)
util:ShowExportFrame(data)
elseif util:IsEmptyString(msg1) or msg1 == "help" then
DEFAULT_CHAT_FRAME:AddMessage("OnyFansLoot usage:")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000help|r: brings up this text")
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000/of|r or |r|cff9482c9/onyfansloot|r { help | export | export n| export help | export key | import | commit | disenchant | clear | autoinv | exclude | exclude clear | exclude show }")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000export|r: exports the latest raid loot into a window to be copy pasted")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000export |r|cff9482c9n|r: where n is between 1 and 5, export one of the last five raids")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000export |r|cff9482c9help|r: bring up a list of raid {key}s")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000export |r|cff9482c9key|r: bring up drops for a specific raid key. Where key is one of the keys got from export help")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000import |r: brings up a window to import from csv")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000stage |r: stages csv import so you can test it on tooltips before sharing it")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000commit |r: commit staged changes so its shared with everyone. Assuming higher list version")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000disenchant |r: One click disenchanting command. Macro this. Checks if item is enchanted as well")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000clear |r: Clears imported lists (but not tooltip lists). useful for removing nags if you are not importing lists but once did")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000autoinv |r: Periodically auto invites people from guild that also have a list into the raid group")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000exclude |r |cff9482c9key|r: Adds items from list drops to exclusion list where key is a key from -of export help-")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000exclude |r |cff9482c9clear|r: Clears the current exlusion list and bumps the version up one. Use this if you are starting a brand new list")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000exclude |r |cff9482c9show|r: prints out what's on the exclude list")
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000exclude |r |cff9482c9add:itemName:playerName|r: adds an item player name combo to the exclusion list. ex. /of exclude add:broken boar tusk:Heliosx")
elseif msg1 and msg1 == "import" then
if util:IsAllowedToImport() then
local instructions = "************DELETE ALL THIS TEXT BEFORE PASTING IN YOUR CSV************\n\n" ..
"******************INSTRUCTIONS******************\n" ..
"DELETE ALL ITEMS WITH STRIKETHROUGH IN SOURCE LIST OR HAVE AN AN EXLUSION LIST\n"..
"STRIKETHROUGH IS NOT IMPORTED INTO CSV SO ANY IMPORT CANNOT TELL THE DIFFERENCE UNLESS YOU HAVE AN EXLUSION LIST\n" ..
"IF A LIST ITEM IS MISSPELLED IT WILL NOT WORK\n\n"..
"THE LIST WILL BE CROSSED CHECKED WITH ATLASLOOT FOR MISSPELLINGS\n\n" ..
"************DELETE ALL THIS TEXT BEFORE PASTING IN YOUR CSV************\n\n"
ImportFrameHeaderString:SetText("CSV Import")
ImportFrameText:SetText(instructions)
ShowUIPanel(ImportFrame, 1)
else
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Sorry you need to be an officer or GM to import")
end
elseif msg1 and msg1 == "stage" then
if not util:IsTableEmpty(ImportedTable) then
util:StageImportedList()
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Imported List Has Been Staged")
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Commit changes for them to take effect and be shared with others")
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Current Tooltips reflect staged list only")
else
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: There is no imported list to stage")
end
elseif msg1 and msg1 == 'commit' then
if OnyFansLoot.isStaged and not util:IsTableEmpty(StagedOfLoot) then
OfLoot = StagedOfLoot
OnyFansLoot.isStaged = false
StagedOfLoot = {}
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Staged changes have been commited. Will share list assuming it has the highest version number")
else
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Nothing currently staged to commit")
end
elseif msg1 and msg1 == 'disenchant' then
DisenchantCommand()
elseif msg1 and msg1 == 'clear' then
ImportedTable = {}
elseif msg1 and msg1 == "autoinv" then
if not OnyFansLoot.raidInvite then
OnyFansLoot.raidInvite = true
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Auto Raid Inviting guild members with lists has been turned |cff9482c9on|r")
else
OnyFansLoot.raidInvite = false
OnyFansLoot.invitedList = {}
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Auto Raid Inviting guild members with lists has been turned |cff9482c9off|r")
end
elseif msg1 and msg2 and msg1 == 'exclude' then
if util:DoesTableContainKey(OfDrops, msg2) and util:IsAllowedToImport() then
for i, v in ipairs(OfDrops[msg2]) do
for k, val in pairs(OfDrops[msg2][i]) do
util:AddToListExclusions(k, val)
end
end
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Added all the list drops from raid: |cff9482c9" .. msg2 .. "|r to exclusion list")
elseif msg2 == 'clear' and util:IsAllowedToImport() then
local exLength, exVersion = util:GetExclusionInfo(ListExclusions)
ListExclusions = {}
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: Exlusion list " .. exVersion .. " has been cleared. New exlusion list version is now |cff9482c9" .. exVersion + 1 .. "|r")
ListExclusions.version = exVersion + 1
elseif msg2 == "show" then
PrintExcludeList()
elseif string.find(msg2, "add:") then
local add, itemName, playerName = util:StrSplit(":", msg2)
util:AddToListExclusions(itemName, playerName)
else
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: This raid key does not exist or not officer. Find a key with the |cff9482c9'of export help'|r command")
end
end
end
function GetExportData(msg2)
local data = "Improper input or doesn't exist"
local lastKeys = util:GetLastNKeys(5, Drops)
if msg2 and tonumber(msg2) ~= nil and tonumber(msg2) <= 5 then
if util:DoesTableContainKey(OfDrops, lastKeys[tonumber(msg2)]) or util:DoesTableContainKey(Drops, lastKeys[tonumber(msg2)]) then
data = util:ExportLootTablesAsString(lastKeys[tonumber(msg2)])
end
elseif msg2 and msg2 == "help" then
data = util:ExportDropTableKeys(Drops)
elseif msg2 and util:DoesTableContainKey(OfDrops, msg2) or util:DoesTableContainKey(Drops, msg2)then
data = util:ExportLootTablesAsString(msg2)
elseif util:IsEmptyString(msg2) and table.getn(lastKeys) > 0 then
data = util:ExportLootTablesAsString(lastKeys[1])
end
return data
end
function DisenchantCommand()
local canDisenchant = IsSpellInSpellBook("Disenchant")
local focus = GetMouseFocus()
local slotID = focus:GetID()
if focus:GetParent() then
local bagID = focus:GetParent():GetID()
if bagID then
local itemLink = GetContainerItemLink(bagID, slotID)
if itemLink and canDisenchant then
HandleDisenchantGlobal(itemLink)
local hexColor, itemString, itemName = util:GetItemLinkParts(itemLink)
if itemString then
HandleDisenchanting(itemString, bagID, slotID, itemLink)
end
elseif not canDisenchant then
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: You're not an enchanter or an error getting an item's ID ")
end
end
end
end
function DisenchantBagItem(bagID, slotID, itemLink)
CastSpellByName("Disenchant")
PickupContainerItem(bagID,slotID)
OnyFansLoot.lastDisenchantedItem = itemLink
OnyFansLoot.LastDisenchantedItemCount = 0
OnyFansLoot.lastDisenchantTime = GetTime()
end
function HandleDisenchanting(itemString, bagID, slotID, itemLink)
local timesToDisenchantEnchanted = 3
local minQualityToDisenchant = 2
local itemId, enchantId, suffixId, uniqueId = util:GetItemStringParts(itemString)
local _, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemId)
if tonumber(quality) >= minQualityToDisenchant then
if tonumber(enchantId) == 0 then
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: |cff9482c9DISENCHANTING|r ".. itemLink)
DisenchantBagItem(bagID,slotID, itemLink)
elseif OnyFansLoot.LastDisenchantedItemCount >= timesToDisenchantEnchanted then
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: |cff9482c9DISENCHANTING|r ".. itemLink .. " with enchantID:" .. enchantId)
DisenchantBagItem(bagID,slotID, itemLink)
else
OnyFansLoot.lastDisenchantedItem = itemLink
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r:".. itemLink .. " is ENCHANTED. Press |cff9482c9" .. (timesToDisenchantEnchanted - OnyFansLoot.LastDisenchantedItemCount) .. "|r more times to disenchant.")
end
else
DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000OnyFansLoot|r: You can't disenchant " .. itemLink)
end
end
function HandleDisenchantGlobal(itemLink)
if not OnyFansLoot.LastDisenchantedItemCount or OnyFansLoot.lastDisenchantedItem ~= itemLink then
OnyFansLoot.LastDisenchantedItemCount = 0
elseif OnyFansLoot.lastDisenchantedItem == itemLink then
OnyFansLoot.LastDisenchantedItemCount = OnyFansLoot.LastDisenchantedItemCount + 1
end
end
function PrintExcludeList()
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000Exclusion List Items:|r ")
for n, v in ipairs(ListExclusions) do
local itemPlayerString = util:TitleCase(v["playerName"]) .. ": " .. util:TitleCase(v["itemName"])
DEFAULT_CHAT_FRAME:AddMessage(" - |cffFF0000Item:|r |cff9482c9".. n .. "|r: " .. itemPlayerString)
end
end