Skip to content

Commit

Permalink
Revert "Flag streak code improvements"
Browse files Browse the repository at this point in the history
This reverts commit 774c05d.

Revert "Track flag attempt streaks P.1 (MT-CTF#1196)"

This reverts commit 6e1f0a8.
  • Loading branch information
LoneWolfHT committed Jun 14, 2024
1 parent 774c05d commit 72f07a1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
56 changes: 0 additions & 56 deletions mods/ctf/ctf_modebase/flags/taking.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
-- this is table of streaks.
-- mega streak means 4 or 5 attempt in less than 10 minutes
local streaks = {
[3] = "three",
[4] = "four",
[5] = "mega",
[7] = "mega",
[8] = "giga",
[10] = "giga",
[12] = "tera",
[14] = "EXA",
}

local function drop_flags(player, pteam)
local pname = player:get_player_name()
local flagteams = ctf_modebase.taken_flags[pname]
Expand Down Expand Up @@ -91,48 +78,6 @@ function ctf_modebase.flag_on_punch(puncher, nodepos, node)
table.insert(ctf_modebase.taken_flags[pname], target_team)
ctf_modebase.flag_taken[target_team] = {p=pname, t=pteam}


if ctf_modebase.flag_attempt_history[pname] == nil then
ctf_modebase.flag_attempt_history[pname] = {}
end
table.insert(ctf_modebase.flag_attempt_history[pname], os.time())

local number_of_attempts = 0
local total_time = 0 -- should be less than 60*10 = 10 minutes
local prev_time = nil
local new = nil
for i = #ctf_modebase.flag_attempt_history[pname], 1, -1 do
local time = ctf_modebase.flag_attempt_history[i]

if prev_time then
total_time = prev_time - time
else
prev_time = time
end

if total_time >= 60*10 then
if not new then
new = table.copy(ctf_modebase.flag_attempt_history[pname])
end

table.remove(new, 1)
else
number_of_attempts = number_of_attempts + 1
end
end

if new then
ctf_modebase.flag_attempt_history[pname] = new
end

local streak = streaks[number_of_attempts]
if number_of_attempts >= 10 then
streak = "EXA"
end
if streak then
minetest.chat_send_all(pname .. " is on a " .. streak .. " attempt streak!")
end

player_api.set_texture(puncher, 2,
"default_wood.png^([combine:16x16:4,0=wool_white.png^[colorize:"..ctf_teams.team[target_team].color..":200)"
)
Expand Down Expand Up @@ -177,7 +122,6 @@ ctf_api.register_on_match_end(function()
ctf_modebase.taken_flags = {}
ctf_modebase.flag_taken = {}
ctf_modebase.flag_captured = {}
ctf_modebase.flag_attempt_history = {}
end)

ctf_teams.register_on_allocplayer(function(player, new_team, old_team)
Expand Down
4 changes: 0 additions & 4 deletions mods/ctf/ctf_modebase/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ ctf_modebase = {

--flag_captured[Team name] = true if captured, otherwise nil
flag_captured = {},

flag_attempt_history = {
-- ["player"] = {time0, time1, time2, ...}
},
}

ctf_gui.old_init()
Expand Down

0 comments on commit 72f07a1

Please sign in to comment.