def get_current(p=None): g = Game.getgame() act = getattr(g, 'current_turn', None) if act: assert isinstance(act, PlayerTurn) if p is not None and act.target is not p: raise GameException('Got unexpected PlayerTurn!') return act
def apply_action(self): tgt = self.target params = self.params g = Game.getgame() if params['effect'] == 'life': to = params['life'] if to > tgt.life: g.process_action(Heal(tgt, tgt, abs(to - tgt.life))) elif to < tgt.life: g.process_action(LifeLost(tgt, tgt, abs(to - tgt.life))) elif params['effect'] == 'cards': to = params['cards'] cur = len(tgt.cards) + len(tgt.showncards) if to > cur: g.process_action(DrawCards(tgt, abs(to - cur))) elif to < cur: g.process_action(ActiveDropCards(tgt, tgt, abs(to - cur))) else: raise GameException('WTF?!') return True