This commit is contained in:
aozhiwei 2024-03-13 17:54:41 +08:00
parent ef14af8401
commit a8939e79c8

View File

@ -110,42 +110,51 @@ func (this *team) StartGame() {
if !this.Started() { if !this.Started() {
this.state = constant.TEAM_STATE_STARTED this.state = constant.TEAM_STATE_STARTED
this.startTime = f5.GetApp().GetNowSeconds() this.startTime = f5.GetApp().GetNowSeconds()
startInfo := struct { this.genStartGameInfo()
ZoneId int32 `json:"zone_id"` f5.GetTimer().SetInterval(1000, func(e int32, args *q5.Args) {
NodeId int32 `json:"node_id"` if e == q5.TIMER_EXEC_EVENT {
MapId int32 `json:"map"` this.SendStateNotify()
RoomUuid string `json:"room_uuid"` }
StartTime int32 `json:"start_time"` })
TeamList []struct { }
TeamUuid string `json:"team_uuid"` }
Members []struct {
AccountId string `json:"account_id"` func (this *team) genStartGameInfo() {
} `json:"members"` startInfo := struct {
} `json:"team_list"` ZoneId int32 `json:"zone_id"`
ObList []struct { NodeId int32 `json:"node_id"`
MapId int32 `json:"map"`
RoomUuid string `json:"room_uuid"`
StartTime int32 `json:"start_time"`
TeamList []struct {
TeamUuid string `json:"team_uuid"`
Members []struct {
AccountId string `json:"account_id"` AccountId string `json:"account_id"`
} `json:"ob_list"` } `json:"members"`
} { } `json:"team_list"`
ZoneId: this.GetZoneId(), ObList []struct {
AccountId string `json:"account_id"`
} `json:"ob_list"`
} {
ZoneId: this.GetZoneId(),
NodeId: this.GetNodeId(), NodeId: this.GetNodeId(),
MapId: this.mapId, MapId: this.mapId,
RoomUuid: q5.ToString(this.GetTeamUuid()), RoomUuid: q5.ToString(this.GetTeamUuid()),
StartTime: int32(this.startTime), StartTime: int32(this.startTime),
} }
{ {
q5.NewSlice(&startInfo.TeamList, 0, 10) q5.NewSlice(&startInfo.TeamList, 0, 10)
ele := q5.NewSliceElement(&startInfo.TeamList) ele := q5.NewSliceElement(&startInfo.TeamList)
ele.TeamUuid = this.GetTeamUuid() ele.TeamUuid = this.GetTeamUuid()
for _, m := range this.accountIdHash { for _, m := range this.accountIdHash {
ele2 := q5.NewSliceElement(&ele.Members) ele2 := q5.NewSliceElement(&ele.Members)
ele2.AccountId = m.GetAccountId() ele2.AccountId = m.GetAccountId()
}
} }
sign := q5.Md5Str(q5.EncodeJson(&startInfo) + "520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)")
payload := "normal_room:" + sign + "|" + q5.EncodeJson(&startInfo)
this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.GetTeamUuid())
this.stateNotifyMsg.JoinMsg.Payload = proto.String(payload)
} }
sign := q5.Md5Str(q5.EncodeJson(&startInfo) + "520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)")
payload := "normal_room:" + sign + "|" + q5.EncodeJson(&startInfo)
this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.GetTeamUuid())
this.stateNotifyMsg.JoinMsg.Payload = proto.String(payload)
} }
func (this *team) broadcastMsg(msg proto.Message) { func (this *team) broadcastMsg(msg proto.Message) {