Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.12 KB | None | 0 0
  1. # -*- coding: cp1252 -*-
  2. import random
  3. import time
  4.  
  5. cash = 500;
  6.  
  7. def potatiswin():
  8.     print "Du fick 3 potäter i rad"
  9.     print "+ 25 $"
  10.     global cash
  11.     cash = cash + 25;
  12.     start()
  13.  
  14. def morotwin():
  15.     print "Du fick 3 morötter i rad"
  16.     print "+ 20 $"
  17.     global cash
  18.     cash = cash + 20;
  19.     start()
  20.  
  21. def gurkawin():
  22.     print "Du fick 3 gurkor i rad"
  23.     print "+ 15 $"
  24.     global cash
  25.     cash = cash + 15;
  26.     start()
  27.  
  28. def start():
  29.     print "Du har nu", cash ,"$"
  30.     youwannaplay()
  31.  
  32. def youwannaplay():
  33.     eee = raw_input("Sätt in 10$ i maskinen för att börja (Enter) ")
  34.     if eee == "":
  35.         print '-10 $'
  36.         game()
  37.     elif cash < 10:
  38.         print 'Du har spelat bort alla dina pengar, dags för en paus?'
  39.     else:
  40.         print "Invalid input"
  41.         start()
  42.  
  43. def game():
  44.     global cash
  45.     cash = cash - 10
  46.  
  47.     w1 = ["","",""]
  48.     w2 = ["","",""]
  49.     w3 = ["","",""]
  50.  
  51.     r1 = random.randint(0,2)
  52.     r2 = random.randint(0,2)
  53.     r3 = random.randint(0,2)
  54.  
  55.     if r1 == 0:
  56.         w1[0] = "Potatis"
  57.         w1[1] = "Morot"
  58.         w1[2] = "Gurka"
  59.     if r1 == 1:
  60.         w1[0] = "Morot"
  61.         w1[1] = "Gurka"
  62.         w1[2] = "Potatis"
  63.     if r1 == 2:
  64.         w1[0] = "Gurka"
  65.         w1[1] = "Potatis"
  66.         w1[2] = "Morot"
  67.  
  68.     if r2 == 0:
  69.         w2[0] = "Potatis"
  70.         w2[1] = "Morot"
  71.         w2[2] = "Gurka"
  72.     if r2 == 1:
  73.         w2[0] = "Morot"
  74.         w2[1] = "Gurka"
  75.         w2[2] = "Potatis"
  76.     if r2 == 2:
  77.         w2[0] = "Gurka"
  78.         w2[1] = "Potatis"
  79.         w2[2] = "Morot"
  80.  
  81.     if r3 == 0:
  82.         w3[0] = "Potatis"
  83.         w3[1] = "Morot"
  84.         w3[2] = "Gurka"
  85.     if r3 == 1:
  86.         w3[0] = "Morot"
  87.         w3[1] = "Gurka"
  88.         w3[2] = "Potatis"
  89.     if r3 == 2:
  90.         w3[0] = "Gurka"
  91.         w3[1] = "Potatis"
  92.         w3[2] = "Morot"
  93.  
  94.     print w1
  95.     time.sleep(1.5)
  96.     print w2
  97.     time.sleep(1.5)
  98.     print w3
  99.     time.sleep(1.5)
  100.  
  101.     if (w1[0] and w2[0] and w3[0]) == ("Potatis"):
  102.         potatiswin();
  103.     elif (w1[0] and w2[0] and w3[0]) == ("Morot"):
  104.         morotwin();
  105.     elif (w1[0] and w2[0] and w3[0]) == ("Gurka"):
  106.         gurkawin();
  107.  
  108.     elif (w1[1] and w2[1] and w3[1]) == ("Potatis"):
  109.         potatiswin();
  110.     elif (w1[1] and w2[1] and w3[1]) == ("Morot"):
  111.         morotwin();
  112.     elif (w1[1] and w2[1] and w3[1]) == ("Gurka"):
  113.         gurkawin();
  114.  
  115.     elif (w1[2] and w2[2] and w3[2]) == ("Potatis"):
  116.         potatiswin();
  117.     elif (w1[2] and w2[2] and w3[2]) == ("Morot"):
  118.         morotwin();
  119.     elif (w1[2] and w2[2] and w3[2]) == ("Gurka"):
  120.         gurkawin();
  121.  
  122.     elif (w1[0] and w2[1] and w3[2]) == ("Potatis"):
  123.         potatiswin();
  124.     elif (w1[0] and w2[1] and w3[2]) == ("Morot"):
  125.         morotwin();
  126.     elif (w1[0] and w2[1] and w3[2]) == ("Gurka"):
  127.         gurkawin();
  128.  
  129.     elif (w1[2] and w2[1] and w3[0]) == ("Potatis"):
  130.         potatiswin();
  131.     elif (w1[2] and w2[1] and w3[0]) == ("Morot"):
  132.         morotwin();
  133.     elif (w1[2] and w2[1] and w3[0]) == ("Gurka"):
  134.         gurkawin();
  135.     else:
  136.         print "Ingen vinst"
  137.         start()
  138.  
  139. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement