Added clock logic

This commit is contained in:
2025-12-15 10:23:46 +01:00
parent f3965aa2fb
commit 9e259bb9fb
5 changed files with 93 additions and 26 deletions

View File

@@ -2,18 +2,24 @@
from board_mate_client import ApiClient, Configuration
from controllers.board_mate_controller import ApiController
from models.clock import Clock
from scripts.timer.grove_rgb_lcd import setRGB, setText
if __name__ == "__main__":
config = Configuration(
host="http://192.168.15.117:8000"
)
setRGB(255, 255, 255)
controller = ApiController(config)
white_name = input("White Name: ")
black_name = input("Black Name: ")
time_value = int(input("Time value: "))
increment = int(input("Increment: "))
white_clock = Clock(time_value, increment)
black_clock = Clock(time_value, increment)
print("Creating the party...")
game_id = controller.create_party(white_name, black_name, time_value, increment)
@@ -24,16 +30,18 @@ if __name__ == "__main__":
print("Party Created!")
currentPlayer = 0
white_clock.start()
while True:
message = None
if currentPlayer == 0 :
message = "White to play"
currentPlayer = 1
white_clock.stop()
else :
message = "Black to play"
currentPlayer = 0
black_clock.start()
move = input(f"{message} : ")
controller.add_move(game_id, move)
setText(f"W ${white_clock.clock_to_str()}\n B ${black_clock.clock_to_str()}")
controller.add_move(game_id, move)