chore.更新Python接口及demo

This commit is contained in:
MistEO
2022-01-03 22:40:23 +08:00
parent 0c2f2b7d9d
commit 075a678cb5
3 changed files with 92 additions and 60 deletions

42
src/Python/sample.py Normal file
View File

@@ -0,0 +1,42 @@
import json
import pathlib
import platform
from interface import Asst, Message
if __name__ == "__main__":
@Asst.CallBackType
def my_callback(msg, details, arg):
m = Message(msg)
if platform.system().lower() == 'windows':
d = json.loads(details.decode('gbk'))
else:
d = json.loads(details.decode('utf-8'))
print(m, d, arg)
if platform.system().lower() == 'windows':
dirname: str = (pathlib.Path.cwd().parent.parent / 'x64' / 'Release').__str__()
else:
dirname: str = (pathlib.Path.cwd().parent.parent / 'build').__str__()
asst = Asst(dirname=dirname, callback=my_callback)
print('version', asst.get_version())
if asst.catch_custom('127.0.0.1:7555'):
print('连接成功')
else:
print('连接失败')
exit()
asst.append_fight("CE-5", 0, 0, 1)
# asst.append_infrast(1, [ "Mfg", "Trade", "Control", "Power", "Reception", "Office", "Dorm"], "Money", 0.3)
# asst.append_award()
asst.start()
# asst.start_recurit_clac([4, 5, 6], True)
while True:
input('>')