diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index caeb52275..f9f8a7f73 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -428,12 +428,12 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr this.AiOperator() } case "ready": - var bStartGame bool // 可以开始游戏 + var bStartGame bool // 可以开始游戏 + this.NexPower = this.player1.Userinfo.Uid + this.curPower = this.player1.Userinfo.Uid + this.player1.Ps = MaxPs + this.player2.Ps = 0 if len(this.szSession) == 1 { // AI对战的话直接开始游戏 - this.NexPower = this.player1.Userinfo.Uid - this.curPower = this.player1.Userinfo.Uid - this.player1.Ps = MaxPs - this.player2.Ps = 0 bStartGame = true } else { if this.player1.Userinfo.Uid == session.GetUserId() { diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 2d7acb77e..9543fa8f4 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -620,13 +620,13 @@ func (this *MapData) CheckInitPlat() { func (this *MapData) SetMap() { sz2 := []int32{ - 5, 5, 4, 1, 1, 2, 5, - 3, 6, 3, 4, 6, 2, 1, - 3, 5, 6, 3, 1, 6, 1, - 1, 2, 6, 5, 4, 1, 3, - 4, 4, 3, 5, 4, 6, 4, - 5, 6, 1, 4, 3, 3, 6, - 5, 3, 5, 3, 6, 1, 5, + 3, 3, 2, 2, 1, 3, 1, + 5, 1, 2, 3, 1, 2, 2, + 3, 4, 3, 5, 6, 1, 6, + 1, 4, 6, 4, 2, 3, 6, + 1, 5, 6, 5, 6, 1, 4, + 5, 3, 4, 1, 4, 3, 3, + 3, 3, 5, 1, 1, 2, 5, // 1, 4, 2, 5, 4, 5, 2, // 3, 2, 3, 5, 2, 1, 4, // 2, 5, 5, 4, 5, 4, 1, @@ -655,15 +655,15 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { if v.Color == 0 { continue } - x := int32(k % Height) // x - y := int32(k / Height) // y - if x+2 < Height { // 上 + x := int32(k % Height) + y := int32(k / Height) + if x+2 < Height { // 上 k1 := this.Plat[k].Color k2 := this.Plat[k+1].Color 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 @@ -687,23 +687,25 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { } // xia pos := k - 1 - if pos%Height > 0 { // 左右 - if pos/Width-1 >= 0 { //左 - p := this.Plat[pos-Width].Color - if p == k1 { - bEliminate = true - return + if x > 0 { + if pos%Height > 0 { // 左右 + if pos/Width-1 >= 0 { //左 + p := this.Plat[pos-Width].Color + if p == k1 { + bEliminate = true + return + } } - } - if pos/Width+1 < Width { // 右 - p := this.Plat[pos+Width].Color - if p == k1 { - bEliminate = true - return + if pos/Width+1 < Width { // 右 + p := this.Plat[pos+Width].Color + if p == k1 { + bEliminate = true + return + } } } } - if pos%Height-1 >= 0 { + if x > 1 { p := this.Plat[pos-1].Color if p == k1 { bEliminate = true @@ -772,61 +774,66 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) { } } - for index := Width - 1; index >= 0; index-- { - for j := 0; j < Height; j++ { - k := index + j*7 - if j+3 < Width { - k1 := this.Plat[k].Color - k2 := this.Plat[k+2*Width].Color - pos := index + (j+1)*7 - if k1 == k2 { - // 上 - if pos%Height+1 < Height { - p := this.Plat[pos+1].Color - if p == k1 { - bEliminate = true - return - } + for k, v := range this.Plat { + if v.Color == 0 { + continue + } + // x := int32(k % Height) // x + y := int32(k / Height) // y + + if y+2 < Width { + k1 := this.Plat[k].Color + k2 := this.Plat[k+2*Width].Color + pos := k + Width + if k1 == k2 { + // 上 + if pos%Height+1 < Height { + p := this.Plat[pos+1].Color + if p == k1 { + bEliminate = true + return } - if pos%Height-1 >= 0 { - p := this.Plat[pos-1].Color - if p == k1 { - bEliminate = true - return - } + } + if pos%Height-1 >= 0 { + p := this.Plat[pos-1].Color + if p == k1 { + bEliminate = true + return } } } } } // 上下检测中间元素左右互换 - for i := 0; i < Height; i++ { - for j := 0; j < Height; j++ { - k := j + i*7 - if k%Height+3 < Height { - k1 := this.Plat[k].Color - k2 := this.Plat[k+2].Color - pos := k + 1 - if k1 == k2 { - if pos/Height+1 < Width { // 右 - p := this.Plat[pos+Width].Color - if p == k1 { - bEliminate = true - return - } + for k, v := range this.Plat { + if v.Color == 0 { + continue + } + + if k%Height+2 < Height { + k1 := this.Plat[k].Color + k2 := this.Plat[k+2].Color + pos := k + 1 + if k1 == k2 { + if pos/Height+1 < Width { // 右 + p := this.Plat[pos+Width].Color + if p == k1 { + bEliminate = true + return } - if pos/Height-1 >= 0 { // 右 - p := this.Plat[pos-Width].Color - if p == k1 { - bEliminate = true - return - } + } + if pos/Height-1 >= 0 { // 右 + p := this.Plat[pos-Width].Color + if p == k1 { + bEliminate = true + return } } } } } if !bEliminate { + fmt.Printf("=====地图数据不能交换===========\n") this.Debugf() } @@ -905,5 +912,5 @@ func (this *MapData) RedsetPlatData() { } this.SetIndelibilityPlat() - this.Debugf() + //this.Debugf() } diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index c0882e251..b2910216d 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -84,9 +84,10 @@ func Test_Main(t *testing.T) { }() m := new(entertainment.MapData) m.InitMap(nil) + + //m.SkillUp(24, 1, 3, 7, true) + m.SetMap() m.Debugf() - m.SkillUp(24, 1, 3, 7, true) - // m.SetMap() b := m.CheckAndRefreshPlat() fmt.Printf("xxxx%v", b) m.RedsetPlatData()