+ def next_action(self, viable_only=False, step=1):
+ num_actions = len(self.card.actions)
+ if num_actions == 0:
+ return
+ player = self.state.player
+ chosen = self.chosen
+ for i in range(num_actions - 1):
+ # loop through each action at most once.
+ chosen = (chosen + step) % num_actions
+ action = self.card.actions[chosen]
+ if not viable_only or action.check_available(player):
+ sound.play_sound('zoop.ogg', volume=0.05)
+ self.chosen = chosen
+
+ def prev_action(self, viable_only=False):
+ return self.next_action(viable_only=viable_only, step=-1)
+
+ def try_perform_action(self):
+ player = self.state.player
+ action = self.card.actions[self.chosen]
+ if not action.check_available(player):
+ sound.play_sound('error.ogg')
+ else:
+ sound.play_sound('chirp.ogg', volume=0.5)
+ action.perform_action(self.state.gameboard, self.card)
+ self.state.gameboard.replace_card(player.position)
+ self.state.gameboard.change_mode(EXAMINE)
+ self.set_position(player.position)
+