Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gametypes: add instagib ctf and instagib freezetag #22

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

30 changes: 30 additions & 0 deletions qllr/gametypes.py
Original file line number Diff line number Diff line change
@@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -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()
5 changes: 3 additions & 2 deletions sql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');



Expand Down Expand Up @@ -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)
);

Loading