diff --git a/README.md b/README.md index 9c6271f..17e4746 100644 --- a/README.md +++ b/README.md @@ -55,3 +55,4 @@ Reasons: ### Note to European A&D and #qlpickup.ru communities Backups of database and feeder config are [here](https://disk.yandex.ru/d/hJfHip6ue7UCNg) + diff --git a/qllr/gametypes.py b/qllr/gametypes.py index 6542609..3b5e889 100644 --- a/qllr/gametypes.py +++ b/qllr/gametypes.py @@ -1,5 +1,9 @@ +import re + GAMETYPE_RULES = {} +ACC_CNT_FIRED_REGEX = re.compile("acc-([a-z]+)-cnt-fired") + def detect_by_match_report(data): for short, gt in GAMETYPE_RULES.items(): @@ -9,6 +13,20 @@ def detect_by_match_report(data): return data["game_meta"]["G"] +def detect_instagib(data): + for player in data["players"]: + for k, v in player: + matches = ACC_CNT_FIRED_REGEX.match(k) + if not matches: + continue + if matches.group(1) in ("rg", "gt"): + continue + if int(v) != 0: + return False + + return True + + class AbstractGametype: def calculate_player_perf(self, player_data, time_factor): raise NotImplementedError() # pragma: nocover @@ -110,9 +128,21 @@ def override_min_player_count(self): return 4 +class GametypeInstaCTF(GametypeCTF): + def force_by_match_report(self, data): + return data["game_meta"]["G"] == "ctf" and detect_instagib(data) + + +class GametypeInstaFreeze(GametypeFT): + def force_by_match_report(self, data): + return data["game_meta"]["G"] == "ft" and detect_instagib(data) + + GAMETYPE_RULES["ad"] = GametypeAD() GAMETYPE_RULES["ca"] = GametypeCA() GAMETYPE_RULES["ctf"] = GametypeCTF() GAMETYPE_RULES["ft"] = GametypeFT() GAMETYPE_RULES["tdm"] = GametypeTDM() GAMETYPE_RULES["tdm2v2"] = GametypeTDM2V2() +GAMETYPE_RULES["ictf"] = GametypeInstaCTF() +GAMETYPE_RULES["ift"] = GametypeInstaFreeze() diff --git a/sql/init.sql b/sql/init.sql index 314bf75..8ddcec9 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -19,7 +19,9 @@ INSERT INTO gametypes (gametype_id, gametype_name, gametype_short) VALUES (3, 'Team Deathmatch', 'tdm'), (4, 'Team Deathmatch (2v2)', 'tdm2v2'), (5, 'Freeze Tag', 'ft'), - (6, 'Clan Arena', 'ca'); + (6, 'Clan Arena', 'ca'), + (7, 'InstaCTF', 'ictf'), + (8, 'InstaFreeze', 'ift'); @@ -178,4 +180,3 @@ CREATE TABLE scoreboards_medals ( FOREIGN KEY (medal_id) REFERENCES medals(medal_id), PRIMARY KEY (match_id, steam_id, team, medal_id) ); -