Fix pro chest requirement bug, add KD requirement
This commit is contained in:
parent
04e9634087
commit
39f1727d35
1 changed files with 9 additions and 3 deletions
|
@ -35,6 +35,10 @@ function ctf.get_spawn(tname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function max(a, b)
|
||||||
|
return (a > b) and a or b
|
||||||
|
end
|
||||||
|
|
||||||
local function get_is_player_pro(player)
|
local function get_is_player_pro(player)
|
||||||
local players = {}
|
local players = {}
|
||||||
for pname, pstat in pairs(ctf_stats.players) do
|
for pname, pstat in pairs(ctf_stats.players) do
|
||||||
|
@ -42,7 +46,9 @@ local function get_is_player_pro(player)
|
||||||
pstat.color = nil
|
pstat.color = nil
|
||||||
table.insert(players, pstat)
|
table.insert(players, pstat)
|
||||||
end
|
end
|
||||||
return ctf_stats.player(player:get_player_name()).score > 0
|
local pstat = ctf_stats.player(player:get_player_name())
|
||||||
|
local kd = pstat.kills / max(pstat.deaths, 1)
|
||||||
|
return pstat.score > 2000 and kd > 2
|
||||||
end
|
end
|
||||||
|
|
||||||
local colors = {"red", "blue"}
|
local colors = {"red", "blue"}
|
||||||
|
@ -99,10 +105,10 @@ for _, chest_color in pairs(colors) do
|
||||||
|
|
||||||
if is_pro then
|
if is_pro then
|
||||||
formspec = formspec .. "listring[current_name;pro]" ..
|
formspec = formspec .. "listring[current_name;pro]" ..
|
||||||
"label[5,-0.2;" .. minetest.formspec_escape("Pro players only (score 200+)") .. "]"
|
"label[5,-0.2;" .. minetest.formspec_escape("Pro players only (2k+ score, good KD)") .. "]"
|
||||||
else
|
else
|
||||||
formspec = formspec .. "listring[current_name;pro]" ..
|
formspec = formspec .. "listring[current_name;pro]" ..
|
||||||
"label[5,-0.2;" .. minetest.formspec_escape("You need more score (200+)") .. "]"
|
"label[5,-0.2;" .. minetest.formspec_escape("You need 2k+ score and good KD") .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
|
|
Loading…
Reference in a new issue