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.

structures.h 10 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. #pragma once
  2. #ifndef STRUCTURES_H
  3. #define STRUCTURES_H
  4. #include <cstdint>
  5. #include <array>
  6. #include <map>
  7. namespace THUAI6
  8. {
  9. // 游戏状态
  10. enum class GameState : unsigned char
  11. {
  12. NullGameState = 0,
  13. GameStart = 1,
  14. GameRunning = 2,
  15. GameEnd = 3,
  16. };
  17. // 所有NullXXXType均为错误类型,其余为可能出现的正常类型
  18. // 位置标志
  19. enum class PlaceType : unsigned char
  20. {
  21. NullPlaceType = 0,
  22. Land = 1,
  23. Wall = 2,
  24. Grass = 3,
  25. ClassRoom = 4,
  26. Gate = 5,
  27. HiddenGate = 6,
  28. Window = 7,
  29. Door3 = 8,
  30. Door5 = 9,
  31. Door6 = 10,
  32. Chest = 11,
  33. };
  34. // 形状标志
  35. enum class ShapeType : unsigned char
  36. {
  37. NullShapeType = 0,
  38. Circle = 1,
  39. Square = 2,
  40. };
  41. // 道具类型
  42. enum class PropType : unsigned char
  43. {
  44. NullPropType = 0,
  45. Key3 = 1,
  46. Key5 = 2,
  47. Key6 = 3,
  48. PropType4 = 4,
  49. };
  50. enum class BulletType : unsigned char
  51. {
  52. NullBulletType = 0,
  53. FlyingKnife = 1,
  54. CommonAttackOfTricker = 2,
  55. FastBullet = 3,
  56. OrdinaryBullet = 4,
  57. AtomBomb = 5,
  58. };
  59. // 玩家类型
  60. enum class PlayerType : unsigned char
  61. {
  62. NullPlayerType = 0,
  63. StudentPlayer = 1,
  64. TrickerPlayer = 2,
  65. };
  66. // 学生类型
  67. enum class StudentType : unsigned char
  68. {
  69. NullStudentType = 0,
  70. Athlete = 1,
  71. StudentType2 = 2,
  72. StudentType3 = 3,
  73. StudentType4 = 4,
  74. };
  75. // 捣蛋鬼类型
  76. enum class TrickerType : unsigned char
  77. {
  78. NullTrickerType = 0,
  79. Assassin = 1,
  80. TrickerType2 = 2,
  81. TrickerType3 = 3,
  82. TrickerType4 = 4,
  83. };
  84. // 学生Buff类型
  85. enum class StudentBuffType : unsigned char
  86. {
  87. NullStudentBuffType = 0,
  88. StudentBuffType1 = 1,
  89. StudentBuffType2 = 2,
  90. StudentBuffType3 = 3,
  91. StudentBuffType4 = 4,
  92. };
  93. enum class TrickerBuffType : unsigned char
  94. {
  95. NullTrickerBuffType = 0,
  96. TrickerBuffType1 = 1,
  97. TrickerBuffType2 = 2,
  98. TrickerBuffType3 = 3,
  99. TrickerBuffType4 = 4,
  100. };
  101. // 学生状态枚举
  102. enum class PlayerState : unsigned char
  103. {
  104. NullState = 0,
  105. Idle = 1,
  106. Learning = 2,
  107. Addicted = 3,
  108. Quit = 4,
  109. Graduated = 5,
  110. Treated = 6,
  111. Rescued = 7,
  112. Stunned = 8,
  113. Treating = 9,
  114. Rescuing = 10,
  115. Swinging = 11,
  116. Attacking = 12,
  117. Locking = 13,
  118. Rummaging = 14,
  119. Climbing = 15,
  120. OpeningAChest = 16,
  121. UsingSpecialSkill = 17,
  122. OpeningAGate = 18,
  123. };
  124. enum class MessageOfObj : unsigned char
  125. {
  126. NullMessageOfObj = 0,
  127. StudentMessage = 1,
  128. TrickerMessage = 2,
  129. PropMessage = 3,
  130. BulletMessage = 4,
  131. BombedBulletMessage = 5,
  132. ClassroomMessage = 6,
  133. DoorMessage = 7,
  134. GateMessage = 8,
  135. ChestMessage = 9,
  136. MapMessage = 10,
  137. NewsMessage = 11,
  138. HiddenGateMessage = 12,
  139. };
  140. enum class HiddenGateState : unsigned char
  141. {
  142. Null = 0,
  143. Refreshed = 1,
  144. Opened = 2,
  145. };
  146. // 玩家类
  147. struct Player
  148. {
  149. int32_t x; // x坐标
  150. int32_t y; // y坐标
  151. int32_t speed; // 移动速度
  152. int32_t viewRange; // 视野范围
  153. int64_t playerID; // 玩家ID
  154. int64_t guid; // 全局唯一ID
  155. int16_t radius; // 圆形物体的半径或正方形物体的内切圆半径
  156. int32_t score; // 分数
  157. double facingDirection; // 朝向
  158. std::vector<double> timeUntilSkillAvailable; // 技能冷却时间
  159. PlayerType playerType; // 玩家类型
  160. std::vector<PropType> props;
  161. PlaceType place; // 所处格子的类型
  162. BulletType bulletType;
  163. PlayerState playerState;
  164. };
  165. struct Student : public Player
  166. {
  167. StudentType studentType;
  168. int32_t determination; // 剩余毅力
  169. int32_t addiction; // 沉迷程度
  170. int32_t learningSpeed;
  171. int32_t treatSpeed;
  172. int32_t treatProgress;
  173. int32_t rescueProgress;
  174. double dangerAlert;
  175. std::vector<StudentBuffType> buff; // buff
  176. };
  177. struct Tricker : public Player
  178. {
  179. double trickDesire;
  180. double classVolume;
  181. TrickerType trickerType; // 捣蛋鬼类型
  182. std::vector<TrickerBuffType> buff; // buff
  183. };
  184. struct Bullet
  185. {
  186. BulletType bulletType; // 子弹类型
  187. int32_t x; // x坐标
  188. int32_t y; // y坐标
  189. double facingDirection; // 朝向
  190. int64_t guid; // 全局唯一ID
  191. PlayerType team; // 子弹所属队伍
  192. PlaceType place; // 所处格子的类型
  193. double bombRange; // 炸弹爆炸范围
  194. int32_t speed; // 子弹速度
  195. };
  196. struct BombedBullet
  197. {
  198. BulletType bulletType;
  199. int32_t x;
  200. int32_t y;
  201. double facingDirection;
  202. int64_t mappingID;
  203. double bombRange;
  204. };
  205. struct Prop
  206. {
  207. int32_t x;
  208. int32_t y;
  209. int64_t guid;
  210. PropType type;
  211. PlaceType place;
  212. double facingDirection; // 朝向
  213. };
  214. struct GameMap
  215. {
  216. std::map<std::pair<int32_t, int32_t>, int32_t> classRoomState;
  217. std::map<std::pair<int32_t, int32_t>, int32_t> gateState;
  218. std::map<std::pair<int32_t, int32_t>, bool> doorState;
  219. std::map<std::pair<int32_t, int32_t>, int32_t> doorProgress;
  220. std::map<std::pair<int32_t, int32_t>, int32_t> chestState;
  221. std::map<std::pair<int32_t, int32_t>, HiddenGateState> hiddenGateState;
  222. };
  223. struct GameInfo
  224. {
  225. int32_t gameTime;
  226. int32_t subjectLeft;
  227. int32_t studentGraduated;
  228. int32_t studentQuited;
  229. int32_t studentScore;
  230. int32_t trickerScore;
  231. bool gateOpened;
  232. bool hiddenGateRefreshed;
  233. bool hiddenGateOpened;
  234. };
  235. // 仅供DEBUG使用,名称可改动
  236. // 还没写完,后面待续
  237. inline std::map<GameState, std::string> gameStateDict{
  238. {GameState::NullGameState, "NullGameState"},
  239. {GameState::GameStart, "GameStart"},
  240. {GameState::GameRunning, "GameRunning"},
  241. {GameState::GameEnd, "GameEnd"},
  242. };
  243. inline std::map<PlayerState, std::string> playerStateDict{
  244. {PlayerState::NullState, "NullState"},
  245. {PlayerState::Idle, "Idle"},
  246. {PlayerState::Learning, "Learning"},
  247. {PlayerState::Addicted, "Addicted"},
  248. {PlayerState::Quit, "Quit"},
  249. {PlayerState::Graduated, "Graduated"},
  250. {PlayerState::Treated, "Treated"},
  251. {PlayerState::Rescued, "Rescued"},
  252. {PlayerState::Stunned, "Stunned"},
  253. {PlayerState::Treating, "Treating"},
  254. {PlayerState::Rescuing, "Rescuing"},
  255. {PlayerState::Swinging, "Swinging"},
  256. {PlayerState::Attacking, "Attacking"},
  257. {PlayerState::Locking, "Locking"},
  258. {PlayerState::Rummaging, "Rummaging"},
  259. {PlayerState::Climbing, "Climbing"},
  260. {PlayerState::OpeningAChest, "OpeningAChest"},
  261. {PlayerState::UsingSpecialSkill, "UsingSpecialSkill"},
  262. {PlayerState::OpeningAGate, "OpeningAGate"},
  263. };
  264. inline std::map<PlayerType, std::string> playerTypeDict{
  265. {PlayerType::NullPlayerType, "NullPlayerType"},
  266. {PlayerType::StudentPlayer, "StudentPlayer"},
  267. {PlayerType::TrickerPlayer, "TrickerPlayer"},
  268. };
  269. inline std::map<PlaceType, std::string> placeTypeDict{
  270. {PlaceType::NullPlaceType, "NullPlaceType"},
  271. {PlaceType::Land, "Land"},
  272. {PlaceType::Wall, "Wall"},
  273. {PlaceType::Grass, "Grass"},
  274. {PlaceType::ClassRoom, "ClassRoom"},
  275. {PlaceType::Gate, "Gate"},
  276. {PlaceType::HiddenGate, "HiddenGate"},
  277. {PlaceType::Door3, "Door3"},
  278. {PlaceType::Door5, "Door5"},
  279. {PlaceType::Door6, "Door6"},
  280. {PlaceType::Window, "Window"},
  281. {PlaceType::Chest, "Chest"},
  282. };
  283. inline std::map<PropType, std::string> propTypeDict{
  284. {PropType::NullPropType, "NullPropType"},
  285. {PropType::Key3, "Key3"},
  286. {PropType::Key5, "Key5"},
  287. {PropType::Key6, "Key6"},
  288. };
  289. inline std::map<BulletType, std::string> bulletTypeDict{
  290. {BulletType::NullBulletType, "NullBulletType"},
  291. {BulletType::FlyingKnife, "FlyingKnife"},
  292. {BulletType::CommonAttackOfTricker, "CommonAttackOfTricker"},
  293. {BulletType::FastBullet, "FastBullet"},
  294. {BulletType::OrdinaryBullet, "OrdinaryBullet"},
  295. {BulletType::AtomBomb, "AtomBomb"},
  296. };
  297. inline std::map<StudentBuffType, std::string> studentBuffDict{
  298. {StudentBuffType::NullStudentBuffType, "NullStudentBuffType"},
  299. };
  300. inline std::map<TrickerBuffType, std::string> trickerBuffDict{
  301. {TrickerBuffType::NullTrickerBuffType, "NullTrickerBuffType"},
  302. };
  303. inline std::map<MessageOfObj, std::string> messageOfObjDict{
  304. {MessageOfObj::NullMessageOfObj, "NullMessageOfObj"},
  305. {MessageOfObj::StudentMessage, "StudentMessage"},
  306. {MessageOfObj::TrickerMessage, "TrickerMessage"},
  307. {MessageOfObj::PropMessage, "PropMessage"},
  308. {MessageOfObj::BulletMessage, "BulletMessage"},
  309. {MessageOfObj::BombedBulletMessage, "BombedBulletMessage"},
  310. {MessageOfObj::NullMessageOfObj, "NullMessageOfObj"},
  311. {MessageOfObj::ClassroomMessage, "ClassroomMessage"},
  312. {MessageOfObj::DoorMessage, "DoorMessage"},
  313. {MessageOfObj::GateMessage, "GateMessage"},
  314. {MessageOfObj::ChestMessage, "ChestMessage"},
  315. {MessageOfObj::MapMessage, "MapMessage"},
  316. {MessageOfObj::NewsMessage, "NewsMessage"},
  317. {MessageOfObj::HiddenGateMessage, "HiddenGateMessage"},
  318. };
  319. } // namespace THUAI6
  320. #endif