From d684e12e93fb38f87ec568381a72a5f49247598b Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 26 Oct 2023 18:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E5=85=A5=E6=B8=B8=E6=88=8F=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E7=94=9F=E6=88=90=E4=B8=80=E5=BC=A0=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E8=87=AA=E6=B6=88=E7=9A=84=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/configure.go | 1 - modules/entertainment/xxlPlat.go | 43 ++++++++++++++++++++++++------ modules/entertainment/xxl_test.go | 5 +++- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/modules/entertainment/configure.go b/modules/entertainment/configure.go index bcc2dc8d1..f107d4fe3 100644 --- a/modules/entertainment/configure.go +++ b/modules/entertainment/configure.go @@ -36,7 +36,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp }) configure.RegisterConfigure(game_block, cfg.NewGameBlock, this.LoadGameBlock) - this.GetGameConsumeintegralReward(100) return } diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index cab625fd8..695b891cb 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -61,7 +61,8 @@ func (this *MapData) InitMap(module *Entertainment) { for i := 0; i < Width*Height; i++ { this.Plat[i] = this.CreateGride(int32(i)) } - this.SetMap() // 方便测试固定地图 + this.SetIndelibilityPlat() + //this.SetMap() // 方便测试固定地图 } // 交换2个元素(参数 oid ) @@ -591,15 +592,13 @@ func (this *MapData) SetMap() { pos++ } } + this.SetIndelibilityPlat() } // 校验当前地图 有没有能消除的 func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { bEliminate = false for k, v := range this.Plat { - if k < 10 { - continue - } if v.Color == 0 { continue } @@ -612,7 +611,7 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { if k1 == k2 { // 校验k3 左边和右边 if true { pos := k + 2 - if pos%Width-1 >= 0 { // 左 + if pos/Width-1 >= 0 { // 左 p := this.Plat[pos-Width].Color if p == k1 { bEliminate = true @@ -658,7 +657,6 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { } } } - } } @@ -701,7 +699,6 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { bEliminate = true return } - } if pos%Height+1 < Height { // 上 p := this.Plat[pos+1].Color @@ -718,7 +715,6 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { } } } - } } @@ -781,3 +777,34 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { } return } + +// 生成一个不能消除的地图 +func (this *MapData) SetIndelibilityPlat() { + for k, v := range this.Plat { + if v.Color == 0 { + continue + } + x := int32(k % Height) // x + + if x+2 < Height { + k1 := this.Plat[k].Color + k2 := this.Plat[k+1].Color + k3 := this.Plat[k+2].Color + if k1 == k2 && k2 == k3 { + this.Plat[k+2].Cid = (k3+1)%5 + 1 + this.Plat[k+2].Color = (k3+1)%5 + 1 + } + } + + if k+2*Width < Total { + k1 := this.Plat[k].Color + k2 := this.Plat[k+Width].Color + k3 := this.Plat[k+2*Width].Color + + if k1 == k2 && k2 == k3 { + this.Plat[k+2*Width].Cid = (k3+1)%5 + 1 + this.Plat[k+2*Width].Color = (k3+1)%5 + 1 + } + } + } +} diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index 06d284324..b4d7faf19 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -85,8 +85,11 @@ func Test_Main(t *testing.T) { m := new(entertainment.MapData) m.InitMap(nil) m.SetMap() + m.SetIndelibilityPlat() m.Debugf() - m.CheckAndRefreshPlat() + if m.CheckAndRefreshPlat() { + fmt.Println("xxxx") + } //var szMap []*pb.MapData // if bSwap, m := m.AiSwapGirde(); bSwap { // szMap = append(szMap, m...)