some update?

This commit is contained in:
沈瑗杰 2021-05-24 05:58:16 +08:00
parent c1b5ca5a63
commit c34d09b97c
9 changed files with 49 additions and 67 deletions

4
.gitignore vendored
View File

@ -139,6 +139,4 @@ dmypy.json
.gitattributes
# some other thing
page1.jpg
page2.jpg
superman.py
other things/

View File

@ -63,6 +63,7 @@ class Game:
self.main_logger = logging.getLogger().getChild('main')
self.server_logger = logging.getLogger().getChild('server')
self.client_logger = logging.getLogger().getChild('client')
# output info
self.main_logger.info(self.lang['logger.created'])
self.main_logger.info(self.lang['logger.main_done'])
self.log_configs()
@ -85,8 +86,8 @@ class Game:
self.main_logger.info('%s %s' % (self.lang['version.now_on'], self.on_python_v))
if self.on_python_v_info[0] == 2:
self.main_logger.critical('%s' % self.lang['version.need3+'])
raise Exception('%s' % self.lang['version.need3+'])
elif self.on_python_v_info[1] <= 8:
raise SystemError('%s' % self.lang['version.need3+'])
elif self.on_python_v_info[1] < 9:
warning = configs.name_handler(self.lang['version.best3.8+'])
self.main_logger.warning(warning)

View File

@ -3,6 +3,7 @@ writen by shenjackyuanjie
mail: 3695888@qq.com
"""
import configparser
import decimal
import logging
import math
@ -19,7 +20,7 @@ except ModuleNotFoundError:
from bin import configs
# logger
tools_logger = logging.getLogger('tools')
tools_logger = logging.getLogger('part-tools')
"""
some tools
@ -215,12 +216,17 @@ def distance(A, B):
# loads
def config(file_name, stack=None): # // TODO 加上.config的读取+解析
type = file_name[file_name.rfind('.') + 1:] # 从最后一个.到末尾 (截取文件格式)
if (type == 'json5') or (type == 'json'):
def config(file_name, stack=None): # // TODO 加上.config的读取+解析
f_type = file_name[file_name.rfind('.') + 1:] # 从最后一个.到末尾 (截取文件格式)
if (f_type == 'json5') or (f_type == 'json'):
try:
with open(file_name, 'r', encoding='utf-8') as jf: # jf -> json file
rd = json5.load(jf)
try:
with open(file_name, 'r', encoding='utf-8') as jf: # jf -> json file
rd = json5.load(jf)
except UnicodeDecodeError:
with open(file_name, 'r', encoding='gbk') as jf:
rd = json5.load(jf)
tools_logger.info('文件 %s 解码错误已重新使用gbk编码打开' % file_name)
except FileNotFoundError as exp:
log = 'no config json(5) file \n file name : %s \n stack : %s' % (
file_name, stack)
@ -229,7 +235,7 @@ def config(file_name, stack=None): # // TODO 加上.config的读取+解析
if stack is not None:
rd = rd[stack]
return rd
elif type == 'xml':
elif f_type == 'xml':
try:
xml_load = parse(file_name)
except FileNotFoundError as exp:
@ -242,9 +248,17 @@ def config(file_name, stack=None): # // TODO 加上.config的读取+解析
return xml_get
else:
return xml_load
elif (f_type == 'config') or (f_type == 'conf'):
cp = configparser.ConfigParser() # cp -> config parser
cf = cp.read(file_name) # cf -> config file
def get_At(name, in_xml, need_type=str):
"""
get Attribute from a XML tree
will raise TypeError if input is not str or list
XML no! Json5 yes!
"""
name_type = type(name)
if name_type == list:
At_list = []

BIN
page1.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 966 KiB

BIN
page2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 960 KiB

View File

@ -1,55 +0,0 @@
import logging
tick_time, velocity, height, add_speed = 0, 0, 0, 0
m = 4610025
gravity = 9.798
R = 637100
n = 0.5943466
H = 70000
F = 208201000
TPS = 10
MSPT = 1 / TPS
logging.basicConfig(filename='logs/super.log',
filemode='w',
level=logging.DEBUG)
while True: # 主tick循环
logging.info([tick_time, velocity, height, add_speed])
# 基础加速度运算
add_speed = (F / m) - ((gravity * (R ** 2)) / ((R + height) ** 2))
# 出大气层判定
if height < 70000: # 没出大气 加速度需要减去大气阻力
add_speed -= ((n * (velocity ** 2) * (10 ** (-6 * height) / H)) / m)
height += (MSPT * velocity) # 高度 加 速度除以TPStick per second每tick加速
velocity += (MSPT * add_speed) # 速度 加 加速度除以TPS
if tick_time < 192: # 一些我也不知道是什么意思的tick判定
m -= ((MSPT * F) / 3399.2) # 3399.2是个啥?
elif tick_time < 240:
m -= (129 * MSPT) # ??? 129?
else:
m -= (4 * MSPT) # 4?
# tick 加时间
tick_time += MSPT
if tick_time < 48: # 如果时间没到48秒
continue
elif tick_time == 48: # 如果时间到了48秒
m = 1243700
F = 44189600
elif tick_time == 96:
m = 193125
F = 8498000
elif tick_time == 144:
m = 40875
F = 1699600
elif tick_time == 192:
m = 10225
F = 446145
elif tick_time == 240:
m = 2308
F = 21245
elif tick_time >= 567:
tick_time += ((12308300 - height) / velocity)
break
print('t: %s' % tick_time)

8
tests/test_config.config Normal file
View File

@ -0,0 +1,8 @@
[test]
test = abc
test2 = 1
test_dic = {'rua!': 1}
[test2]
test = abc
test2 = 1
test_dic = {'rua!': 1}

16
tests/test_config_file.py Normal file
View File

@ -0,0 +1,16 @@
import configparser
configs = configparser.ConfigParser()
configs.read('test_config.config')
print(configs.sections())
for c in configs.sections():
for con in configs[c]:
name = configs[c][con]
print(c, con, name)
conf = configparser.ConfigParser()
conf.read('test_config.config')
print(type(conf))
print(conf[:])