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
|
if stat.deaths > 1 then
|
||||||
kd = kd / stat.deaths
|
kd = kd / stat.deaths
|
||||||
end
|
end
|
||||||
|
local ca = stat.captures
|
||||||
|
if stat.attempts > 1 then
|
||||||
|
ca = ca / stat.attempts
|
||||||
|
end
|
||||||
result = result ..
|
result = result ..
|
||||||
minetest.colorize("#63d437", "Kills: ") ..
|
minetest.colorize("#63d437", "Kills: ") ..
|
||||||
minetest.colorize("#ffea00", stat.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("#ffea00", math.floor(kd * 10) / 10 ..
|
||||||
minetest.colorize("#63d437", "\nBounty kills: ")) ..
|
minetest.colorize("#63d437", "\nBounty kills: ")) ..
|
||||||
minetest.colorize("#ffea00", stat.bounty_kills ..
|
minetest.colorize("#ffea00", stat.bounty_kills ..
|
||||||
minetest.colorize("#63d437", " | Captures: ") ..
|
minetest.colorize("#63d437", "\nCaptures: ") ..
|
||||||
minetest.colorize("#ffea00", stat.captures ..
|
minetest.colorize("#ffea00", stat.captures ..
|
||||||
minetest.colorize("#63d437", " | Attempts: ")) ..
|
minetest.colorize("#63d437", " | Attempts: ")) ..
|
||||||
minetest.colorize("#ffea00", stat.attempts ..
|
minetest.colorize("#ffea00", stat.attempts ..
|
||||||
|
minetest.colorize("#63d437", " | Capture Rate: ")) ..
|
||||||
|
minetest.colorize("#ffea00", math.floor(ca * 100) .. "%" ..
|
||||||
minetest.colorize("#63d437", "\nScore: ")) ..
|
minetest.colorize("#63d437", "\nScore: ")) ..
|
||||||
minetest.colorize("#ffea00", math.floor(stat.score)))
|
minetest.colorize("#ffea00", math.floor(stat.score)))
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,13 +5,14 @@ ctf_stats.rankings_display_count = 50
|
||||||
local tablecolumns = {
|
local tablecolumns = {
|
||||||
"tablecolumns[color;",
|
"tablecolumns[color;",
|
||||||
"text;",
|
"text;",
|
||||||
"text,width=16;",
|
"text,width=10;",
|
||||||
"text,width=4;",
|
"text,width=4;",
|
||||||
"text,width=4;",
|
"text,width=4;",
|
||||||
"text,width=4;",
|
"text,width=4;",
|
||||||
"text,width=6;",
|
"text,width=6;",
|
||||||
"text,width=6;",
|
"text,width=6;",
|
||||||
"text,width=6;",
|
"text,width=6;",
|
||||||
|
"text,width=6;",
|
||||||
"text,width=6]"
|
"text,width=6]"
|
||||||
}
|
}
|
||||||
tablecolumns = table.concat(tablecolumns, "")
|
tablecolumns = table.concat(tablecolumns, "")
|
||||||
|
@ -125,7 +126,7 @@ function ctf_stats.get_formspec(title, players, header, target)
|
||||||
ret = ret .. tablecolumns
|
ret = ret .. tablecolumns
|
||||||
ret = ret .. "tableoptions[highlight=#00000000]"
|
ret = ret .. "tableoptions[highlight=#00000000]"
|
||||||
ret = ret .. "table[0.5,0;13.25,6.1;scores;"
|
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
|
local hstat, hplace
|
||||||
if type(target) == "number" then
|
if type(target) == "number" then
|
||||||
|
@ -153,6 +154,10 @@ function ctf_stats.get_formspec(title, players, header, target)
|
||||||
if pstat.deaths > 1 then
|
if pstat.deaths > 1 then
|
||||||
kd = kd / pstat.deaths
|
kd = kd / pstat.deaths
|
||||||
end
|
end
|
||||||
|
local ca = pstat.captures
|
||||||
|
if pstat.attempts > 1 then
|
||||||
|
ca = ca / pstat.attempts
|
||||||
|
end
|
||||||
ret = ret ..
|
ret = ret ..
|
||||||
"," .. string.gsub(color, "0x", "#") ..
|
"," .. string.gsub(color, "0x", "#") ..
|
||||||
"," .. i ..
|
"," .. i ..
|
||||||
|
@ -163,6 +168,7 @@ function ctf_stats.get_formspec(title, players, header, target)
|
||||||
"," .. pstat.bounty_kills ..
|
"," .. pstat.bounty_kills ..
|
||||||
"," .. pstat.captures ..
|
"," .. pstat.captures ..
|
||||||
"," .. pstat.attempts ..
|
"," .. pstat.attempts ..
|
||||||
|
"," .. math.floor(ca * 100) .. "%" ..
|
||||||
"," .. math.floor(pstat.score * 10) / 10
|
"," .. math.floor(pstat.score * 10) / 10
|
||||||
end
|
end
|
||||||
ret = ret .. ";-1]"
|
ret = ret .. ";-1]"
|
||||||
|
@ -175,6 +181,10 @@ function ctf_stats.get_formspec(title, players, header, target)
|
||||||
if hstat.deaths > 1 then
|
if hstat.deaths > 1 then
|
||||||
h_kd = h_kd / hstat.deaths
|
h_kd = h_kd / hstat.deaths
|
||||||
end
|
end
|
||||||
|
local h_ca = hstat.captures
|
||||||
|
if hstat.attempts > 1 then
|
||||||
|
h_ca = h_ca / hstat.attempts
|
||||||
|
end
|
||||||
|
|
||||||
ret = ret .. tablecolumns
|
ret = ret .. tablecolumns
|
||||||
ret = ret .. "tableoptions[highlight=#00000000]"
|
ret = ret .. "tableoptions[highlight=#00000000]"
|
||||||
|
@ -188,6 +198,7 @@ function ctf_stats.get_formspec(title, players, header, target)
|
||||||
"," .. hstat.bounty_kills ..
|
"," .. hstat.bounty_kills ..
|
||||||
"," .. hstat.captures ..
|
"," .. hstat.captures ..
|
||||||
"," .. hstat.attempts ..
|
"," .. hstat.attempts ..
|
||||||
|
"," .. math.floor(h_ca * 100) .. "%" ..
|
||||||
"," .. math.floor(hstat.score * 10) / 10 .. ";-1]"
|
"," .. math.floor(hstat.score * 10) / 10 .. ";-1]"
|
||||||
--[[ else
|
--[[ else
|
||||||
ret = ret .. "box[0.5,6.1;13.25,0.4;#101010]"
|
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>Bounty kills</th>" ..
|
||||||
"<th>Captures</th>" ..
|
"<th>Captures</th>" ..
|
||||||
"<th>Attempts</th>" ..
|
"<th>Attempts</th>" ..
|
||||||
|
"<th>Capture Rate</th>" ..
|
||||||
"<th>Score</th></tr>"
|
"<th>Score</th></tr>"
|
||||||
|
|
||||||
for i = 1, math.min(#players, 50) do
|
for i = 1, math.min(#players, 50) do
|
||||||
|
@ -221,6 +233,10 @@ function ctf_stats.get_html(title)
|
||||||
if pstat.deaths > 1 then
|
if pstat.deaths > 1 then
|
||||||
kd = kd / pstat.deaths
|
kd = kd / pstat.deaths
|
||||||
end
|
end
|
||||||
|
local ca = pstat.captures
|
||||||
|
if pstat.attempts > 1 then
|
||||||
|
ca = ca / pstat.attempts
|
||||||
|
end
|
||||||
ret = ret ..
|
ret = ret ..
|
||||||
"<tr><td>" .. i ..
|
"<tr><td>" .. i ..
|
||||||
"</td><td>" .. pstat.name ..
|
"</td><td>" .. pstat.name ..
|
||||||
|
@ -230,6 +246,7 @@ function ctf_stats.get_html(title)
|
||||||
"</td><td>" .. pstat.bounty_kills ..
|
"</td><td>" .. pstat.bounty_kills ..
|
||||||
"</td><td>" .. pstat.captures ..
|
"</td><td>" .. pstat.captures ..
|
||||||
"</td><td>" .. pstat.attempts ..
|
"</td><td>" .. pstat.attempts ..
|
||||||
|
"</td><td>" .. math.floor(ca * 100) .. "%" ..
|
||||||
"</td><td>" .. math.floor(pstat.score*10)/10 .. "</td></tr>"
|
"</td><td>" .. math.floor(pstat.score*10)/10 .. "</td></tr>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue