separate game logic from bot interface,
introduce exceptions instead of boolean returns, remove repetitive code, begin unit tests, improve docstrings, update to python-telegram-bot==4.1.1, add ponyorm settings classes (unused)
This commit is contained in:
15
game.py
15
game.py
@ -48,6 +48,7 @@ class Game(object):
|
||||
|
||||
@property
|
||||
def players(self):
|
||||
"""Returns a list of all players in this game"""
|
||||
players = list()
|
||||
if not self.current_player:
|
||||
return players
|
||||
@ -61,18 +62,23 @@ class Game(object):
|
||||
return players
|
||||
|
||||
def reverse(self):
|
||||
""" Reverse the direction of play """
|
||||
"""Reverses the direction of game"""
|
||||
self.reversed = not self.reversed
|
||||
|
||||
def turn(self):
|
||||
""" Mark the turn as over and change the current player """
|
||||
"""Marks the turn as over and change the current player"""
|
||||
self.logger.debug("Next Player")
|
||||
self.current_player = self.current_player.next
|
||||
self.current_player.drew = False
|
||||
self.current_player.turn_started = datetime.now()
|
||||
self.choosing_color = False
|
||||
|
||||
def play_card(self, card):
|
||||
""" Play a card and trigger its effects """
|
||||
"""
|
||||
Plays a card and triggers its effects.
|
||||
Should be called only from Player.play or on game start to play the
|
||||
first card
|
||||
"""
|
||||
self.deck.dismiss(self.last_card)
|
||||
self.last_card = card
|
||||
|
||||
@ -100,7 +106,6 @@ class Game(object):
|
||||
self.choosing_color = True
|
||||
|
||||
def choose_color(self, color):
|
||||
""" Carries out the color choosing and turns the game """
|
||||
"""Carries out the color choosing and turns the game"""
|
||||
self.last_card.color = color
|
||||
self.turn()
|
||||
self.choosing_color = False
|
||||
|
Reference in New Issue
Block a user