Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions v1.0/launcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import time, os, random
from mrmine_main import mrmine_start_game
from colorama import Fore as color

print("""
Enter the ID for the game you would like to play.
1. Mr. Mine [WIP]""")
game=input(" > ")
try:
game=int(game)
except Exception:
print("Invalid ID.")
exit()
if game==1:
print("Starting Mr. Mine...")
time.sleep(0.5)
print("Loading Game...")
time.sleep(random.uniform(0.5, 1.5))
os.system('clear')
i=0
d1=random.randint(-3, 3)
d2=random.randint(-3, 3)
d3=random.randint(-3, 3)
while i<=100:
print("="*102)
print("|"+color.GREEN+"█"*i+color.WHITE+"█"*(100-i)+"|")
print("|"+color.GREEN+"█"*i+color.WHITE+"█"*(100-i)+"|")
print("|"+color.GREEN+"█"*i+color.WHITE+"█"*(100-i)+"|","("+str(i)+"%)")
print("="*102)
if i<=15+d1:
print(color.WHITE+"Loading Launcher...")
elif i<=50+d2:
print(color.WHITE+"Initializing Game...")
elif i<=80+d3:
print(color.WHITE+"Loading GUI...")
elif i<100:
print("Loading Scripts...")
elif i==100:
break
time.sleep(random.uniform(0.1, 0.3))
os.system('clear')
i+=1
print(color.WHITE+"Loading Complete!")
time.sleep(2)
print(color.WHITE+"Welcome to Mr. Mine!")
time.sleep(1)
os.system('clear')
mrmine_start_game()
15 changes: 15 additions & 0 deletions v1.0/mrmine/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@
==============="""
}

def read_save():
save_data = {}
with open('mrmine_save.txt', 'r') as file:
for line in file:
line = line.strip()
if '=' in line: # Ensuring there's a key-value split
key, value = line.split('=', 1) # Split on first '=' to handle complex values
try:
# Attempt to evaluate the value for correct data types
save_data[key] = eval(value)
except Exception:
# If eval fails, it's likely a string or ambiguous format
save_data[key] = value
return save_data

def update_GUI_func(key):
if key=='q':
os.system('clear')
Expand Down
18 changes: 13 additions & 5 deletions v1.0/mrmine/main_script.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from threading import Thread
from mrmine_keypress_detector import detect_keypress_nonblocking
from mrmine_gui import update_GUI, scroll, update_GUI_func
import os
import os, time

# Make the relay of keys more accessible
key_pressed = None
Expand All @@ -28,7 +28,7 @@ def tick():
elif key in ["k", "q", "c", "s", "h", "u", " ", "p", "r"]:
update_GUI_func(key)

def read_save_file_to_dict():
def read_save():
save_data = {}
with open('mrmine_save.txt', 'r') as file:
for line in file:
Expand All @@ -38,23 +38,31 @@ def read_save_file_to_dict():
try:
# Attempt to evaluate the value for correct data types
save_data[key] = eval(value)
except:
except Exception:
# If eval fails, it's likely a string or ambiguous format
save_data[key] = value
return save_data

def mrmine_start_game():
os.system('clear')
update_GUI()
try:
read_save_file_to_dict()
save_data=read_save()
except Exception:
print("Error while loading save file.")
save_data=None
print("Exiting the game...")
exit()
if save_data['BROADCAST_TYPE'] != "none":
print("Message from devs: "+save_data['BROADCAST_MESSAGE'])
time.sleep(1)
os.system('clear')
try:
listener_thread = Thread(target=keypress_listener)
listener_thread.daemon = True
listener_thread.start()
update_GUI()
while True:
tick()
except KeyboardInterrupt:
print("Game interrupted, exiting...")
exit()