Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- def importfile():
- """reads in the file"""
- with open ("USER.csv","r") as myfile:
- reader = csv.reader(myfile)
- studentlist = list(reader)
- return studentlist
- def ded():
- print("player 1")
- User=input("usename: ")
- Pass=input("paswword: ")
- return(User,Pass)
- def checkuser(username,password,uList):
- valid = False
- for i in range(0,len(uList)):
- if username == uList[i][0] and password == uList[i][1]:
- valid = True
- break
- else:
- valid = False
- return (valid)
- def main(studentlist):
- uname,pword=ded()
- validUser=checkuser(uname,pword,studentlist)
- if validUser==True:
- print("Welcome to the game player 1")
- else:
- print("Incorrect details entered!")
- main(studentlist)
- studentlist = importfile()
- main(studentlist)
- def ded():
- print("player2")
- User=input("usename: ")
- Pass=input("paswword: ")
- return(User,Pass)
- def checkuser(username,password,uList):
- valid = False
- for i in range(0,len(uList)):
- if username == uList[i][0] and password == uList[i][1]:
- valid = True
- break
- else:
- valid = False
- return (valid)
- def main(studentlist):
- uname,pword=ded()
- validUser=checkuser(uname,pword,studentlist)
- if validUser==True:
- print("Welcome to the game player2")
- else:
- print("Incorrect details entered!")
- main(studentlist)
- studentlist = importfile()
- main(studentlist)
- from random import randint
- from time import sleep
- playerOneWins = 0
- playerTwoWins = 0
- for i in range(0,5):
- print("Player 1 it's your turn. Type 'roll' to roll the dice or tap enter to see your result. ")
- userOneInput = input(">>>")
- if userOneInput == "roll":
- valueOne = randint(1,12)
- print("Player 1 rolled ", valueOne)
- print(" Player 2 it's your turn. Type 'roll' to roll the dice or tap enter to end the game and see your result. ")
- userTwoInput = input(">>>")
- if userTwoInput == "roll":
- valueTwo = randint(1,12)
- print("Player 2 rolled ", valueTwo)
- if valueOne > valueTwo:
- print("Player 1 wins this round! ")
- playerOneWins += 1
- elif valueOne == valueTwo:
- print("It's a tie! ")
- else:
- print("Player 2 wins this round;")
- playerTwoWins += 1
- elif userTwoInput == "forfeit":
- print("Player 1 wins this round! ")
- playerOneWins += 1
- else:
- print("the game ended, your results are shown bellow.")
- break
- elif userOneInput == "forfeit":
- print ("Player 2 wins this round! ")
- playerTwoWins += 1
- else:
- print("the game ended, your results are shown bellow.")
- break
- sleep(2)
- print("Final results: ", playerOneWins, "-", playerTwoWins)
- if playerOneWins > playerTwoWins:
- print("Player 1 is the winner! ")
- elif playerOneWins == playerTwoWins:
- print("It's a tie! ")
- else:
- print("Player 2 is the winner! ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement