diff --git a/mods/ctf/ctf_stats/chat.lua b/mods/ctf/ctf_stats/chat.lua index d37942a..44dd715 100644 --- a/mods/ctf/ctf_stats/chat.lua +++ b/mods/ctf/ctf_stats/chat.lua @@ -259,3 +259,48 @@ minetest.register_chatcommand("makepro", { end end }) + +minetest.register_chatcommand("makecapturepro", { + params = "[player_name]", + description = "Make player a 'capture pro'", + privs = {ctf_admin = true}, + func = function(name, param) + -- Check if param is specified, else target the caller + param = param:trim() + if param == "" then + param = name + end + + local modified = false + local stats = ctf_stats.player(param) + + local deaths = math.max(stats.deaths, 1) + if stats.kills < 1.0 * deaths then + stats.kills = math.ceil(1.01 * deaths) + modified = true + end + + if stats.score < 10000 then + stats.score = 10000 + modified = true + end + + if stats.captures < 30 then + stats.captures = 30 + modified = true + end + + local attempts = math.max(stats.attempts, 1) + if stats.captures < 0.33 * attempts then + stats.captures = math.ceil(0.34 * attempts) + modified = true + end + + if modified then + ctf_stats.request_save() + return true, "Made " .. param .. " a pro!" + else + return false, param .. " is already a pro!" + end + end +})