|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- from typing import List, Union, Tuple
- from concurrent.futures import Future
- from abc import abstractmethod, ABCMeta
- import PyAPI.structures as THUAI6
-
-
- class ILogic(metaclass=ABCMeta):
- # IAPI统一可用的接口
-
- @abstractmethod
- def GetTrickers(self) -> List[THUAI6.Tricker]:
- pass
-
- @abstractmethod
- def GetStudents(self) -> List[THUAI6.Student]:
- pass
-
- @abstractmethod
- def GetProps(self) -> List[THUAI6.Prop]:
- pass
-
- @abstractmethod
- def GetBullets(self) -> List[THUAI6.Bullet]:
- pass
-
- @abstractmethod
- def GetSelfInfo(self) -> Union[THUAI6.Student, THUAI6.Tricker]:
- pass
-
- @abstractmethod
- def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
- pass
-
- @abstractmethod
- def GetPlaceType(self, x: int, y: int) -> THUAI6.PlaceType:
- pass
-
- @abstractmethod
- def GetClassroomProgress(self, x: int, y: int) -> int:
- pass
-
- @abstractmethod
- def GetChestProgress(self, x: int, y: int) -> int:
- pass
-
- @abstractmethod
- def GetGateProgress(self, x: int, y: int) -> int:
- pass
-
- @abstractmethod
- def IsDoorOpen(self, x: int, y: int) -> bool:
- pass
-
- @abstractmethod
- def GetHiddenGateState(self, x: int, y: int) -> THUAI6.HiddenGateState:
- pass
-
- @abstractmethod
- def GetDoorProgress(self, x: int, y: int) -> int:
- pass
-
- @abstractmethod
- def GetGameInfo(self) -> THUAI6.GameInfo:
- pass
-
- @abstractmethod
- def Move(self, time: int, angle: float) -> bool:
- pass
-
- @abstractmethod
- def PickProp(self, propType: THUAI6.PropType) -> bool:
- pass
-
- @abstractmethod
- def UseProp(self, propType: THUAI6.PropType) -> bool:
- pass
-
- @abstractmethod
- def ThrowProp(self, propType: THUAI6.PropType) -> bool:
- pass
-
- @abstractmethod
- def UseSkill(self, skillID: int) -> bool:
- pass
-
- @abstractmethod
- def SendMessage(self, toID: int, message: Union[str, bytes]) -> 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
-
- @abstractmethod
- def Attack(self, angle: float) -> bool:
- pass
-
- @abstractmethod
- def OpenDoor(self) -> bool:
- pass
-
- @abstractmethod
- def CloseDoor(self) -> bool:
- pass
-
- @abstractmethod
- def SkipWindow(self) -> bool:
- pass
-
- @abstractmethod
- def StartOpenGate(self) -> bool:
- pass
-
- @abstractmethod
- def StartOpenChest(self) -> bool:
- pass
-
- @abstractmethod
- def EndAllAction(self) -> bool:
- pass
-
- # IStudentAPI使用的接口
-
- @abstractmethod
- def Graduate(self) -> bool:
- pass
-
- @abstractmethod
- def StartLearning(self) -> bool:
- pass
-
- @abstractmethod
- def StartEncourageMate(self, mateID: int) -> bool:
- pass
-
- @abstractmethod
- def StartRouseMate(self, mateID: int) -> bool:
- pass
-
- @abstractmethod
- def HaveView(
- self, gridX: int, gridY: int, selfX: int, selfY: int, viewRange: int
- ) -> bool:
- pass
-
-
- class IAPI(metaclass=ABCMeta):
- # 选手可执行的操作
- # 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴
-
- @abstractmethod
- def Move(self, timeInMilliseconds: int, angle: float) -> Future[bool]:
- pass
-
- # 向特定方向移动
-
- @abstractmethod
- def MoveRight(self, timeInMilliseconds: int) -> Future[bool]:
- pass
-
- @abstractmethod
- def MoveLeft(self, timeInMilliseconds: int) -> Future[bool]:
- pass
-
- @abstractmethod
- def MoveUp(self, timeInMilliseconds: int) -> Future[bool]:
- pass
-
- @abstractmethod
- def MoveDown(self, timeInMilliseconds: int) -> Future[bool]:
- pass
-
- # 道具和技能相关
-
- @abstractmethod
- def PickProp(self, propType: THUAI6.PropType) -> Future[bool]:
- pass
-
- @abstractmethod
- def UseProp(self, propType: THUAI6.PropType) -> Future[bool]:
- pass
-
- @abstractmethod
- def ThrowProp(self, propType: THUAI6.PropType) -> Future[bool]:
- pass
-
- @abstractmethod
- def UseSkill(self, skillID: int) -> Future[bool]:
- pass
-
- @abstractmethod
- def Attack(self, angle: float) -> Future[bool]:
- pass
-
- @abstractmethod
- def OpenDoor(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def CloseDoor(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def SkipWindow(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def StartOpenGate(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def StartOpenChest(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def EndAllAction(self) -> Future[bool]:
- pass
-
- # 消息相关,接收消息时无消息则返回(-1, '')
-
- @abstractmethod
- def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[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 GetTrickers(self) -> List[THUAI6.Tricker]:
- pass
-
- @abstractmethod
- def GetStudents(self) -> List[THUAI6.Student]:
- pass
-
- @abstractmethod
- def GetProps(self) -> List[THUAI6.Prop]:
- pass
-
- @abstractmethod
- def GetBullets(self) -> List[THUAI6.Bullet]:
- pass
-
- @abstractmethod
- def GetSelfInfo(self) -> Union[THUAI6.Student, THUAI6.Tricker]:
- pass
-
- @abstractmethod
- def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
- pass
-
- @abstractmethod
- def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
- pass
-
- @abstractmethod
- def IsDoorOpen(self, cellX: int, cellY: int) -> bool:
- pass
-
- @abstractmethod
- def GetChestProgress(self, cellX: int, cellY: int) -> int:
- pass
-
- @abstractmethod
- def GetGateProgress(self, cellX: int, cellY: int) -> int:
- pass
-
- @abstractmethod
- def GetClassroomProgress(self, cellX: int, cellY: int) -> int:
- pass
-
- @abstractmethod
- def GetDoorProgress(self, cellX: int, cellY: int) -> int:
- pass
-
- @abstractmethod
- def GetHiddenGateState(self, cellX: int, cellY: int) -> THUAI6.HiddenGateState:
- pass
-
- @abstractmethod
- def GetGameInfo(self) -> THUAI6.GameInfo:
- pass
-
- @abstractmethod
- def HaveView(self, gridX: int, gridY: int) -> bool:
- pass
-
- # 用于DEBUG的输出函数,仅在DEBUG模式下有效
-
- @abstractmethod
- def Print(self, cont: str) -> None:
- pass
-
- @abstractmethod
- def PrintStudent(self) -> None:
- pass
-
- @abstractmethod
- def PrintTricker(self) -> None:
- pass
-
- @abstractmethod
- def PrintProp(self) -> None:
- pass
-
- @abstractmethod
- def PrintSelfInfo(self) -> None:
- pass
-
-
- class IStudentAPI(IAPI, metaclass=ABCMeta):
- # 人类阵营的特殊函数
-
- @abstractmethod
- def Graduate(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def StartLearning(self) -> Future[bool]:
- pass
-
- @abstractmethod
- def StartEncourageMate(self, mateID: int) -> Future[bool]:
- pass
-
- @abstractmethod
- def StartRouseMate(self, mateID: int) -> Future[bool]:
- pass
-
- @abstractmethod
- def GetSelfInfo(self) -> THUAI6.Student:
- pass
-
-
- class ITrickerAPI(IAPI, metaclass=ABCMeta):
- # 屠夫阵营的特殊函数
-
- @abstractmethod
- def GetSelfInfo(self) -> THUAI6.Tricker:
- pass
-
-
- class IAI(metaclass=ABCMeta):
- @abstractmethod
- def StudentPlay(self, api: IStudentAPI) -> None:
- pass
-
- @abstractmethod
- def TrickerPlay(self, api: ITrickerAPI) -> 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
|