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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. ClassroomMessage = 6,
  128. DoorMessage = 7,
  129. GateMessage = 8,
  130. ChestMessage = 9,
  131. MapMessage = 10,
  132. NewsMessage = 11,
  133. HiddenGateMessage = 12,
  134. };
  135. // 玩家类
  136. struct Player
  137. {
  138. int32_t x; // x坐标
  139. int32_t y; // y坐标
  140. int32_t speed; // 移动速度
  141. int32_t viewRange; // 视野范围
  142. int64_t playerID; // 玩家ID
  143. int64_t guid; // 全局唯一ID
  144. int16_t radius; // 圆形物体的半径或正方形物体的内切圆半径
  145. int32_t score; // 分数
  146. double facingDirection; // 朝向
  147. std::vector<double> timeUntilSkillAvailable; // 技能冷却时间
  148. PlayerType playerType; // 玩家类型
  149. std::vector<PropType> props;
  150. PlaceType place; // 所处格子的类型
  151. BulletType bulletType;
  152. PlayerState playerState;
  153. };
  154. struct Student : public Player
  155. {
  156. StudentType studentType;
  157. int32_t determination; // 剩余毅力
  158. int32_t addiction; // 沉迷程度
  159. int32_t learningSpeed;
  160. int32_t treatSpeed;
  161. int32_t treatProgress;
  162. int32_t rescueProgress;
  163. double dangerAlert;
  164. std::vector<StudentBuffType> buff; // buff
  165. };
  166. struct Tricker : public Player
  167. {
  168. int32_t damage;
  169. double trickDesire;
  170. double classVolume;
  171. TrickerType trickerType; // 捣蛋鬼类型
  172. std::vector<TrickerBuffType> buff; // buff
  173. };
  174. struct Bullet
  175. {
  176. BulletType bulletType; // 子弹类型
  177. int32_t x; // x坐标
  178. int32_t y; // y坐标
  179. double facingDirection; // 朝向
  180. int64_t guid; // 全局唯一ID
  181. PlayerType team; // 子弹所属队伍
  182. PlaceType place; // 所处格子的类型
  183. double bombRange; // 炸弹爆炸范围
  184. int32_t speed; // 子弹速度
  185. };
  186. struct BombedBullet
  187. {
  188. BulletType bulletType;
  189. int32_t x;
  190. int32_t y;
  191. double facingDirection;
  192. int64_t mappingID;
  193. double bombRange;
  194. };
  195. struct Prop
  196. {
  197. int32_t x;
  198. int32_t y;
  199. int32_t size;
  200. int64_t guid;
  201. PropType type;
  202. PlaceType place;
  203. double facingDirection; // 朝向
  204. bool isMoving;
  205. };
  206. struct GameMap
  207. {
  208. std::map<std::pair<int32_t, int32_t>, int32_t> classRoomState;
  209. std::map<std::pair<int32_t, int32_t>, int32_t> gateState;
  210. std::map<std::pair<int32_t, int32_t>, bool> doorState;
  211. std::map<std::pair<int32_t, int32_t>, int32_t> doorNumber;
  212. std::map<std::pair<int32_t, int32_t>, int32_t> chestState;
  213. std::map<std::pair<int32_t, int32_t>, bool> hiddenGateState;
  214. };
  215. struct GameInfo
  216. {
  217. int32_t gameTime;
  218. int32_t subjectLeft;
  219. int32_t studentGraduated;
  220. int32_t studentQuited;
  221. int32_t studentScore;
  222. int32_t trickerScore;
  223. bool gateOpened;
  224. bool hiddenGateRefreshed;
  225. bool hiddenGateOpened;
  226. };
  227. // 仅供DEBUG使用,名称可改动
  228. // 还没写完,后面待续
  229. inline std::map<GameState, std::string> gameStateDict{
  230. {GameState::NullGameState, "NullGameState"},
  231. {GameState::GameStart, "GameStart"},
  232. {GameState::GameRunning, "GameRunning"},
  233. {GameState::GameEnd, "GameEnd"},
  234. };
  235. inline std::map<PlayerState, std::string> playerStateDict{
  236. {PlayerState::NullState, "NullState"},
  237. {PlayerState::Idle, "Idle"},
  238. {PlayerState::Learning, "Learning"},
  239. {PlayerState::Addicted, "Addicted"},
  240. {PlayerState::Quit, "Quit"},
  241. {PlayerState::Graduated, "Graduated"},
  242. {PlayerState::Treated, "Treated"},
  243. {PlayerState::Rescued, "Rescued"},
  244. {PlayerState::Stunned, "Stunned"},
  245. {PlayerState::Treating, "Treating"},
  246. {PlayerState::Rescuing, "Rescuing"},
  247. {PlayerState::Swinging, "Swinging"},
  248. {PlayerState::Attacking, "Attacking"},
  249. {PlayerState::Locking, "Locking"},
  250. {PlayerState::Rummaging, "Rummaging"},
  251. {PlayerState::Climbing, "Climbing"},
  252. };
  253. inline std::map<PlayerType, std::string> playerTypeDict{
  254. {PlayerType::NullPlayerType, "NullPlayerType"},
  255. {PlayerType::StudentPlayer, "StudentPlayer"},
  256. {PlayerType::TrickerPlayer, "TrickerPlayer"},
  257. };
  258. inline std::map<PlaceType, std::string> placeTypeDict{
  259. {PlaceType::NullPlaceType, "NullPlaceType"},
  260. {PlaceType::Land, "Land"},
  261. {PlaceType::Wall, "Wall"},
  262. {PlaceType::Grass, "Grass"},
  263. {PlaceType::ClassRoom, "ClassRoom"},
  264. {PlaceType::Gate, "Gate"},
  265. {PlaceType::HiddenGate, "HiddenGate"},
  266. {PlaceType::Door, "Door"},
  267. {PlaceType::Window, "Window"},
  268. {PlaceType::Chest, "Chest"},
  269. };
  270. inline std::map<PropType, std::string> propTypeDict{
  271. {PropType::NullPropType, "NullPropType"},
  272. };
  273. inline std::map<StudentBuffType, std::string> studentBuffDict{
  274. {StudentBuffType::NullStudentBuffType, "NullStudentBuffType"},
  275. };
  276. inline std::map<TrickerBuffType, std::string> trickerBuffDict{
  277. {TrickerBuffType::NullTrickerBuffType, "NullTrickerBuffType"},
  278. };
  279. inline std::map<MessageOfObj, std::string> messageOfObjDict{
  280. {MessageOfObj::NullMessageOfObj, "NullMessageOfObj"},
  281. {MessageOfObj::StudentMessage, "StudentMessage"},
  282. {MessageOfObj::TrickerMessage, "TrickerMessage"},
  283. {MessageOfObj::PropMessage, "PropMessage"},
  284. {MessageOfObj::BulletMessage, "BulletMessage"},
  285. {MessageOfObj::BombedBulletMessage, "BombedBulletMessage"},
  286. {MessageOfObj::NullMessageOfObj, "NullMessageOfObj"},
  287. {MessageOfObj::ClassroomMessage, "ClassroomMessage"},
  288. {MessageOfObj::DoorMessage, "DoorMessage"},
  289. {MessageOfObj::GateMessage, "GateMessage"},
  290. {MessageOfObj::ChestMessage, "ChestMessage"},
  291. {MessageOfObj::MapMessage, "MapMessage"},
  292. {MessageOfObj::NewsMessage, "NewsMessage"},
  293. {MessageOfObj::HiddenGateMessage, "HiddenGateMessage"},
  294. };
  295. } // namespace THUAI6
  296. #endif