Change card after taking action.
authorJeremy Thurgood <firxen@gmail.com>
Tue, 13 May 2014 20:38:40 +0000 (22:38 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Tue, 13 May 2014 20:38:40 +0000 (22:38 +0200)
naja/gameboard.py
naja/widgets/info_area.py

index 980a046c4c4f68e690219a2a216f818df018ce9e..8d4106cc931011dea15725842abf188a0b51f999 100644 (file)
@@ -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:
index ad31e68f9bee50974c71f661e0b58cf61fc0d957..0bb02f41aca8551d453680fdf68e363066ee8ad6 100644 (file)
@@ -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: