SHARE
TWEET

Untitled

a guest Nov 16th, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. import csv
  3. import time
  4.  
  5. def username1():
  6.     while True:
  7.         username1 = input("What username would you like to have? ")
  8.         if len(username1) < 8:
  9.             print("Your username must have more than 8 characters")
  10.             continue
  11.         else:
  12.             print("Your username has the correct amount of characters")
  13.         if username1.upper == username1 or username1.lower() == username1:
  14.             print("Your username must contain both upper and lowercase letters")
  15.             continue
  16.         else:
  17.             print("Your username has upper and lowercase letters")
  18.         file = open("accountinfo.txt","a")
  19.         file.write("Player 1 Username: ")
  20.         file.write(username1)
  21.         file.write("\n")
  22.         file.close()
  23.         break
  24.  
  25. def password1():
  26.     while True:
  27.         password1 = input("What password would you like? ")
  28.         if len(password1) < 8:
  29.             print("Your password must have more than 8 characters")
  30.             continue
  31.         else:
  32.             print("Your password has the correct amount of characters")
  33.         if password1.upper == password1 or password1.lower() == password1:
  34.             print("Your password must contain both upper and lowercase letters")
  35.             continue
  36.         else:
  37.             print("Your password has upper and lowercase letters")
  38.         file = open("accountinfo.txt","a")
  39.         file.write("Player 1 Password: ")
  40.         file.write(password1)
  41.         file.write("\n")
  42.         file.close()
  43.         break
  44.  
  45. def username2():
  46.     while True:
  47.         username2 = input("What username would you like to have? ")
  48.         if len(username2) < 8:
  49.             print("Your username must have more than 8 characters")
  50.             continue
  51.         else:
  52.             print("Your username has the correct amount of characters")
  53.         if username2.upper == username2 or username2.lower() == username2:
  54.             print("Your username must contain both upper and lowercase letters")
  55.             continue
  56.         else:
  57.             print("Your username has upper and lowercase letters")
  58.         file = open("accountinfo.txt","a")
  59.         file.write("Player 2 Username: ")
  60.         file.write(username2)
  61.         file.write("\n")
  62.         file.close()
  63.         break
  64.  
  65. def password2():
  66.     while True:
  67.         password2 = input("What password would you like? ")
  68.         if len(password2) < 8:
  69.             print("Your password must have more than 8 characters")
  70.             continue
  71.         else:
  72.             print("Your password has the correct amount of characters")
  73.         if password2.upper == password2 or password2.lower() == password2:
  74.             print("Your password must contain both upper and lowercase letters")
  75.             continue
  76.         else:
  77.             print("Your password has upper and lowercase letters")
  78.         file = open("accountinfo.txt","a")
  79.         file.write("Player 2 Password: ")
  80.         file.write(password2)
  81.         file.write("\n")
  82.         file.close()
  83.         break
  84.  
  85. def game():
  86.     while True:
  87.         player1 = input("Player 1 Username  = ") # Asks player 1 to input a variable
  88.         player1pass = input("Player 1 Password = ") # Asks Player 1 to input a variable
  89.         print("You've successfully logged in.")
  90.         player2 = input("Player 2 Username  = ") # Asks player 2 to input a variable
  91.         player2pass = input("Player 2 Password = ") # Asks player 2 to input another variable
  92.         print("You've successfully logged in.")    
  93.         player1=0
  94.         player2=0
  95.         print("Player 1 Ready?")
  96.         print("Player 2 Ready?")
  97.         print("-----------------------------------------------------")
  98.         totalscore1=0
  99.         totalscore2=0
  100.         dice1 = random.randint(1,6)
  101.         dice2 = random.randint(1,6)
  102.         roundno = 1
  103.         while roundno < 2:
  104.             totalscore1=totalscore1+player1
  105.             totalscore2=totalscore2+player2
  106.             player1=dice1+dice2
  107.             roundno=roundno+1
  108.             print("Round",roundno)
  109.             time.sleep(1)
  110.             roll = input("Player 1, please press enter to roll")
  111.             print("Player 1 is rolling")
  112.             print("Player 1's first roll is",dice1)
  113.             time.sleep(1)
  114.             print("Player 1's second roll is",dice2)
  115.             time.sleep(1)
  116.             if player1 %2==0:
  117.                 print("This is an even number. so +10 points")
  118.                 time.sleep(1)
  119.                 player1=player1+10
  120.                 time.sleep(1)
  121.                 print("Score is",player1)
  122.                 if player1<= 0:
  123.                     print("You have lost the game")
  124.                     sys.exit()
  125.             else:
  126.                 print("This is an odd number.")
  127.                 time.sleep(2)
  128.                 player1=player1-5
  129.                 print("Score is",player1)
  130.                 time.sleep(3)
  131.                 print("Player 1 score",player1)
  132.  
  133.  
  134.             print("-----------------------------------------------------")
  135.             time.sleep(1)
  136.             #player 2
  137.             dice1 = random.randint(1,6)
  138.             dice2 = random.randint(1,6)
  139.             totalscore1=totalscore1+player1
  140.             totalscore2=totalscore2+player2
  141.             player2=dice1+dice2
  142.             print("-----------------------------------------------------")
  143.             roll = input("Player 2 press enter to roll")
  144.             print("Player 2 is rolling")
  145.             time.sleep(1)
  146.             print("Player 2's first roll is",dice1)
  147.             time.sleep(1)
  148.             roll = input("Player 2 press enter to roll again")
  149.             time.sleep(1)
  150.             print("Player 2's second roll is",dice2)
  151.             time.sleep(1)
  152.             if player2 %2==0:
  153.                 print("This is an even number. so +10 points")
  154.                 time.sleep(1)
  155.                 player2=player2+10
  156.                 print("Score is",player2)
  157.                 time.sleep(1)
  158.                 if player2<= 0:
  159.                     print("You have lost the game")
  160.                     sys.exit()
  161.             else:
  162.                 print("This is an odd number.")
  163.                 time.sleep(1)
  164.                 player2=player2-5
  165.                 print("Score is",player2)
  166.                 time.sleep(3)
  167.                 print("Player 2 score",player2)
  168.             print("-----------------------------------------------------")
  169.  
  170.         print("The total score for player 1 is ",totalscore1)
  171.         print("The total score for player 2 is ",totalscore2)
  172.         if totalscore1 > totalscore2:
  173.             print("Player 1 Wins!")
  174.             file = open("scores.txt","a")
  175.             file.write(int(player1))
  176.             file.write(" has ")
  177.             file.write(str(totalscore1))
  178.             file.write(" points")
  179.             file.write("\n")
  180.             file.close()
  181.         if totalscore2 > totalscore1:
  182.             print("Player 2 Wins!")
  183.             file = open("scores.txt","a")
  184.             file.write(int(player2))
  185.             file.write(" has ")
  186.             file.write(str(totalscore2))
  187.             file.write(" points")
  188.             file.write("\n")
  189.             file.close()
  190.  
  191. #username1()
  192. #password1()
  193. #username2()
  194. #password2()
  195. game()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top