diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-03-09 13:38:22 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2018-03-09 13:38:22 +0100 |
commit | 493b116f73ec3912ca7af3d6ece3434279cbcfb5 (patch) | |
tree | b6955491311fb0d810e9de9a7dd9b8059d04a10c /swiftstory/GameManager.py | |
parent | 735bc5af0929392f27386aa3fa0c26d39f300672 (diff) |
renamed the project SwiftStory
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/GameManager.py')
-rw-r--r-- | swiftstory/GameManager.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/swiftstory/GameManager.py b/swiftstory/GameManager.py new file mode 100644 index 0000000..7cdb5da --- /dev/null +++ b/swiftstory/GameManager.py @@ -0,0 +1,34 @@ +from swiftstory.Game import Game +from swiftstory.Cards import Cards + +import os + +class GameManager(): + def __init__(self): + self.langs = {} + + for filename in next(os.walk('usr/share/swiftstory/lang'))[1]: + self.langs[filename] = {} + + for lang in self.langs: + self.langs[lang]['black_cards'] = Cards.get_black_cards(lang) + self.langs[lang]['white_cards'] = Cards.get_white_cards(lang) + + self.langs[lang]['games'] = {} + + 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 = games[game_name] = Game(white_cards, black_cards) + + return game |