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

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