def __init__(self, select: Select, min_pieces: Selector, max_pieces: Selector, player: Selector, line_number: int): super(PlayerSelect, self).__init__(line_number) self.select = select self.min = ValueSelector(0) if min_pieces is None else min_pieces self.max = ValueSelector( 99999999) if max_pieces is None else max_pieces from Game.selectors import ScopeSelector self.player = ScopeSelector("player") if player is None else player
class PlayerSelect(Step): def __init__(self, select: Select, min_pieces: Selector, max_pieces: Selector, player: Selector, line_number: int): super(PlayerSelect, self).__init__(line_number) self.select = select self.min = ValueSelector(0) if min_pieces is None else min_pieces self.max = ValueSelector( 99999999) if max_pieces is None else max_pieces from Game.selectors import ScopeSelector self.player = ScopeSelector("player") if player is None else player 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)
class PlayerSelect(Step): def __init__(self, select: Select, min_pieces: Selector, max_pieces: Selector, player: Selector, line_number: int): super(PlayerSelect, self).__init__(line_number) self.select = select self.min = ValueSelector(0) if min_pieces is None else min_pieces self.max = ValueSelector(99999999) if max_pieces is None else max_pieces from Game.selectors import ScopeSelector self.player = ScopeSelector("player") if player is None else player 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 __init__(self, select: Select, min_pieces: Selector, max_pieces: Selector, player: Selector, line_number: int): super(PlayerSelect, self).__init__(line_number) self.select = select self.min = ValueSelector(0) if min_pieces is None else min_pieces self.max = ValueSelector(99999999) if max_pieces is None else max_pieces from Game.selectors import ScopeSelector self.player = ScopeSelector("player") if player is None else player