def press(self, instance: Widget): if self.controller.game_state == 'setup': Popup(title="Invalid move !", content=Label(text="You still need to position your submarines !"), size_hint=(1,None) ,size=(200,200)).open() return if instance.sq_location in self.played_cooridinates: Popup(title="Invalid move !", content=Label(text="You can't play the same square again !"), size_hint=(1,None) ,size=(200,200)).open() return self.played_cooridinates.append(instance.sq_location) res = self.controller.play_human_turn(instance.sq_location) if not res: instance.text = "X" instance.background_color = 1, 0, 0, 1 else: instance.text = 'HIT' name = self.controller.get_submarine_name(instance.sq_location) instance.background_color = 0, 1, 0, 1 # dark green # if name == "Destroyer": # instance.background_color = 1, 0, 1, 1 # dark pink # if name == "Submarine": # instance.background_color = 0, 1, 1, 1 # dark turquoise (blue) # if name == "Cruiser": # instance.background_color = 0, 0, 1, 10 # dark blue # if name == "Battleship": # instance.background_color = 2, 0, 1, 2 # pink # if name == "Carrier": # instance.background_color = 0, 1, 0, 1 # dark green self.controller.active_turn = 'computer' self.controller.game_state='computer_turn'