Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Vapok/CommunityDKP
Browse files Browse the repository at this point in the history
  • Loading branch information
Taidtuskecyh authored and Taidtuskecyh committed Dec 26, 2020
2 parents 079e6d4 + e002efc commit 449bc83
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 10 deletions.
54 changes: 52 additions & 2 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,10 @@ end
-- if the result is 1 level deeper, it would be CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]][search[1][2]][search[1][3]]. CommDKP:GetTable(CommDKP_DKPTable, true)[search[2][1]][search[2][2]][search[2][3]] would locate the second return, if there is one.
-- use to search for players in SavedVariables. Only two possible returns is the table or false.
-------------------------------------
function CommDKP:Table_Search(tar, val, field)
function CommDKP:Table_Search(tar, val, field, limit)
local value = string.upper(tostring(val));
local location = {}
local tableLimit = limit or -1;
for k,v in pairs(tar) do
if(type(v) == "table") then
local temp1 = k
Expand All @@ -821,9 +822,15 @@ function CommDKP:Table_Search(tar, val, field)
if field then
if k == field then
tinsert(location, {temp1, temp2, temp3, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, {temp1, temp2, temp3, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -832,9 +839,15 @@ function CommDKP:Table_Search(tar, val, field)
if field then
if k == field then
tinsert(location, {temp1, temp2, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, {temp1, temp2, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -843,9 +856,15 @@ function CommDKP:Table_Search(tar, val, field)
if field then
if k == field then
tinsert(location, {temp1, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, {temp1, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -854,9 +873,15 @@ function CommDKP:Table_Search(tar, val, field)
if field then
if k == field then
tinsert(location, k)
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, k)
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -867,9 +892,10 @@ function CommDKP:Table_Search(tar, val, field)
end
end

function CommDKP:TableStrFind(tar, val, field) -- same function as above, but searches values that contain the searched string rather than exact string matches
function CommDKP:TableStrFind(tar, val, field, limit) -- same function as above, but searches values that contain the searched string rather than exact string matches
local value = string.upper(tostring(val)); -- ex. CommDKP:TableStrFind(CommDKP:GetTable(CommDKP_DKPHistory, true), "Vapok") will return the path to any table element that contains "Vapok"
local location = {}
local tableLimit = limit or -1 -- so some functions dont operate on huge tables when they need like last 20 records...
for k,v in pairs(tar) do
if(type(v) == "table") then
local temp1 = k
Expand All @@ -884,9 +910,15 @@ function CommDKP:TableStrFind(tar, val, field) -- same function as
if field then
if k == field then
tinsert(location, {temp1, temp2, temp3, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, {temp1, temp2, temp3, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -895,9 +927,15 @@ function CommDKP:TableStrFind(tar, val, field) -- same function as
if field then
if k == field then
tinsert(location, {temp1, temp2, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, {temp1, temp2, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -906,9 +944,15 @@ function CommDKP:TableStrFind(tar, val, field) -- same function as
if field then
if k == field then
tinsert(location, {temp1, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, {temp1, k} )
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand All @@ -917,9 +961,15 @@ function CommDKP:TableStrFind(tar, val, field) -- same function as
if field then
if k == field then
tinsert(location, k)
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
else
tinsert(location, k)
if tableLimit ~= -1 and #location >= tableLimit then
return location;
end;
end
end;
end
Expand Down
10 changes: 8 additions & 2 deletions Modules/DKPHistory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,15 @@ function CommDKP:DKPHistory_Update(reset)
if not strfind(dkp, "-") then
CommDKP.ConfigTab6.history[i].d:SetText("|cff00ff00"..dkp.." "..L["DKP"].."|r - |cff616ccf"..reason.."|r |cff555555("..timeofday..")|r by |c"..c.hex..curOfficer.."|r");
else
if strfind(reason, L["WEEKLYDECAY"]) or strfind(reason, "Migration Correction") then
if filter and filter ~= L["DELETEDENTRY"] and strfind(reason, L["WEEKLYDECAY"]) then
local decay = {strsplit(",", dkp)}
CommDKP.ConfigTab6.history[i].d:SetText("|cffff0000"..decay[#decay].." "..L["DKP"].."|r - |cff616ccf"..reason.."|r |cff555555("..timeofday..")|r by |c"..c.hex..curOfficer.."|r");
-- get substring till player name and split to get correct player index for decay list
local playerIndex = {strsplit(",", string.sub(players, 1, strfind(players, filter..",")))};
-- Print decay value using playerIndex instead of percentage
CommDKP.ConfigTab6.history[i].d:SetText("|cffff0000"..decay[#playerIndex].." "..L["DKP"].."|r - |cff616ccf"..reason.."|r |cff555555("..timeofday..")|r by |c"..c.hex..curOfficer.."|r");
elseif strfind(reason, L["WEEKLYDECAY"]) or strfind(reason, "Migration Correction") then
local decay = {strsplit(",", dkp)}
CommDKP.ConfigTab6.history[i].d:SetText("|cffff0000"..decay[#decay].." "..L["DKP"].."|r - |cff616ccf"..reason.."|r |cff555555("..timeofday..")|r by |c"..c.hex..curOfficer.."|r"..decay[#decay].." "..L["DKP"].."|r - |cff616ccf"..reason.."|r |cff555555("..timeofday..")|r by |c"..c.hex..curOfficer.."|r");
else
CommDKP.ConfigTab6.history[i].d:SetText("|cffff0000"..dkp.." "..L["DKP"].."|r - |cff616ccf"..reason.."|r |cff555555("..timeofday..")|r by |c"..c.hex..curOfficer.."|r");
end
Expand Down
27 changes: 21 additions & 6 deletions TableFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ local function DisplayUserHistory(self, player)
local PlayerTable = {}
local c, PlayerSearch, PlayerSearch2, LifetimeSearch, RowCount, curDate;

PlayerSearch = CommDKP:TableStrFind(CommDKP:GetTable(CommDKP_DKPHistory, true), player, "players")
PlayerSearch2 = CommDKP:Table_Search(CommDKP:GetTable(CommDKP_Loot, true), player, "player")
LifetimeSearch = CommDKP:Table_Search(CommDKP:GetTable(CommDKP_DKPTable, true), player, "player")
PlayerSearch = CommDKP:TableStrFind(CommDKP:GetTable(CommDKP_DKPHistory, true), player, "players", 20)
PlayerSearch2 = CommDKP:Table_Search(CommDKP:GetTable(CommDKP_Loot, true), player, "player", 20)
LifetimeSearch = CommDKP:Table_Search(CommDKP:GetTable(CommDKP_DKPTable, true), player, "player", 20)

c = CommDKP:GetCColors(CommDKP:GetTable(CommDKP_DKPTable, true)[LifetimeSearch[1][1]].class)

Expand All @@ -120,15 +120,28 @@ local function DisplayUserHistory(self, player)
if PlayerSearch then
for i=1, #PlayerSearch do
if not CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].deletes and not CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].deletedby and not CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].hidden then
tinsert(PlayerTable, {reason = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].reason, date = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].date, dkp = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].dkp})
tinsert(
PlayerTable, {
reason = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].reason,
date = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].date,
dkp = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].dkp,
players = CommDKP:GetTable(CommDKP_DKPHistory, true)[PlayerSearch[i][1]].players
}
)
end
end
end

if PlayerSearch2 then
for i=1, #PlayerSearch2 do
if not CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].deletes and not CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].deletedby and not CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].hidden then
tinsert(PlayerTable, {loot = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].loot, date = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].date, zone = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].zone, boss = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].boss, cost = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].cost})
tinsert(PlayerTable, {
loot = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].loot,
date = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].date,
zone = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].zone,
boss = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].boss,
cost = CommDKP:GetTable(CommDKP_Loot, true)[PlayerSearch2[i][1]].cost
})
end
end
end
Expand All @@ -152,7 +165,9 @@ local function DisplayUserHistory(self, player)
if PlayerTable[i].dkp then
if strfind(PlayerTable[i].dkp, "%%") then
local decay = {strsplit(",", PlayerTable[i].dkp)}
GameTooltip:AddDoubleLine(" "..PlayerTable[i].reason, "|cffff0000"..decay[#decay].." DKP|r", 1.0, 0, 0);
-- get substring till player name and split to get correct player index for decay list
local playerIndex = {strsplit(",", string.sub(PlayerTable[i].players, 1, (strfind(PlayerTable[i].players, player..","))))};
GameTooltip:AddDoubleLine(" "..PlayerTable[i].reason, "|cffff0000"..decay[#playerIndex].." DKP|r", 1.0, 0, 0);
elseif tonumber(PlayerTable[i].dkp) < 0 then
GameTooltip:AddDoubleLine(" "..PlayerTable[i].reason, "|cffff0000"..CommDKP_round(PlayerTable[i].dkp, core.DB.modes.rounding).." DKP|r", 1.0, 0, 0);
else
Expand Down

0 comments on commit 449bc83

Please sign in to comment.