52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package uigame
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) LatticeGridCheck(session comm.IUserSession, req *pb.UiGameLatticeGridReq) (errdata *pb.ErrorData) {
|
|
if req.Hdid == "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
// 走迷宫格子
|
|
func (this *apiComp) LatticeGrid(session comm.IUserSession, req *pb.UiGameLatticeGridReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.LatticeGridCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
var (
|
|
consum *cfg.Gameatn // 获取消耗
|
|
)
|
|
list, _ := this.module.modelLattice.getLatticeList(session.GetUserId(), req.Hdid)
|
|
if _, ok := list.Gotarr[req.Grid]; ok {
|
|
return
|
|
}
|
|
// 校验消耗
|
|
if conf, err := this.module.configure.GetPuzzleConsumConf(); err != nil {
|
|
consum = &cfg.Gameatn{
|
|
A: conf.Itemget.A,
|
|
T: conf.Itemget.T,
|
|
N: 1,
|
|
}
|
|
}
|
|
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{consum}, true); errdata != nil {
|
|
return
|
|
}
|
|
|
|
list.Gotarr[req.Grid] = 1
|
|
update := make(map[string]interface{}, 0)
|
|
update["gotarr"] = list.Gotarr
|
|
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), update) // 修改进度
|
|
session.SendMsg(string(this.module.GetType()), "latticegrid", &pb.UiGameLatticeGridResp{Data: list})
|
|
return
|
|
}
|