From 18a9c8ab663ff3fccbd63ef6ef2f1cc205d67fd7 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 9 Jun 2023 18:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=AD=A6=E9=A6=86npc?= =?UTF-8?q?=E8=B8=A2=E9=A6=86=E6=9D=A1=E4=BB=B6=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/practice/api_info.go | 24 ++++++++++++++++++++++++ modules/practice/modelPandata.go | 10 +++++----- modules/practice/module.go | 2 +- pb/practice_db.pb.go | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/modules/practice/api_info.go b/modules/practice/api_info.go index 2d16e6b90..d824818d2 100644 --- a/modules/practice/api_info.go +++ b/modules/practice/api_info.go @@ -17,6 +17,7 @@ func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.PracticeInfoRe func (this *apiComp) Info(session comm.IUserSession, req *pb.PracticeInfoReq) (errdata *pb.ErrorData) { var ( err error + open bool room *pb.DBPracticeRoom update map[string]interface{} = make(map[string]interface{}) ) @@ -45,6 +46,29 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.PracticeInfoReq) (e } } + if room.Npcstate == -1 { //未开启 检查是否开启 + if open, errdata = this.module.ModuleSys.CheckOpenCondCfgById(session.GetUserId(), "pavilion_kick"); errdata != nil { + return + } + if open { + if err = this.module.modelPandata.refreshnpc(room); err != nil { + this.module.Errorln(err) + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_SystemError, + Title: pb.ErrorCode_SystemError.ToString(), + Message: err.Error(), + } + return + } + update["currnpc"] = room.Currnpc + update["npcstate"] = room.Npcstate + update["refresh"] = room.Refresh + update["battlenum"] = room.Battlenum + update["captain"] = room.Captain + update["formation"] = room.Formation + } + } + if room.Npcstate == 3 { //CD中 cd := int32(configure.Now().Sub(time.Unix(room.Refresh, 0)).Seconds()) if cd >= this.module.ModuleTools.GetGlobalConf().PandamasChallengeCd { diff --git a/modules/practice/modelPandata.go b/modules/practice/modelPandata.go index 9529824aa..ae8af4d76 100644 --- a/modules/practice/modelPandata.go +++ b/modules/practice/modelPandata.go @@ -52,13 +52,13 @@ func (this *modelPandata) queryUserMartialhall(uid string) (result *pb.DBPractic Pillar3: &pb.DBPracticePillar{Index: 3, Lv: 1}, Pillarf: &pb.DBPracticePillar{Index: 4, Isunlock: 0, Lv: 1}, Statuers: make([]*pb.DBPracticeStatuer, 0), - Npcstate: 3, + Npcstate: -1, Refresh: configure.Now().Unix(), } - if err = this.refreshnpc(result); err != nil { - this.module.Errorln(err) - return - } + // if err = this.refreshnpc(result); err != nil { + // this.module.Errorln(err) + // return + // } if err = this.Add(uid, result); err != nil { this.module.Errorln(err) return diff --git a/modules/practice/module.go b/modules/practice/module.go index 5b9be462e..6527ed64a 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -144,7 +144,7 @@ func (this *Practice) AddItems(session comm.IUserSession, items map[string]int32 Pillar3: &pb.DBPracticePillar{Index: 3, Lv: 1}, Pillarf: &pb.DBPracticePillar{Index: 4, Isunlock: 0, Lv: 1}, Statuers: make([]*pb.DBPracticeStatuer, 0), - Npcstate: 3, + Npcstate: -1, Refresh: configure.Now().Unix(), } id = make([]string, 0) diff --git a/pb/practice_db.pb.go b/pb/practice_db.pb.go index 6ad58da04..ca9375afb 100644 --- a/pb/practice_db.pb.go +++ b/pb/practice_db.pb.go @@ -303,7 +303,7 @@ type DBPracticeRoom struct { Pillarf *DBPracticePillar `protobuf:"bytes,11,opt,name=pillarf,proto3" json:"pillarf"` //好友柱子 Statuers []*DBPracticeStatuer `protobuf:"bytes,12,rep,name=statuers,proto3" json:"statuers"` //武馆雕像 Currnpc int32 `protobuf:"varint,13,opt,name=currnpc,proto3" json:"currnpc"` //当前npc - Npcstate int32 `protobuf:"varint,14,opt,name=npcstate,proto3" json:"npcstate"` //npc状态 0 未挑战 1 挑战失败 2挑战成功 3 CD中 + Npcstate int32 `protobuf:"varint,14,opt,name=npcstate,proto3" json:"npcstate"` //npc状态 -1未开启 0 未挑战 1 挑战失败 2挑战成功 3 CD中 Refresh int64 `protobuf:"varint,15,opt,name=refresh,proto3" json:"refresh"` //刷新时间 Battlenum int32 `protobuf:"varint,16,opt,name=battlenum,proto3" json:"battlenum"` //战斗次数 Captain int32 `protobuf:"varint,17,opt,name=captain,proto3" json:"captain"` //战斗征信队长位