50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package uigame
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) PuzzleGridCheck(session comm.IUserSession, req *pb.UiGamePuzzleGridReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// 点击某个格子进行拼图
|
|
func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleGridReq) (errdata *pb.ErrorData) {
|
|
if errdata = this.PuzzleGridCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
var (
|
|
consum *cfg.Gameatn // 获取消耗
|
|
)
|
|
list, _ := this.module.modelPuzzle.getPuzzleList(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.Val -= 1
|
|
// if list.Val < 0 { // 拼图数量不足
|
|
// 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()), "puzzlegrid", &pb.UiGamePuzzleGridResp{Data: list})
|
|
return
|
|
}
|