Advertisement
Guest User

Card Game old Gcse Python Code

a guest
Oct 13th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.46 KB | None | 0 0
  1. import random
  2. ####################################################
  3. def deck_creation():
  4.   colours = ["red","black","yellow"]
  5.   deck = []
  6.   b=-10
  7.   for i in range(3):
  8.     b+=10
  9.     for a in range(10):
  10.       deck.append([])
  11.       deck[(a+b)].append(a+1)
  12.       deck[(a+b)].append(colours[i])
  13.   random.shuffle(deck)
  14.   return (deck)
  15. ####################################################
  16. creds = [["a","a"], ["james", "the"], ["mat", "dog"]]
  17. a=0
  18. while a < 1:
  19.     print("")
  20.     user=input("Enter Your Username:")
  21.     pas=input("Enter Your Password:")
  22.     for item in creds:
  23.       if item[0] == user and item[1]==pas:
  24.         print ("__________________________login successfull!__________________________")
  25.         deck = deck_creation()
  26.         a=+1
  27.       else: print ("------", end="")
  28. ####################################################
  29. player1 =[]
  30. player2 =[]
  31. for i in range(15):
  32.   player1.append(deck[0])
  33.   player2.append(deck[1])
  34.   deck.remove(deck[0])
  35.   deck.remove(deck[0])
  36. ####################################################
  37. def p1w():
  38.   print ("Player1 Won!")
  39.   print ("player1 cards=", player1[0], "player2 cards=", player2[0])
  40.   player1_wins.append(player1[0])
  41.   player1_wins.append(player2[0])
  42.   player1.remove(player1[0])
  43.   player2.remove(player2[0])
  44. def p2w():
  45.   print ("Player2 Won!")
  46.   print ("player1 cards=", player1[0], "player2 cards=", player2[0])
  47.   player2_wins.append(player1[0])
  48.   player1_wins.append(player2[0])
  49.   player2.remove(player2[0])
  50.   player1.remove(player1[0])
  51. ####################################################
  52. player1_wins=[]
  53. player2_wins=[]
  54. for i in range(15):  
  55.   if player1[0][1] == player2[0][1]:
  56.     if player1[0][0] > player2[0][0]:p1w()
  57.     else:p2w()
  58.   elif player1[0][1] == "red" and player2[0][1]== "black": p1w()
  59.   elif player2[0][1] == "red" and player1[0][1]== "black": p2w()
  60.   elif player1[0][1] == "yellow" and player2[0][1]== "red": p1w()
  61.   elif player2[0][1] == "yellow" and player1[0][1]== "red": p2w()
  62.   elif player1[0][1] == "black" and player2[0][1]== "yellow": p1w()
  63.   elif player2[0][1] == "black" and player1[0][1]== "yellow": p2w()
  64. print ("-------------------------------------------------------------------------")
  65. print ("player1 wins = ", player1_wins, "   TOTAL =", len(player1_wins))
  66. print ("")
  67. print ("player2 wins = ", player2_wins, "   TOTAL =", len(player2_wins))
  68. print ("")
  69. if (len(player1_wins))>(len(player2_wins)): print ("OVERALL Player1 WINS")
  70. else: print ("OVERALL Player2 WINS")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement