From 30970cb7d9e6823d84c01ecdf864e51cdc853386 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 18 Oct 2023 11:33:13 +0800 Subject: [PATCH] =?UTF-8?q?ui=E5=B0=8F=E6=B8=B8=E6=88=8F=E9=A2=9D=E5=A4=96?= =?UTF-8?q?=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/gamemgr.go | 4 ++-- modules/entertainment/module.go | 5 +++++ modules/entertainment/room.go | 2 +- modules/uigame/api_minergrid.go | 9 ++++++++- modules/uigame/api_puzzlegrid.go | 12 ++++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/modules/entertainment/gamemgr.go b/modules/entertainment/gamemgr.go index a2cb5886a..b4a646cb6 100644 --- a/modules/entertainment/gamemgr.go +++ b/modules/entertainment/gamemgr.go @@ -28,9 +28,9 @@ func (this *gameMgrComp) Init(service core.IService, module core.IModule, comp c return } -func (this *gameMgrComp) CreateRoom(session [2]comm.IUserSession) { +func (this *gameMgrComp) CreateRoom(s1 comm.IUserSession, s2 comm.IUserSession) { room := new(Room) //初始化房间 - room.InitRoom(session) + room.InitRoom(s1, s2) this.lock.Lock() this.rooms[room.Id] = room diff --git a/modules/entertainment/module.go b/modules/entertainment/module.go index 8ca9174b4..062c44d16 100644 --- a/modules/entertainment/module.go +++ b/modules/entertainment/module.go @@ -57,3 +57,8 @@ func (this *Entertainment) Start() (err error) { // this.xxl.DropGirde() return } + +// 匹配完成 +func (this *Entertainment) MatchingComplete(s1 comm.IUserSession, s2 comm.IUserSession) { + this.gameMgr.CreateRoom(s1, s2) +} diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index afb826392..61c5b4939 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -16,7 +16,7 @@ type Room struct { chessboard *MapData } -func (this *Room) InitRoom(session [2]comm.IUserSession) *Room { +func (this *Room) InitRoom(s1 comm.IUserSession, s2 comm.IUserSession) *Room { this.chessboard = new(MapData) this.chessboard.InitMap() // 初始化棋盘 return &Room{ diff --git a/modules/uigame/api_minergrid.go b/modules/uigame/api_minergrid.go index 47ba40ab0..3cfe8e133 100644 --- a/modules/uigame/api_minergrid.go +++ b/modules/uigame/api_minergrid.go @@ -25,6 +25,7 @@ func (this *apiComp) MinerKey(session comm.IUserSession, req *pb.UiGameMinerKeyR } var ( atno []*pb.UserAtno + res []*cfg.Gameatn ) list, _ := this.module.modelMiner.getMinerList(session.GetUserId(), req.Hdid) if _, ok := list.Gotarr[req.Cid]; ok { // 重复拼图 @@ -39,7 +40,13 @@ func (this *apiComp) MinerKey(session comm.IUserSession, req *pb.UiGameMinerKeyR } } if len(conf.Costget) > 0 { - if errdata, atno = this.module.DispenseAtno(session, conf.Costget, true); errdata != nil { + res = append(res, conf.Costget...) + } + if c, err := this.module.configure.GetMinerConf(req.Cid); err == nil { + res = append(res, c.Itemid) + } + if len(res) > 0 { + if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { return } } diff --git a/modules/uigame/api_puzzlegrid.go b/modules/uigame/api_puzzlegrid.go index 48946fba3..f4d5e02f2 100644 --- a/modules/uigame/api_puzzlegrid.go +++ b/modules/uigame/api_puzzlegrid.go @@ -25,6 +25,7 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG } var ( atno []*pb.UserAtno + res []*cfg.Gameatn ) list, _ := this.module.modelPuzzle.getPuzzleList(session.GetUserId(), req.Hdid) if _, ok := list.Puzzle[req.Grid]; ok { // 重复拼图 @@ -43,6 +44,17 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG return } } + if len(conf.Costget) > 0 { + res = append(res, conf.Costget...) + } + if c, err := this.module.configure.GetMinerConf(req.Grid); err == nil { + res = append(res, c.Itemid) + } + if len(res) > 0 { + if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { + return + } + } } list.Puzzle[req.Grid] = 1