From 6c6238fa98b25ac2d513697c7615ab841591b4fa Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 21 Dec 2023 11:06:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=8D=81=E5=AD=97=E6=8A=80?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 35 ++++++-------- modules/entertainment/xxlPlat.go | 79 +++++++++++++++++--------------- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index c67d2b6ca..160b65473 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -225,23 +225,6 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } return } else if req.Itype > 0 { //玩家卡牌技能 - var ( - conf *cfg.GamePlayerSkillData - err error - list *pb.DBXXLData - ) - if conf, err = this.module.configure.GetGamePlaySkill(req.Itype); err != nil { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ConfigNoFound, // 配置校验 - Title: pb.ErrorCode_ConfigNoFound.ToString(), - Message: err.Error(), - } - return - } - if list, err = this.module.model.getEntertainmList(session.GetUserId()); err == nil { - this.module.Debugf("%v,%v", conf, list) - - } if curPlayer.Skill[req.Itype] <= 0 { errdata = &pb.ErrorData{ Code: pb.ErrorCode_EntertainNoSkillCard, // 技能卡不足 @@ -253,7 +236,6 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr if errdata = this.UserCardSkill(curPlayer, color, req.Itype, req.Curid); errdata != nil { return } - return } if req.Itype == 0 && req.Curid == 0 && req.Targetid == 0 { @@ -953,12 +935,12 @@ func (this *Room) UserCardSkill(curPlayer *pb.PlayerData, color int32, skillid i if conf.Skilltouch == 101 { // 技能类型为1 szMap = this.chessboard.HitElem(color, curid) } else if conf.Skilltouch == 102 { - this.chessboard.ShuffleElem() // 初始化棋盘 + this.chessboard.ShuffleElem() szMap = append(szMap, &pb.MapData{ Data: this.chessboard.Plat, }) } else if conf.Skilltouch == 103 { - //this.chessboard.HitCrossElem() // 初始化棋盘 + this.chessboard.HitCrossElem(color, curid) // 消除十字 szMap = append(szMap, &pb.MapData{ Data: this.chessboard.Plat, }) @@ -979,6 +961,19 @@ func (this *Room) UserCardSkill(curPlayer *pb.PlayerData, color int32, skillid i v.ChangeType = 1 } this.NexPower = this.curPower + if conf.Number == 2 { // 只有2类型扣除 + if list, err := this.module.model.getEntertainmList(curPlayer.Userinfo.Uid); err == nil { + if _, ok := list.Skill[skillid]; ok { + list.Skill[skillid] -= 1 + if list.Skill[skillid] < 0 { + list.Skill[skillid] = 0 + } + this.module.model.modifyEntertainmList(curPlayer.Userinfo.Uid, map[string]interface{}{ + "skill": list.Skill, + }) + } + } + } if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ Mpadata: szMap, diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 54c2b81f7..cde46657a 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -1329,49 +1329,56 @@ func (this *MapData) ShuffleElem() { } func (this *MapData) HitCrossElem(color int32, curid int32) (szMap []*pb.MapData) { - var ids []int // 十字id - var energy int32 - var curScore int32 + var ( + ids []int // 十字id + energy int32 + curScore int32 + xc map[int]struct{} + ) x := int(curid / Width) y := int(curid % Height) - - for i := 0; i < Height; i++ { // 上 + xc = make(map[int]struct{}, 0) + for i := 0; i < Height; i++ { // 上下 + if y+i < Height { + ids = append(ids, x*Width+(y+i)) + } if y-i > 0 { - ids = append(ids, (x-1)*Width+(y)) + ids = append(ids, x*Width+(y-i)) } } - if this.Plat[curid].Special == 0 { - if this.Plat[curid].Color == color { + + for i := 0; i < Height; i++ { // 左右 + if x+i < Width { + ids = append(ids, (x+i)*Width+(y)) + } + if x-i >= 0 { + ids = append(ids, (x-i)*Width+(y)) + } + } + for _, v := range ids { + if this.Plat[curid].Special == 0 { + xc[v] = struct{}{} + } else { + for key := range this.SpecialElem(int(v), this.Plat[v].Special) { + xc[key] = struct{}{} + } + } + } + + for id := range xc { + if this.Plat[id].Color == color { energy++ } - curScore = this.Plat[curid].Score - this.Plat[curid] = &pb.GirdeData{} - if this.DropGirde() { - szMap = append(szMap, &pb.MapData{ - Data: this.GetPalatData(), - CurSocre: curScore, - CurEnergy: 0, - }) - } - sz, _ := this.CheckMap(color, false) - szMap = append(szMap, sz...) - } else { - x := this.SpecialElem(int(curid), this.Plat[curid].Special) - for id := range x { - if this.Plat[id].Color == color { - energy++ - } - curScore += this.Plat[id].Score - this.Plat[id] = &pb.GirdeData{} - this.operElem = append(this.operElem, int32(id)) - } - if this.DropGirde() { - szMap = append(szMap, &pb.MapData{ - Data: this.GetPalatData(), - CurSocre: curScore, - CurEnergy: energy, - }) - } + curScore += this.Plat[id].Score + this.Plat[id] = &pb.GirdeData{} + this.operElem = append(this.operElem, int32(id)) + } + if this.DropGirde() { + szMap = append(szMap, &pb.MapData{ + Data: this.GetPalatData(), + CurSocre: curScore, + CurEnergy: energy, + }) } return }