57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
package jielong
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) StartGameCheck(session comm.IUserSession, req *pb.JielongStartGameReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) StartGame(session comm.IUserSession, req *pb.JielongStartGameReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
list *pb.DBJielongData
|
|
err error
|
|
update map[string]interface{}
|
|
)
|
|
update = make(map[string]interface{}, 0)
|
|
if errdata = this.StartGameCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
list, err = this.module.modelJielong.getUserJielongData(session.GetUserId())
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
// 校验门票够不够
|
|
jielongItem := this.module.ModuleTools.GetGlobalConf().FastplayItem
|
|
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{jielongItem}, true); errdata != nil {
|
|
return
|
|
}
|
|
if list.Status == 1 {
|
|
list.Curwin = 0
|
|
update["curwin"] = list.Curwin
|
|
}
|
|
if len(update) > 0 {
|
|
this.module.modelJielong.changeJielongData(session.GetUserId(), update)
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "startgame", &pb.JielongStartGameResp{
|
|
Susses: true,
|
|
})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "JielongStartGameReq", jielongItem)
|
|
})
|
|
return
|
|
}
|