Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
fixed negative number bet execution
Browse files Browse the repository at this point in the history
speed improvements
fixed settings
  • Loading branch information
HumanBot000 committed Dec 4, 2022
1 parent ea33684 commit c5abf41
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 94 deletions.
117 changes: 24 additions & 93 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os
import platform
import random
import re

import GPUtil
import psutil
from colorama import Fore


Expand All @@ -21,6 +18,8 @@ def get_coins():
settings_file = open("settings.txt", "r+")
coins = settings_file.readlines()[0]
coins = int(re.split(":", coins)[1])
if coins <= 0:
coins = 0
return coins


Expand Down Expand Up @@ -75,75 +74,12 @@ def settings(coins):
coins = coins - coins_to_clear
update_coins(coins)
elif setting == 3:
allowed = str(
input("To make it a lot easier to debug we collect some datas like operating system and free memory\n"
"is that okay for you? (y/n):"))
if allowed == "y":
disk_io = psutil.disk_io_counters()
partitions = psutil.disk_partitions()
virtual_memory = psutil.virtual_memory()
uname = platform.uname()
swap = psutil.swap_memory()
print(
f"{Fore.LIGHTBLUE_EX}Mini Games is a collection od classic mini and casino games with it's own money system.\n"
f"If you want to create a bug/issue report at https://github.com/HumanBot000/MiniGames/issues please copy the text below."
f"This makes it a lot easier to debug:\n\n"
f"{Fore.RED}\n")
print("-" * 40, "system info read out with python", "-" * 40)
print(f"Version:{get_version()}")
print(f"System: {uname.system}")
print(f"Node Name: {uname.node}")
print(f"Release: {uname.release}")
print(f"Version: {uname.version}")
print(f"Machine: {uname.machine}")
print(f"Processor: {uname.processor}")
# print(f"Boot Time: {bt.day}.{bt.month}.{bt.year} {bt.hour}:{bt.minute}: {bt.second} ")
print("Actual Cores:", psutil.cpu_count(logical=False))
print("Logical Cores:", psutil.cpu_count(logical=True))
print(f"Max Frequency:, {psutil.cpu_freq().max:.1f}Mhz")
print(f"Curren Frequency: {psutil.cpu_freq().current:.1f}Mhz")
print(f"Cpu usage: {psutil.cpu_percent()}%")
print("Utilization per core:")
for i, perc in enumerate(psutil.cpu_percent(percpu=True, interval=1)):
print(f"Core {i}: {perc} %")
# print(f"Total RAM: {disk_adjustsize(virtual_memory.total)}")
print(f"Available RAM: {disk_adjustsize(virtual_memory.available)}")
# print(f"Used RAM: {virtual_memory.used}")
# print(f"Percentage of available RAM: {virtual_memory.percent}%")
# print(f"Total SWAP: {disk_adjustsize(swap.total)}")
print(f"Free SWAP: {disk_adjustsize(swap.free)}")
# print(f"Used SWAP: {disk_adjustsize(swap.used)}")
print(f"Percentage SWAP: : {swap.percent}%")
for p in partitions:
print(f"Device: {p.device}")
print(f"\tMountpoint: {p.mountpoint}")
print(f"\tFile system type: {p.fstype}")
try:
partitions_usage = psutil.disk_usage(p.mountpoint)
except PermissionError:
print(Fore.RED)
print("Error no permissions")
continue
# print(f"Total Size: {disk_adjustsize(partitions_usage.total)}")
# print(f"Used: {disk_adjustsize(partitions_usage.used)}")
print(f"Free: {disk_adjustsize(partitions_usage.free)}")
# print(f"Percentage: {partitions_usage.percent}%")
# print(f"Read since boot: {disk_adjustsize(disk_io.read_bytes)}")
# print(f"Written since boot {disk_adjustsize(disk_io.write_bytes)}")
# print("-" * 40, "GPU/Graphic Card", "-" * 40)
gpus = GPUtil.getGPUs()
# for gpu in gpus:
# print(f"ID: {gpu.id}")
# print(f"Name: {gpu.name}")
# print(f"\tLoad: {gpu.load * 100}%")
# print(f"Free mem: {gpu.memoryFree}MB")
# print(f"Used mem: {gpu.memoryUsed}MB")
# print(f"\tTotal Mem: {gpu.memoryTotal}MB")
# print(f"Temperature: {gpu.temperature}°C")
else:
print(
f"{Fore.LIGHTBLUE_EX}Mini Games is a collection od classic mini and casino games with it's own money system.\n"
f"Please create a bug/issue report at https://github.com/HumanBot000/MiniGames/issues")
print(
f"{Fore.LIGHTBLUE_EX}Mini Games is a collection od classic mini and casino games with it's own money system.\n"
f"If you want to create a bug/issue report at https://github.com/HumanBot000/MiniGames/issues please copy the text below."
f"This makes it a lot easier to debug:"
f"{Fore.RED}\n")
print(f"{Fore.RED}version:{get_version()}{Fore.RESET}")
input()
print(Fore.RESET)
elif setting == 0:
Expand All @@ -158,7 +94,10 @@ def validate_int(number):
except Exception:
return False
else:
return number
if number >=0:
return number
else:
return False


def game_guess_the_number():
Expand Down Expand Up @@ -408,11 +347,11 @@ def game_black_jack():
def game_jackpot():
clear_console()
print(Fore.CYAN)
coins = get_coins()
coins = get_coins()
coins_start = coins
task = str(input("Please select a Task: [0] Rules | [1] Play | [2] Back:"))
print(task)
if validate_int(task) == False and task !="0":
if validate_int(task) == False and task != "0":
print(Fore.RED)
print("Please enter a valid number")
print(Fore.RESET)
Expand All @@ -424,7 +363,7 @@ def game_jackpot():
print(Fore.GREEN)
print(f"Inputs: \n bet: [a number between 0 and your coins] the bet you like to set \n action:[0,1]\n"
f"The Game:you have a multiplier at the beginning its by x0 than you decide if you want to raise it \n"
f"or end the game if you raise it you have a 50%/33% chance to double the multiplier 0 -> 2 -> 4 -> ...\n"
f"or end the game if you raise it you have a 40% chance to double the multiplier 0 -> 2 -> 4 -> ...\n"
f"If you are unlucky all your coins are away\n"
f"Note if you end with a x0 multiplier your coins are also gone")
print(Fore.RESET)
Expand All @@ -451,24 +390,17 @@ def game_jackpot():
input()
game_jackpot()
if task == 1:
if multiplier == 0:
if random.randint(1, 2) == 1: # 50%
if random.randint(1, 10) <= 4: # 40%
if multiplier == 0:
multiplier = 2
else:
update_coins(coins)
print(
f"{Fore.GREEN}You lost with x{multiplier}{Fore.RESET}")
input()
game_jackpot()
else:
if random.randint(1, 3) == 1: # 33%
multiplier = multiplier * 2
else:
update_coins(coins)
print(
f"{Fore.GREEN}You lost with x{multiplier}{Fore.RESET}")
input()
game_jackpot()
else:
update_coins(coins)
print(
f"{Fore.RED}You lost all your coins are gone{Fore.RESET}")
input()
game_jackpot()
else:
print(f"{Fore.RED}You only have {coins} coins {Fore.RESET}")
input()
Expand Down Expand Up @@ -531,6 +463,5 @@ def main():
else:
main()

main()

# TODO check for negativ money
main()
3 changes: 2 additions & 1 deletion settings.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
money:2567
money:100
version:v2.0

0 comments on commit c5abf41

Please sign in to comment.