From 223a0dcd1dae43de948333b2d5b882c20116a172 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 2 Nov 2023 10:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E8=83=BD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/xxlPlat.go | 43 ++++++++++++++++++++++++------- modules/entertainment/xxl_test.go | 2 +- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index e55c2ac1d..2d7acb77e 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -505,12 +505,11 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, skillEnergy int32 // 技能获得的能量 ids []int ) - + x = make(map[int]struct{}) if skillid == 1 { // 随机消除盘面上X个方块 - x = make(map[int]struct{}) ids = utils.RandomNumbers(0, Total-1, int(value)) - } else if skillid == 2 { // 找到pos 位置的所有方块 + } else if skillid == 4 { // 找到pos 位置的所有方块 x := int(pos / Width) y := int(pos % Height) for i := 1; i < 7; i++ { @@ -530,12 +529,38 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, } } - } else if skillid == 3 { //选中一个方块,然后消除盘面上所有相同颜色的方块。 - c := this.Plat[pos].Color - for index, v1 := range this.Plat { - if v1.Color == c { - ids = append(ids, index) - } + } else if skillid == 3 || skillid == 5 { //选中一个方块,消除周围一圈 + x := int(pos / Width) + y := int(pos % Height) + if x-1 >= 0 { // 左 + ids = append(ids, (x-1)*Width+(y)) + } + if y-1 >= 0 { // 下 + ids = append(ids, (x)*Width+(y-1)) + } + if y+1 < Height { // 上 + ids = append(ids, (x)*Width+(y+1)) + } + if x+1 < Width { // 右 + ids = append(ids, (x+1)*Width+(y)) + } + if x-1 >= 0 && y+1 < Height { // 左上 + ids = append(ids, (x-1)*Width+(y+1)) + } + if x-1 >= 0 && y-1 >= 0 { // 左下 + ids = append(ids, (x-1)*Width+(y-1)) + } + + if x+1 < Width && y+1 < Height { // 右上 + ids = append(ids, (x+1)*Width+(y+1)) + } + if x+1 < Width && y-1 >= 0 { // 右下 + ids = append(ids, (x+1)*Width+(y-1)) + } + + } else if skillid == 2 { // 消除中间的一列宝石 + for i := 0; i < Height; i++ { + ids = append(ids, 3*Width+i) } } for _, id := range ids { diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index 79e456390..c0882e251 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -85,7 +85,7 @@ func Test_Main(t *testing.T) { m := new(entertainment.MapData) m.InitMap(nil) m.Debugf() - m.SkillUp(24, 1, 2, 7, true) + m.SkillUp(24, 1, 3, 7, true) // m.SetMap() b := m.CheckAndRefreshPlat() fmt.Printf("xxxx%v", b)