from play_and_code import *
import random

tick_speed(1.5)

phase = 1

spieler_auswahl = 1
computer_auswahl = 1

def main():
    global phase, spieler_auswahl, computer_auswahl
    text("Schere Stein Papier", GREEN,200,50, 38)

    if phase == 1:
        text("Phase 1", GREEN,200,100, 38)

        schere_farbe = WHITE
        stein_farbe = WHITE
        papier_farbe = WHITE

        if is_key_pressed(DOWN):
            spieler_auswahl = spieler_auswahl + 1
        if is_key_pressed(UP):
            spieler_auswahl = spieler_auswahl - 1

        if spieler_auswahl == 4:
            spieler_auswahl = 1
        if spieler_auswahl < 1:
            spieler_auswahl = 3

        ### ich wähle meine farbe
        if spieler_auswahl == 1:
            schere_farbe = GREEN
        elif spieler_auswahl == 2:
            stein_farbe = GREEN
        elif spieler_auswahl == 3:
            papier_farbe = GREEN
        ###

        text("Schere", schere_farbe ,500,250, 38)
        text("Stein", stein_farbe ,500,300, 38)
        text("Papier", papier_farbe ,500,350, 38)
        
        if is_key_pressed(SPACE):
            phase = 2
    elif phase == 2:
        text("Phase 2", GREEN,200,100, 38)
        computer_auswahl = random.randint(1,3)
        phase = 3
    elif phase == 3:
        text("Phase 3", GREEN,200,100, 38)
        if spieler_auswahl == computer_auswahl:
            text("Unentschieden", YELLOW ,500,250, 38)
        if spieler_auswahl == 1 and computer_auswahl == 2:
            text("Computer hat gewonnen", RED ,500,250, 38)
        
        if is_key_pressed(RIGHT):
            phase = 1

start(main)

