prepare for DEMO!
This commit is contained in:
parent
f9f9e09f17
commit
5f2962c248
@ -6,9 +6,10 @@ mail: 3695888@qq.com
|
|||||||
import os
|
import os
|
||||||
import bin
|
import bin
|
||||||
import sys
|
import sys
|
||||||
|
from bin import main
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def game():
|
||||||
# Python vision check
|
# Python vision check
|
||||||
py_v_info = sys.version_info
|
py_v_info = sys.version_info
|
||||||
py_v = str("%d.%d.%d" % (py_v_info[0], py_v_info[1], py_v_info[2]))
|
py_v = str("%d.%d.%d" % (py_v_info[0], py_v_info[1], py_v_info[2]))
|
||||||
@ -16,8 +17,8 @@ def main():
|
|||||||
if py_v_info[0] == 2:
|
if py_v_info[0] == 2:
|
||||||
raise Exception("Simple Rocket need python vision 3+")
|
raise Exception("Simple Rocket need python vision 3+")
|
||||||
# start games
|
# start games
|
||||||
game = bin.bin.main.Game()
|
game = main.Game()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
game()
|
||||||
|
40
bin/main.py
40
bin/main.py
@ -14,31 +14,61 @@ try:
|
|||||||
from bin import tools
|
from bin import tools
|
||||||
from bin import client
|
from bin import client
|
||||||
from bin import server
|
from bin import server
|
||||||
|
from bin import configs
|
||||||
except (ModuleNotFoundError, ImportError, ImportWarning):
|
except (ModuleNotFoundError, ImportError, ImportWarning):
|
||||||
import tools
|
import tools
|
||||||
import client
|
import client
|
||||||
import server
|
import server
|
||||||
|
import configs
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# basic config
|
# basic config
|
||||||
self.start_time = time.strftime("%Y-%m-%d %H-%M-%S", time.gmtime(time.time()))
|
self.start_time = time.strftime(
|
||||||
|
"%Y-%m-%d %H-%M-%S", time.gmtime(time.time()))
|
||||||
self.configs = ''
|
self.configs = ''
|
||||||
# share memory
|
# share memory
|
||||||
self.dicts = share().dict()
|
self.dicts = share().dict()
|
||||||
self.lists = share().list()
|
self.lists = share().list()
|
||||||
# logger
|
# logger
|
||||||
|
# log config
|
||||||
|
self.log_config = tools.configs('configs/logging.json5')
|
||||||
|
self.log_file_config = self.log_config['file']
|
||||||
|
self.log_file_handler = logging.FileHandler(configs.name_handler(
|
||||||
|
self.log_file_config['filename']['main'], self.log_file_config['filename']['formats']))
|
||||||
|
# logger
|
||||||
|
# all logger
|
||||||
|
# client logger
|
||||||
|
self.client_log_config = self.log_config['client']
|
||||||
self.client_logger = logging.getLogger('client')
|
self.client_logger = logging.getLogger('client')
|
||||||
|
self.client_fmt = logging.Formatter(
|
||||||
|
fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s",
|
||||||
|
datefmt=self.client_log_config['date_fmt'])
|
||||||
self.client_stream_handler = logging.StreamHandler()
|
self.client_stream_handler = logging.StreamHandler()
|
||||||
|
self.client_stream_handler.setLevel(self.client_log_config['level'])
|
||||||
|
self.client_stream_handler.setFormatter(self.client_fmt)
|
||||||
|
self.client_logger.addHandler(self.client_stream_handler)
|
||||||
|
# server logger
|
||||||
|
self.server_log_config = self.log_config['server']
|
||||||
self.server_logger = logging.getLogger('server')
|
self.server_logger = logging.getLogger('server')
|
||||||
|
self.server_fmt = logging.Formatter(
|
||||||
|
fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s",
|
||||||
|
datefmt=self.server_log_config['date_fmt'])
|
||||||
self.server_stream_handler = logging.StreamHandler()
|
self.server_stream_handler = logging.StreamHandler()
|
||||||
self.log_file_handler = logging.FileHandler('')
|
self.server_stream_handler.setLevel(self.server_log_config['level'])
|
||||||
self.log_formatter = logging.Formatter("[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s")
|
self.server_stream_handler.setFormatter(self.server_fmt)
|
||||||
|
self.server_logger.addHandler(self.server_stream_handler)
|
||||||
|
# file logger
|
||||||
|
self.log_formatter = logging.Formatter(
|
||||||
|
fmt="[%(asctime)s][%(name)s]:[%(levelname)s] %(message)s",
|
||||||
|
datefmt=self.log_config['date_fmt'])
|
||||||
# client and server
|
# client and server
|
||||||
self.client = client.RenderThread(self.client_logger, self.dicts, self.lists, net_mode='local')
|
self.client = client.RenderThread(
|
||||||
self.server = server.server(self.lists, self.dicts, self.server_logger, net_mode='local')
|
self.client_logger, self.dicts, self.lists, net_mode='local')
|
||||||
|
self.server = server.server(
|
||||||
|
self.lists, self.dicts, self.server_logger, net_mode='local')
|
||||||
|
|
||||||
# start
|
# start
|
||||||
self.client.startGame()
|
self.client.startGame()
|
||||||
|
26
bin/tools.py
26
bin/tools.py
@ -6,6 +6,7 @@ mail: 3695888@qq.com
|
|||||||
import json5
|
import json5
|
||||||
import decimal
|
import decimal
|
||||||
import logging
|
import logging
|
||||||
|
from xml.dom.minidom import parse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import configs
|
import configs
|
||||||
@ -81,7 +82,7 @@ def D_C(listA: list, listB: list) -> '1': # stand for Duplicate check
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def S_C_float_check(SC) -> None: # stand for Scientific notation's float check
|
def S_C_float_check(SC): # stand for Scientific notation's float check
|
||||||
"""
|
"""
|
||||||
formats:
|
formats:
|
||||||
SC list format:docs.basic_config.json:basic_number"""
|
SC list format:docs.basic_config.json:basic_number"""
|
||||||
@ -151,7 +152,7 @@ def G_C(M, m, R, G): # stand for gravity calculation
|
|||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
def distance(A, B) -> float:
|
def distance(A, B):
|
||||||
"""
|
"""
|
||||||
formats:
|
formats:
|
||||||
A & B format: docs.basic_config:basic_poi
|
A & B format: docs.basic_config:basic_poi
|
||||||
@ -171,20 +172,31 @@ def distance(A, B) -> float:
|
|||||||
return poi_dis[2]
|
return poi_dis[2]
|
||||||
|
|
||||||
|
|
||||||
"""
|
# loads
|
||||||
loads
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def config(file_name, stack=None):
|
def config(file_name, stack=None):
|
||||||
# rd = {} # rd -> return data
|
type = file_name[file_name.rfind('.') + 1:] # 从最后一次.到末尾(截取文件格式)
|
||||||
|
if (type == 'json5') or (type == 'json'):
|
||||||
try:
|
try:
|
||||||
with open(file_name, "r") as jf: # jf -> json file
|
with open(file_name, "r") as jf: # jf -> json file
|
||||||
rd = json5.load(jf)
|
rd = json5.load(jf)
|
||||||
except FileNotFoundError as exp:
|
except FileNotFoundError as exp:
|
||||||
log = "no config file \n file name : %s \n stack : %s" % (file_name, stack)
|
log = "no config json(5) file \n file name : %s \n stack : %s" % (file_name, stack)
|
||||||
tools_logger.exception(log)
|
tools_logger.exception(log)
|
||||||
raise FileNotFoundError(log)
|
raise FileNotFoundError(log)
|
||||||
if stack is not None:
|
if stack is not None:
|
||||||
rd = rd[stack]
|
rd = rd[stack]
|
||||||
return rd
|
return rd
|
||||||
|
elif type == 'xml':
|
||||||
|
try:
|
||||||
|
xml_load = parse(file_name)
|
||||||
|
except FileNotFoundError as exp:
|
||||||
|
log = "no config json(5) file \n file name : %s \n stack : %s" % (file_name, stack)
|
||||||
|
tools_logger.exception(log)
|
||||||
|
raise FileNotFoundError(log)
|
||||||
|
if stack is not None:
|
||||||
|
xml_get = xml_load.getElementsByTagName(stack)
|
||||||
|
return xml_get
|
||||||
|
else:
|
||||||
|
return xml_load
|
||||||
|
8
bin/unpack_textures.py
Normal file
8
bin/unpack_textures.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
"""
|
||||||
|
writen by shenjackyuanjie
|
||||||
|
mail: 3695888@qq.com
|
||||||
|
"""
|
||||||
|
|
||||||
|
from xml.dom.minidom import parse
|
||||||
|
|
||||||
|
|
@ -2,24 +2,30 @@
|
|||||||
'server': {
|
'server': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
// option: CRITICAL ERROR WARNING INFO DEBUG
|
// option: CRITICAL ERROR WARNING INFO DEBUG
|
||||||
'date_fmt': '%Y-%m-%d %H-%M-%S'
|
'fmt': '',
|
||||||
|
// format
|
||||||
|
'date_fmt': '%Y-%m-%d %H-%M-%S',
|
||||||
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
||||||
},
|
},
|
||||||
'client': {
|
'client': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
// option: CRITICAL ERROR WARNING INFO DEBUG
|
// option: CRITICAL ERROR WARNING INFO DEBUG
|
||||||
'date_fmt': '%Y-%m-%d %H-%M-%S'
|
'date_fmt': '%Y-%m-%d %H-%M-%S',
|
||||||
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
||||||
},
|
},
|
||||||
'file': {
|
'file': {
|
||||||
'level': 'DEBUG',
|
'level': 'DEBUG',
|
||||||
// option: CRITICAL ERROR WARNING INFO DEBUG
|
// option: CRITICAL ERROR WARNING INFO DEBUG
|
||||||
|
'date_fmt': '%Y-%m-%d %H-%M-%S',
|
||||||
|
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
||||||
'filename': {
|
'filename': {
|
||||||
'main': '{date} SR.log',
|
'main': '{date} SR.log',
|
||||||
// {date} -> date
|
// {date} -> date
|
||||||
'{date}': '%Y-%m-%d %H-%M-%S'
|
'formats': {
|
||||||
|
'{date}': '%Y-%m-%d %H-%M-%S',
|
||||||
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
// format at https://docs.python.org/zh-cn/3.8/library/time.html#time.strftime
|
||||||
// can and more {xx} by adding more obj EZ
|
// can and more {xx} by adding more obj EZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user