def b4(self): """ functie apelata in cazul apasarii butonului B4 """ if opponent == "calculator" and ("B" in self.text_label.text() or "calculatorului" in self.text_label.text()): return global buttons if buttons[0] == " ": buttons[0] = "B4" self.text_label.setText(" ") if game.ver_start("B4", player): self.B4Button.setText("0") else: if game.check_player(player) == 1 or game.check_player_start( player, "B4") == 0: self.set_text_label_err( "Ai inceput de pe o groapa care nu este a ta!") elif game.get_points("B4") == 0: self.set_text_label_err( "Groapa nu are niciun punct! Incepe din nou!") elif buttons[1] == " ": buttons[1] = "B4" if buttons[0] != " " and buttons[1] != " ": points = self.play() if points == -2: pass if points >= 0 and points <= 6: self.B4Button.setText(self.convert_points_to_text(points)) elif points >= 7: self.B4Button.setText(str(points))
def a1(self): """ functie apelata in cazul apasarii butonului A1, actualizeaza variabila "buttons" care tine evidenta mutarilor si mai apoi actualizeaza si punctele de pe buton """ # daca e randul calculatorului nu se intampla nimic if opponent == "calculator" and ("B" in self.text_label.text() or "calculatorului" in self.text_label.text()): return global buttons # daca e primul buton apasat se verifica daca este un inceput de mutare si daca este corect if buttons[0] == " ": buttons[0] = "A1" self.text_label.setText(" ") if game.ver_start("A1", player): self.A1Button.setText("0") else: if game.check_player(player) == 1 or game.check_player_start( player, "A1") == 0: self.set_text_label_err( "Ai inceput de pe o groapa care nu este a ta!") elif game.get_points("A1") == 0: self.set_text_label_err( "Groapa nu are niciun punct! Incepe din nou!") # daca este al 2-lea buton apasat se actualizeaza variabila buttons, se apeleaza functia play # pentru a updata punctajul si pentru a afla punctele corespunzatoare butonului A1 si se # actualizeaza punctele de pe buton elif buttons[1] == " ": buttons[1] = "A1" if buttons[0] != " " and buttons[1] != " ": points = self.play() # daca sunt pana in 6 puncte in textul de pe buton vor aparea si bulinele, altfel nu, din # motive vizuale if points == -2: pass if points >= 0 and points <= 6: self.A1Button.setText(self.convert_points_to_text(points)) elif points >= 7: self.A1Button.setText(str(points))