coop.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. package msg
  2. import "leafstalk/covenant/model"
  3. // 随机匹配 c->s
  4. type RandMatch struct {
  5. PlayerId int64 `json:"userId"`
  6. LevelId int64 `json:"levelId"`
  7. Level int64 `json:"level"`
  8. }
  9. type ResponseRandMatch struct {
  10. ErrCode int `json:"errCode"`
  11. Msg string `json:"msg,omitempty"`
  12. Data int64 `json:"data"` //0:成功 1:已匹配
  13. PlayerId int64 `json:"userId,omitempty"`
  14. }
  15. // 心跳检测 c->s
  16. type MatchHeartBeat struct {
  17. PlayerId int64 `json:"userId"`
  18. }
  19. type ResponseMatchHeartBeat struct {
  20. ErrCode int `json:"errCode"`
  21. Msg string `json:"msg,omitempty"`
  22. Data int64 `json:"data"` //0:正在匹配 1:非匹配状态
  23. }
  24. // 取消匹配 c->s
  25. type CancleMatch struct {
  26. PlayerId int64 `json:"userId"`
  27. }
  28. type ResponseCancleMatch struct {
  29. ErrCode int `json:"errCode"`
  30. Msg string `json:"msg,omitempty"`
  31. Data int64 `json:"data"`
  32. PlayerId int64 `json:"userId,omitempty"`
  33. }
  34. // 匹配确认与状态检查 s->s
  35. // 体力是否够, 是否正在匹配 是否已解锁
  36. type MatchSure struct {
  37. PublishMsg
  38. // RpcRequestMsg
  39. PlayerId int64 `json:"userId"`
  40. LevelId int64 `json:"levelId"`
  41. }
  42. // 返回战斗装备
  43. type ResponseMatchSure struct {
  44. RpcResponseMsg
  45. PlayerId int64 `json:"userId"`
  46. Data *model.EnterChapterDataItem `json:"data"`
  47. // ErrCode int64 `json:"errCode"` //0:正在匹配 2:取消匹配 3:在战斗中
  48. }
  49. // 匹配失败通知
  50. type MatchFailNotify struct {
  51. PublishMsg
  52. PlayerId int64 `json:"userId"`
  53. LevelId int64 `json:"levelId"`
  54. Step int64 `json:"step"`
  55. Reason int64 `json:"reason"`
  56. }
  57. // 删除房间
  58. type GameSyncDelRoom struct {
  59. PlayerId int64 `json:"userId"`
  60. SyncRoomId int64 `json:"syncRoomId,string"`
  61. }
  62. type ResponseGameSyncDelRoom struct {
  63. ErrCode int `json:"errCode"`
  64. Msg string `json:"msg,omitempty"`
  65. Data int64 `json:"data"`
  66. }
  67. type GameSyncDelRoomIs struct {
  68. PlayerId int64 `json:"userId"`
  69. SyncRoomId int64 `json:"syncRoomId,string"`
  70. }
  71. // 匹配状态查询 s->c
  72. type QueryMatchStatus struct {
  73. ErrCode int `json:"errCode"`
  74. Msg string `json:"msg,omitempty"`
  75. Data int64 `json:"data"`
  76. }
  77. // c ->s
  78. type ResponseQueryMatchStatus struct {
  79. PlayerId int64 `json:"userId"`
  80. MatchState int64 `json:"matchState"`
  81. }
  82. type QueryMatchStatusResult struct {
  83. PlayerId int64 `json:"userId"`
  84. Status int64 `json:"status"` //1:正在匹配 2:取消匹配 3:在战斗中
  85. }
  86. // 通知服务器扣除体力 s->s
  87. type MatchSucess struct {
  88. PublishMsg
  89. // RpcRequestMsg
  90. PlayerId int64 `json:"userId"`
  91. LevelId int64 `json:"levelId"`
  92. }
  93. // 返回房间id
  94. type ResponseMatchSucess struct {
  95. RpcResponseMsg
  96. PlayerId int64 `json:"userId"`
  97. // ErrCode int64 `json:"errCode"` //0:成功 1:失败
  98. }
  99. // 告诉同步服务器创建房间
  100. type CreateRoom struct {
  101. RpcRequest
  102. PlayerIds []int64 `json:"userIds"`
  103. }
  104. type ResponseCreateRoom struct {
  105. RpcResponse
  106. }
  107. // 告诉客户端进入房间
  108. // 附带双方装备 s->s->c
  109. type EnterRoomIs struct {
  110. PublishMsg
  111. PlayerId int64 `json:"userId"`
  112. Data *model.EnterRoomData `json:"data"`
  113. }
  114. type EnterRoom struct {
  115. ErrCode int `json:"errCode"`
  116. Msg string `json:"msg,omitempty"`
  117. Data *model.EnterRoomData `json:"data"`
  118. }
  119. // type EnterRoomData struct {
  120. // SyncRoomId int64 `json:"syncRoomId,string"`
  121. // Seed int64 `json:"seed"`
  122. // LevelId int64 `json:"chapterId"`
  123. // Players []*model.EnterChapterDataItem `json:"players"`
  124. // GameSyncAddr string `json:"gameSyncAddr"`
  125. // }
  126. // 玩家状态上报
  127. type ReportStatus struct {
  128. }
  129. type PublishMsger interface {
  130. SetPublisher(string)
  131. }
  132. type PublishMsg struct {
  133. Publisher string `json:"publisher"`
  134. }
  135. func (pm *PublishMsg) SetPublisher(publisher string) {
  136. pm.Publisher = publisher
  137. }
  138. // 创建邀请代码 c->s
  139. type CreateCoopTeam struct {
  140. PlayerId int64 `json:"userId"`
  141. LevelId int64 `json:"levelId"`
  142. Level int64 `json:"level"`
  143. }
  144. type ResponseCreateCoopTeam struct {
  145. ErrCode int `json:"errCode"`
  146. Msg string `json:"msg,omitempty"`
  147. Data string `json:"data"` // 邀请码
  148. PlayerId int64 `json:"userId,omitempty"`
  149. }
  150. // 加入队伍
  151. type JoinCoopTeam struct {
  152. PlayerId int64 `json:"userId"`
  153. InviteCode string `json:"inviteCode"`
  154. }
  155. type ResponseJoinCoopTeam struct {
  156. ErrCode int `json:"errCode"` //1:状态错误 2:队伍已开始或已解散
  157. Msg string `json:"msg,omitempty"`
  158. Data string `json:"data"` // 邀请码
  159. PlayerId int64 `json:"userId,omitempty"` //客户端不用
  160. }
  161. // 玩家退出
  162. type PlayerExit struct {
  163. PlayerIds []int64 `json:"userIds"`
  164. }
  165. // 查询队伍是否存在
  166. // type QueryCoopTeamExist struct {
  167. // PlayerId int64 `json:"userId"`
  168. // InviteCodes []string `json:"inviteCodes"`
  169. // }
  170. // type ResponseQueryCoopTeamExist struct {
  171. // ErrCode int `json:"errCode"`
  172. // Msg string `json:"msg,omitempty"`
  173. // Data QueryCoopTeamExistData `json:"data"` // 邀请码
  174. // PlayerId int64 `json:"userId,omitempty"` //客户端不用
  175. // }
  176. // type QueryCoopTeamExistData struct {
  177. // Founds []string `json:"founds"` // 存在
  178. // NoFounds []string `json:"noFounds"` // 不存在
  179. // }
  180. // // 请求加入队伍
  181. // type RequestJoinTeamIs struct {
  182. // PublishMsg
  183. // PlayerId int64 `json:"userId"`
  184. // InviteCode string `json:"inviteCode"`
  185. // }
  186. // // 返回房间id
  187. // type ResponseRequestJoinTeamIs struct {
  188. // PlayerId int64 `json:"userId"`
  189. // ErrCode int64 `json:"errCode"` //0:成功 1:失败
  190. // }