Add files via upload
This commit is contained in:
+41
-20
@@ -63,7 +63,7 @@ local totalRow = nil
|
||||
---------------------------------------------------------------
|
||||
local function NewStatBlock()
|
||||
return {
|
||||
wins = 0, losses = 0,
|
||||
wins = 0, draws = 0, losses = 0,
|
||||
kills = 0, deaths = 0, hk = 0,
|
||||
marks = 0, honor = 0,
|
||||
bestKB = 0, streak = 0, bestStreak = 0,
|
||||
@@ -84,6 +84,7 @@ local function EnsureDB()
|
||||
if s.bestStreak == nil then s.bestStreak = 0 end
|
||||
if s.hk == nil then s.hk = 0 end
|
||||
if s.marks == nil then s.marks = 0 end
|
||||
if s.draws == nil then s.draws = 0 end
|
||||
db.stats[k] = s
|
||||
end
|
||||
return db
|
||||
@@ -309,22 +310,33 @@ local function RecordEnd(key, index)
|
||||
if not s then return end
|
||||
|
||||
local playerWon = false
|
||||
local isDraw = false
|
||||
local winner = GetBattlefieldWinner()
|
||||
if winner then
|
||||
local myFaction = UnitFactionGroup("player")
|
||||
local wonAsAlliance = (winner == 1 and myFaction == "Alliance")
|
||||
local wonAsHorde = (winner == 0 and myFaction == "Horde")
|
||||
playerWon = wonAsAlliance or wonAsHorde
|
||||
if playerWon then
|
||||
s.wins = s.wins + 1
|
||||
s.streak = s.streak + 1
|
||||
if s.streak > s.bestStreak then s.bestStreak = s.streak end
|
||||
else
|
||||
s.losses = s.losses + 1
|
||||
-- Some server builds (incl. Turtle/Octo) report a draw as a winner
|
||||
-- value that is neither 0 (Horde) nor 1 (Alliance). Treat anything
|
||||
-- else as a draw so it isn't miscounted as a loss.
|
||||
isDraw = (winner ~= 0 and winner ~= 1)
|
||||
if isDraw then
|
||||
s.draws = s.draws + 1
|
||||
s.streak = 0
|
||||
else
|
||||
local wonAsAlliance = (winner == 1 and myFaction == "Alliance")
|
||||
local wonAsHorde = (winner == 0 and myFaction == "Horde")
|
||||
playerWon = wonAsAlliance or wonAsHorde
|
||||
if playerWon then
|
||||
s.wins = s.wins + 1
|
||||
s.streak = s.streak + 1
|
||||
if s.streak > s.bestStreak then s.bestStreak = s.streak end
|
||||
else
|
||||
s.losses = s.losses + 1
|
||||
s.streak = 0
|
||||
end
|
||||
end
|
||||
local isBG = (key == "AV" or key == "WSG" or key == "AB")
|
||||
if isBG then
|
||||
-- Draws award the loss-tier mark count.
|
||||
s.marks = s.marks + (playerWon and MARKS_WIN or MARKS_LOSS)
|
||||
end
|
||||
end
|
||||
@@ -352,9 +364,15 @@ local function RecordEnd(key, index)
|
||||
if key == "AV" or key == "WSG" or key == "AB" then
|
||||
marksMsg = " +" .. (playerWon and MARKS_WIN or MARKS_LOSS) .. " marks"
|
||||
end
|
||||
Print(BG_NAMES[key] .. " recorded ("
|
||||
.. (playerWon and "|cff66ff66win|r" or "|cffff6666loss|r")
|
||||
.. marksMsg .. ").")
|
||||
local outcomeStr
|
||||
if isDraw then
|
||||
outcomeStr = "|cffffff66draw|r"
|
||||
elseif playerWon then
|
||||
outcomeStr = "|cff66ff66win|r"
|
||||
else
|
||||
outcomeStr = "|cffff6666loss|r"
|
||||
end
|
||||
Print(BG_NAMES[key] .. " recorded (" .. outcomeStr .. marksMsg .. ").")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------
|
||||
@@ -763,10 +781,10 @@ end
|
||||
---------------------------------------------------------------
|
||||
-- UI: build row FontStrings inside the stats panel
|
||||
---------------------------------------------------------------
|
||||
local COL_X = { 14, 158, 208, 258, 308, 354, 400, 446, 496, 550, 614 }
|
||||
local COL_W = { 140, 46, 46, 46, 46, 46, 46, 46, 50, 60, 58 }
|
||||
local COL_J = { "LEFT", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER" }
|
||||
local COL_NAMES = { "bg", "games", "win", "loss", "ratio", "kb", "hk", "dth", "kd", "honor", "mk" }
|
||||
local COL_X = { 14, 158, 208, 258, 308, 358, 408, 454, 500, 550, 604, 668 }
|
||||
local COL_W = { 140, 46, 46, 46, 46, 46, 46, 46, 46, 50, 60, 58 }
|
||||
local COL_J = { "LEFT", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER" }
|
||||
local COL_NAMES = { "bg", "games", "win", "draw", "loss", "ratio", "kb", "hk", "dth", "kd", "honor", "mk" }
|
||||
|
||||
local ROW_HEIGHT = 22
|
||||
local ROW_TOP = -34
|
||||
@@ -776,7 +794,7 @@ local function MakeRow(panel, tag, yOff, striped)
|
||||
if striped then
|
||||
local bg = panel:CreateTexture("RPVPRowBG"..tag, "BACKGROUND")
|
||||
bg:SetTexture(1, 1, 1, 0.04)
|
||||
bg:SetWidth(660); bg:SetHeight(ROW_HEIGHT - 2)
|
||||
bg:SetWidth(714); bg:SetHeight(ROW_HEIGHT - 2)
|
||||
bg:SetPoint("TOPLEFT", panel, "TOPLEFT", 14, yOff + 2)
|
||||
end
|
||||
for c = 1, table.getn(COL_NAMES) do
|
||||
@@ -812,7 +830,7 @@ local function BuildStatsRows()
|
||||
local totalY = ROW_TOP - n * ROW_HEIGHT - 4
|
||||
local div = panel:CreateTexture("RPVPTotalDivider", "ARTWORK")
|
||||
div:SetTexture(1, 1, 1, 0.25)
|
||||
div:SetWidth(660); div:SetHeight(1)
|
||||
div:SetWidth(714); div:SetHeight(1)
|
||||
div:SetPoint("TOPLEFT", panel, "TOPLEFT", 14, totalY + 2)
|
||||
|
||||
totalRow = MakeRow(panel, "TOTAL", totalY - 6, false)
|
||||
@@ -847,7 +865,8 @@ local function FormatQueueLine()
|
||||
end
|
||||
|
||||
local function FillRow(r, s)
|
||||
local games = s.wins + s.losses
|
||||
local draws = s.draws or 0
|
||||
local games = s.wins + draws + s.losses
|
||||
local pct = 0
|
||||
if games > 0 then pct = math.floor((s.wins / games) * 100 + 0.5) end
|
||||
local kd = "-"
|
||||
@@ -859,6 +878,7 @@ local function FillRow(r, s)
|
||||
|
||||
r.games:SetText(games)
|
||||
r.win:SetText(s.wins)
|
||||
r.draw:SetText(draws)
|
||||
r.loss:SetText(s.losses)
|
||||
r.ratio:SetText(pct .. "%")
|
||||
r.kb:SetText(s.kills)
|
||||
@@ -892,6 +912,7 @@ function RelationshipsPVP_Refresh()
|
||||
if r then FillRow(r, s) end
|
||||
|
||||
totals.wins = totals.wins + s.wins
|
||||
totals.draws = totals.draws + (s.draws or 0)
|
||||
totals.losses = totals.losses + s.losses
|
||||
totals.kills = totals.kills + s.kills
|
||||
totals.hk = totals.hk + s.hk
|
||||
|
||||
Reference in New Issue
Block a user