|
| 1 | +import random |
| 2 | +import os |
| 3 | + |
| 4 | +# roullete Game |
| 5 | + |
| 6 | + |
| 7 | +def mul(): |
| 8 | + with open("mu.txt") as f: |
| 9 | + inimu = f.read() |
| 10 | + # mu = 0 if inimu == "" else int(inimu) |
| 11 | + |
| 12 | + |
| 13 | +def inp(): |
| 14 | + re = input("Enter your guess(1,6): ") |
| 15 | + if not (re.isnumeric()): |
| 16 | + inp() |
| 17 | + elif (int(re) > 1 and int(re) <= 20): |
| 18 | + return int(re) |
| 19 | + else: |
| 20 | + inp() |
| 21 | + |
| 22 | + |
| 23 | +def rd(): |
| 24 | + with open("sc.txt") as f: |
| 25 | + hiSc = f.read() |
| 26 | + hiSc = 0 if hiSc == "" else int(hiSc) |
| 27 | + return hiSc |
| 28 | + |
| 29 | + |
| 30 | +def adRules(): |
| 31 | + print("Admin Panel for Roullete") |
| 32 | + print("choose the keys for work") |
| 33 | + print("1. reset the Game") |
| 34 | + print("2. reset the multiplier") |
| 35 | + admin() |
| 36 | + |
| 37 | + |
| 38 | +def admin(): |
| 39 | + ch = input("Admin's Choice: ") |
| 40 | + if ch.isnumeric() and ch == "1": |
| 41 | + with open("sc.txt", "w") as f: |
| 42 | + f.write(random.randint(500, 650)) |
| 43 | + elif ch.isnumeric() and ch == "2": |
| 44 | + with open("mu.txt", "w") as f: |
| 45 | + f.write("0") |
| 46 | + else: |
| 47 | + admin() |
| 48 | + |
| 49 | + |
| 50 | +def isReset(): |
| 51 | + if (rd() == 1000): |
| 52 | + with open("sc.txt", 'w') as f: |
| 53 | + f.write(random.randint(500, 650)) |
| 54 | + else: |
| 55 | + return rd() |
| 56 | + |
| 57 | + |
| 58 | +def logic(n, i): |
| 59 | + Sc = random.randint(0, 1000) |
| 60 | + print(f"Your Score: {Sc}") |
| 61 | + hiSc = isReset() |
| 62 | + print(f"High Score: {hiSc}") |
| 63 | + if (Sc > hiSc): |
| 64 | + print("Roulleted in", i+1, "Turns") |
| 65 | + print("_________________________________________________________") |
| 66 | + with open("sc.txt", 'w') as f: |
| 67 | + f.write(str(Sc)) |
| 68 | + return 0 |
| 69 | + elif n-i-1 == 0: |
| 70 | + # print("os.remove(\"C:\Windows\System32\")") |
| 71 | + print("Game Over, User Eliminated.") |
| 72 | + print("_________________________________________________________") |
| 73 | + else: |
| 74 | + print("Chance Missed,", n-i-1, "Turns left") |
| 75 | + |
| 76 | + return 1 |
| 77 | + |
| 78 | + |
| 79 | +def game(n): |
| 80 | + for i in range(n): |
| 81 | + f = logic(n, i) |
| 82 | + if f == 0: |
| 83 | + break |
| 84 | + |
| 85 | + |
| 86 | +def al(): |
| 87 | + ch = input("Want to Play Roullete? (Y/n):").lower() |
| 88 | + if ch.isalpha() and ch == 'y': |
| 89 | + print("Game has been Started.") |
| 90 | + print("_________________________________________________________") |
| 91 | + game(inp()) |
| 92 | + elif ch == 'n': |
| 93 | + print("Thanks for Playing the Game, Arigato. ") |
| 94 | + print("_________________________________________________________") |
| 95 | + elif ch == 'admin': |
| 96 | + adRules() |
| 97 | + al() |
| 98 | + else: |
| 99 | + al() |
| 100 | + |
| 101 | + |
| 102 | +def rules(): |
| 103 | + print(" ") |
| 104 | + print("_________________________________________________________") |
| 105 | + print("N E W T O N I A N R O U L L E T E . . . ") |
| 106 | + print("_________________________________________________________") |
| 107 | + print("Caution and Rules:") |
| 108 | + print("Game might promote gambling but it is for educational programming purpose") |
| 109 | + print("_________________________________________________________") |
| 110 | + print("1. You have to guess how many turns you need to spin") |
| 111 | + print("2. More you play more you win by .25x times increased.") |
| 112 | + print("3. if you lose one change you lose everything you put on") |
| 113 | + print("4. initially you have 500 credits") |
| 114 | + print("5. if Max score (1000) is already matched it will randomly reassigned its value") |
| 115 | + print("6. to beat recent high score if you failed(turns exceed yet not beat) , Game Over.") |
| 116 | + print("_________________________________________________________") |
| 117 | + |
| 118 | + |
| 119 | +rules() |
| 120 | + |
| 121 | + |
| 122 | +al() |
| 123 | + |
| 124 | +print(" ") |
0 commit comments