from tkinter import *
import random
def get_winner(player1, player2):
winning_combinations = {
"Animal": "Água",
"Água": "Fogo",
"Fogo": "Animal"
}
if player1 == player2:
resultado = "Empate"
elif winning_combinations[player1] == player2:
resultado = "Jogador 1 vence"
else:
resultado = "Jogador 2 vence"
return resultado
def app(*args):
player_choice = var.get()
choices = ["Animal", "Água", "Fogo"]
computer_choice = random.choice(choices)
resultado = get_winner(player_choice, computer_choice)
mensagem = f"O jogador 2 jogou: {computer_choice}.\nResultado: {resultado}"
resultado_texto.config(text=mensagem)
root = Tk()
root.geometry("500x300")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Bem-vindo ao jogo Animal, Água, Fogo")
titulo = Label(root, text="Bem-vindo ao jogo Animal, Água, Fogo",
font=("Arial", "18", "bold"), bg="#103030",
fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(root, text="Escolha:",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.1, rely=0.25)
var = StringVar()
dropDownList = ["Animal", "Água", "Fogo"]
dropdown = OptionMenu(root, var, *dropDownList, command=app)
var.set(dropDownList[0])
dropdown.config(font=("Arial", "15", "bold"),
foreground="#00FFFF", background="#008080")
dropdown.place(relx=0.35, rely=0.35, relwidth=0.4)
dropdown["menu"].config(font=("Arial", "18", "bold"),
foreground="#00FFFF", background="#008080")
resultado_texto = Label(root, font=("Arial", 15, "bold"), bg="#103030", fg="#49e3e3")
resultado_texto.place(relx=0.05, rely=0.65, relwidth=0.9, relheight=0.3)
root.mainloop()