You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Interface.py 8.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. from typing import List, Union
  2. from concurrent.futures import Future
  3. from abc import abstractmethod, ABCMeta
  4. import PyAPI.structures as THUAI6
  5. class ILogic(metaclass=ABCMeta):
  6. # IAPI统一可用的接口
  7. @abstractmethod
  8. def GetTrickers(self) -> List[THUAI6.Tricker]:
  9. pass
  10. @abstractmethod
  11. def GetStudents(self) -> List[THUAI6.Student]:
  12. pass
  13. @abstractmethod
  14. def GetProps(self) -> List[THUAI6.Prop]:
  15. pass
  16. @abstractmethod
  17. def GetSelfInfo(self) -> Union[THUAI6.Student, THUAI6.Tricker]:
  18. pass
  19. @abstractmethod
  20. def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
  21. pass
  22. @abstractmethod
  23. def GetPlaceType(self, x: int, y: int) -> THUAI6.PlaceType:
  24. pass
  25. @abstractmethod
  26. def GetClassroomProgress(self, x: int, y: int) -> int:
  27. pass
  28. @abstractmethod
  29. def GetChestProgress(self, x: int, y: int) -> int:
  30. pass
  31. @abstractmethod
  32. def GetGateProgress(self, x: int, y: int) -> int:
  33. pass
  34. @abstractmethod
  35. def IsDoorOpen(self, x: int, y: int) -> bool:
  36. pass
  37. @abstractmethod
  38. def GetHiddenGateState(self, x: int, y: int) -> THUAI6.HiddenGateState:
  39. pass
  40. @abstractmethod
  41. def GetDoorProgress(self, x: int, y: int) -> int:
  42. pass
  43. @abstractmethod
  44. def GetGameInfo(self) -> THUAI6.GameInfo:
  45. pass
  46. @abstractmethod
  47. def Move(self, time: int, angle: float) -> bool:
  48. pass
  49. @abstractmethod
  50. def PickProp(self, propType: THUAI6.PropType) -> bool:
  51. pass
  52. @abstractmethod
  53. def UseProp(self, propType: THUAI6.PropType) -> bool:
  54. pass
  55. @abstractmethod
  56. def UseSkill(self, skillID: int) -> bool:
  57. pass
  58. @abstractmethod
  59. def SendMessage(self, toID: int, message: str) -> bool:
  60. pass
  61. @abstractmethod
  62. def HaveMessage(self) -> bool:
  63. pass
  64. @abstractmethod
  65. def GetMessage(self) -> tuple[int, str]:
  66. pass
  67. @abstractmethod
  68. def WaitThread(self) -> bool:
  69. pass
  70. @abstractmethod
  71. def GetCounter(self) -> int:
  72. pass
  73. @abstractmethod
  74. def GetPlayerGUIDs(self) -> List[int]:
  75. pass
  76. @abstractmethod
  77. def Attack(self, angle: float) -> bool:
  78. pass
  79. @abstractmethod
  80. def OpenDoor(self) -> bool:
  81. pass
  82. @abstractmethod
  83. def CloseDoor(self) -> bool:
  84. pass
  85. @abstractmethod
  86. def SkipWindow(self) -> bool:
  87. pass
  88. @abstractmethod
  89. def StartOpenGate(self) -> bool:
  90. pass
  91. @abstractmethod
  92. def StartOpenChest(self) -> bool:
  93. pass
  94. @abstractmethod
  95. def EndAllAction(self) -> bool:
  96. pass
  97. # IStudentAPI使用的接口
  98. @abstractmethod
  99. def Graduate(self) -> bool:
  100. pass
  101. @abstractmethod
  102. def StartLearning(self) -> bool:
  103. pass
  104. @abstractmethod
  105. def StartTreatMate(self, mateID: int) -> bool:
  106. pass
  107. @abstractmethod
  108. def StartRescueMate(self, mateID: int) -> bool:
  109. pass
  110. class IAPI(metaclass=ABCMeta):
  111. # 选手可执行的操作
  112. # 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴
  113. @abstractmethod
  114. def Move(self, timeInMilliseconds: int, angle: float) -> Future[bool]:
  115. pass
  116. # 向特定方向移动
  117. @abstractmethod
  118. def MoveRight(self, timeInMilliseconds: int) -> Future[bool]:
  119. pass
  120. @abstractmethod
  121. def MoveLeft(self, timeInMilliseconds: int) -> Future[bool]:
  122. pass
  123. @abstractmethod
  124. def MoveUp(self, timeInMilliseconds: int) -> Future[bool]:
  125. pass
  126. @abstractmethod
  127. def MoveDown(self, timeInMilliseconds: int) -> Future[bool]:
  128. pass
  129. # 道具和技能相关
  130. @abstractmethod
  131. def PickProp(self, propType: THUAI6.PropType) -> Future[bool]:
  132. pass
  133. @abstractmethod
  134. def UseProp(self, propType: THUAI6.PropType) -> Future[bool]:
  135. pass
  136. @abstractmethod
  137. def UseSkill(self, skillID: int) -> Future[bool]:
  138. pass
  139. @abstractmethod
  140. def Attack(self, angle: float) -> Future[bool]:
  141. pass
  142. @abstractmethod
  143. def OpenDoor(self) -> Future[bool]:
  144. pass
  145. @abstractmethod
  146. def CloseDoor(self) -> Future[bool]:
  147. pass
  148. @abstractmethod
  149. def SkipWindow(self) -> Future[bool]:
  150. pass
  151. @abstractmethod
  152. def StartOpenGate(self) -> Future[bool]:
  153. pass
  154. @abstractmethod
  155. def StartOpenChest(self) -> Future[bool]:
  156. pass
  157. @abstractmethod
  158. def EndAllAction(self) -> Future[bool]:
  159. pass
  160. # 消息相关,接收消息时无消息则返回(-1, '')
  161. @abstractmethod
  162. def SendMessage(self, toID: int, message: str) -> Future[bool]:
  163. pass
  164. @abstractmethod
  165. def HaveMessage(self) -> Future[bool]:
  166. pass
  167. @abstractmethod
  168. def GetMessage(self) -> Future[tuple[int, str]]:
  169. pass
  170. # 等待下一帧
  171. @abstractmethod
  172. def Wait(self) -> Future[bool]:
  173. pass
  174. # 获取各类游戏中的消息
  175. @abstractmethod
  176. def GetFrameCount(self) -> int:
  177. pass
  178. @abstractmethod
  179. def GetPlayerGUIDs(self) -> List[int]:
  180. pass
  181. @abstractmethod
  182. def GetTrickers(self) -> List[THUAI6.Tricker]:
  183. pass
  184. @abstractmethod
  185. def GetStudents(self) -> List[THUAI6.Student]:
  186. pass
  187. @abstractmethod
  188. def GetProps(self) -> List[THUAI6.Prop]:
  189. pass
  190. @abstractmethod
  191. def GetSelfInfo(self) -> Union[THUAI6.Student, THUAI6.Tricker]:
  192. pass
  193. @abstractmethod
  194. def GetFullMap(self) -> List[List[THUAI6.PlaceType]]:
  195. pass
  196. @abstractmethod
  197. def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType:
  198. pass
  199. @abstractmethod
  200. def IsDoorOpen(self, cellX: int, cellY: int) -> bool:
  201. pass
  202. @abstractmethod
  203. def GetChestProgress(self, cellX: int, cellY: int) -> int:
  204. pass
  205. @abstractmethod
  206. def GetGateProgress(self, cellX: int, cellY: int) -> int:
  207. pass
  208. @abstractmethod
  209. def GetClassroomProgress(self, cellX: int, cellY: int) -> int:
  210. pass
  211. @abstractmethod
  212. def GetDoorProgress(self, cellX: int, cellY: int) -> int:
  213. pass
  214. @abstractmethod
  215. def GetHiddenGateState(self, cellX: int, cellY: int) -> THUAI6.HiddenGateState:
  216. pass
  217. @abstractmethod
  218. def GetGameInfo(self) -> THUAI6.GameInfo:
  219. pass
  220. # 用于DEBUG的输出函数,仅在DEBUG模式下有效
  221. @abstractmethod
  222. def PrintStudent(self) -> None:
  223. pass
  224. @abstractmethod
  225. def PrintTricker(self) -> None:
  226. pass
  227. @abstractmethod
  228. def PrintProp(self) -> None:
  229. pass
  230. @abstractmethod
  231. def PrintSelfInfo(self) -> None:
  232. pass
  233. class IStudentAPI(IAPI, metaclass=ABCMeta):
  234. # 人类阵营的特殊函数
  235. @abstractmethod
  236. def Graduate(self) -> Future[bool]:
  237. pass
  238. @abstractmethod
  239. def StartLearning(self) -> Future[bool]:
  240. pass
  241. @abstractmethod
  242. def StartTreatMate(self, mateID: int) -> Future[bool]:
  243. pass
  244. @abstractmethod
  245. def StartRescueMate(self, mateID: int) -> Future[bool]:
  246. pass
  247. @abstractmethod
  248. def GetSelfInfo(self) -> THUAI6.Student:
  249. pass
  250. class ITrickerAPI(IAPI, metaclass=ABCMeta):
  251. # 屠夫阵营的特殊函数
  252. @abstractmethod
  253. def GetSelfInfo(self) -> THUAI6.Tricker:
  254. pass
  255. class IAI(metaclass=ABCMeta):
  256. @abstractmethod
  257. def StudentPlay(self, api: IStudentAPI) -> None:
  258. pass
  259. @abstractmethod
  260. def TrickerPlay(self, api: ITrickerAPI) -> None:
  261. pass
  262. class IGameTimer(metaclass=ABCMeta):
  263. # 用于计时的接口
  264. @abstractmethod
  265. def StartTimer(self) -> None:
  266. pass
  267. @abstractmethod
  268. def EndTimer(self) -> None:
  269. pass
  270. @abstractmethod
  271. def Play(self, ai: IAI) -> None:
  272. pass
  273. class IErrorHandler(metaclass=ABCMeta):
  274. @staticmethod
  275. @abstractmethod
  276. def result():
  277. pass