from shreksapawn_module import *
import time

s = Strategy()
u = User()
counter = Counter()

u.putName()
print()
print("Hello " + u.name + "! Your pieces are 'o'. You make the first move.")
print()
time.sleep(3)



for j in range(100):

    u1 = UserPiece("C",0)
    u2 = UserPiece("C",1)
    u3 = UserPiece("C",2)
    s1 = SystemPiece("A",0)
    s2 = SystemPiece("A",1)
    s3 = SystemPiece("A",2)
    b = Board([u1,u2,u3,s1,s2,s3])

    b.showBoard()
    move_to_be_removed = [0,0]

    for i in range(8):
        u.makeMove(b)
        b.showBoard()

        if b.endGame():
            counter.displayWhoWon("u", u)
            s.removeLosingMove(last_system_move[0],last_system_move[1])
            break

        last_system_move = s.makeMove(b)
        b.showBoard()

        if b.endGame():
            counter.displayWhoWon("s", u)
            break

    counter.displayCount(u)
    print()

    while True:
        play_again = input("Do you want to play again? 0-yes  1-no ")
        if play_again.isdigit() and int(play_again) in range(2):
            play_again = int(play_again)
            break
        else:
            print()
            print("Please answer with one of the given options (e.g. type '0').")
            print()
    print()
    if play_again == 1:
        print("Thank you for playing!")
        break






