def _set_combo_box_values(self): self._grid_sizes = [ GridSize.small, GridSize.medium, GridSize.large ] # fill the grid size combo box for grid_size in self._grid_sizes: grid_size_numerical = grid_size.value grid_size_textual = \ EnumConverters.grid_size_to_string_converter(grid_size) grid_size_caption = "{0} ({1}x{1})".format(grid_size_textual, grid_size_numerical) self.ui.comboBoxGridSize.addItem(grid_size_caption, QVariant(grid_size)) self._player_types[PlayerType.human] = Human.default() self._player_types[PlayerType.cpu] = CPU.default() player_one_textual = EnumConverters.player_type_to_string_converter( PlayerType.human ) player_two_textual = EnumConverters.player_type_to_string_converter( PlayerType.cpu ) # fill the player combo boxes self.ui.comboBoxPlayerOne.addItem( player_one_textual, QVariant(self._player_types[PlayerType.human])) self.ui.comboBoxPlayerTwo.addItem( player_two_textual, QVariant(self._player_types[PlayerType.cpu]))
def setUp(self): super(TestGrid, self).setUp() grid_size = GridSize.small fleet_size_multiplier = EnumConverters.\ grid_size_to_fleet_size_multiplier_converter(grid_size) self.dimensions = grid_size.value self.grid = Grid(GridPosition.left, grid_size) self.fleet = Fleet(fleet_size_multiplier) self.player = Human.default()
from input_helpers import InputHelpers from output_helpers import OutputHelpers if __name__ == "__main__": colorama.init() print(Fore.YELLOW + "Raging Seas, version 1.0" + Style.RESET_ALL) grid_size = InputHelpers.grid_size_input() fleet_size_multiplier = EnumConverters.\ grid_size_to_fleet_size_multiplier_converter(grid_size) fleet_size = fleet_size_multiplier * constants.DEFAULT_FLEET_SIZE player_one = Human(Grid(GridPosition.left, grid_size), Fleet(fleet_size_multiplier)) player_two = CPU(Grid(GridPosition.right, grid_size), Fleet(fleet_size_multiplier)) winner = None session = Session(SessionType.offline, player_one, player_two) OutputHelpers.clear_output() clear = True # setting player one's fleet i = 0 while i < fleet_size: print(Style.RESET_ALL) if clear: