def __init__(self, field, *args, **kwargs): super().__init__(*args, **kwargs) self.user_field = field self.ai_field = Field.randomize() self.user_buttons = {} self.ai_buttons = {} self.help_text = None self.lock = False self.init_visual()
def randomize_field(self): self.field = Field.randomize() for button in self.buttons.values(): button.setText('') for ship in self.field.ships: for row, col in ship.coordinates: self.buttons[(row, col)].setText(str(ship.length)) self.next_btn.setEnabled(True)