67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
package practice
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
"time"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.PracticeInfoReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
///练功请求
|
|
func (this *apiComp) Info(session comm.IUserSession, req *pb.PracticeInfoReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
err error
|
|
room *pb.DBPracticeRoom
|
|
update map[string]interface{} = make(map[string]interface{})
|
|
)
|
|
if room, err = this.module.modelPandata.queryUserMartialhall(session.GetUserId()); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
if room.Npcstate == 0 && room.Currnpc == 0 {
|
|
this.module.modelPandata.refreshnpc(room)
|
|
update["currnpc"] = room.Currnpc
|
|
update["captain"] = room.Captain
|
|
update["formation"] = room.Formation
|
|
}
|
|
|
|
for i := 0; i < len(room.Statuers); {
|
|
if configure.Now().After(time.Unix(room.Statuers[i].End, 0)) {
|
|
room.Statuers = append(room.Statuers[:i], room.Statuers[i+1:]...)
|
|
update["statuers"] = room.Statuers
|
|
} else {
|
|
i++
|
|
}
|
|
}
|
|
|
|
if room.Npcstate == 3 { //CD中
|
|
cd := int32(configure.Now().Sub(time.Unix(room.Refresh, 0)).Seconds())
|
|
if cd >= this.module.configure.GetGlobalConf().PandamasChallengeCd {
|
|
if err = this.module.modelPandata.refreshnpc(room); err != nil {
|
|
this.module.Errorln(err)
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
update["npcstate"] = room.Npcstate
|
|
update["refresh"] = room.Refresh
|
|
update["battlenum"] = room.Battlenum
|
|
update["captain"] = room.Captain
|
|
update["formation"] = room.Formation
|
|
}
|
|
}
|
|
if len(update) > 0 {
|
|
this.module.modelPandata.Change(session.GetUserId(), update)
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "info", &pb.PracticeInfoResp{Info: room})
|
|
return
|
|
}
|