Skip to content

Commit

Permalink
Rows backround is colored according to estimated bracket
Browse files Browse the repository at this point in the history
  • Loading branch information
kakysha committed Oct 25, 2019
1 parent 6420ccf commit ce7199f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 32 deletions.
43 changes: 24 additions & 19 deletions GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local GUI = {}
_G["HonorSpyGUI"] = GUI

local mainFrame, statusLine, playerStandings, reportBtn, scroll = nil, nil, nil, nil
local rows = {}
local rows, brackets = {}, {}
local playersPerRow = 50
local needsRelayout = true

Expand All @@ -14,7 +14,21 @@ local colors = {
["GREY"] = "aaaaaa",
["RED"] = "C41F3B",
["GREEN"] = "00FF96",
["SHAMAN"] = "0070DE"
["SHAMAN"] = "0070DE",
["br14"] = {color="a911f5",r=0.663,g=0.067,b=0.961},
["br13"] = {color="672492",r=0.404,g=0.141,b=0.573},
["br12"] = {color="5645aa",r=0.337,g=0.271,b=0.667},
["br11"] = {color="1370ba",r=0.075,g=0.439,b=0.729},
["br10"] = {color="277ee5",r=0.153,g=0.494,b=0.898},
["br9"] = {color="2d83de",r=0.176,g=0.514,b=0.871},
["br8"] = {color="1acbeb",r=0.102,g=0.796,b=0.922},
["br7"] = {color="3f788a",r=0.247,g=0.471,b=0.541},
["br6"] = {color="c84d72",r=0.784,g=0.302,b=0.447},
["br5"] = {color="09dfa0",r=0.035,g=0.875,b=0.627},
["br4"] = {color="04bc25",r=0.016,g=0.737,b=0.145},
["br3"] = {color="e96258",r=0.914,g=0.384,b=0.345},
["br2"] = {color="90f3e1",r=0.565,g=0.953,b=0.882},
["br1"] = {color="d1cf88",r=0.82,g=0.812,b=0.533}
}

local playerName = UnitName("player")
Expand All @@ -28,7 +42,13 @@ function GUI:Show(skipUpdate)
end)
end

