Commit 05c27303 authored by Fedrico Otaran's avatar Fedrico Otaran
Browse files

Agrego valor correspondiente de acuerdo al turno

parent 90619c5d
Pipeline #244 failed with stages
in 0 seconds
import PySimpleGUI as sg
from itertools import cycle
from src.windows import board
......@@ -8,7 +9,13 @@ def start():
def loop():
window = board.build("Fede", "Milka")
player_1 = {"name": "Maria", "value": "X"}
player_2 = {"name": "Marta", "value": "O"}
turn = cycle([player_1, player_2])
board_data = [[" "] * 3 for _i in range(3)]
window = board.build(player_1, player_2, board_data)
while True:
event, _values = window.read()
......@@ -17,7 +24,7 @@ def loop():
break
if event.startswith("cell"):
_prefix, x, y = event.split("-")
print(f"Celda: {x},{y}")
player = next(turn)
window[event].update(player["value"])
return window
import PySimpleGUI as sg
def build(player1_name, player2_name):
def build(player_1, player_2, board_data):
layout = [
[sg.Text('Jugador 1: ' + player1_name, key='-P1-', text_color='darkblue')],
[sg.Text('Jugador 2: ' + player2_name, key='-P2-', text_color='white')],
[sg.Text('')]
[sg.Text("Jugador 1: " + player_1["name"], key="-P1-", text_color="darkblue")],
[sg.Text("Jugador 2: " + player_2["name"], key="-P2-", text_color="white")],
[sg.Text("")],
]
for y in range(3):
layout += [
[sg.Button(' ', size=(8, 4), key=f"cell-{x}-{y}") for x in range(3)]
[
sg.Button(board_data[x][y], size=(8, 4), key=f"cell-{x}-{y}")
for x in range(3)
]
]
board = sg.Window('Ta Te Ti').Layout(layout)
board = sg.Window("Ta Te Ti").Layout(layout)
return board
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment