Browse Source

feat(PyAPI): 🚧 complete the structure of PyAPI, finish communication module

tags/0.1.0
DragonAura 2 years ago
parent
commit
46c5cd702c
25 changed files with 2704 additions and 2 deletions
  1. +1
    -0
      .gitignore
  2. +2
    -2
      CAPI/API/src/Communication.cpp
  3. +2
    -0
      CAPI/API/src/logic.cpp
  4. +1
    -0
      PyAPI/.gitattributes
  5. +27
    -0
      PyAPI/API/AI.py
  6. +237
    -0
      PyAPI/API/API.py
  7. +211
    -0
      PyAPI/API/Communication.py
  8. +240
    -0
      PyAPI/API/DebugAPI.py
  9. +302
    -0
      PyAPI/API/Interface.py
  10. +16
    -0
      PyAPI/API/State.py
  11. +164
    -0
      PyAPI/API/logic.py
  12. +26
    -0
      PyAPI/API/main.py
  13. +105
    -0
      PyAPI/API/structures.py
  14. +225
    -0
      PyAPI/API/utils.py
  15. +32
    -0
      PyAPI/README.md
  16. +44
    -0
      PyAPI/proto/Message2Clients_pb2.py
  17. +186
    -0
      PyAPI/proto/Message2Clients_pb2.pyi
  18. +35
    -0
      PyAPI/proto/Message2Server_pb2.py
  19. +72
    -0
      PyAPI/proto/Message2Server_pb2.pyi
  20. +42
    -0
      PyAPI/proto/MessageType_pb2.py
  21. +93
    -0
      PyAPI/proto/MessageType_pb2.pyi
  22. +25
    -0
      PyAPI/proto/Services_pb2.py
  23. +6
    -0
      PyAPI/proto/Services_pb2.pyi
  24. +603
    -0
      PyAPI/proto/Services_pb2_grpc.py
  25. +7
    -0
      dependency/proto/py_output.sh

+ 1
- 0
.gitignore View File

@@ -2,3 +2,4 @@
.vs/ .vs/
.vscode/ .vscode/
CAPI/build CAPI/build
PyAPI/test

+ 2
- 2
CAPI/API/src/Communication.cpp View File

@@ -219,7 +219,7 @@ bool Communication::HaveMessage()


