#!/usr/bin/env python3

from board_mate_client import ApiClient, Configuration
from controllers.board_mate_controller import ApiController

if __name__ == "__main__":
    config = Configuration(
        host="http://192.168.15.117:8000"
    )

    controller = ApiController(config)

    white_name = input("White Name: ")
    black_name = input("Black Name: ")
    time_value = int(input("Time value: "))
    increment = int(input("Increment: "))
    print("Creating the party...")

    game_id = controller.create_party(white_name, black_name, time_value, increment)
    if game_id is None :
        print("An error occurred while creating the party. Exiting...")
        exit()

    print("Party Created!")

    currentPlayer = 0
    while True:
        message = None
        if currentPlayer == 0 :
            message = "White to play"
            currentPlayer = 1
        else :
            message = "Black to play"
            currentPlayer = 0

        move = input(f"{message} : ")

        controller.add_move(game_id, move)

