Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import pickle
- try:
- highscore = pickle.load(open("/sdcard/Download/top10.txt", "rb"))
- except IOError:
- print("fisierul nu exista")
- highscore = []
- listaNumere = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
- amesteca = random.shuffle(listaNumere)
- number = random.choice(listaNumere)
- #number = random.randint(1, 10)
- punctaj = [50, 80, 100]
- punctajBonus = [10, 20, 30] # inca nu este bagat
- def ghicireNumar():
- vieti = 3
- while vieti != 0:
- ghicire = int(input("Numar norocos: "))
- if ghicire == number and vieti == 3:
- print("Ai castigat, " + nume + "!! Cu un punctaj de " + str(punctaj[-1]))
- highscore.append((nume, punctaj[-1]))
- break
- elif ghicire == number and vieti == 2:
- print("Ai castigat, " + nume + "!! Cu un punctaj de " + str(punctaj[1]))
- highscore.append((nume, punctaj[1]))
- break
- elif ghicire == number and vieti == 1:
- print("Ai castigat, " + nume + "!! Cu un punctaj de " + str(punctaj[0]))
- highscore.append((nume, punctaj[0]))
- break
- else:
- print("Gresit!! Mai ai " + str(vieti-1) + " incercari")
- vieti = vieti -1
- if vieti == 0:
- for item in highscore:
- print(str(item) + "\n")
- def salvareTop():
- dumptop = pickle.dump(highscore, open("/sdcard/Download/top10.txt", "wb"))
- def highScore():
- print("Top 10")
- top = 10
- for i in highscore:
- print(i)
- top -= 1
- if top == 0:
- break
- def meniu():
- alege = int(input("1. Start joc\n2. Top10\n3. Exit\n:"))
- if alege == 1:
- ghicireNumar()
- salvareTop()
- elif alege == 2:
- highScore()
- else:
- print ("pa")
- if __name__ == "__main__":
- nume = input("Nickname: ")
- print("Salut, " + nume + "!")
- meniu()
- # Mai trebuie:
- # -salvarea top-ului si incarcarea lui la fiecare rulare
- # -punctajul bonus
Add Comment
Please, Sign In to add comment