void Communication::ReadMessage(int64_t playerID) void Communication::ReadMessage(int64_t playerID)
{ {
auto tRead = [&]()
auto tRead = [=]()
{ {
auto request = THUAI62Proto::THUAI62ProtobufID(playerID); auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
ClientContext context; ClientContext context;
@@ -235,7 +235,7 @@ void Communication::ReadMessage(int64_t playerID)


void Communication::AddPlayer(int64_t playerID, THUAI6::PlayerType playerType, THUAI6::HumanType humanType, THUAI6::ButcherType butcherType) void Communication::AddPlayer(int64_t playerID, THUAI6::PlayerType playerType, THUAI6::HumanType humanType, THUAI6::ButcherType butcherType)
{ {
auto tMessage = [&]()
auto tMessage = [=]()
{ {
protobuf::PlayerMsg playerMsg = THUAI62Proto::THUAI62ProtobufPlayer(playerID, playerType, humanType, butcherType); protobuf::PlayerMsg playerMsg = THUAI62Proto::THUAI62ProtobufPlayer(playerID, playerType, humanType, butcherType);
grpc::ClientContext context; grpc::ClientContext context;


+ 2
- 0
CAPI/API/src/logic.cpp View File

@@ -184,6 +184,7 @@ void Logic::ProcessMessage()
logger->info("Message thread start!"); logger->info("Message thread start!");
pComm->AddPlayer(playerID, playerType, humanType, butcherType); pComm->AddPlayer(playerID, playerType, humanType, butcherType);
logger->info("Join the player!"); logger->info("Join the player!");
pComm->ReadMessage(playerID);
while (gameState != THUAI6::GameState::GameEnd) while (gameState != THUAI6::GameState::GameEnd)
{ {
if (pComm->HaveMessage2Client()) if (pComm->HaveMessage2Client())
@@ -523,6 +524,7 @@ void Logic::Main(CreateAIFunc createAI, std::string IP, std::string port, bool f
} }
else else
{ {
AILoop = false;
logger->error("Connect to the server failed, AI thread will not be started."); logger->error("Connect to the server failed, AI thread will not be started.");
return; return;
} }


+ 1
- 0
PyAPI/.gitattributes View File

@@ -0,0 +1 @@
proto/** linguist-generated

+ 27
- 0
PyAPI/API/AI.py View File

@@ -0,0 +1,27 @@
from abc import abstractmethod
from typing import Union
from Interface import IHumanAPI, IButcherAPI, IAI
import structures as THUAI6


class Setting:
# 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新
def asynchronous() -> bool:
return False

# 选手必须修改该函数的返回值来选择自己的阵营
def playerType() -> THUAI6.PlayerType:
return THUAI6.PlayerType.HumanPlayer

# 选手需要将两个都定义,本份代码中不选择的阵营任意定义即可
def humanType() -> THUAI6.HumanType:
return THUAI6.HumanType.HumanType1

def butcherType() -> THUAI6.ButcherType:
return THUAI6.ButcherType.ButcherType1


class AI(IAI):
def play(self, api: Union[IHumanAPI, IButcherAPI]) -> None:
# 选手在这里实现自己的逻辑,要求和上面选择的阵营保持一致,否则会发生错误
return

+ 237
- 0
PyAPI/API/API.py View File

@@ -0,0 +1,237 @@
from Interface import ILogic, IHumanAPI, IButcherAPI, IGameTimer, IAI
from typing import List, Union
import structures as THUAI6


class HumanAPI(IHumanAPI, IGameTimer):

# 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴

def __init__(self, logic: ILogic):
self.__logic = logic

def Move(self, timeInMilliseconds: int, angle: float) -> bool:
pass

# 向特定方向移动

def MoveRight(self, timeInMilliseconds: int) -> bool:
pass

def MoveLeft(self, timeInMilliseconds: int) -> bool:
pass

def MoveUp(self, timeInMilliseconds: int) -> bool:
pass

def MoveDown(self, timeInMilliseconds: int) -> bool:
pass

# 道具和技能相关

def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

def UseProp(self) -> bool:
pass

def UseSkill(self) -> bool:
pass

# 消息相关,接收消息时无消息则返回(-1, '')

def SendMessage(self, toID: int, message: str) -> bool:
pass

def HaveMessage(self) -> bool:
pass

def GetMessage(self) -> tuple[int, str]:
pass

# 等待下一帧

def Wait(self) -> bool:
pass

# 获取各类游戏中的消息

def GetFrameCount(self) -> int:
pass

def GetPlayerGUIDs(self) -> List[int]:
pass

def GetButchers(self) -> List[THUAI6.Butcher]:
pass

def GetHumans(self) -> List[THUAI6.Human]:
pass

def GetProps(self) -> List[THUAI6.Prop]:
pass

def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
pass

# 用于DEBUG的输出函数,仅在DEBUG模式下有效

def PrintHuman(self) -> None:
pass

def PrintButcher(self) -> None:
pass

def PrintProp(self) -> None:
pass

def PrintSelfInfo(self) -> None:
pass

# 人类阵营的特殊函数

def Escape(self) -> bool:
pass

def StartFixMachine(self) -> bool:
pass

def EndFixMachine(self) -> bool:
pass

def StartSaveHuman(self) -> bool:
pass

def EndSaveHuman(self) -> bool:
pass

# Timer用

def StartTimer(self) -> None:
pass

def EndTimer(self) -> None:
pass

def Play(self, ai: IAI) -> None:
pass


class ButcherAPI(IButcherAPI, IGameTimer):

# 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴

def Move(self, timeInMilliseconds: int, angle: float) -> bool:
pass

# 向特定方向移动

def MoveRight(self, timeInMilliseconds: int) -> bool:
pass

def MoveLeft(self, timeInMilliseconds: int) -> bool:
pass

def MoveUp(self, timeInMilliseconds: int) -> bool:
pass

def MoveDown(self, timeInMilliseconds: int) -> bool:
pass

# 道具和技能相关

def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

def UseProp(self) -> bool:
pass

def UseSkill(self) -> bool:
pass

# 消息相关,接收消息时无消息则返回(-1, '')

def SendMessage(self, toID: int, message: str) -> bool:
pass

def HaveMessage(self) -> bool:
pass

def GetMessage(self) -> tuple[int, str]:
pass

# 等待下一帧

def Wait(self) -> bool:
pass

# 获取各类游戏中的消息

def GetFrameCount(self) -> int:
pass

def GetPlayerGUIDs(self) -> List[int]:
pass

def GetButchers(self) -> List[THUAI6.Butcher]:
pass

def GetHumans(self) -> List[THUAI6.Human]:
pass

def GetProps(self) -> List[THUAI6.Prop]:
pass

def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
pass

# 用于DEBUG的输出函数,仅在DEBUG模式下有效

def PrintHuman(self) -> None:
pass

def PrintButcher(self) -> None:
pass

def PrintProp(self) -> None:
pass

def PrintSelfInfo(self) -> None:
pass

# 屠夫阵营的特殊函数

def Attack(self, angle: float) -> bool:
pass

def CarryHuman(self) -> bool:
pass

def ReleaseHuman(self) -> bool:
pass

def HangHuman(self) -> bool:
pass

# Timer用

def StartTimer(self) -> None:
pass

def EndTimer(self) -> None:
pass

def Play(self, ai: IAI) -> None:
pass

+ 211
- 0
PyAPI/API/Communication.py View File

@@ -0,0 +1,211 @@
from queue import Queue
import grpc
import threading
import proto.Message2Clients_pb2 as Message2Clients
import proto.Message2Server_pb2 as Message2Server
import proto.MessageType_pb2 as MessageType
import proto.Services_pb2_grpc as Services
from logic import Logic
from Interface import IErrorHandler
from utils import THUAI62Proto
import structures as THUAI6


# 使用gRPC的异步来减少通信对于选手而言损失的时间,而gRPC的return值有result()方法,故若连接错误时也应当返回一个具有result()方法的对象,使用此处的ErrorHandler类来实现
class BoolErrorHandler(IErrorHandler):
@staticmethod
def result():
return False


class Communication:

__THUAI6Stub: Services.AvailableServiceStub
__haveNewMessage: bool
__message2Client: Message2Clients.MessageToClient
__messageQueue: Queue # Python的Queue是线程安全的,故无须自己实现Queue

def __init__(self, sIP: str, sPort: str):
aim = sIP + ':' + sPort
channel = grpc.insecure_channel(aim)
self.__THUAI6Stub = Services.AvailableServiceStub(channel)
self.__haveNewMessage = False
self.__messageQueue = Queue()

def Move(self, time: int, angle: float, playerID: int) -> bool:
try:
moveResult = self.__THUAI6Stub.Move(
THUAI62Proto.THUAI62ProtobufMove(time, angle, playerID))
except grpc.RpcError as e:
return False
else:
return moveResult.act_success

def PickProp(self, propType: THUAI6.PropType, playerID: int) -> bool:
try:
pickResult = self.__THUAI6Stub.PickProp(
THUAI62Proto.THUAI62ProtobufPick(propType, playerID))
except grpc.RpcError as e:
return False
else:
return pickResult.act_success

def UseProp(self, playerID: int):
try:
useResult = self.__THUAI6Stub.UseProp(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return useResult.act_success

def UseSkill(self, playerID: int) -> bool:
try:
useResult = self.__THUAI6Stub.UseSkill(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return useResult.act_success

def SendMessage(self, toID: int, message: str, playerID: int) -> bool:
try:
sendResult = self.__THUAI6Stub.SendMessage(
THUAI62Proto.THUAI62ProtobufSend(message, toID, playerID))
except grpc.RpcError as e:
return False
else:
return sendResult.act_success

def HaveMessage(self) -> bool:
return not self.__messageQueue.empty()

def GetMessage(self) -> tuple[int, str]:
try:
message = self.__messageQueue.get_nowait()
except Exception as e:
return -1, ''
else:
return message

def ReadMessage(self, playerID: int) -> None:
def tRead():
try:
for msg in self.__THUAI6Stub.GetMessage(
THUAI62Proto.THUAI62ProtobufID(playerID)):
self.__messageQueue.put(
(msg.from_player_id, msg.message_received))
except grpc.RpcError as e:
return

threading.Thread(target=tRead).start()

def Escape(self, playerID: int) -> bool:
try:
escapeResult = self.__THUAI6Stub.Escape(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return escapeResult.act_success

def StartFixMachine(self, playerID: int) -> bool:
try:
fixResult = self.__THUAI6Stub.StartFixMachine(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return fixResult.act_success

def EndFixMachine(self, playerID: int) -> bool:
try:
fixResult = self.__THUAI6Stub.EndFixMachine(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return fixResult.act_success

def StartSaveHuman(self, playerID: int) -> bool:
try:
saveResult = self.__THUAI6Stub.StartSaveHuman(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return saveResult.act_success

def EndSaveHuman(self, playerID: int) -> bool:
try:
saveResult = self.__THUAI6Stub.EndSaveHuman(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return saveResult.act_success

def Attack(self, angle: float, playerID: int) -> bool:
try:
attackResult = self.__THUAI6Stub.Attack(
THUAI62Proto.THUAI62ProtobufAttack(angle, playerID))
except grpc.RpcError as e:
return False
else:
return attackResult.act_success

def CarryHuman(self, playerID: int) -> bool:
try:
carryResult = self.__THUAI6Stub.CarryHuman(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return carryResult.act_success

def ReleaseHuman(self, playerID: int) -> bool:
try:
releaseResult = self.__THUAI6Stub.ReleaseHuman(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return releaseResult.act_success

def HangHuman(self, playerID: int) -> bool:
try:
hangResult = self.__THUAI6Stub.HangHuman(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return hangResult.act_success

def TryConnection(self, playerID: int) -> bool:
try:
connectResult = self.__THUAI6Stub.TryConnection(
THUAI62Proto.THUAI62ProtobufID(playerID))
except grpc.RpcError as e:
return False
else:
return True

def HaveMessage2Client(self) -> bool:
return self.__haveNewMessage

def GetMessage2Client(self) -> Message2Clients.MessageToClient:
self.__haveNewMessage = False
return self.__message2Client

def AddPlayer(self, playerID: int, playerType: THUAI6.PlayerType, humanType: THUAI6.HumanType, butcherType: THUAI6.ButcherType) -> None:
def tMessage():
try:
playerMsg = THUAI62Proto.THUAI62ProtobufPlayer(
playerID, playerType, humanType, butcherType)
for msg in self.__THUAI6Stub.AddPlayer(playerMsg):
self.__haveNewMessage = True
self.__message2Client = msg
except grpc.RpcError as e:
return

threading.Thread(target=tMessage).start()

+ 240
- 0
PyAPI/API/DebugAPI.py View File

@@ -0,0 +1,240 @@
from Interface import IHumanAPI, IButcherAPI, IGameTimer, IAI
from logic import ILogic

from Interface import ILogic, IHumanAPI, IButcherAPI, IGameTimer
from typing import List, Union
import structures as THUAI6


class HumanDebugAPI(IHumanAPI, IGameTimer):

# 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴

def __init__(self, logic: ILogic):
self.__logic = logic

def Move(self, timeInMilliseconds: int, angle: float) -> bool:
pass

# 向特定方向移动

def MoveRight(self, timeInMilliseconds: int) -> bool:
pass

def MoveLeft(self, timeInMilliseconds: int) -> bool:
pass

def MoveUp(self, timeInMilliseconds: int) -> bool:
pass

def MoveDown(self, timeInMilliseconds: int) -> bool:
pass

# 道具和技能相关

def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

def UseProp(self) -> bool:
pass

def UseSkill(self) -> bool:
pass

# 消息相关,接收消息时无消息则返回(-1, '')

def SendMessage(self, toID: int, message: str) -> bool:
pass

def HaveMessage(self) -> bool:
pass

def GetMessage(self) -> tuple[int, str]:
pass

# 等待下一帧

def Wait(self) -> bool:
pass

# 获取各类游戏中的消息

def GetFrameCount(self) -> int:
pass

def GetPlayerGUIDs(self) -> List[int]:
pass

def GetButchers(self) -> List[THUAI6.Butcher]:
pass

def GetHumans(self) -> List[THUAI6.Human]:
pass

def GetProps(self) -> List[THUAI6.Prop]:
pass

def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
pass

# 用于DEBUG的输出函数,仅在DEBUG模式下有效

def PrintHuman(self) -> None:
pass

def PrintButcher(self) -> None:
pass

def PrintProp(self) -> None:
pass

def PrintSelfInfo(self) -> None:
pass

# 人类阵营的特殊函数

def Escape(self) -> bool:
pass

def StartFixMachine(self) -> bool:
pass

def EndFixMachine(self) -> bool:
pass

def StartSaveHuman(self) -> bool:
pass

def EndSaveHuman(self) -> bool:
pass

# Timer用

def StartTimer(self) -> None:
pass

def EndTimer(self) -> None:
pass

def Play(self, ai: IAI) -> None:
pass


class ButcherDebugAPI(IButcherAPI, IGameTimer):

# 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴

def Move(self, timeInMilliseconds: int, angle: float) -> bool:
pass

# 向特定方向移动

def MoveRight(self, timeInMilliseconds: int) -> bool:
pass

def MoveLeft(self, timeInMilliseconds: int) -> bool:
pass

def MoveUp(self, timeInMilliseconds: int) -> bool:
pass

def MoveDown(self, timeInMilliseconds: int) -> bool:
pass

# 道具和技能相关

def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

def UseProp(self) -> bool:
pass

def UseSkill(self) -> bool:
pass

# 消息相关,接收消息时无消息则返回(-1, '')

def SendMessage(self, toID: int, message: str) -> bool:
pass

def HaveMessage(self) -> bool:
pass

def GetMessage(self) -> tuple[int, str]:
pass

# 等待下一帧

def Wait(self) -> bool:
pass

# 获取各类游戏中的消息

def GetFrameCount(self) -> int:
pass

def GetPlayerGUIDs(self) -> List[int]:
pass

def GetButchers(self) -> List[THUAI6.Butcher]:
pass

def GetHumans(self) -> List[THUAI6.Human]:
pass

def GetProps(self) -> List[THUAI6.Prop]:
pass

def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
pass

# 用于DEBUG的输出函数,仅在DEBUG模式下有效

def PrintHuman(self) -> None:
pass

def PrintButcher(self) -> None:
pass

def PrintProp(self) -> None:
pass

def PrintSelfInfo(self) -> None:
pass

# 屠夫阵营的特殊函数

def Attack(self, angle: float) -> bool:
pass

def CarryHuman(self) -> bool:
pass

def ReleaseHuman(self) -> bool:
pass

def HangHuman(self) -> bool:
pass

# Timer用

def StartTimer(self) -> None:
pass

def EndTimer(self) -> None:
pass

def Play(self, ai: IAI) -> None:
pass

+ 302
- 0
PyAPI/API/Interface.py View File

@@ -0,0 +1,302 @@
from abc import abstractmethod, ABCMeta
from typing import List, Union
import structures as THUAI6


class ILogic(metaclass=ABCMeta):

# IAPI统一可用的接口

@abstractmethod
def GetButchers(self) -> List[THUAI6.Butcher]:
pass

@abstractmethod
def GetHumans(self) -> List[THUAI6.Human]:
pass

@abstractmethod
def GetProps(self) -> List[THUAI6.Prop]:
pass

@abstractmethod
def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

@abstractmethod
def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

@abstractmethod
def GetPlaceType(self, x: int, y: int) -> THUAI6.PlaceType:
pass

@abstractmethod
def Move(self, time: int, angle: float) -> bool:
pass

@abstractmethod
def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

@abstractmethod
def UseProp(self) -> bool:
pass

@abstractmethod
def UseSkill(self) -> bool:
pass

@abstractmethod
def SendMessage(self, toID: int, message: str) -> bool:
pass

@abstractmethod
def HaveMessage(self) -> bool:
pass

@abstractmethod
def GetMessage(self) -> tuple[int, str]:
pass

@abstractmethod
def WaitThread(self) -> bool:
pass

@abstractmethod
def GetCounter(self) -> int:
pass

@abstractmethod
def GetPlayerGUIDs(self) -> List[int]:
pass

# IHumanAPI使用的接口

@abstractmethod
def Escape(self) -> bool:
pass

@abstractmethod
def StartFixMachine(self) -> bool:
pass

@abstractmethod
def EndFixMachine(self) -> bool:
pass

@abstractmethod
def StartSaveHuman(self) -> bool:
pass

@abstractmethod
def EndSaveHuman(self) -> bool:
pass

# Butcher使用的接口

@abstractmethod
def Attack(self, angle: float) -> bool:
pass

@abstractmethod
def CarryHuman(self) -> bool:
pass

@abstractmethod
def ReleaseHuman(self) -> bool:
pass

@abstractmethod
def HangHuman(self) -> bool:
pass


class IAPI(metacls=ABCMeta):

# 选手可执行的操作
# 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴

@abstractmethod
def Move(self, timeInMilliseconds: int, angle: float) -> bool:
pass

# 向特定方向移动

@abstractmethod
def MoveRight(self, timeInMilliseconds: int) -> bool:
pass

@abstractmethod
def MoveLeft(self, timeInMilliseconds: int) -> bool:
pass

@abstractmethod
def MoveUp(self, timeInMilliseconds: int) -> bool:
pass

@abstractmethod
def MoveDown(self, timeInMilliseconds: int) -> bool:
pass

# 道具和技能相关

@abstractmethod
def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

@abstractmethod
def UseProp(self) -> bool:
pass

@abstractmethod
def UseSkill(self) -> bool:
pass

# 消息相关,接收消息时无消息则返回(-1, '')

@abstractmethod
def SendMessage(self, toID: int, message: str) -> bool:
pass

@abstractmethod
def HaveMessage(self) -> bool:
pass

@abstractmethod
def GetMessage(self) -> tuple[int, str]:
pass

# 等待下一帧

@abstractmethod
def Wait(self) -> bool:
pass

# 获取各类游戏中的消息

@abstractmethod
def GetFrameCount(self) -> int:
pass

@abstractmethod
def GetPlayerGUIDs(self) -> List[int]:
pass

@abstractmethod
def GetButchers(self) -> List[THUAI6.Butcher]:
pass

@abstractmethod
def GetHumans(self) -> List[THUAI6.Human]:
pass

@abstractmethod
def GetProps(self) -> List[THUAI6.Prop]:
pass

@abstractmethod
def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

@abstractmethod
def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

@abstractmethod
def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
pass

# 用于DEBUG的输出函数,仅在DEBUG模式下有效

@abstractmethod
def PrintHuman(self) -> None:
pass

@abstractmethod
def PrintButcher(self) -> None:
pass

@abstractmethod
def PrintProp(self) -> None:
pass

@abstractmethod
def PrintSelfInfo(self) -> None:
pass


class IHumanAPI(IAPI, metaclass=ABCMeta):

# 人类阵营的特殊函数

@abstractmethod
def Escape(self) -> bool:
pass

@abstractmethod
def StartFixMachine(self) -> bool:
pass

@abstractmethod
def EndFixMachine(self) -> bool:
pass

@abstractmethod
def StartSaveHuman(self) -> bool:
pass

@abstractmethod
def EndSaveHuman(self) -> bool:
pass


class IButcherAPI(IAPI, metaclass=ABCMeta):

# 屠夫阵营的特殊函数

@abstractmethod
def Attack(self, angle: float) -> bool:
pass

@abstractmethod
def CarryHuman(self) -> bool:
pass

@abstractmethod
def ReleaseHuman(self) -> bool:
pass

@abstractmethod
def HangHuman(self) -> bool:
pass


class IAI(metaclass=ABCMeta):
@abstractmethod
def play(self, api: Union[IHumanAPI, IButcherAPI]) -> None:
pass


class IGameTimer(metaclass=ABCMeta):

# 用于计时的接口

@abstractmethod
def StartTimer(self) -> None:
pass

@abstractmethod
def EndTimer(self) -> None:
pass

@abstractmethod
def Play(self, ai: IAI) -> None:
pass


class IErrorHandler(metaclass=ABCMeta):
@staticmethod
@abstractmethod
def result():
pass

+ 16
- 0
PyAPI/API/State.py View File

@@ -0,0 +1,16 @@
from typing import List, Union
import structures as THUAI6


class State:
teamScore: int
self: Union[THUAI6.Human, THUAI6.Butcher]

humans: List[THUAI6.Human]
butchers: List[THUAI6.Butcher]

props: List[THUAI6.Prop]

map: List[List[THUAI6.PlaceType]]

guids: List[int]

+ 164
- 0
PyAPI/API/logic.py View File

@@ -0,0 +1,164 @@
from abc import abstractmethod
from typing import List, Union, Callable
import threading

from Interface import ILogic, IGameTimer
from State import State
import structures as THUAI6
import proto.Message2Clients_pb2 as Message2Clients
import proto.Message2Server_pb2 as Message2Server
import proto.MessageType_pb2 as MessageType


class Logic(ILogic):
def __init__(self, playerType: THUAI6.PlayerType, playerID: int, humanType: THUAI6.HumanType, butcherType: THUAI6.ButcherType) -> None:

# 类型、ID
self.__playerType: THUAI6.PlayerType = playerType
self.__playerID: int = playerID
self.__humanType: THUAI6.HumanType = humanType
self.__butcherType: THUAI6.ButcherType = butcherType

# 存储状态
self.__currentState: State
self.__bufferState: State

# timer,用于实际运行AI
self.__timer: IGameTimer

# AI线程
self.__threadAI: threading.Thread

# 互斥锁
self.__mtxAI: threading.Lock
self.__mtxBuffer: threading.Lock
self.__mtxTimer: threading.Lock

# 条件变量
self.__cvBuffer: threading.Condition
self.__cvAI: threading.Condition

# 保存缓冲区数
self.__counterState: int
self.__counterBuffer: int

# 记录游戏状态
self.__gameState: THUAI6.GameState = THUAI6.GameState.NullGameState

# 是否应该执行player()
self.__AILoop: bool = True

# buffer是否更新完毕
self.__bufferUpdated: bool = False

# 是否应当启动AI
self.__AIStart: bool = False

# asynchronous为true时控制内容更新的变量
self.__freshed: bool = False

# IAPI统一可用的接口

def GetButchers(self) -> List[THUAI6.Butcher]:
pass

def GetHumans(self) -> List[THUAI6.Human]:
pass

def GetProps(self) -> List[THUAI6.Prop]:
pass

def GetSelfInfo(self) -> Union[THUAI6.Human, THUAI6.Butcher]:
pass

def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
pass

def GetPlaceType(self, x: int, y: int) -> THUAI6.PlaceType:
pass

def Move(self, time: int, angle: float) -> bool:
pass

def PickProp(self, propType: THUAI6.PropType) -> bool:
pass

def UseProp(self) -> bool:
pass

def UseSkill(self) -> bool:
pass

def SendMessage(self, toID: int, message: str) -> bool:
pass

def HaveMessage(self) -> bool:
pass

def GetMessage(self) -> tuple[int, str]:
pass

def WaitThread(self) -> bool:
pass

def GetCounter(self) -> int:
pass

def GetPlayerGUIDs(self) -> List[int]:
pass

# IHumanAPI使用的接口

def Escape(self) -> bool:
pass

def StartFixMachine(self) -> bool:
pass

def EndFixMachine(self) -> bool:
pass

def StartSaveHuman(self) -> bool:
pass

def EndSaveHuman(self) -> bool:
pass

# Butcher使用的接口

def Attack(self, angle: float) -> bool:
pass

def CarryHuman(self) -> bool:
pass

def ReleaseHuman(self) -> bool:
pass

def HangHuman(self) -> bool:
pass

# Logic内部逻辑
def __TryConnection(self) -> bool:
pass

def __ProcessMessage(self) -> None:
pass

def __LoadBuffer(self) -> None:
pass

def __UnBlockBuffer(self) -> None:
pass

def __UnBlockAI(self) -> None:
pass

def __Update(self) -> None:
pass

def __Wait(self) -> None:
pass

def Main(self, createAI: Callable, IP: str, port: str, file: bool, print: bool, warnOnly: bool) -> None:
pass

+ 26
- 0
PyAPI/API/main.py View File

@@ -0,0 +1,26 @@
import sys
from typing import List, Callable
from logic import Logic
from AI import AI, Setting
from Interface import IAI
import structures as THUAI6


def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None:
pID: int = 114514
sIP: str = "114.51.41.91"
sPort: str = "9810"
file: bool = False
print: bool = False
warnOnly: bool = False
logic = Logic(Setting.playerType(), pID,
Setting.humanType(), Setting.butcherType())
logic.Main(AIBuilder, sIP, sPort, file, print, warnOnly)


def CreateAI() -> IAI:
return AI()


if __name__ == '__main__':
THUAI6Main(sys.argv, CreateAI)

+ 105
- 0
PyAPI/API/structures.py View File

@@ -0,0 +1,105 @@
from enum import Enum
from typing import List


class GameState(Enum):
NullGameState = 0
GameStart = 1
GameRunning = 2
GameEnd = 3


class PlaceType(Enum):
NullPlaceType = 0
Land = 1
Wall = 2
Grass = 3
Machine = 4
Gate = 5
HiddenGate = 6


class ShapeType(Enum):
NullShapeType = 0
Square = 1
Circle = 2


class PlayerType(Enum):
NullPlayerType = 0
HumanPlayer = 1
ButcherPlayer = 2


class PropType(Enum):
NullPropType = 0
PropType1 = 1


class HumanType(Enum):
NullHumanType = 0
HumanType1 = 1


class ButcherType(Enum):
NullButcherType = 0
ButcherType1 = 1


class HumanBuffType(Enum):
NullHumanBuffType = 0
HumanBuffType1 = 1


class ButcherBuffType(Enum):
NullButcherBuffType = 0
ButcherBuffType1 = 1


class HumanState(Enum):
NullHumanState = 0
Idle = 1
Fixing = 2
Dying = 3
OnChair = 4
Dead = 5


class Player:
x: int
y: int
speed: int
viewRange: int
playerID: int
guid: int
radius: int
timeUntilSkillAvailable: float
playerType: PlayerType
prop: PropType
place: PlaceType


class Human(Player):
state: HumanState
life: int
hangedTime: int
humanType: HumanType
buff: List[HumanBuffType]


class Butcher(Player):
damage: int
movable: bool
butcherType: ButcherType
buff: List[ButcherBuffType]


class Prop:
x: int
y: int
size: int
guid: int
type: PropType
place: PlaceType
facingDirection: float
isMoving: bool

+ 225
- 0
PyAPI/API/utils.py View File

@@ -0,0 +1,225 @@
import structures as THUAI6
from typing import Final, List
import proto.Message2Clients_pb2 as Message2Clients
import proto.Message2Server_pb2 as Message2Server
import proto.MessageType_pb2 as MessageType

numOfGridPerCell: Final[int] = 1000


# 起到NameSpace的作用
class NoInstance:
def __call__(self, *args, **kwargs):
raise TypeError("This class cannot be instantiated.")


class AssistFunction(NoInstance):
# 辅助函数
@staticmethod
def CellToGrid(cell: int) -> int:
return cell*numOfGridPerCell+numOfGridPerCell//2

@staticmethod
def GridToCell(grid: int) -> int:
return grid//numOfGridPerCell


class Proto2THUAI6(NoInstance):
placeTypeDict: Final[dict] = {
MessageType.NULL_PLACE_TYPE: THUAI6.PlaceType.NullPlaceType,
MessageType.WALL: THUAI6.PlaceType.Wall,
MessageType.LAND: THUAI6.PlaceType.Land,
MessageType.GRASS: THUAI6.PlaceType.Grass,
MessageType.MACHINE: THUAI6.PlaceType.Machine,
MessageType.GATE: THUAI6.PlaceType.Gate,
MessageType.HIDDEN_GATE: THUAI6.PlaceType.HiddenGate}

shapeTypeDict: Final[dict] = {
MessageType.NULL_SHAPE_TYPE: THUAI6.ShapeType.NullShapeType,
MessageType.SQUARE: THUAI6.ShapeType.Square,
MessageType.CIRCLE: THUAI6.ShapeType.Circle}

propTypeDict: Final[dict] = {
MessageType.NULL_PROP_TYPE: THUAI6.PropType.NullPropType,
MessageType.PTYPE1: THUAI6.PropType.PropType1, }

playerTypeDict: Final[dict] = {
MessageType.NULL_PLAYER_TYPE: THUAI6.PlayerType.NullPlayerType,
MessageType.HUMAN_PLAYER: THUAI6.PlayerType.HumanPlayer,
MessageType.BUTCHER_PLAYER: THUAI6.PlayerType.ButcherPlayer}

humanTypeDict: Final[dict] = {
MessageType.NULL_HUMAN_TYPE: THUAI6.HumanType.NullHumanType,
MessageType.HUMANTYPE1: THUAI6.HumanType.HumanType1, }

butcherTypeDict: Final[dict] = {
MessageType.NULL_BUTCHER_TYPE: THUAI6.ButcherType.NullButcherType,
MessageType.BUTCHERTYPE1: THUAI6.ButcherType.ButcherType1, }

humanBuffTypeDict: Final[dict] = {
MessageType.NULL_HBUFF_TYPE: THUAI6.HumanBuffType.NullHumanBuffType,
MessageType.HBUFFTYPE1: THUAI6.HumanBuffType.HumanBuffType1, }

butcherBuffTypeDict: Final[dict] = {
MessageType.NULL_BBUFF_TYPE: THUAI6.ButcherBuffType.NullButcherBuffType,
MessageType.BBUFFTYPE1: THUAI6.ButcherBuffType.ButcherBuffType1, }

humanStateDict: Final[dict] = {
MessageType.NULL_STATUS: THUAI6.HumanState.NullHumanState,
MessageType.IDLE: THUAI6.HumanState.Idle,
MessageType.FIXING: THUAI6.HumanState.Fixing,
MessageType.DYING: THUAI6.HumanState.Dying,
MessageType.ON_CHAIR: THUAI6.HumanState.OnChair,
MessageType.DEAD: THUAI6.HumanState.Dead}

gameStateDict: Final[dict] = {
MessageType.NULL_GAME_STATE: THUAI6.GameState.NullGameState,
MessageType.GAME_START: THUAI6.GameState.GameStart,
MessageType.GAME_RUNNING: THUAI6.GameState.GameRunning,
MessageType.GAME_END: THUAI6.GameState.GameEnd}

# 用于将Proto的对象转为THUAI6的对象
@staticmethod
def Protobuf2THUAI6Butcher(butcherMsg: Message2Clients.MessageOfButcher) -> THUAI6.Butcher:
butcher = THUAI6.Butcher()
butcher.x = butcherMsg.x
butcher.y = butcherMsg.y
butcher.speed = butcherMsg.speed
butcher.damage = butcherMsg.damage
butcher.timeUntilSkillAvailable = butcherMsg.time_until_skill_available
butcher.place = Proto2THUAI6.placeTypeDict[butcherMsg.place]
butcher.prop = Proto2THUAI6.propTypeDict[butcherMsg.prop]
butcher.butcherType = Proto2THUAI6.butcherTypeDict[butcherMsg.butcher_type]
butcher.guid = butcherMsg.guid
butcher.movable = butcherMsg.movable
butcher.playerID = butcherMsg.player_id
butcher.viewRange = butcherMsg.view_range
butcher.radius = butcherMsg.radius
butcher.buff.clear()
for buff in butcherMsg.buff:
butcher.buff.append(Proto2THUAI6.butcherBuffTypeDict[buff])
return butcher

@staticmethod
def Protobuf2THUAI6Human(humanMsg: Message2Clients.MessageOfHuman) -> THUAI6.Human:
human = THUAI6.Human()
human.x = humanMsg.x
human.y = humanMsg.y
human.speed = humanMsg.speed
human.life = humanMsg.life
human.hangedTime = humanMsg.hanged_time
human.timeUntilSkillAvailable = humanMsg.time_until_skill_available
human.place = Proto2THUAI6.placeTypeDict[humanMsg.place]
human.prop = Proto2THUAI6.propTypeDict[humanMsg.prop]
human.humanType = Proto2THUAI6.humanTypeDict[humanMsg.human_type]
human.guid = humanMsg.guid
human.state = Proto2THUAI6.humanStateDict[humanMsg.state]
human.playerID = humanMsg.player_id
human.viewRange = humanMsg.view_range
human.radius = humanMsg.radius
human.buff.clear()
for buff in humanMsg.buff:
human.buff.append(Proto2THUAI6.humanBuffTypeDict[buff])
return human

@staticmethod
def Protobuf2THUAI6Prop(propMsg: Message2Clients.MessageOfProp) -> THUAI6.Prop:
prop = THUAI6.Prop()
prop.x = propMsg.x
prop.y = propMsg.y
prop.type = Proto2THUAI6.propTypeDict[propMsg.type]
prop.guid = propMsg.guid
prop.size = propMsg.size
prop.facingDirection = propMsg.facing_direction
prop.isMoving = propMsg.is_moving
return prop

@staticmethod
def Protobuf2THUAI6Map(mapMsg: Message2Clients.MessageOfMap) -> List[List[THUAI6.PlaceType]]:
map = []
for row in mapMsg.row:
newRow = []
for place in row.col:
newRow.append(Proto2THUAI6.placeTypeDict[place])
map.append(newRow)
return map


class THUAI62Proto(NoInstance):
placeTypeDict: Final[dict] = {
THUAI6.PlaceType.NullPlaceType: MessageType.NULL_PLACE_TYPE,
THUAI6.PlaceType.Wall: MessageType.WALL,
THUAI6.PlaceType.Land: MessageType.LAND,
THUAI6.PlaceType.Grass: MessageType.GRASS,
THUAI6.PlaceType.Machine: MessageType.MACHINE,
THUAI6.PlaceType.Gate: MessageType.GATE,
THUAI6.PlaceType.HiddenGate: MessageType.HIDDEN_GATE}

shapeTypeDict: Final[dict] = {
THUAI6.ShapeType.NullShapeType: MessageType.NULL_SHAPE_TYPE,
THUAI6.ShapeType.Square: MessageType.SQUARE,
THUAI6.ShapeType.Circle: MessageType.CIRCLE}

propTypeDict: Final[dict] = {
THUAI6.PropType.NullPropType: MessageType.NULL_PROP_TYPE,
THUAI6.PropType.PropType1: MessageType.PTYPE1, }

playerTypeDict: Final[dict] = {
THUAI6.PlayerType.NullPlayerType: MessageType.NULL_PLAYER_TYPE,
THUAI6.PlayerType.HumanPlayer: MessageType.HUMAN_PLAYER,
THUAI6.PlayerType.ButcherPlayer: MessageType.BUTCHER_PLAYER}

humanTypeDict: Final[dict] = {
THUAI6.HumanType.NullHumanType: MessageType.NULL_HUMAN_TYPE,
THUAI6.HumanType.HumanType1: MessageType.HUMANTYPE1, }

butcherTypeDict: Final[dict] = {
THUAI6.ButcherType.NullButcherType: MessageType.NULL_BUTCHER_TYPE,
THUAI6.ButcherType.ButcherType1: MessageType.BUTCHERTYPE1, }

humanBuffTypeDict: Final[dict] = {
THUAI6.HumanBuffType.NullHumanBuffType: MessageType.NULL_HBUFF_TYPE,
THUAI6.HumanBuffType.HumanBuffType1: MessageType.HBUFFTYPE1, }

butcherBuffTypeDict: Final[dict] = {
THUAI6.ButcherBuffType.NullButcherBuffType: MessageType.NULL_BBUFF_TYPE,
THUAI6.ButcherBuffType.ButcherBuffType1: MessageType.BBUFFTYPE1, }

humanStateDict: Final[dict] = {
THUAI6.HumanState.NullHumanState: MessageType.NULL_STATUS,
THUAI6.HumanState.Idle: MessageType.IDLE,
THUAI6.HumanState.Fixing: MessageType.FIXING,
THUAI6.HumanState.Dying: MessageType.DYING,
THUAI6.HumanState.OnChair: MessageType.ON_CHAIR,
THUAI6.HumanState.Dead: MessageType.DEAD}

gameStateDict: Final[dict] = {
THUAI6.GameState.NullGameState: MessageType.NULL_GAME_STATE,
THUAI6.GameState.GameStart: MessageType.GAME_START,
THUAI6.GameState.GameRunning: MessageType.GAME_RUNNING,
THUAI6.GameState.GameEnd: MessageType.GAME_END}

# 用于将THUAI6的对象转为Proto的对象
@staticmethod
def THUAI62ProtobufPlayer(playerID: int, playerType: THUAI6.PlayerType, humanType: THUAI6.HumanType, butcherType: THUAI6.ButcherType) -> Message2Server.PlayerMsg:
return Message2Server.PlayerMsg(player_id=playerID, player_type=THUAI62Proto.playerTypeDict[playerType], human_type=THUAI62Proto.humanTypeDict[humanType], butcher_type=THUAI62Proto.butcherTypeDict[butcherType])

@staticmethod
def THUAI62ProtobufID(playerID: int) -> Message2Server.IDMsg:
return Message2Server.IDMsg(player_id=playerID)

@staticmethod
def THUAI62ProtobufMove(time: int, angle: float, id: int) -> Message2Server.MoveMsg:
return Message2Server.MoveMsg(player_id=id, angle=angle, time_in_milliseconds=time)

@staticmethod
def THUAI62ProtobufPick(prop: THUAI6.PropType, id: int) -> Message2Server.PickMsg:
return Message2Server.PickMsg(player_id=id, prop_type=THUAI62Proto.propTypeDict[prop])

@staticmethod
def THUAI62ProtobufSend(msg: str, toID: int, id: int) -> Message2Server.SendMsg:
return Message2Server.SendMsg(player_id=id, to_player_id=toID, message=msg)

@staticmethod
def THUAI62ProtobufAttack(angle: float, id: int) -> Message2Server.AttackMsg:
return Message2Server.AttackMsg(player_id=id, angle=angle)

+ 32
- 0
PyAPI/README.md View File

@@ -0,0 +1,32 @@
# PyAPI

## 简介

Python 通信组件与选手接口

## 目标

### 基本目标

* 基于Protobuf和gRPC,在C++接口的基础上修改,为客户端提供Python通信组件
* 为选手提供游戏接口

### 重要目标

* 针对Python的语言特性,做出相应调整
* 改进选手接口,设计可用的异步接口

### 提高目标

* 提供其他语言的接口:Java、Rust、C#……

## 统一约定

* Python版本使用Python3.9.16

## 注意事项

* 充分利用Python的语言特性,尽量防止对C++接口做简单的语言翻译
* 降低各个模块的耦合度,注意避免相互依赖、环形依赖等问题
* 避免忙等待,注意线程安全,做好线程同步
* 思考如何选手利用Python的特性做出违法操作

+ 44
- 0
PyAPI/proto/Message2Clients_pb2.py View File

@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Message2Clients.proto
"""Generated protocol buffer code."""
import MessageType_pb2 as MessageType__pb2
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
b'\n\x15Message2Clients.proto\x12\x08protobuf\x1a\x11MessageType.proto\"\xa5\x03\n\x0eMessageOfHuman\x12\t\n\x01x\x18\x01 \x01(\x05\x12\t\n\x01y\x18\x02 \x01(\x05\x12\r\n\x05speed\x18\x03 \x01(\x05\x12\x0c\n\x04life\x18\x04 \x01(\x05\x12\x13\n\x0bhanged_time\x18\x05 \x01(\x05\x12\"\n\x1atime_until_skill_available\x18\x06 \x01(\x01\x12\"\n\x05place\x18\x07 \x01(\x0e\x32\x13.protobuf.PlaceType\x12 \n\x04prop\x18\x08 \x01(\x0e\x32\x12.protobuf.PropType\x12\'\n\nhuman_type\x18\t \x01(\x0e\x32\x13.protobuf.HumanType\x12\x0c\n\x04guid\x18\n \x01(\x03\x12#\n\x05state\x18\x0b \x01(\x0e\x32\x14.protobuf.HumanState\x12\x12\n\nchair_time\x18\x0c \x01(\x01\x12\x13\n\x0bground_time\x18\x0e \x01(\x01\x12\x11\n\tplayer_id\x18\x0f \x01(\x03\x12\x12\n\nview_range\x18\x10 \x01(\x05\x12\x0e\n\x06radius\x18\x11 \x01(\x05\x12%\n\x04\x62uff\x18\x12 \x03(\x0e\x32\x17.protobuf.HumanBuffType\"\xdd\x02\n\x10MessageOfButcher\x12\t\n\x01x\x18\x01 \x01(\x05\x12\t\n\x01y\x18\x02 \x01(\x05\x12\r\n\x05speed\x18\x03 \x01(\x05\x12\x0e\n\x06\x64\x61mage\x18\x04 \x01(\x05\x12\"\n\x1atime_until_skill_available\x18\x05 \x01(\x01\x12\"\n\x05place\x18\x06 \x01(\x0e\x32\x13.protobuf.PlaceType\x12 \n\x04prop\x18\x07 \x01(\x0e\x32\x12.protobuf.PropType\x12+\n\x0c\x62utcher_type\x18\x08 \x01(\x0e\x32\x15.protobuf.ButcherType\x12\x0c\n\x04guid\x18\t \x01(\x03\x12\x0f\n\x07movable\x18\n \x01(\x08\x12\x11\n\tplayer_id\x18\x0b \x01(\x03\x12\x12\n\nview_range\x18\x0c \x01(\x05\x12\x0e\n\x06radius\x18\r \x01(\x05\x12\'\n\x04\x62uff\x18\x0e \x03(\x0e\x32\x19.protobuf.ButcherBuffType\"\xb4\x01\n\rMessageOfProp\x12 \n\x04type\x18\x01 \x01(\x0e\x32\x12.protobuf.PropType\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\x12\x18\n\x10\x66\x61\x63ing_direction\x18\x04 \x01(\x01\x12\x0c\n\x04guid\x18\x05 \x01(\x03\x12\"\n\x05place\x18\x06 \x01(\x0e\x32\x13.protobuf.PlaceType\x12\x0c\n\x04size\x18\x07 \x01(\x05\x12\x11\n\tis_moving\x18\x08 \x01(\x08\"{\n\x13MessageOfPickedProp\x12 \n\x04type\x18\x01 \x01(\x0e\x32\x12.protobuf.PropType\x12\t\n\x01x\x18\x02 \x01(\x05\x12\t\n\x01y\x18\x03 \x01(\x05\x12\x18\n\x10\x66\x61\x63ing_direction\x18\x04 \x01(\x01\x12\x12\n\nmapping_id\x18\x05 \x01(\x03\"`\n\x0cMessageOfMap\x12\'\n\x03row\x18\x02 \x03(\x0b\x32\x1a.protobuf.MessageOfMap.Row\x1a\'\n\x03Row\x12 \n\x03\x63ol\x18\x01 \x03(\x0e\x32\x13.protobuf.PlaceType\"\xfc\x01\n\x0fMessageToClient\x12/\n\rhuman_message\x18\x01 \x03(\x0b\x32\x18.protobuf.MessageOfHuman\x12\x33\n\x0f\x62utcher_message\x18\x02 \x03(\x0b\x32\x1a.protobuf.MessageOfButcher\x12-\n\x0cprop_message\x18\x03 \x03(\x0b\x32\x17.protobuf.MessageOfProp\x12+\n\x0bmap_message\x18\x04 \x01(\x0b\x32\x16.protobuf.MessageOfMap\x12\'\n\ngame_state\x18\x05 \x01(\x0e\x32\x13.protobuf.GameState\"J\n\x07MoveRes\x12\x14\n\x0c\x61\x63tual_speed\x18\x01 \x01(\x03\x12\x14\n\x0c\x61\x63tual_angle\x18\x02 \x01(\x01\x12\x13\n\x0b\x61\x63t_success\x18\x03 \x01(\x08\"\x1e\n\x07\x42oolRes\x12\x13\n\x0b\x61\x63t_success\x18\x01 \x01(\x08\"P\n\x06MsgRes\x12\x14\n\x0chave_message\x18\x01 \x01(\x08\x12\x16\n\x0e\x66rom_player_id\x18\x02 \x01(\x03\x12\x18\n\x10message_received\x18\x03 \x01(\tb\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(
DESCRIPTOR, 'Message2Clients_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_MESSAGEOFHUMAN._serialized_start = 55
_MESSAGEOFHUMAN._serialized_end = 476
_MESSAGEOFBUTCHER._serialized_start = 479
_MESSAGEOFBUTCHER._serialized_end = 828
_MESSAGEOFPROP._serialized_start = 831
_MESSAGEOFPROP._serialized_end = 1011
_MESSAGEOFPICKEDPROP._serialized_start = 1013
_MESSAGEOFPICKEDPROP._serialized_end = 1136
_MESSAGEOFMAP._serialized_start = 1138
_MESSAGEOFMAP._serialized_end = 1234
_MESSAGEOFMAP_ROW._serialized_start = 1195
_MESSAGEOFMAP_ROW._serialized_end = 1234
_MESSAGETOCLIENT._serialized_start = 1237
_MESSAGETOCLIENT._serialized_end = 1489
_MOVERES._serialized_start = 1491
_MOVERES._serialized_end = 1565
_BOOLRES._serialized_start = 1567
_BOOLRES._serialized_end = 1597
_MSGRES._serialized_start = 1599
_MSGRES._serialized_end = 1679
# @@protoc_insertion_point(module_scope)

+ 186
- 0
PyAPI/proto/Message2Clients_pb2.pyi View File

@@ -0,0 +1,186 @@
import MessageType_pb2 as _MessageType_pb2
from google.protobuf.internal import containers as _containers
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor


class BoolRes(_message.Message):
__slots__ = ["act_success"]
ACT_SUCCESS_FIELD_NUMBER: _ClassVar[int]
act_success: bool
def __init__(self, act_success: bool = ...) -> None: ...


class MessageOfButcher(_message.Message):
__slots__ = ["buff", "butcher_type", "damage", "guid", "movable", "place", "player_id",
"prop", "radius", "speed", "time_until_skill_available", "view_range", "x", "y"]
BUFF_FIELD_NUMBER: _ClassVar[int]
BUTCHER_TYPE_FIELD_NUMBER: _ClassVar[int]
DAMAGE_FIELD_NUMBER: _ClassVar[int]
GUID_FIELD_NUMBER: _ClassVar[int]
MOVABLE_FIELD_NUMBER: _ClassVar[int]
PLACE_FIELD_NUMBER: _ClassVar[int]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
PROP_FIELD_NUMBER: _ClassVar[int]
RADIUS_FIELD_NUMBER: _ClassVar[int]
SPEED_FIELD_NUMBER: _ClassVar[int]
TIME_UNTIL_SKILL_AVAILABLE_FIELD_NUMBER: _ClassVar[int]
VIEW_RANGE_FIELD_NUMBER: _ClassVar[int]
X_FIELD_NUMBER: _ClassVar[int]
Y_FIELD_NUMBER: _ClassVar[int]
buff: _containers.RepeatedScalarFieldContainer[_MessageType_pb2.ButcherBuffType]
butcher_type: _MessageType_pb2.ButcherType
damage: int
guid: int
movable: bool
place: _MessageType_pb2.PlaceType
player_id: int
prop: _MessageType_pb2.PropType
radius: int
speed: int
time_until_skill_available: float
view_range: int
x: int
y: int
def __init__(self, x: _Optional[int] = ..., y: _Optional[int] = ..., speed: _Optional[int] = ..., damage: _Optional[int] = ..., time_until_skill_available: _Optional[float] = ..., place: _Optional[_Union[_MessageType_pb2.PlaceType, str]] = ..., prop: _Optional[_Union[_MessageType_pb2.PropType, str]] = ...,
butcher_type: _Optional[_Union[_MessageType_pb2.ButcherType, str]] = ..., guid: _Optional[int] = ..., movable: bool = ..., player_id: _Optional[int] = ..., view_range: _Optional[int] = ..., radius: _Optional[int] = ..., buff: _Optional[_Iterable[_Union[_MessageType_pb2.ButcherBuffType, str]]] = ...) -> None: ...


class MessageOfHuman(_message.Message):
__slots__ = ["buff", "chair_time", "ground_time", "guid", "hanged_time", "human_type", "life", "place",
"player_id", "prop", "radius", "speed", "state", "time_until_skill_available", "view_range", "x", "y"]
BUFF_FIELD_NUMBER: _ClassVar[int]
CHAIR_TIME_FIELD_NUMBER: _ClassVar[int]
GROUND_TIME_FIELD_NUMBER: _ClassVar[int]
GUID_FIELD_NUMBER: _ClassVar[int]
HANGED_TIME_FIELD_NUMBER: _ClassVar[int]
HUMAN_TYPE_FIELD_NUMBER: _ClassVar[int]
LIFE_FIELD_NUMBER: _ClassVar[int]
PLACE_FIELD_NUMBER: _ClassVar[int]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
PROP_FIELD_NUMBER: _ClassVar[int]
RADIUS_FIELD_NUMBER: _ClassVar[int]
SPEED_FIELD_NUMBER: _ClassVar[int]
STATE_FIELD_NUMBER: _ClassVar[int]
TIME_UNTIL_SKILL_AVAILABLE_FIELD_NUMBER: _ClassVar[int]
VIEW_RANGE_FIELD_NUMBER: _ClassVar[int]
X_FIELD_NUMBER: _ClassVar[int]
Y_FIELD_NUMBER: _ClassVar[int]
buff: _containers.RepeatedScalarFieldContainer[_MessageType_pb2.HumanBuffType]
chair_time: float
ground_time: float
guid: int
hanged_time: int
human_type: _MessageType_pb2.HumanType
life: int
place: _MessageType_pb2.PlaceType
player_id: int
prop: _MessageType_pb2.PropType
radius: int
speed: int
state: _MessageType_pb2.HumanState
time_until_skill_available: float
view_range: int
x: int
y: int
def __init__(self, x: _Optional[int] = ..., y: _Optional[int] = ..., speed: _Optional[int] = ..., life: _Optional[int] = ..., hanged_time: _Optional[int] = ..., time_until_skill_available: _Optional[float] = ..., place: _Optional[_Union[_MessageType_pb2.PlaceType, str]] = ..., prop: _Optional[_Union[_MessageType_pb2.PropType, str]] = ..., human_type: _Optional[_Union[_MessageType_pb2.HumanType, str]]
= ..., guid: _Optional[int] = ..., state: _Optional[_Union[_MessageType_pb2.HumanState, str]] = ..., chair_time: _Optional[float] = ..., ground_time: _Optional[float] = ..., player_id: _Optional[int] = ..., view_range: _Optional[int] = ..., radius: _Optional[int] = ..., buff: _Optional[_Iterable[_Union[_MessageType_pb2.HumanBuffType, str]]] = ...) -> None: ...


class MessageOfMap(_message.Message):
__slots__ = ["row"]

class Row(_message.Message):
__slots__ = ["col"]
COL_FIELD_NUMBER: _ClassVar[int]
col: _containers.RepeatedScalarFieldContainer[_MessageType_pb2.PlaceType]
def __init__(
self, col: _Optional[_Iterable[_Union[_MessageType_pb2.PlaceType, str]]] = ...) -> None: ...
ROW_FIELD_NUMBER: _ClassVar[int]
row: _containers.RepeatedCompositeFieldContainer[MessageOfMap.Row]
def __init__(
self, row: _Optional[_Iterable[_Union[MessageOfMap.Row, _Mapping]]] = ...) -> None: ...


class MessageOfPickedProp(_message.Message):
__slots__ = ["facing_direction", "mapping_id", "type", "x", "y"]
FACING_DIRECTION_FIELD_NUMBER: _ClassVar[int]
MAPPING_ID_FIELD_NUMBER: _ClassVar[int]
TYPE_FIELD_NUMBER: _ClassVar[int]
X_FIELD_NUMBER: _ClassVar[int]
Y_FIELD_NUMBER: _ClassVar[int]
facing_direction: float
mapping_id: int
type: _MessageType_pb2.PropType
x: int
y: int
def __init__(self, type: _Optional[_Union[_MessageType_pb2.PropType, str]] = ..., x: _Optional[int] = ...,
y: _Optional[int] = ..., facing_direction: _Optional[float] = ..., mapping_id: _Optional[int] = ...) -> None: ...


class MessageOfProp(_message.Message):
__slots__ = ["facing_direction", "guid",
"is_moving", "place", "size", "type", "x", "y"]
FACING_DIRECTION_FIELD_NUMBER: _ClassVar[int]
GUID_FIELD_NUMBER: _ClassVar[int]
IS_MOVING_FIELD_NUMBER: _ClassVar[int]
PLACE_FIELD_NUMBER: _ClassVar[int]
SIZE_FIELD_NUMBER: _ClassVar[int]
TYPE_FIELD_NUMBER: _ClassVar[int]
X_FIELD_NUMBER: _ClassVar[int]
Y_FIELD_NUMBER: _ClassVar[int]
facing_direction: float
guid: int
is_moving: bool
place: _MessageType_pb2.PlaceType
size: int
type: _MessageType_pb2.PropType
x: int
y: int
def __init__(self, type: _Optional[_Union[_MessageType_pb2.PropType, str]] = ..., x: _Optional[int] = ..., y: _Optional[int] = ..., facing_direction: _Optional[float]
= ..., guid: _Optional[int] = ..., place: _Optional[_Union[_MessageType_pb2.PlaceType, str]] = ..., size: _Optional[int] = ..., is_moving: bool = ...) -> None: ...


class MessageToClient(_message.Message):
__slots__ = ["butcher_message", "game_state",
"human_message", "map_message", "prop_message"]
BUTCHER_MESSAGE_FIELD_NUMBER: _ClassVar[int]
GAME_STATE_FIELD_NUMBER: _ClassVar[int]
HUMAN_MESSAGE_FIELD_NUMBER: _ClassVar[int]
MAP_MESSAGE_FIELD_NUMBER: _ClassVar[int]
PROP_MESSAGE_FIELD_NUMBER: _ClassVar[int]
butcher_message: _containers.RepeatedCompositeFieldContainer[MessageOfButcher]
game_state: _MessageType_pb2.GameState
human_message: _containers.RepeatedCompositeFieldContainer[MessageOfHuman]
map_message: MessageOfMap
prop_message: _containers.RepeatedCompositeFieldContainer[MessageOfProp]
def __init__(self, human_message: _Optional[_Iterable[_Union[MessageOfHuman, _Mapping]]] = ..., butcher_message: _Optional[_Iterable[_Union[MessageOfButcher, _Mapping]]] = ..., prop_message: _Optional[
_Iterable[_Union[MessageOfProp, _Mapping]]] = ..., map_message: _Optional[_Union[MessageOfMap, _Mapping]] = ..., game_state: _Optional[_Union[_MessageType_pb2.GameState, str]] = ...) -> None: ...


class MoveRes(_message.Message):
__slots__ = ["act_success", "actual_angle", "actual_speed"]
ACTUAL_ANGLE_FIELD_NUMBER: _ClassVar[int]
ACTUAL_SPEED_FIELD_NUMBER: _ClassVar[int]
ACT_SUCCESS_FIELD_NUMBER: _ClassVar[int]
act_success: bool
actual_angle: float
actual_speed: int
def __init__(self, actual_speed: _Optional[int] = ...,
actual_angle: _Optional[float] = ..., act_success: bool = ...) -> None: ...


class MsgRes(_message.Message):
__slots__ = ["from_player_id", "have_message", "message_received"]
FROM_PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
HAVE_MESSAGE_FIELD_NUMBER: _ClassVar[int]
MESSAGE_RECEIVED_FIELD_NUMBER: _ClassVar[int]
from_player_id: int
have_message: bool
message_received: str

def __init__(self, have_message: bool = ...,
from_player_id: _Optional[int] = ..., message_received: _Optional[str] = ...) -> None: ...

+ 35
- 0
PyAPI/proto/Message2Server_pb2.py View File

@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Message2Server.proto
"""Generated protocol buffer code."""
import MessageType_pb2 as MessageType__pb2
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x14Message2Server.proto\x12\x08protobuf\x1a\x11MessageType.proto\"\xaf\x01\n\tPlayerMsg\x12\x11\n\tplayer_id\x18\x01 \x01(\x03\x12)\n\x0bplayer_type\x18\x02 \x01(\x0e\x32\x14.protobuf.PlayerType\x12)\n\nhuman_type\x18\x03 \x01(\x0e\x32\x13.protobuf.HumanTypeH\x00\x12-\n\x0c\x62utcher_type\x18\x04 \x01(\x0e\x32\x15.protobuf.ButcherTypeH\x00\x42\n\n\x08job_type\"I\n\x07MoveMsg\x12\x11\n\tplayer_id\x18\x01 \x01(\x03\x12\r\n\x05\x61ngle\x18\x02 \x01(\x01\x12\x1c\n\x14time_in_milliseconds\x18\x03 \x01(\x03\"C\n\x07PickMsg\x12\x11\n\tplayer_id\x18\x01 \x01(\x03\x12%\n\tprop_type\x18\x02 \x01(\x0e\x32\x12.protobuf.PropType\"C\n\x07SendMsg\x12\x11\n\tplayer_id\x18\x01 \x01(\x03\x12\x14\n\x0cto_player_id\x18\x02 \x01(\x03\x12\x0f\n\x07message\x18\x03 \x01(\t\"-\n\tAttackMsg\x12\x11\n\tplayer_id\x18\x01 \x01(\x03\x12\r\n\x05\x61ngle\x18\x02 \x01(\x01\"\x1a\n\x05IDMsg\x12\x11\n\tplayer_id\x18\x01 \x01(\x03\x62\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(
DESCRIPTOR, 'Message2Server_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_PLAYERMSG._serialized_start = 54
_PLAYERMSG._serialized_end = 229
_MOVEMSG._serialized_start = 231
_MOVEMSG._serialized_end = 304
_PICKMSG._serialized_start = 306
_PICKMSG._serialized_end = 373
_SENDMSG._serialized_start = 375
_SENDMSG._serialized_end = 442
_ATTACKMSG._serialized_start = 444
_ATTACKMSG._serialized_end = 489
_IDMSG._serialized_start = 491
_IDMSG._serialized_end = 517
# @@protoc_insertion_point(module_scope)

+ 72
- 0
PyAPI/proto/Message2Server_pb2.pyi View File

@@ -0,0 +1,72 @@
import MessageType_pb2 as _MessageType_pb2
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union

DESCRIPTOR: _descriptor.FileDescriptor


class AttackMsg(_message.Message):
__slots__ = ["angle", "player_id"]
ANGLE_FIELD_NUMBER: _ClassVar[int]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
angle: float
player_id: int
def __init__(
self, player_id: _Optional[int] = ..., angle: _Optional[float] = ...) -> None: ...


class IDMsg(_message.Message):
__slots__ = ["player_id"]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
player_id: int
def __init__(self, player_id: _Optional[int] = ...) -> None: ...


class MoveMsg(_message.Message):
__slots__ = ["angle", "player_id", "time_in_milliseconds"]
ANGLE_FIELD_NUMBER: _ClassVar[int]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
TIME_IN_MILLISECONDS_FIELD_NUMBER: _ClassVar[int]
angle: float
player_id: int
time_in_milliseconds: int
def __init__(self, player_id: _Optional[int] = ..., angle: _Optional[float]
= ..., time_in_milliseconds: _Optional[int] = ...) -> None: ...


class PickMsg(_message.Message):
__slots__ = ["player_id", "prop_type"]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
PROP_TYPE_FIELD_NUMBER: _ClassVar[int]
player_id: int
prop_type: _MessageType_pb2.PropType
def __init__(self, player_id: _Optional[int] = ...,
prop_type: _Optional[_Union[_MessageType_pb2.PropType, str]] = ...) -> None: ...


class PlayerMsg(_message.Message):
__slots__ = ["butcher_type", "human_type", "player_id", "player_type"]
BUTCHER_TYPE_FIELD_NUMBER: _ClassVar[int]
HUMAN_TYPE_FIELD_NUMBER: _ClassVar[int]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
PLAYER_TYPE_FIELD_NUMBER: _ClassVar[int]
butcher_type: _MessageType_pb2.ButcherType
human_type: _MessageType_pb2.HumanType
player_id: int
player_type: _MessageType_pb2.PlayerType
def __init__(self, player_id: _Optional[int] = ..., player_type: _Optional[_Union[_MessageType_pb2.PlayerType, str]] = ...,
human_type: _Optional[_Union[_MessageType_pb2.HumanType, str]] = ..., butcher_type: _Optional[_Union[_MessageType_pb2.ButcherType, str]] = ...) -> None: ...


class SendMsg(_message.Message):
__slots__ = ["message", "player_id", "to_player_id"]
MESSAGE_FIELD_NUMBER: _ClassVar[int]
PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
TO_PLAYER_ID_FIELD_NUMBER: _ClassVar[int]
message: str
player_id: int
to_player_id: int

def __init__(self, player_id: _Optional[int] = ..., to_player_id: _Optional[int]
= ..., message: _Optional[str] = ...) -> None: ...

+ 42
- 0
PyAPI/proto/MessageType_pb2.py View File

@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: MessageType.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11MessageType.proto\x12\x08protobuf*g\n\tPlaceType\x12\x13\n\x0fNULL_PLACE_TYPE\x10\x00\x12\x08\n\x04LAND\x10\x01\x12\x08\n\x04WALL\x10\x02\x12\t\n\x05GRASS\x10\x03\x12\x0b\n\x07MACHINE\x10\x04\x12\x08\n\x04GATE\x10\x05\x12\x0f\n\x0bHIDDEN_GATE\x10\x06*8\n\tShapeType\x12\x13\n\x0fNULL_SHAPE_TYPE\x10\x00\x12\n\n\x06\x43IRCLE\x10\x01\x12\n\n\x06SQUARE\x10\x02*N\n\x08PropType\x12\x12\n\x0eNULL_PROP_TYPE\x10\x00\x12\n\n\x06PTYPE1\x10\x01\x12\n\n\x06PTYPE2\x10\x02\x12\n\n\x06PTYPE3\x10\x03\x12\n\n\x06PTYPE4\x10\x04*d\n\rHumanBuffType\x12\x13\n\x0fNULL_HBUFF_TYPE\x10\x00\x12\x0e\n\nHBUFFTYPE1\x10\x01\x12\x0e\n\nHBUFFTYPE2\x10\x02\x12\x0e\n\nHBUFFTYPE3\x10\x03\x12\x0e\n\nHBUFFTYPE4\x10\x04*V\n\nHumanState\x12\x0f\n\x0bNULL_STATUS\x10\x00\x12\x08\n\x04IDLE\x10\x01\x12\n\n\x06\x46IXING\x10\x02\x12\t\n\x05\x44YING\x10\x03\x12\x0c\n\x08ON_CHAIR\x10\x04\x12\x08\n\x04\x44\x45\x41\x44\x10\x05*f\n\x0f\x42utcherBuffType\x12\x13\n\x0fNULL_BBUFF_TYPE\x10\x00\x12\x0e\n\nBBUFFTYPE1\x10\x01\x12\x0e\n\nBBUFFTYPE2\x10\x02\x12\x0e\n\nBBUFFTYPE3\x10\x03\x12\x0e\n\nBBUFFTYPE4\x10\x04*H\n\nPlayerType\x12\x14\n\x10NULL_PLAYER_TYPE\x10\x00\x12\x10\n\x0cHUMAN_PLAYER\x10\x01\x12\x12\n\x0e\x42UTCHER_PLAYER\x10\x02*`\n\tHumanType\x12\x13\n\x0fNULL_HUMAN_TYPE\x10\x00\x12\x0e\n\nHUMANTYPE1\x10\x01\x12\x0e\n\nHUMANTYPE2\x10\x02\x12\x0e\n\nHUMANTYPE3\x10\x03\x12\x0e\n\nHUMANTYPE4\x10\x04*l\n\x0b\x42utcherType\x12\x15\n\x11NULL_BUTCHER_TYPE\x10\x00\x12\x10\n\x0c\x42UTCHERTYPE1\x10\x01\x12\x10\n\x0c\x42UTCHERTYPE2\x10\x02\x12\x10\n\x0c\x42UTCHERTYPE3\x10\x03\x12\x10\n\x0c\x42UTCHERTYPE4\x10\x04*P\n\tGameState\x12\x13\n\x0fNULL_GAME_STATE\x10\x00\x12\x0e\n\nGAME_START\x10\x01\x12\x10\n\x0cGAME_RUNNING\x10\x02\x12\x0c\n\x08GAME_END\x10\x03\x62\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(
DESCRIPTOR, 'MessageType_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_PLACETYPE._serialized_start = 31
_PLACETYPE._serialized_end = 134
_SHAPETYPE._serialized_start = 136
_SHAPETYPE._serialized_end = 192
_PROPTYPE._serialized_start = 194
_PROPTYPE._serialized_end = 272
_HUMANBUFFTYPE._serialized_start = 274
_HUMANBUFFTYPE._serialized_end = 374
_HUMANSTATE._serialized_start = 376
_HUMANSTATE._serialized_end = 462
_BUTCHERBUFFTYPE._serialized_start = 464
_BUTCHERBUFFTYPE._serialized_end = 566
_PLAYERTYPE._serialized_start = 568
_PLAYERTYPE._serialized_end = 640
_HUMANTYPE._serialized_start = 642
_HUMANTYPE._serialized_end = 738
_BUTCHERTYPE._serialized_start = 740
_BUTCHERTYPE._serialized_end = 848
_GAMESTATE._serialized_start = 850
_GAMESTATE._serialized_end = 930
# @@protoc_insertion_point(module_scope)

+ 93
- 0
PyAPI/proto/MessageType_pb2.pyi View File

@@ -0,0 +1,93 @@
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from typing import ClassVar as _ClassVar

BBUFFTYPE1: ButcherBuffType
BBUFFTYPE2: ButcherBuffType
BBUFFTYPE3: ButcherBuffType
BBUFFTYPE4: ButcherBuffType
BUTCHERTYPE1: ButcherType
BUTCHERTYPE2: ButcherType
BUTCHERTYPE3: ButcherType
BUTCHERTYPE4: ButcherType
BUTCHER_PLAYER: PlayerType
CIRCLE: ShapeType
DEAD: HumanState
DESCRIPTOR: _descriptor.FileDescriptor
DYING: HumanState
FIXING: HumanState
GAME_END: GameState
GAME_RUNNING: GameState
GAME_START: GameState
GATE: PlaceType
GRASS: PlaceType
HBUFFTYPE1: HumanBuffType
HBUFFTYPE2: HumanBuffType
HBUFFTYPE3: HumanBuffType
HBUFFTYPE4: HumanBuffType
HIDDEN_GATE: PlaceType
HUMANTYPE1: HumanType
HUMANTYPE2: HumanType
HUMANTYPE3: HumanType
HUMANTYPE4: HumanType
HUMAN_PLAYER: PlayerType
IDLE: HumanState
LAND: PlaceType
MACHINE: PlaceType
NULL_BBUFF_TYPE: ButcherBuffType
NULL_BUTCHER_TYPE: ButcherType
NULL_GAME_STATE: GameState
NULL_HBUFF_TYPE: HumanBuffType
NULL_HUMAN_TYPE: HumanType
NULL_PLACE_TYPE: PlaceType
NULL_PLAYER_TYPE: PlayerType
NULL_PROP_TYPE: PropType
NULL_SHAPE_TYPE: ShapeType
NULL_STATUS: HumanState
ON_CHAIR: HumanState
PTYPE1: PropType
PTYPE2: PropType
PTYPE3: PropType
PTYPE4: PropType
SQUARE: ShapeType
WALL: PlaceType


class PlaceType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class ShapeType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class PropType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class HumanBuffType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class HumanState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class ButcherBuffType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class PlayerType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class HumanType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class ButcherType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []


class GameState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []

+ 25
- 0
PyAPI/proto/Services_pb2.py View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Services.proto
"""Generated protocol buffer code."""
import Message2Server_pb2 as Message2Server__pb2
import Message2Clients_pb2 as Message2Clients__pb2
from google.protobuf.internal import builder as _builder
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()


DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0eServices.proto\x12\x08protobuf\x1a\x15Message2Clients.proto\x1a\x14Message2Server.proto2\xfa\x06\n\x10\x41vailableService\x12\x33\n\rTryConnection\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12=\n\tAddPlayer\x12\x13.protobuf.PlayerMsg\x1a\x19.protobuf.MessageToClient0\x01\x12,\n\x04Move\x12\x11.protobuf.MoveMsg\x1a\x11.protobuf.MoveRes\x12\x30\n\x08PickProp\x12\x11.protobuf.PickMsg\x1a\x11.protobuf.BoolRes\x12-\n\x07UseProp\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12.\n\x08UseSkill\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12\x33\n\x0bSendMessage\x12\x11.protobuf.SendMsg\x1a\x11.protobuf.BoolRes\x12\x31\n\nGetMessage\x12\x0f.protobuf.IDMsg\x1a\x10.protobuf.MsgRes0\x01\x12\x35\n\x0fStartFixMachine\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12\x33\n\rEndFixMachine\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12\x34\n\x0eStartSaveHuman\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12\x32\n\x0c\x45ndSaveHuman\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12\x30\n\x06\x41ttack\x12\x13.protobuf.AttackMsg\x1a\x11.protobuf.BoolRes\x12\x30\n\nCarryHuman\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12\x32\n\x0cReleaseHuman\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12/\n\tHangHuman\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolRes\x12,\n\x06\x45scape\x12\x0f.protobuf.IDMsg\x1a\x11.protobuf.BoolResb\x06proto3')

_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'Services_pb2', globals())
if _descriptor._USE_C_DESCRIPTORS == False:

DESCRIPTOR._options = None
_AVAILABLESERVICE._serialized_start = 74
_AVAILABLESERVICE._serialized_end = 964
# @@protoc_insertion_point(module_scope)

+ 6
- 0
PyAPI/proto/Services_pb2.pyi View File

@@ -0,0 +1,6 @@
import Message2Clients_pb2 as _Message2Clients_pb2
import Message2Server_pb2 as _Message2Server_pb2
from google.protobuf import descriptor as _descriptor
from typing import ClassVar as _ClassVar

DESCRIPTOR: _descriptor.FileDescriptor

+ 603
- 0
PyAPI/proto/Services_pb2_grpc.py View File

@@ -0,0 +1,603 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

import Message2Clients_pb2 as Message2Clients__pb2
import Message2Server_pb2 as Message2Server__pb2


class AvailableServiceStub(object):
"""Missing associated documentation comment in .proto file."""

def __init__(self, channel):
"""Constructor.

Args:
channel: A grpc.Channel.
"""
self.TryConnection = channel.unary_unary(
'/protobuf.AvailableService/TryConnection',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.AddPlayer = channel.unary_stream(
'/protobuf.AvailableService/AddPlayer',
request_serializer=Message2Server__pb2.PlayerMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.MessageToClient.FromString,
)
self.Move = channel.unary_unary(
'/protobuf.AvailableService/Move',
request_serializer=Message2Server__pb2.MoveMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.MoveRes.FromString,
)
self.PickProp = channel.unary_unary(
'/protobuf.AvailableService/PickProp',
request_serializer=Message2Server__pb2.PickMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.UseProp = channel.unary_unary(
'/protobuf.AvailableService/UseProp',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.UseSkill = channel.unary_unary(
'/protobuf.AvailableService/UseSkill',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.SendMessage = channel.unary_unary(
'/protobuf.AvailableService/SendMessage',
request_serializer=Message2Server__pb2.SendMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.GetMessage = channel.unary_stream(
'/protobuf.AvailableService/GetMessage',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.MsgRes.FromString,
)
self.StartFixMachine = channel.unary_unary(
'/protobuf.AvailableService/StartFixMachine',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.EndFixMachine = channel.unary_unary(
'/protobuf.AvailableService/EndFixMachine',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.StartSaveHuman = channel.unary_unary(
'/protobuf.AvailableService/StartSaveHuman',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.EndSaveHuman = channel.unary_unary(
'/protobuf.AvailableService/EndSaveHuman',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.Attack = channel.unary_unary(
'/protobuf.AvailableService/Attack',
request_serializer=Message2Server__pb2.AttackMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.CarryHuman = channel.unary_unary(
'/protobuf.AvailableService/CarryHuman',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.ReleaseHuman = channel.unary_unary(
'/protobuf.AvailableService/ReleaseHuman',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.HangHuman = channel.unary_unary(
'/protobuf.AvailableService/HangHuman',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)
self.Escape = channel.unary_unary(
'/protobuf.AvailableService/Escape',
request_serializer=Message2Server__pb2.IDMsg.SerializeToString,
response_deserializer=Message2Clients__pb2.BoolRes.FromString,
)


class AvailableServiceServicer(object):
"""Missing associated documentation comment in .proto file."""

def TryConnection(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def AddPlayer(self, request, context):
"""游戏开局调用一次的服务
连接上后等待游戏开始,server会定时通过该服务向所有client发送消息。
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def Move(self, request, context):
"""游戏过程中玩家执行操作的服务
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def PickProp(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def UseProp(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def UseSkill(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def SendMessage(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def GetMessage(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def StartFixMachine(self, request, context):
"""开始修理机器
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def EndFixMachine(self, request, context):
"""主动停止修复
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def StartSaveHuman(self, request, context):
"""开始救人
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def EndSaveHuman(self, request, context):
"""主动停止救人
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def Attack(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def CarryHuman(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def ReleaseHuman(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def HangHuman(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def Escape(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_AvailableServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'TryConnection': grpc.unary_unary_rpc_method_handler(
servicer.TryConnection,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'AddPlayer': grpc.unary_stream_rpc_method_handler(
servicer.AddPlayer,
request_deserializer=Message2Server__pb2.PlayerMsg.FromString,
response_serializer=Message2Clients__pb2.MessageToClient.SerializeToString,
),
'Move': grpc.unary_unary_rpc_method_handler(
servicer.Move,
request_deserializer=Message2Server__pb2.MoveMsg.FromString,
response_serializer=Message2Clients__pb2.MoveRes.SerializeToString,
),
'PickProp': grpc.unary_unary_rpc_method_handler(
servicer.PickProp,
request_deserializer=Message2Server__pb2.PickMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'UseProp': grpc.unary_unary_rpc_method_handler(
servicer.UseProp,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'UseSkill': grpc.unary_unary_rpc_method_handler(
servicer.UseSkill,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'SendMessage': grpc.unary_unary_rpc_method_handler(
servicer.SendMessage,
request_deserializer=Message2Server__pb2.SendMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'GetMessage': grpc.unary_stream_rpc_method_handler(
servicer.GetMessage,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.MsgRes.SerializeToString,
),
'StartFixMachine': grpc.unary_unary_rpc_method_handler(
servicer.StartFixMachine,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'EndFixMachine': grpc.unary_unary_rpc_method_handler(
servicer.EndFixMachine,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'StartSaveHuman': grpc.unary_unary_rpc_method_handler(
servicer.StartSaveHuman,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'EndSaveHuman': grpc.unary_unary_rpc_method_handler(
servicer.EndSaveHuman,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'Attack': grpc.unary_unary_rpc_method_handler(
servicer.Attack,
request_deserializer=Message2Server__pb2.AttackMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'CarryHuman': grpc.unary_unary_rpc_method_handler(
servicer.CarryHuman,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'ReleaseHuman': grpc.unary_unary_rpc_method_handler(
servicer.ReleaseHuman,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'HangHuman': grpc.unary_unary_rpc_method_handler(
servicer.HangHuman,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
'Escape': grpc.unary_unary_rpc_method_handler(
servicer.Escape,
request_deserializer=Message2Server__pb2.IDMsg.FromString,
response_serializer=Message2Clients__pb2.BoolRes.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'protobuf.AvailableService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))

# This class is part of an EXPERIMENTAL API.


class AvailableService(object):
"""Missing associated documentation comment in .proto file."""

@staticmethod
def TryConnection(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/TryConnection',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def AddPlayer(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_stream(request, target, '/protobuf.AvailableService/AddPlayer',
Message2Server__pb2.PlayerMsg.SerializeToString,
Message2Clients__pb2.MessageToClient.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def Move(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/Move',
Message2Server__pb2.MoveMsg.SerializeToString,
Message2Clients__pb2.MoveRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def PickProp(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/PickProp',
Message2Server__pb2.PickMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def UseProp(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/UseProp',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def UseSkill(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/UseSkill',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def SendMessage(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/SendMessage',
Message2Server__pb2.SendMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def GetMessage(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_stream(request, target, '/protobuf.AvailableService/GetMessage',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.MsgRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def StartFixMachine(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/StartFixMachine',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def EndFixMachine(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/EndFixMachine',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def StartSaveHuman(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/StartSaveHuman',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def EndSaveHuman(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/EndSaveHuman',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def Attack(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/Attack',
Message2Server__pb2.AttackMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def CarryHuman(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/CarryHuman',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def ReleaseHuman(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/ReleaseHuman',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def HangHuman(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/HangHuman',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def Escape(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/protobuf.AvailableService/Escape',
Message2Server__pb2.IDMsg.SerializeToString,
Message2Clients__pb2.BoolRes.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

+ 7
- 0
dependency/proto/py_output.sh View File

@@ -0,0 +1,7 @@
python3 -m grpc_tools.protoc -I. --python_out=. --pyi_out=. MessageType.proto
python3 -m grpc_tools.protoc -I. --python_out=. --pyi_out=. Message2Clients.proto
python3 -m grpc_tools.protoc -I. --python_out=. --pyi_out=. Message2Server.proto
python3 -m grpc_tools.protoc -I. --python_out=. --pyi_out=. --grpc_python_out=. Services.proto
chmod -R 755 ./
mv -f ./*.py ../../PyAPI/proto
mv -f ./*.pyi ../../PyAPI/proto

Loading…
Cancel
Save