from play_and_code import *
import random

# 0 = Schere , 1 = Stein, 2 = Papier
auswahl = 0

gegner_auswahl = 0

phase = 0

tick_speed(1.5)

def main():
    global auswahl, phase, gegner_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(DOWN):
            auswahl = auswahl + 1

        if auswahl > 2:
            auswahl = 0
            
        if is_key_pressed(UP):
            auswahl = auswahl - 1

        if auswahl < 0:
            auswahl = 2

        
        text("Schere", schere_farbe, 200, WINDOW_HEIGHT / 2 -100, 36)
        text("Stein", stein_farbe, 200, WINDOW_HEIGHT / 2 , 36)
        text("Papier", papier_farbe, 200, WINDOW_HEIGHT / 2 + 100, 36)

        #SPACE
        if is_key_pressed(SPACE):
            phase = 1

        
    elif phase == 1:
        text("This is Phase 1", GREEN, 200, WINDOW_HEIGHT / 2 + 200,36)
        gegner_auswahl = random.randint(0,2)
        phase = 2
        
    elif phase == 2:
        text("This is Phase 2", GREEN, 200, WINDOW_HEIGHT / 2 + 200,36)

        # int("27") + int("27")
        # str(27)
        # auswahl , gegner_auswahl

        wahl = ""

        if auswahl == 0:
            wahl = "Schere"
        elif auswahl == 1:
            wahl = "Stein"
        else:
            wahl = "Papier"

        text("Du hast " + wahl + " gewählt!", GREEN, 200, WINDOW_HEIGHT / 2 - 200,36)
    
        if gegner_auswahl == 0:
            wahl = "Schere"
        elif gegner_auswahl == 1:
            wahl = "Stein"
        else:
            wahl = "Papier"

        text("Der Gegner hat " + wahl + " gewählt!", GREEN, 200, WINDOW_HEIGHT / 2 - 100,36)
        
        if auswahl == 0 and gegner_auswahl == 1:
            text("Der Gegner hat gewonnen", RED, 200, WINDOW_HEIGHT / 2 ,36)

        if is_key_pressed(RIGHT):
            phase = 0

start(main)