rows = self:BuildStandingsTable()
rows = HonorSpy:BuildStandingsTable()
local brk = HonorSpy:GetBrackets(#rows)
for i = 1, #brk do
for j = brk[i], (brk[i+1] or 0)+1, -1 do
brackets[j] = i
end
end

local poolSizeText = format(L['Pool Size'] .. ': %d ', #rows)
statusLine:SetText('|cff777777/hs show|r ' .. poolSizeText .. ' |cff777777/hs search nickname|r')
Expand Down Expand Up @@ -75,21 +95,6 @@ function GUI:Reset()
end
end

function GUI:BuildStandingsTable()
local t = { }
for playerName, player in pairs(HonorSpy.db.factionrealm.currentStandings) do
table.insert(t, {playerName, player.class, player.thisWeekHonor, player.lastWeekHonor, player.standing, player.RP, player.rank, player.last_checked})
end

local sort_column = 3; -- ThisWeekHonor
if (HonorSpy.db.factionrealm.sort == L["Rank"]) then sort_column = 6; end
table.sort(t, function(a,b)
return a[sort_column] > b[sort_column]
end)

return t
end

function GUI:UpdateTableView()
local buttons = HybridScrollFrame_GetButtons(scroll);
local offset = HybridScrollFrame_GetOffset(scroll);
Expand Down Expand Up @@ -122,7 +127,7 @@ function GUI:UpdateTableView()
if (name == playerName) then
button.Background:SetColorTexture(0.5, 0.5, 0.5, 0.2)
else
button.Background:SetColorTexture(0, 0, 0, 0.2)
button.Background:SetColorTexture(colors["br"..brackets[itemIndex]].r, colors["br"..brackets[itemIndex]].g, colors["br"..brackets[itemIndex]].b, 0.1)
end

button:Show();
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ You have three options:

1. It inspects every player in 'inspect range' which you target or mouseover
2. It syncs your db with other party/raid/bg members and your guildmates on your death
3. It can estimate your (or specific player) onward RP, Rank and Progress, taking into account your (player's) standing and pool size.
3. It can export your internal DB in CSV format to copy-paste it into Google Spreadsheets for future calculations. [Spreadsheet done specially for HonorSpy](https://docs.google.com/spreadsheets/d/1OvZ7PRhrFjRn8IoH8HIPwHfRDEq50uO64YLCsSsjBQc/edit#gid=2113352865), it will estimate RP for all players.
4. It supports automatic weekly pvp reset. Reset day can be configured.
3. It can estimate your (or specific player) onward RP, Rank and Progress, taking into account your (player's) standing and pool size
3. It can export your internal DB in CSV format to copy-paste it into Google Spreadsheets for future calculations. [Spreadsheet done specially for HonorSpy](https://docs.google.com/spreadsheets/d/1OvZ7PRhrFjRn8IoH8HIPwHfRDEq50uO64YLCsSsjBQc/edit#gid=2113352865), it will estimate RP for all players
4. It supports automatic weekly pvp reset. Reset day can be configured
6. Supports sorting by Rank and Honor
7. *Esc → Interface Options → Addons → HonorSpy* for addon settings.
7. Rows backround is colored according to estimated bracket
8. *Esc → Interface Options → Addons → HonorSpy* for addon settings

It only stores players with >15HKs.
Reset day can be configured, default is Wednesday. Reset time is fixed at 10AM UTC.
Expand All @@ -41,4 +42,4 @@ P.S. Do not be afraid of losing all your data, very likely that other players wi

### Screenshot

![HonorSpy Screenshot](https://habrastorage.org/webt/kj/fd/-v/kjfd-vhcyfupuisl5yshh0vzija.png)
![HonorSpy Screenshot](https://habrastorage.org/webt/hn/ec/e7/hnece7zzgwob86ia9putwks6vay.png)
2 changes: 1 addition & 1 deletion export.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function HonorSpy:ExportCSV()
local exportwindow = _G["ARLCopyFrame"]
local editbox = _G["ARLCopyEdit"]

local data = HonorSpyGUI:BuildStandingsTable();
local data = HonorSpy:BuildStandingsTable();
local text = "";
for _, row in pairs(data) do
text = ""
Expand Down
43 changes: 36 additions & 7 deletions honorspy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,35 +181,64 @@ local options = {
}
LibStub("AceConfig-3.0"):RegisterOptionsTable("HonorSpy", options, {"honorspy", "hs"})

function HonorSpy:BuildStandingsTable()
local t = { }
for playerName, player in pairs(HonorSpy.db.factionrealm.currentStandings) do
table.insert(t, {playerName, player.class, player.thisWeekHonor, player.lastWeekHonor, player.standing, player.RP, player.rank, player.last_checked})
end

local sort_column = 3; -- ThisWeekHonor
if (HonorSpy.db.factionrealm.sort == L["Rank"]) then sort_column = 6; end
table.sort(t, function(a,b)
return a[sort_column] > b[sort_column]
end)

return t
end

-- REPORT
function HonorSpy:GetBrackets(pool_size)
-- 1 2 3 4 5 6 7 8 9 10 11 12 13 14
local brk = {1, 0.858, 0.715, 0.587, 0.477, 0.377, 0.287, 0.207, 0.137, 0.077, 0.037, 0.017, 0.007, 0.002} -- brackets percentage

if (not pool_size) then
return brk
end
for i = 1,14 do
brk[i] = math.floor(brk[i]*pool_size+.5)
end
return brk
end

function HonorSpy:Estimate(playerOfInterest)
if (not playerOfInterest) then
playerOfInterest = playerName
end
playerOfInterest = string.upper(string.sub(playerOfInterest, 1, 1))..string.lower(string.sub(playerOfInterest, 2))

local pool_size = 0;

local standing = -1;
local t = HonorSpyGUI:BuildStandingsTable()
local t = HonorSpy:BuildStandingsTable()
local avg_lastchecked = 0;
pool_size = table.getn(t);
for i = 1, table.getn(t) do
local pool_size = #t;

for i = 1, pool_size do
if (playerOfInterest == t[i][1]) then
standing = i
end
end
if (standing == -1) then
return
end;
-- 1 2 3 4 5 6 7 8 9 10 11 12 13 14
local brk = {1, 0.858, 0.715, 0.587, 0.477, 0.377, 0.287, 0.207, 0.137, 0.077, 0.037, 0.017, 0.007, 0.002} -- brackets percentage

local RP = {0, 400} -- RP for each bracket
local Ranks = {0, 2000} -- RP for each rank

local bracket = 1;
local inside_br_progress = 0;
local brk = self:GetBrackets(pool_size)

for i = 2,14 do
brk[i] = math.floor(brk[i]*pool_size+.5);
if (standing > brk[i]) then
inside_br_progress = (brk[i-1] - standing)/(brk[i-1] - brk[i])
break
Expand Down

0 comments on commit ce7199f

Please sign in to comment.