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 8.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. Door = 8,
  30. Chest = 9,
  31. };
  32. // 形状标志
  33. enum class ShapeType : unsigned char
  34. {
  35. NullShapeType = 0,
  36. Circle = 1,
  37. Square = 2,
  38. };
  39. // 道具类型
  40. enum class PropType : unsigned char
  41. {
  42. NullPropType = 0,
  43. PropType1 = 1,
  44. PropType2 = 2,
  45. PropType3 = 3,
  46. PropType4 = 4,
  47. };
  48. enum class BulletType : unsigned char
  49. {
  50. NullBulletType = 0,
  51. LineBullet = 1,
  52. CommonBullet = 2,
  53. FastBullet = 3,
  54. OrdinaryBullet = 4,
  55. AtomBomb = 5,
  56. };
  57. // 玩家类型
  58. enum class PlayerType : unsigned char
  59. {
  60. NullPlayerType = 0,
  61. StudentPlayer = 1,
  62. TrickerPlayer = 2,
  63. };
  64. // 学生类型
  65. enum class StudentType : unsigned char
  66. {
  67. NullStudentType = 0,
  68. StudentType1 = 1,
  69. StudentType2 = 2,
  70. StudentType3 = 3,
  71. StudentType4 = 4,
  72. };
  73. // 捣蛋鬼类型
  74. enum class TrickerType : unsigned char
  75. {
  76. NullTrickerType = 0,
  77. TrickerType1 = 1,
  78. TrickerType2 = 2,
  79. TrickerType3 = 3,
  80. TrickerType4 = 4,
  81. };
  82. // 学生Buff类型
  83. enum class StudentBuffType : unsigned char
  84. {
  85. NullStudentBuffType = 0,
  86. StudentBuffType1 = 1,
  87. StudentBuffType2 = 2,
  88. StudentBuffType3 = 3,
  89. StudentBuffType4 = 4,
  90. };
  91. enum class TrickerBuffType : unsigned char
  92. {
  93. NullTrickerBuffType = 0,
  94. TrickerBuffType1 = 1,
  95. TrickerBuffType2 = 2,
  96. TrickerBuffType3 = 3,
  97. TrickerBuffType4 = 4,
  98. };
  99. // 学生状态枚举
  100. enum class PlayerState : unsigned char
  101. {
  102. NullState = 0,
  103. Idle = 1,
  104. Learning = 2,
  105. Addicted = 3,
  106. Quit = 4,
  107. Graduated = 5,
  108. Treated = 6,
  109. Rescued = 7,
  110. Stunned = 8,
  111. Treating = 9,
  112. Rescuing = 10,
  113. Swinging = 11,
  114. Attacking = 12,
  115. Locking = 13,
  116. Rummaging = 14,
  117. Climbing = 15,
  118. };
  119. enum class MessageOfObj : unsigned char
  120. {
  121. NullMessageOfObj = 0,
  122. StudentMessage = 1,
  123. TrickerMessage = 2,
  124. PropMessage = 3,
  125. BulletMessage = 4,
  126. BombedBulletMessage = 5,
  127. };
  128. enum class MessageOfMapObj : unsigned char
  129. {
  130. NullMessageOfMapObj = 0,
  131. ClassroomMessage = 1,
  132. DoorMessage = 2,
  133. GateMessage = 3,
  134. ChestMessage = 4,
  135. };
  136. // 玩家类
  137. struct Player
  138. {
  139. int32_t x; // x坐标
  140. int32_t y; // y坐标
  141. int32_t speed; // 移动速度
  142. int32_t viewRange; // 视野范围
  143. int64_t playerID; // 玩家ID
  144. int64_t guid; // 全局唯一ID
  145. int16_t radius; // 圆形物体的半径或正方形物体的内切圆半径
  146. int32_t damage; // 攻击伤害
  147. double timeUntilSkillAvailable; // 技能冷却时间
  148. PlayerType playerType; // 玩家类型
  149. std::vector<PropType> props;
  150. PlaceType place; // 所处格子的类型
  151. PlayerState playerState;
  152. };
  153. struct Student : public Player
  154. {
  155. StudentType studentType;
  156. int32_t determination; // 剩余毅力(本次Emo之前还能承受的伤害)
  157. int32_t failNum; // 挂科数量
  158. double failTime; // 挂科时间
  159. double emoTime; // EMO时间
  160. std::vector<StudentBuffType> buff; // buff
  161. };
  162. struct Tricker : public Player
  163. {
  164. TrickerType trickerType; // 捣蛋鬼类型
  165. std::vector<TrickerBuffType> buff; // buff
  166. };
  167. struct Bullet
  168. {
  169. BulletType bulletType; // 子弹类型
  170. int32_t x; // x坐标
  171. int32_t y; // y坐标
  172. double facingDirection; // 朝向
  173. int64_t guid; // 全局唯一ID
  174. PlayerType team; // 子弹所属队伍
  175. PlaceType place; // 所处格子的类型
  176. double bombRange; // 炸弹爆炸范围
  177. };
  178. struct BombedBullet
  179. {
  180. BulletType bulletType;
  181. int32_t x;
  182. int32_t y;
  183. double facingDirection;
  184. int64_t mappingID;
  185. double bombRange;
  186. };
  187. struct Prop
  188. {
  189. int32_t x;
  190. int32_t y;
  191. int32_t size;
  192. int64_t guid;
  193. PropType type;
  194. PlaceType place;
  195. double facingDirection; // 朝向
  196. bool isMoving;
  197. };
  198. struct GameMap
  199. {
  200. std::vector<std::vector<PlaceType>> gameMap;
  201. std::map<std::pair<int32_t, int32_t>, int32_t> classRoomState;
  202. std::map<std::pair<int32_t, int32_t>, int32_t> gateState;
  203. std::map<std::pair<int32_t, int32_t>, bool> doorState;
  204. std::map<std::pair<int32_t, int32_t>, int32_t> chestState;
  205. };
  206. struct GameInfo
  207. {
  208. int32_t gameTime;
  209. int32_t subjectLeft;
  210. int32_t studentGraduated;
  211. int32_t studentQuited;
  212. int32_t studentScore;
  213. int32_t trickerScore;
  214. bool gateOpened;
  215. bool hiddenGateRefreshed;
  216. bool hiddenGateOpened;
  217. };
  218. // 仅供DEBUG使用,名称可改动
  219. // 还没写完,后面待续
  220. inline std::map<GameState, std::string> gameStateDict{
  221. {GameState::NullGameState, "NullGameState"},
  222. {GameState::GameStart, "GameStart"},
  223. {GameState::GameRunning, "GameRunning"},
  224. {GameState::GameEnd, "GameEnd"},
  225. };
  226. inline std::map<PlayerState, std::string> playerStateDict{
  227. {PlayerState::NullState, "NullState"},
  228. {PlayerState::Idle, "Idle"},
  229. {PlayerState::Learning, "Learning"},
  230. {PlayerState::Addicted, "Addicted"},
  231. {PlayerState::Quit, "Quit"},
  232. {PlayerState::Graduated, "Graduated"},
  233. {PlayerState::Treated, "Treated"},
  234. {PlayerState::Rescued, "Rescued"},
  235. {PlayerState::Stunned, "Stunned"},
  236. {PlayerState::Treating, "Treating"},
  237. {PlayerState::Rescuing, "Rescuing"},
  238. {PlayerState::Swinging, "Swinging"},
  239. {PlayerState::Attacking, "Attacking"},
  240. {PlayerState::Locking, "Locking"},
  241. {PlayerState::Rummaging, "Rummaging"},
  242. {PlayerState::Climbing, "Climbing"},
  243. };
  244. inline std::map<PlayerType, std::string> playerTypeDict{
  245. {PlayerType::NullPlayerType, "NullPlayerType"},
  246. {PlayerType::StudentPlayer, "StudentPlayer"},
  247. {PlayerType::TrickerPlayer, "TrickerPlayer"},
  248. };
  249. inline std::map<PlaceType, std::string> placeTypeDict{
  250. {PlaceType::NullPlaceType, "NullPlaceType"},
  251. {PlaceType::Land, "Land"},
  252. {PlaceType::Wall, "Wall"},
  253. {PlaceType::Grass, "Grass"},
  254. {PlaceType::ClassRoom, "ClassRoom"},
  255. {PlaceType::Gate, "Gate"},
  256. {PlaceType::HiddenGate, "HiddenGate"},
  257. {PlaceType::Door, "Door"},
  258. {PlaceType::Window, "Window"},
  259. {PlaceType::Chest, "Chest"},
  260. };
  261. inline std::map<PropType, std::string> propTypeDict{
  262. {PropType::NullPropType, "NullPropType"},
  263. };
  264. inline std::map<StudentBuffType, std::string> studentBuffDict{
  265. {StudentBuffType::NullStudentBuffType, "NullStudentBuffType"},
  266. };
  267. inline std::map<TrickerBuffType, std::string> trickerBuffDict{
  268. {TrickerBuffType::NullTrickerBuffType, "NullTrickerBuffType"},
  269. };
  270. inline std::map<MessageOfObj, std::string> messageOfObjDict{
  271. {MessageOfObj::NullMessageOfObj, "NullMessageOfObj"},
  272. {MessageOfObj::StudentMessage, "StudentMessage"},
  273. {MessageOfObj::TrickerMessage, "TrickerMessage"},
  274. {MessageOfObj::PropMessage, "PropMessage"},
  275. {MessageOfObj::BulletMessage, "BulletMessage"},
  276. {MessageOfObj::BombedBulletMessage, "BombedBulletMessage"},
  277. };
  278. inline std::map<MessageOfMapObj, std::string> messageOfMapObjDict{
  279. {MessageOfMapObj::NullMessageOfMapObj, "NullMessageOfMapObj"},
  280. {MessageOfMapObj::ClassroomMessage, "ClassroomMessage"},
  281. {MessageOfMapObj::DoorMessage, "DoorMessage"},
  282. {MessageOfMapObj::GateMessage, "GateMessage"},
  283. {MessageOfMapObj::ChestMessage, "ChestMessage"},
  284. };
  285. } // namespace THUAI6
  286. #endif