from play_and_code import *
import random

tick_speed(3)

phase = 0
auswahl = 0
computer_auswahl = 0

def main():
    global phase, auswahl, computer_auswahl

    if phase == 0:

        schere_farbe = RED
        stein_farbe = RED
        papier_farbe = RED

        if auswahl == 0:
            schere_farbe = WHITE
        elif auswahl == 1:
            stein_farbe = WHITE
        elif auswahl == 2:
            papier_farbe = WHITE

        if is_key_pressed(UP):
            auswahl = auswahl - 1
        elif is_key_pressed(DOWN):
            auswahl = auswahl + 1

        if auswahl > 2 :
            auswahl = 0
        if auswahl < 0:
            auswahl = 2
            
        text("SCHERE 0", schere_farbe, 100,100, 35 )
        text("STEIN 1", stein_farbe, 100,200, 35 )
        text("PAPIER 2", papier_farbe, 100,300, 35 )

        if is_key_pressed(SPACE):
            phase = 1
        
    elif phase == 1:
        computer_auswahl = random.randint(0,2)
        phase = 2
    else:

        if computer_auswahl == 0:
            text("COMPUTER HAT SCHERE", WHITE , 300,50, 35 )
        elif computer_auswahl == 1:
            text("COMPUTER HAT STEIN", WHITE , 300,50, 35 )
        elif computer_auswahl == 2:
            text("COMPUTER HAT PAPIER", WHITE , 300,50, 35 )
            
        if auswahl == 0 and computer_auswahl == 1:
            text("DU HAST VERLOREN", RED , 300,100, 35 )
        elif auswahl == 1 and computer_auswahl == 0:
            text("DU HAST GEWONNEN", GREEN , 300,100, 35 )

        elif auswahl == 0 and computer_auswahl == 2:
            text("DU HAST GEWONNEN", GREEN , 300,100, 35 )
        elif auswahl == 2 and computer_auswahl == 0:
            text("DU HAST VERLOREN", RED , 300,100, 35 )

        elif auswahl == 1 and computer_auswahl == 2:
            text("DU HAST VERLOREN", RED , 300,100, 35 )
        elif auswahl == 2 and computer_auswahl == 1:
            text("DU HAST GEWONNEN", GREEN , 300,100, 35 )


        elif auswahl == computer_auswahl:
            text("UNENTSCHIEDEN", YELLOW , 300,100, 35 )

        if is_key_pressed(RIGHT):
            phase = 0
            

start(main)
