diff --git a/Difficult_Rocket.py b/Difficult_Rocket.py index e96c109..ae9728e 100644 --- a/Difficult_Rocket.py +++ b/Difficult_Rocket.py @@ -1,23 +1,11 @@ -''' +""" writen by shenjackyuanjie mail: 3695888@qq.com -''' +""" -import sys from bin import main - -def game(): - # Python vision check - py_v_info = sys.version_info - py_v = str('%d.%d.%d' % (py_v_info[0], py_v_info[1], py_v_info[2])) - if py_v_info[0] == 2: - raise Exception('Difficult Rocket need python vision 3+') - # start games +if __name__ == '__main__': game = main.Game() game.start() - - -if __name__ == '__main__': - game() diff --git a/bin/client.py b/bin/client.py index bf84a8f..7756af8 100644 --- a/bin/client.py +++ b/bin/client.py @@ -5,7 +5,6 @@ mail: 3695888@qq.com import multiprocessing as mp -import re import pyglet import pyglet.app from pyglet import image @@ -21,7 +20,7 @@ except (ModuleNotFoundError, ImportError, ImportWarning): import tools -class RenderThread(mp.Process, pyglet.window.Window): +class client(mp.Process, pyglet.window.Window): def __init__(self, logger, dev_dic=None, dev_list=None, path=None, net_mode='local'): ''' @@ -64,7 +63,7 @@ class RenderThread(mp.Process, pyglet.window.Window): # setup self.setup() - def startGame(self): + def start_game(self): pyglet.app.run() return diff --git a/bin/main.py b/bin/main.py index be36989..6b36314 100644 --- a/bin/main.py +++ b/bin/main.py @@ -26,10 +26,16 @@ class Game: def __init__(self): # basic config + self.on_python_v_info = sys.version_info + self.on_python_v = str('%d.%d.%d' % (self.on_python_v_info[0], + self.on_python_v_info[1], + self.on_python_v_info[2])) self.start_time = time.strftime('%Y-%m-%d %H-%M-%S', time.gmtime(time.time())) + # share memory self.dicts = share().dict() self.lists = share().list() + # logger self.log_config = tools.config('configs/logging.json5', 'file') self.log_filename = configs.name_handler(self.log_config['filename']['main'], @@ -39,7 +45,7 @@ class Game: self.root_logger_stream_handler.setLevel(self.log_config['level']) self.root_logger_stream_handler.setFormatter(self.root_logger_fmt) self.root_logger_stream_handler.setLevel(tools.log_level(self.log_config['level'])) - self.root_logger_file_handler = logging.FileHandler(self.log_filename) + self.root_logger_file_handler = logging.FileHandler('logs/' + self.log_filename) self.root_logger_file_handler.setFormatter(self.root_logger_fmt) self.root_logger_file_handler.setLevel(tools.log_level(self.log_config['level'])) # root logger setup @@ -51,25 +57,23 @@ class Game: self.server_logger = logging.getLogger().getChild('server') self.client_logger = logging.getLogger().getChild('client') self.main_logger.info('client logger and server logger done') + + # version check self.python_version_check() # client and server - self.client = client.RenderThread( - self.client_logger, self.dicts, self.lists, net_mode='local') - self.server = server.server( - self.lists, self.dicts, self.server_logger, net_mode='local') + self.client = client.client(self.client_logger, self.dicts, self.lists, net_mode='local') + self.server = server.server(self.lists, self.dicts, self.server_logger, net_mode='local') # //todo log configs def python_version_check(self) -> None: - py_v_info = sys.version_info - py_v = str('%d.%d.%d' % (py_v_info[0], py_v_info[1], py_v_info[2])) - self.main_logger.info('Difficult Rocket is running on Python Vision %s' % py_v) - if py_v_info[0] == 2: - self.main_logger.critical('Difficult Rocket need Python vision 3+ but not %s ' % py_v) - raise Exception('Difficult Rocket need python vision 3+ but not %s ' % py_v) - elif py_v_info[1] <= 7: - self.main_logger.warning('Difficult is develop in Python version 3.8 \n and you are running on %s may \ - cause error' % py_v) + self.main_logger.info('Difficult Rocket is running on Python Vision %s' % self.on_python_v) + if self.on_python_v_info[0] == 2: + self.main_logger.critical('Difficult Rocket need Python vision 3+ but not %s ' % self.on_python_v) + raise Exception('Difficult Rocket need python vision 3+ but not %s ' % self.on_python_v) + elif self.on_python_v_info[1] <= 7: + self.main_logger.warning('Difficult is develop in Python version 3.8 \n\ + and you are running on %s may cause error' % self.on_python_v) def start(self): # start - self.client.startGame() + self.client.start_game()