X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Fwidgets%2Finfo_area.py;h=4c79f07d330641123285efb5d7e928e32f7fee7b;hb=a99e4ae79d235b6047625fb1de2559f66b3a7562;hp=58068d75429620a7eb40842d741d4f0e05987472;hpb=558ff08be6951579d134aca37232af1f7a532d6c;p=naja.git diff --git a/naja/widgets/info_area.py b/naja/widgets/info_area.py index 58068d7..4c79f07 100644 --- a/naja/widgets/info_area.py +++ b/naja/widgets/info_area.py @@ -4,7 +4,7 @@ Widget for the game board information area. import pygame import pygame.locals as pgl -from naja.constants import INFO_SIZE, EIGHT_BIT_SCALE, MOVE, ACT +from naja.constants import INFO_SIZE, EIGHT_BIT_SCALE, MOVE, ACT, KEYS from naja.events import InvalidateTheWorld from naja.resources import resources from naja.resources.mutators import EIGHT_BIT @@ -82,18 +82,21 @@ class InfoAreaWidget(Widget): if self.state.gameboard.player_mode == MOVE: return super(InfoAreaWidget, self).handle_event(ev) if ev.type == pgl.KEYDOWN: - if ev.key in (pgl.K_RETURN, pgl.K_KP_ENTER): - self.card.actions[self.chosen].perform_action( - self.state.gameboard, self.card) + if ev.key in KEYS.SELECT: + action = self.card.actions[self.chosen] + if not action.check_available(self.state.gameboard.player): + print "BEEP!" + return True + action.perform_action(self.state.gameboard, self.card) self.state.gameboard.change_mode() InvalidateTheWorld.post() return True - if ev.key in (pgl.K_UP, pgl.K_w): + if ev.key in KEYS.UP: if self.chosen > 0: self.chosen -= 1 InvalidateTheWorld.post() return True - if ev.key in (pgl.K_DOWN, pgl.K_s): + if ev.key in KEYS.DOWN: if self.chosen + 1 < len(self.card.actions): self.chosen += 1 InvalidateTheWorld.post()