Commits

Dominic Kexel committed 576d813

added ABC for game class

  • Participants
  • Parent commits 81e6d17

Comments (0)

Files changed (2)

File game/game.py

 from gametrigger import T_ATTACK, T_GAIN
 from triggerinfo import TriggerInfo
 from infotoken import InfoToken
+from gameinterface import GameInterface
 import logging
 from framework.event import ChangePhaseEvent, ChangeSubPhaseEvent,\
     ChangePilesEvent, ChangeBoardEvent, ChangeHandEvent, MessageEvent,\
 SUBPHASE = 8
 
 
-class Game(object):
+class Game(GameInterface):
 
     def __init__(self, ev):
         self.running = False

File game/gameinterface.py

+import abc
+
+
+class GameInterface(object):
+    __metaclass__ = abc.ABCMeta
+
+    @abc.abstractmethod
+    def take_card_from_pile(self, player, pile, safe=False, to_hand=False, to_deck=False, message=None):
+        """Let the player pick a card from a pile
+
+        :param player: the player that should take a card
+        :type player: Player
+        :param pile: the pile the player should take the card from
+        :type pile: Pile
+        :param safe: ignore empty piles if True
+        :type safe: bool
+        :param to_hand: the card should go to hand instead of discard pile
+        :type to_hand: bool
+        :param to_deck: the card should go on top of the deck instead of discard pile
+        :type to_deck: bool
+        :param message: message to display instead of '<playername> took <cardname>'
+        :param message: str
+        """
+        pass
+
+    @abc.abstractmethod
+    def whisper(self, message, player=None):
+        """Send a message a player
+
+        :param message: the message the player should receive
+        :type message: str
+        :param player: the player that should receive the message instead of the active player
+        :type player: Player
+        """
+        pass
+
+    @abc.abstractmethod
+    def yell(self, message):
+        """Send a message to all players
+
+        :param message: the message the players should receive
+        :type message: str
+        """
+        pass
+
+    @abc.abstractmethod
+    def update_player(self, player=None):
+        """Tell player(s) the game state was updated
+
+        :param player: The player which should receive the update instead of all players
+        :type player: Player
+        """
+        pass
+