时间里计时器处理
This commit is contained in:
parent
aff72fa398
commit
866b768e96
@ -40,7 +40,9 @@ type Room struct {
|
||||
|
||||
func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
fmt.Printf("超时+++++%d\n", time.Now().Unix())
|
||||
|
||||
if this.operatetimer != nil {
|
||||
this.operatetimer = nil
|
||||
}
|
||||
if this.player1.Userinfo.Uid == this.curPower { // 给玩家2
|
||||
this.NexPower = this.player2.Userinfo.Uid
|
||||
this.player2.Ps = MaxPs // 恢复体力
|
||||
@ -83,10 +85,6 @@ func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
// 二号玩家是机器人
|
||||
if len(this.szSession) == 1 {
|
||||
this.AiOperator()
|
||||
} else {
|
||||
// if this.operatetimer != nil {
|
||||
// this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut) // 开启新的定时器
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,10 +154,6 @@ func (this *Room) AiOperator() {
|
||||
this.NexPower = this.player1.Userinfo.Uid
|
||||
this.player1.Ps = MaxPs
|
||||
this.round++
|
||||
if this.operatetimer != nil { // 开启新的定时器
|
||||
timewheel.Remove(this.operatetimer)
|
||||
}
|
||||
//this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut)
|
||||
}
|
||||
// 校验下次是不是消除
|
||||
if !this.chessboard.CheckAndRefreshPlat() {
|
||||
@ -418,12 +412,12 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if this.curPower != this.NexPower { // 下一次操作不是自己 清除定时器
|
||||
if this.operatetimer != nil {
|
||||
timewheel.Remove(this.operatetimer)
|
||||
this.operatetimer = nil
|
||||
}
|
||||
if this.curPower != this.NexPower && len(this.szSession) > 1 {
|
||||
//this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut) // 开启新的定时器
|
||||
}
|
||||
// 变更权限
|
||||
this.curPower = this.NexPower
|
||||
@ -486,7 +480,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
// 游戏开始开启一个定时器
|
||||
this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut)
|
||||
//this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut)
|
||||
}
|
||||
|
||||
case "reconnect": // 重连
|
||||
@ -529,8 +523,10 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
case "operatorover": // 操作完成 开启一个定时器
|
||||
if this.operatetimer != nil {
|
||||
timewheel.Remove(this.operatetimer)
|
||||
this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut)
|
||||
this.operatetimer = nil
|
||||
}
|
||||
this.operatetimer = timewheel.Add(time.Second*time.Duration(this.MaxTime), this.operateTimeOut)
|
||||
|
||||
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "startimer", &pb.EntertainStarTimerPush{
|
||||
Time: this.MaxTime,
|
||||
}, this.szSession...); err != nil {
|
||||
@ -554,6 +550,7 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
|
||||
)
|
||||
if this.operatetimer != nil {
|
||||
timewheel.Remove(this.operatetimer)
|
||||
this.operatetimer = nil
|
||||
}
|
||||
winner = this.player1
|
||||
bReward = true
|
||||
|
Loading…
Reference in New Issue
Block a user