color1 = [1,1,0,1]
color2 = [.5, 0, .5 ]
c = 1
class freestyle(GridLayout):
def court(self):
global color1
global color2
self.s1 = self.b1.background_color and self.b2.background_color and self.b3.background_color
self.s2 = self.b4.background_color and self.b5.background_color and self.b6.background_color
self.s3 = self.b7.background_color and self.b8.background_color and self.b9.background_color
self.c1 = self.b1.background_color and self.b4.background_color and self.b7.background_color
self.c2 = self.b2.background_color and self.b5.background_color and self.b8.background_color
self.c3 = self.b3.background_color and self.b6.background_color and self.b9.background_color
self.d1 = self.b1.background_color and self.b5.background_color and self.b9.background_color
self.d2 = self.b3.background_color and self.b5.background_color and self.b7.background_color
if self.s1 == color1 or color2:
print("s1")
return self.s1
if self.s2 == color1 or color2:
print("s2")
return self.s2
if self.s3 == color1 or color2:
return self.s3
if self.c1 == color1 or color2:
print("c1")
return self.c1
if self.c2 == color1 or color2:
return self.c2
if self.c3 == color1 or color2:
return self.c3
if self.d1 == color1 or color2:
return self.d1
if self.d2 == color1 or color2:
return self.d2
def reload(self):
global c
self.b1.background_color =[0, .79, .05, 1]
self.b2.background_color =[0, .79, .05, 1]
self.b3.background_color =[0, .79, .05, 1]
self.b4.background_color =[0, .79, .05, 1]
self.b5.background_color =[0, .79, .05, 1]
self.b6.background_color =[0, .79, .05, 1]
self.b7.background_color =[0, .79, .05, 1]
self.b8.background_color =[0, .79, .05, 1]
self.b9.background_color =[0, .79, .05, 1]
c +=1
def win(self):
if self.court() == [1,1,0,1]:
self.lab.text = f"{player1} WIN"
sleep(2)
self.reload()
if self.court() == [.5, 0, .5 ]:
self.lab.text = f"{player2} WIN"
sleep(2)
self.reload()
def bb1(self):
global c
if c % 2 or c == 0:
self.lab.text = f"ходит: {player1}"
self.b1.background_color = [1, 1, 0, 1 ]
c +=1
else:
self.b1.background_color = [.5, 0, .5 ]
self.lab.text = f"ходит: {player2}"
c = 1
self.win()
def bb2(self):
global c
if c % 2 or c == 0:
self.lab.text = f"ходит: {player1}"
self.b2.background_color = [1, 1, 0, 1 ]
c +=1
else:
self.b2.background_color = [.5, 0, .5 ]
self.lab.text = f"ходит: {player2}"
c +=1
self.win()
def bb3(self):
global c
if c % 2 or c == 0:
self.lab.text = f"ходит: {player1}"
self.b3.background_color = [1, 1, 0, 1 ]
c +=1
else:
self.b3.background_color = [.5, 0, .5 ]
self.lab.text = f"ходит: {player2}"
c +=1
self.win()