0
import easygui
from easygui import *
import random
import sys
compscore = 0
playerscore = 0
for i in range(0,5):
    def gamerules():
        msgbox ('For this game you must choose one of the option to batle against your optonint')
    def player_choice():
        msg = ('Rock, Paper, Scissors')
        title = ('Choose your action')
        choices =['Rock','Paper','Scissors']
        choice = choicebox(msg, title, choices)
        if choice =='Rock':
            msgbox('You chose Rock', image = 'sizzors_gif.gif')
        elif choice == 'Paper':
            msgbox('You chose Paper', image = 'paer_gif.gif')
        elif choice == 'Scissors':
            msgbox('You chose Scissors', image = 'source.gif')
        return msgbox
    def computer_choice():
        msg = ('the computer choose')
        title = ('computer turn')
        computer_choice = [ 'Rock', 'Paper', 'Sizzors' ]
        computer = (random.sample(computer_choice, 1))
        compchoice = (computer)
        choice = buttonbox(msg, title, compchoice)
        if choice == 'Sizzors':
            msgbox('computer choose rock:', image = 'source.gif')
            sizzors = 'sizzors'
            return sizzors
        elif choice == 'Rock':
            msgbox('computer choose sizzors :', image = 'sizzors_gif.gif')
            rock = 'rock'
            return rock
        elif choice == 'Paper':
            msgbox('computer choose paper :', image = 'paer_gif.gif')
            paper = 'paper'
            return paper


    def roundwinner(player,computer, compwinner, playerwinner):
        if player == 'rock' and computer == 'paper':
                msgbox('you lost the point goes to the computer')
                compwinner = compwinner + 1
        elif computer == 'sizzors': 
                msgbox("You win!", "continue", image = 'Ghuman_winner.gif')
                playerwinner = playerwinner + 1
        else:
                msgbox ('you and the computer tied no point is rewarded', "continue")
        if player == "Paper" and computer == "Scissors":
                msgbox ("You lose!", computer, "continue", player)
                compwinner = compwinner + 1
        elif computer  == 'rock':
                msgbox ("You win!", player, "continue", computer)
                playerwinner = playerwinner + 1
        if player == "Scissors":
            if computer == "Rock":
                msgbox ("You lose...", computer, "continue", player)
                compwinner = compwinner + 1
            else:
                msgbox ("You win!", player, "continue", computer)
                playerwinner = playerwinner + 1

move = player_choice()
computermove = computer_choice()
winner = roundwinner (move, computermove, compscore, playerscore )
roganjosh
  • 12,594
  • 4
  • 29
  • 46

1 Answers1

0

You shouldn't put function definition into for loop (because only the last one will remain); Instead, put those last lines in the for loop:

for i in range(5):
    move = player_choice()
    computermove = computer_choice()
    winner = roundwinner (move, computermove, compscore, playerscore )

In addition, you don't need to specify 0 in for i in range(0, 5); for i in range(5) will do the same.

Edit

def player_choice():
    msg = ('Rock, Paper, Scissors')
    title = ('Choose your action')
    choices =['Rock','Paper','Scissors']
    choice = choicebox(msg, title, choices)
    if choice == 'Rock':
        msgbox('You chose Rock', image='sizzors_gif.gif')
    elif choice == 'Paper':
        msgbox('You chose Paper', image='paer_gif.gif')
    elif choice == 'Scissors':
        msgbox('You chose Scissors', image='source.gif')
    return choice
Community
  • 1
  • 1
Pedram Parsian
  • 3,750
  • 3
  • 19
  • 34