From 94f49a9d39e8fd159116cb31def72c47d0a1f53e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sun, 12 Nov 2023 00:59:13 -0500 Subject: [PATCH] Games have min and max player counts --- src/heckbot/cogs/picker.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/heckbot/cogs/picker.py b/src/heckbot/cogs/picker.py index 896ad2a..6667c0e 100644 --- a/src/heckbot/cogs/picker.py +++ b/src/heckbot/cogs/picker.py @@ -12,6 +12,8 @@ from bot import db_conn from bot import HeckBot +PLAYERS_MAX = 100 +PLAYERS_MIN = 1 RESOURCE_DIR = 'resources/' @@ -61,7 +63,16 @@ def load_games(self): with open(f'{RESOURCE_DIR}/games.csv') as f: csv_reader = csv.reader(f) for line in csv_reader: - self._game_constraints[line[0]] = int(line[1]) + if len(line) == 1: + self._game_constraints[line[0]] = (PLAYERS_MIN, PLAYERS_MAX) + elif len(line) == 2: + self._game_constraints[line[0]] = ( + int(line[1]), PLAYERS_MAX + ) + else: + self._game_constraints[line[0]] = ( + int(line[1]), int(line[2]) + ) for player_file in os.listdir(f'{RESOURCE_DIR}/players'): player = player_file.rpartition('.')[0] @@ -84,7 +95,7 @@ def random_game(self, players: list[str]): options = options.intersection(self._owned_games[player]) options = { item for item in options - if self._game_constraints[item] <= len(players) + if self._game_constraints[item][0] <= len(players) <= self._game_constraints[item][1] } if len(options) == 0: r += "No games available. Y'all are too picky."