diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 9fed98888..5e8a7f40f 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -229,195 +229,7 @@ func (this *MapData) Debugf() { } } -// 检查5消 (s 是生成新的一个新的元素 key 下标 value 消除后效果类型) -func (this *MapData) Check5X() (bEliminate bool, xiaochu []int, s map[int]int) { - //var xiaochu []int // 即将消除的key - s = make(map[int]int) - for k, v := range this.Plat { - - if v.Cid == 0 { - continue - } - x := int32(k % Height) // x - if x+4 < Height { - k1 := this.Plat[k].Color - k2 := this.Plat[k+1].Color - k3 := this.Plat[k+2].Color - k4 := this.Plat[k+3].Color - k5 := this.Plat[k+4].Color - - if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 { - s[k+2] = FiveType - xiaochu = append(xiaochu, []int{k, k + 1, k + 2, k + 3, k + 4}...) - this.Plat[k].Cid = 0 - this.Plat[k+1].Cid = 0 - this.Plat[k+2].Cid = 0 - this.Plat[k+3].Cid = 0 - this.Plat[k+4].Cid = 0 - bEliminate = true - } - } - if k+4*Width < Total { - k1 := this.Plat[k].Color - k2 := this.Plat[k+Width].Color - k3 := this.Plat[k+2*Width].Color - k4 := this.Plat[k+3*Width].Color - k5 := this.Plat[k+4*Width].Color - - if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 { - s[k+2*Width] = FiveType - xiaochu = append(xiaochu, []int{k, k + Width, k + 2*Width, k + 3*Width, k + 4*Width}...) - this.Plat[k].Cid = 0 - this.Plat[k+Width].Cid = 0 - this.Plat[k+2*Width].Cid = 0 - this.Plat[k+3*Width].Cid = 0 - this.Plat[k+4*Width].Cid = 0 - bEliminate = true - } - } - } - - // // 校验上下左右 - // for j := 0; j < Width; j++ { - // for k := 0; k < Height; k++ { - // pos := j*Width + k - // if pos+2 < Height { - // k1 := this.Plat[pos].Color - // k2 := this.Plat[pos+1].Color - // k3 := this.Plat[pos+2].Color - // var k4 int32 - // var k5 int32 - // if k1 == k2 && k3 == k1 { // 三个颜色相等 - // tmp := pos - // index := 0 - // for { - // index++ - // if tmp/Width-2 >= 0 { // k1 的左右 - // k4 = this.Plat[tmp/Width-1].Color - // k5 = this.Plat[tmp/Width-2].Color - // if k1 == k4 && k1 == k5 { - // bEliminate = true - // s[tmp] = FiveType - // this.Plat[pos].Cid = 0 - // this.Plat[pos+1].Cid = 0 - // this.Plat[pos+2].Cid = 0 - // this.Plat[tmp/Width-1].Cid = 0 - // this.Plat[tmp/Width-2].Cid = 0 - // } - // } - // if tmp/Width+2 < Width { - // k4 = this.Plat[tmp/Width+1].Color - // k5 = this.Plat[tmp/Width+2].Color - // if k1 == k4 && k1 == k5 { - // bEliminate = true - // s[tmp] = FiveType - // this.Plat[pos].Cid = 0 - // this.Plat[pos+1].Cid = 0 - // this.Plat[pos+2].Cid = 0 - // this.Plat[tmp/Width+1].Cid = 0 - // this.Plat[tmp/Width+2].Cid = 0 - // } - // } - // tmp = pos + 2 - // if index == 2 { - // break - // } - // } - // } - // } - - // } - // } - return -} - -func (this *MapData) Check4X() (bEliminate bool, xiaochu []int, s map[int]int) { - var ( - newElem int // 生成的一个新的元素CID - ) - s = make(map[int]int) - - for k, v := range this.Plat { - - if v.Cid == 0 { - continue - } - x := int32(k % Height) // x - newElem = 0 - if x+3 < Height { - k1 := this.Plat[k].Color - k2 := this.Plat[k+1].Color - k3 := this.Plat[k+2].Color - k4 := this.Plat[k+3].Color - - if k1 == k2 && k3 == k4 && k2 == k3 { - for _, v1 := range this.operElem { - for i := 0; i <= 3; i++ { - if int(v1) == k+i { - newElem = int(v1) - break - } - } - if newElem != 0 { - break - } - } - if newElem == 0 { - newElem = k + 2 // 给个默认值 - } - // 如果当前生成的也是一个特殊的元素 直接消除 - if this.Plat[newElem].Special == 0 { - s[newElem] = FourUType - } - - xiaochu = append(xiaochu, []int{k, k + 1, k + 2, k + 3}...) - for _, v := range xiaochu { - this.Plat[v].Cid = 0 - } - bEliminate = true - } - } - if k+3*Width < Total { - k1 := this.Plat[k].Color - k2 := this.Plat[k+Width].Color - k3 := this.Plat[k+2*Width].Color - k4 := this.Plat[k+3*Width].Color - - if k1 == k2 && k3 == k4 && k2 == k3 { - for _, v1 := range this.operElem { - for i := 0; i <= 3; i++ { - if int(v1) == k+i*Width { - newElem = int(v1) // 创建一个特殊的元素 - break - } - } - if newElem != 0 { - break - } - } - if newElem == 0 { - newElem = k + 2*Width // 给个默认值 - } - - // 如果当前生成的也是一个特殊的元素 直接消除 - if this.Plat[newElem].Special == 0 { - s[newElem] = FourLType - } - xiaochu = append(xiaochu, k+Width) - xiaochu = append(xiaochu, []int{k, k + Width, k + 2*Width, k + 3*Width}...) - for _, v := range xiaochu { - this.Plat[v].Cid = 0 - } - bEliminate = true - } - } - } - - return -} - -func (this *MapData) Check3X() (bEliminate bool, xiaochu []int) { - //var xiaochu []int // 即将消除的key +func (this *MapData) Check3X() (bEliminate bool) { for k, v := range this.Plat { b := false for _, e := range this.operElem { @@ -430,35 +242,25 @@ func (this *MapData) Check3X() (bEliminate bool, xiaochu []int) { 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 { - xiaochu = append(xiaochu, []int{k, k + 1, k + 2}...) - this.Plat[k].Cid = 0 - this.Plat[k+1].Cid = 0 - this.Plat[k+2].Cid = 0 bEliminate = true + return } } - 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 { - xiaochu = append(xiaochu, []int{k, k + Width, k + 2*Width}...) - this.Plat[k].Cid = 0 - this.Plat[k+Width].Cid = 0 - this.Plat[k+2*Width].Cid = 0 bEliminate = true + return } } } - return } @@ -1078,8 +880,7 @@ func (this *MapData) SetIndelibilityPlat() { } } for { - if b, _ := this.Check3X(); b { - fmt.Printf("plat init\n") + if b := this.Check3X(); b { if _, xc := this.CheckMap(0, false); !xc { break }