def filter(self, selected, game_state: GameState): new_selected = [] for item in selected: game_state.set_selected(item) if self.test.test(game_state): new_selected.append(item) return new_selected
def perform(self, game_state: GameState): selected = self.selector.select(game_state) try: game_state.set_var(selected, self.label) except: print("Selector: " + str(self.selector)) print("Selected: " + str(selected)) raise
def perform(self, game_state: GameState): selected = self.selector.select(game_state) try: game_state.set_var(selected, self.label) except: print("Selector: "+str(self.selector)) print("Selected: "+str(selected)) raise
def perform(self, game_state: GameState): self.select.perform(game_state) selected = game_state.get_var(self.select.label) real_max = self.max.select_one_of_type(game_state, int) real_min = self.min.select_one_of_type(game_state, int) assert(real_min <= real_max), "Min greater than max"+str(self.min)+" "+str(self.max) assert(real_min <= len(selected)), "Min greater than available options selected by "+str(self.select) if real_max > len(selected): real_max = len(selected) if selected: from Game.game import Player player = self.player.select_one_of_type(game_state, Player) selected = player.select(selected, real_min, real_max, game_state, self.line_num) assert(len(selected) <= real_max) assert(len(selected) >= real_min) game_state.set_var(selected, self.select.label)
def perform(self, game_state: GameState): self.select.perform(game_state) selected = game_state.get_var(self.select.label) real_max = self.max.select_one_of_type(game_state, int) real_min = self.min.select_one_of_type(game_state, int) assert (real_min <= real_max), "Min greater than max" + str( self.min) + " " + str(self.max) assert ( real_min <= len(selected) ), "Min greater than available options selected by " + str(self.select) if real_max > len(selected): real_max = len(selected) if selected: from Game.game import Player player = self.player.select_one_of_type(game_state, Player) selected = player.select(selected, real_min, real_max, game_state, self.line_num) assert (len(selected) <= real_max) assert (len(selected) >= real_min) game_state.set_var(selected, self.select.label)
def perform(self, game_state: GameState): action = self.action_selector.select_one_of_type(game_state, Action) for piece in self.selector.select(game_state): game_state.set_var([piece], self.label) action.perform(game_state)
def perform(self, game_state: GameState): game_state.del_var(self.to_remove)
def perform(self, game_state: GameState): game_state.winners = self.winners.select(game_state) from Game.game import WonException raise WonException()
def select(self, game_state: GameState, selected: list): return game_state.get_var(self.variable_name)