From 963216cd4493996f5859347fe50249fb5865d6e5 Mon Sep 17 00:00:00 2001 From: Jeremy Thurgood Date: Tue, 13 May 2014 22:38:40 +0200 Subject: [PATCH] Change card after taking action. --- naja/gameboard.py | 4 ++++ naja/widgets/info_area.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/naja/gameboard.py b/naja/gameboard.py index 980a046..8d4106c 100644 --- a/naja/gameboard.py +++ b/naja/gameboard.py @@ -90,6 +90,10 @@ class GameBoard(object): self.health -= 1 # TODO: Check win/lose + def replace_card(self, position): + location = LocationCard.new_location(choice(self.locations).copy()) + self.board_locations[position] = location + def change_mode(self): """Advance to the next mode""" if self.player_mode == MOVE: diff --git a/naja/widgets/info_area.py b/naja/widgets/info_area.py index ad31e68..0bb02f4 100644 --- a/naja/widgets/info_area.py +++ b/naja/widgets/info_area.py @@ -85,11 +85,13 @@ class InfoAreaWidget(Widget): return super(InfoAreaWidget, self).handle_event(ev) if ev.type == pgl.KEYDOWN: if ev.key in KEYS.SELECT: + player = self.state.gameboard.player action = self.card.actions[self.chosen] - if not action.check_available(self.state.gameboard.player): + if not action.check_available(player): print "BEEP!" else: action.perform_action(self.state.gameboard, self.card) + self.state.gameboard.replace_card(player.position) self.state.gameboard.change_mode() return finish_event() if ev.key in KEYS.UP: -- 2.34.1