Skip to content

Commit 35dfce6

Browse files
Merge pull request #3 from XtheGxmerz0/main
merge v1.0 branch with main
2 parents da3ff3e + 217703f commit 35dfce6

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

v1.0/launcher.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import time, os, random
2+
from mrmine_main import mrmine_start_game
3+
from colorama import Fore as color
4+
5+
print("""
6+
Enter the ID for the game you would like to play.
7+
1. Mr. Mine [WIP]""")
8+
game=input(" > ")
9+
try:
10+
game=int(game)
11+
except Exception:
12+
print("Invalid ID.")
13+
exit()
14+
if game==1:
15+
print("Starting Mr. Mine...")
16+
time.sleep(0.5)
17+
print("Loading Game...")
18+
time.sleep(random.uniform(0.5, 1.5))
19+
os.system('clear')
20+
i=0
21+
d1=random.randint(-3, 3)
22+
d2=random.randint(-3, 3)
23+
d3=random.randint(-3, 3)
24+
while i<=100:
25+
print("="*102)
26+
print("|"+color.GREEN+"█"*i+color.WHITE+"█"*(100-i)+"|")
27+
print("|"+color.GREEN+"█"*i+color.WHITE+"█"*(100-i)+"|")
28+
print("|"+color.GREEN+"█"*i+color.WHITE+"█"*(100-i)+"|","("+str(i)+"%)")
29+
print("="*102)
30+
if i<=15+d1:
31+
print(color.WHITE+"Loading Launcher...")
32+
elif i<=50+d2:
33+
print(color.WHITE+"Initializing Game...")
34+
elif i<=80+d3:
35+
print(color.WHITE+"Loading GUI...")
36+
elif i<100:
37+
print("Loading Scripts...")
38+
elif i==100:
39+
break
40+
time.sleep(random.uniform(0.1, 0.3))
41+
os.system('clear')
42+
i+=1
43+
print(color.WHITE+"Loading Complete!")
44+
time.sleep(2)
45+
print(color.WHITE+"Welcome to Mr. Mine!")
46+
time.sleep(1)
47+
os.system('clear')
48+
mrmine_start_game()

v1.0/mrmine/gui.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@
4646
==============="""
4747
}
4848

49+
def read_save():
50+
save_data = {}
51+
with open('mrmine_save.txt', 'r') as file:
52+
for line in file:
53+
line = line.strip()
54+
if '=' in line: # Ensuring there's a key-value split
55+
key, value = line.split('=', 1) # Split on first '=' to handle complex values
56+
try:
57+
# Attempt to evaluate the value for correct data types
58+
save_data[key] = eval(value)
59+
except Exception:
60+
# If eval fails, it's likely a string or ambiguous format
61+
save_data[key] = value
62+
return save_data
63+
4964
def update_GUI_func(key):
5065
if key=='q':
5166
os.system('clear')

v1.0/mrmine/main_script.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from threading import Thread
22
from mrmine_keypress_detector import detect_keypress_nonblocking
33
from mrmine_gui import update_GUI, scroll, update_GUI_func
4-
import os
4+
import os, time
55

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

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

4646
def mrmine_start_game():
4747
os.system('clear')
48-
update_GUI()
4948
try:
50-
read_save_file_to_dict()
49+
save_data=read_save()
5150
except Exception:
5251
print("Error while loading save file.")
52+
save_data=None
53+
print("Exiting the game...")
54+
exit()
55+
if save_data['BROADCAST_TYPE'] != "none":
56+
print("Message from devs: "+save_data['BROADCAST_MESSAGE'])
57+
time.sleep(1)
58+
os.system('clear')
5359
try:
5460
listener_thread = Thread(target=keypress_listener)
5561
listener_thread.daemon = True
5662
listener_thread.start()
63+
update_GUI()
5764
while True:
5865
tick()
5966
except KeyboardInterrupt:
6067
print("Game interrupted, exiting...")
68+
exit()

0 commit comments

Comments
 (0)