52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
package moonfantasy
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
"time"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) DareCheck(session comm.IUserSession, req *pb.MoonfantasyDareReq) (code pb.ErrorCode) {
|
|
return
|
|
}
|
|
|
|
///获取本服聊天消息记录
|
|
func (this *apiComp) Dare(session comm.IUserSession, req *pb.MoonfantasyDareReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
globalconf *cfg.GameGlobalData
|
|
mdata *pb.DBMoonfantasy
|
|
err error
|
|
)
|
|
if code = this.DareCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
if mdata, err = this.module.modelDream.queryDreamData(req.Uid, req.Mid); err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if mdata == nil {
|
|
code = pb.ErrorCode_MoonfantasyHasExpired
|
|
return
|
|
}
|
|
if mdata.Joinnum >= mdata.Numup {
|
|
code = pb.ErrorCode_MoonfantasyJoinUp
|
|
return
|
|
}
|
|
|
|
globalconf = this.module.configure.GetGlobalConf()
|
|
|
|
if time.Now().Sub(time.Unix(mdata.Ctime, 0)).Seconds() >= float64(globalconf.DreamlandLimit) {
|
|
code = pb.ErrorCode_MoonfantasyHasExpired
|
|
return
|
|
}
|
|
this.module.modelDream.ChangeList(req.Uid, req.Mid, map[string]interface{}{
|
|
"joinnum": mdata.Joinnum + 1,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyDareResp{})
|
|
return
|
|
}
|