迷宫小游戏
This commit is contained in:
parent
052534e0ec
commit
50a7845250
51
modules/uigame/api_latticegrid.go
Normal file
51
modules/uigame/api_latticegrid.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
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
|
||||||
|
}
|
52
modules/uigame/api_latticereward.go
Normal file
52
modules/uigame/api_latticereward.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package uigame
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
//参数校验
|
||||||
|
func (this *apiComp) LatticeRewardCheck(session comm.IUserSession, req *pb.UiGameLatticeRewardReq) (errdata *pb.ErrorData) {
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击某个格子进行拼图
|
||||||
|
func (this *apiComp) LatticeReward(session comm.IUserSession, req *pb.UiGameLatticeRewardReq) (errdata *pb.ErrorData) {
|
||||||
|
if errdata = this.LatticeRewardCheck(session, req); errdata != nil {
|
||||||
|
return // 参数校验失败直接返回
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
atno []*pb.UserAtno
|
||||||
|
)
|
||||||
|
list, _ := this.module.modelLattice.getLatticeList(session.GetUserId(), req.Hdid)
|
||||||
|
if _, err := this.module.configure.GetLatticeConf(req.Id); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
list, _ := this.module.modelPuzzle.getPuzzleList(session.GetUserId(), req.Hdid)
|
||||||
|
if _, ok := list.Puzzle[req.Id]; ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// if errdata, atno = this.module.DispenseAtno(session, conf.Puzzleward, true); errdata != nil {
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// 记录数据
|
||||||
|
list.Puzzle[req.Id] = 1
|
||||||
|
update := make(map[string]interface{}, 0)
|
||||||
|
update["puzzle"] = list.Puzzle
|
||||||
|
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), update) // 修改进度
|
||||||
|
}
|
||||||
|
|
||||||
|
session.SendMsg(string(this.module.GetType()), "latticereward", &pb.UiGameLatticeRewardResp{
|
||||||
|
Data: list,
|
||||||
|
Atno: atno,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
@ -8,7 +8,13 @@ import (
|
|||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *apiComp) PuzzleGridCheck(session comm.IUserSession, req *pb.UiGamePuzzleGridReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) PuzzleGridCheck(session comm.IUserSession, req *pb.UiGamePuzzleGridReq) (errdata *pb.ErrorData) {
|
||||||
|
if req.Hdid == "" {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ReqParameterError,
|
||||||
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ var moduleName = "viking"
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
game_puzzle = "game_uigamepuzzle.json"
|
game_puzzle = "game_uigamepuzzle.json"
|
||||||
|
game_lattice = "game_uigamelattice.json"
|
||||||
game_consum = "game_uigameconsum.json"
|
game_consum = "game_uigameconsum.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
this.module = module.(*UiGame)
|
this.module = module.(*UiGame)
|
||||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||||
game_puzzle: cfg.NewGameUiGamePuzzle,
|
game_puzzle: cfg.NewGameUiGamePuzzle,
|
||||||
|
game_lattice: cfg.NewGameUiGameLattice,
|
||||||
game_consum: cfg.NewGameUiGameConsum,
|
game_consum: cfg.NewGameUiGameConsum,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -96,3 +98,17 @@ func (this *configureComp) GetLatticeConsumConf() (conf *cfg.GameUiGameConsumDat
|
|||||||
this.module.Errorf("GetLatticeConsumConf conf not found key :puzzle")
|
this.module.Errorf("GetLatticeConsumConf conf not found key :puzzle")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (this *configureComp) GetLatticeConf(id int32) (conf *cfg.GameUiGameLatticeData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_lattice); err == nil {
|
||||||
|
if configure, ok := v.(*cfg.GameUiGameLattice); ok {
|
||||||
|
if conf = configure.Get(id); conf != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.module.Errorf("GetLatticeConf conf not found key :%d", id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user