Add "Capture Rate" statistic
This commit is contained in:
parent
7c0283df64
commit
ca8cde8a0a
2 changed files with 26 additions and 3 deletions
|
@ -40,6 +40,10 @@ local function return_as_chat_result(to, target)
|
|||
if stat.deaths > 1 then
|
||||
kd = kd / stat.deaths
|
||||
end
|
||||
local ca = stat.captures
|
||||
if stat.attempts > 1 then
|
||||
ca = ca / stat.attempts
|
||||
end
|
||||
result = result ..
|
||||
minetest.colorize("#63d437", "Kills: ") ..
|
||||
minetest.colorize("#ffea00", stat.kills ..
|
||||
|
@ -49,10 +53,12 @@ local function return_as_chat_result(to, target)
|
|||
minetest.colorize("#ffea00", math.floor(kd * 10) / 10 ..
|
||||
minetest.colorize("#63d437", "\nBounty kills: ")) ..
|
||||
minetest.colorize("#ffea00", stat.bounty_kills ..
|
||||
minetest.colorize("#63d437", " | Captures: ") ..
|
||||
minetest.colorize("#63d437", "\nCaptures: ") ..
|
||||
minetest.colorize("#ffea00", stat.captures ..
|
||||
minetest.colorize("#63d437", " | Attempts: ")) ..
|
||||
minetest.colorize("#ffea00", stat.attempts ..
|
||||
minetest.colorize("#63d437", " | Capture Rate: ")) ..
|
||||
minetest.colorize("#ffea00", math.floor(ca * 100) .. "%" ..
|
||||
minetest.colorize("#63d437", "\nScore: ")) ..
|
||||
minetest.colorize("#ffea00", math.floor(stat.score)))
|
||||
end
|
||||
|
|
|
@ -5,13 +5,14 @@ ctf_stats.rankings_display_count = 50
|
|||
local tablecolumns = {
|
||||
"tablecolumns[color;",
|
||||
"text;",
|
||||
"text,width=16;",
|
||||
"text,width=10;",
|
||||
"text,width=4;",
|
||||
"text,width=4;",
|
||||
"text,width=4;",
|
||||
"text,width=6;",
|
||||
"text,width=6;",
|
||||
"text,width=6;",
|
||||
"text,width=6;",
|
||||
"text,width=6]"
|
||||
}
|
||||
tablecolumns = table.concat(tablecolumns, "")
|
||||
|
@ -125,7 +126,7 @@ function ctf_stats.get_formspec(title, players, header, target)
|
|||
ret = ret .. tablecolumns
|
||||
ret = ret .. "tableoptions[highlight=#00000000]"
|
||||
ret = ret .. "table[0.5,0;13.25,6.1;scores;"
|
||||
ret = ret .. "#ffffff,,Player,Kills,Deaths,K/D,Bounty Kills,Captures,Attempts,Score"
|
||||
ret = ret .. "#ffffff,,Player,Kills,Deaths,K/D,Bounty Kills,Captures,Attempts,Capture Rate,Score"
|
||||
|
||||
local hstat, hplace
|
||||
if type(target) == "number" then
|
||||
|
@ -153,6 +154,10 @@ function ctf_stats.get_formspec(title, players, header, target)
|
|||
if pstat.deaths > 1 then
|
||||
kd = kd / pstat.deaths
|
||||
end
|
||||
local ca = pstat.captures
|
||||
if pstat.attempts > 1 then
|
||||
ca = ca / pstat.attempts
|
||||
end
|
||||
ret = ret ..
|
||||
"," .. string.gsub(color, "0x", "#") ..
|
||||
"," .. i ..
|
||||
|
@ -163,6 +168,7 @@ function ctf_stats.get_formspec(title, players, header, target)
|
|||
"," .. pstat.bounty_kills ..
|
||||
"," .. pstat.captures ..
|
||||
"," .. pstat.attempts ..
|
||||
"," .. math.floor(ca * 100) .. "%" ..
|
||||
"," .. math.floor(pstat.score * 10) / 10
|
||||
end
|
||||
ret = ret .. ";-1]"
|
||||
|
@ -175,6 +181,10 @@ function ctf_stats.get_formspec(title, players, header, target)
|
|||
if hstat.deaths > 1 then
|
||||
h_kd = h_kd / hstat.deaths
|
||||
end
|
||||
local h_ca = hstat.captures
|
||||
if hstat.attempts > 1 then
|
||||
h_ca = h_ca / hstat.attempts
|
||||
end
|
||||
|
||||
ret = ret .. tablecolumns
|
||||
ret = ret .. "tableoptions[highlight=#00000000]"
|
||||
|
@ -188,6 +198,7 @@ function ctf_stats.get_formspec(title, players, header, target)
|
|||
"," .. hstat.bounty_kills ..
|
||||
"," .. hstat.captures ..
|
||||
"," .. hstat.attempts ..
|
||||
"," .. math.floor(h_ca * 100) .. "%" ..
|
||||
"," .. math.floor(hstat.score * 10) / 10 .. ";-1]"
|
||||
--[[ else
|
||||
ret = ret .. "box[0.5,6.1;13.25,0.4;#101010]"
|
||||
|
@ -213,6 +224,7 @@ function ctf_stats.get_html(title)
|
|||
"<th>Bounty kills</th>" ..
|
||||
"<th>Captures</th>" ..
|
||||
"<th>Attempts</th>" ..
|
||||
"<th>Capture Rate</th>" ..
|
||||
"<th>Score</th></tr>"
|
||||
|
||||
for i = 1, math.min(#players, 50) do
|
||||
|
@ -221,6 +233,10 @@ function ctf_stats.get_html(title)
|
|||
if pstat.deaths > 1 then
|
||||
kd = kd / pstat.deaths
|
||||
end
|
||||
local ca = pstat.captures
|
||||
if pstat.attempts > 1 then
|
||||
ca = ca / pstat.attempts
|
||||
end
|
||||
ret = ret ..
|
||||
"<tr><td>" .. i ..
|
||||
"</td><td>" .. pstat.name ..
|
||||
|
@ -230,6 +246,7 @@ function ctf_stats.get_html(title)
|
|||
"</td><td>" .. pstat.bounty_kills ..
|
||||
"</td><td>" .. pstat.captures ..
|
||||
"</td><td>" .. pstat.attempts ..
|
||||
"</td><td>" .. math.floor(ca * 100) .. "%" ..
|
||||
"</td><td>" .. math.floor(pstat.score*10)/10 .. "</td></tr>"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue