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.6 kB

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