From 2a633f92567bacd2d3d934deb7514e3955ef4c9a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 1 Nov 2023 14:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E6=97=B6=E8=B5=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 7694150d9..329d85e7a 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -15,8 +15,6 @@ import ( const ( MaxPs = 2 // 最大体力 - //MaxRound = 7 // 最大回合数 - MaxTime = 1800 // 游戏操作时间 ) //游戏房间 @@ -36,6 +34,7 @@ type Room struct { rd2 bool // 玩家2 是否准备 Status int32 //房间游戏状态 0未开始 1 已开始 2 已结束 RoomType int32 // 房间类型 1 是好友创房 + MaxTime int32 // 操作时间 } func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) { @@ -56,7 +55,7 @@ func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) { if this.operatetimer != nil { timewheel.Remove(this.operatetimer) } // 回合+1 - this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut) // 开启新的定时器 + this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut) // 开启新的定时器 } } @@ -375,7 +374,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.round++ if this.operatetimer != nil { timewheel.Remove(this.operatetimer) - this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut) // 开启新的定时器 + this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut) // 开启新的定时器 } } } @@ -449,6 +448,12 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } } if bStartGame { + // 初始化规则相关 + if len(this.szSession) == 1 { + this.MaxTime = this.module.ModuleTools.GetGlobalConf().ConsumePveTime + } else { + this.MaxTime = this.module.ModuleTools.GetGlobalConf().ConsumePvpTime + } var weight []int32 // 权重 // 开始随机玩法 list := this.module.configure.GetGameConsumeIntegral() @@ -470,8 +475,9 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr }, this.szSession...); err != nil { this.module.Errorln(err) } - this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut) + this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut) } + case "reconnect": // 重连 session.SendMsg(string(this.module.GetType()), "reconnect", &pb.EntertainReconnectResp{ Roomid: this.Id,