From abd360d9fd6dc1a77cd38c213bc9532d85973ca0 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 8 Jun 2015 04:49:37 +0100 Subject: the server now handles the language properly Signed-off-by: Olivier Gayot --- CAO_GameManager.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'CAO_GameManager.py') diff --git a/CAO_GameManager.py b/CAO_GameManager.py index a3a12e5..8c01547 100644 --- a/CAO_GameManager.py +++ b/CAO_GameManager.py @@ -1,18 +1,34 @@ from CAO_Game import CAO_Game from CAO_Cards import CAO_Cards +import os + class CAO_GameManager(): def __init__(self): - self.games = {} + self.langs = {} + + for filename in next(os.walk('lang'))[1]: + self.langs[filename] = {} + + for lang in self.langs: + self.langs[lang]['black_cards'] = CAO_Cards.get_black_cards(lang) + self.langs[lang]['white_cards'] = CAO_Cards.get_white_cards(lang) - self.black_cards = CAO_Cards.get_black_cards() - self.white_cards = CAO_Cards.get_white_cards() + self.langs[lang]['games'] = {} - def join_game(self, game_name): - game = self.games.get(game_name) + def join_game(self, game_name, lang): + if self.langs.get(lang) is None: + return None + + games = self.langs[lang]['games'] + black_cards = self.langs[lang]['black_cards'] + white_cards = self.langs[lang]['white_cards'] + + game = games.get(game_name) if game is None: print('Starting new game') - game = self.games[game_name] = CAO_Game(self.white_cards, self.black_cards) + + game = games[game_name] = CAO_Game(white_cards, black_cards) return game -- cgit v1.2.3