Dateien hochladen nach „“
parent
73db25e0b3
commit
d8690562c6
|
@ -4,8 +4,13 @@ class game():
|
|||
import sys
|
||||
import subprocess
|
||||
import pkg_resources
|
||||
import os
|
||||
print("initializing hashengine and installing dependencies if missing")
|
||||
required = {'keyboard', 'sounddevice', 'soundfile'}
|
||||
self.linecount = 0
|
||||
if os.name == 'nt':
|
||||
required = {'sounddevice', 'soundfile', 'windows-curses'}
|
||||
else:
|
||||
required = {'sounddevice', 'soundfile'}
|
||||
installed = {pkg.key for pkg in pkg_resources.working_set}
|
||||
missing = required - installed
|
||||
|
||||
|
@ -16,21 +21,13 @@ class game():
|
|||
print(i)
|
||||
subprocess.check_call([python, '-m', 'pip', 'install', i], stdout=sys.stdout)
|
||||
print("done")
|
||||
import os
|
||||
import ctypes
|
||||
import string
|
||||
def isAdmin():
|
||||
try:
|
||||
is_admin = (os.getuid() == 0)
|
||||
except AttributeError:
|
||||
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||
return is_admin
|
||||
if not isAdmin():
|
||||
print("error: hashengine needs to be run as an admin")
|
||||
input("enter to continue...")
|
||||
exit()
|
||||
self.osmodule = __import__("os")
|
||||
self.keyboard = __import__("keyboard")
|
||||
import curses
|
||||
self.screen = curses.initscr()
|
||||
self.screen.nodelay(1)
|
||||
curses.noecho()
|
||||
curses.endwin()
|
||||
try:
|
||||
self.sounddevice = __import__("sounddevice")
|
||||
except OSError:
|
||||
|
@ -54,7 +51,7 @@ class game():
|
|||
self.map["{}:{}".format(i, f)] = " "
|
||||
|
||||
self.objects = []
|
||||
|
||||
|
||||
def round2(self, target):
|
||||
from decimal import localcontext, Decimal, ROUND_HALF_UP
|
||||
with localcontext() as ctx:
|
||||
|
@ -62,8 +59,13 @@ class game():
|
|||
return Decimal(target).to_integral_value()
|
||||
|
||||
def update(self):
|
||||
import curses
|
||||
curses.noecho()
|
||||
curses.endwin()
|
||||
temp = self.screen.getch()
|
||||
#temp = ""
|
||||
for i in self.pressedkeys:
|
||||
if self.keyboard.is_pressed(i):
|
||||
if temp == ord(i):
|
||||
self.pressedkeys[i] = True
|
||||
else:
|
||||
self.pressedkeys[i] = False
|
||||
|
|
Loading…
Reference in New Issue