This commit is contained in:
liwei1dao 2023-11-02 15:09:22 +08:00
commit f14bfa7567
3 changed files with 81 additions and 73 deletions

View File

@ -429,11 +429,11 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
} }
case "ready": case "ready":
var bStartGame bool // 可以开始游戏 var bStartGame bool // 可以开始游戏
if len(this.szSession) == 1 { // AI对战的话直接开始游戏
this.NexPower = this.player1.Userinfo.Uid this.NexPower = this.player1.Userinfo.Uid
this.curPower = this.player1.Userinfo.Uid this.curPower = this.player1.Userinfo.Uid
this.player1.Ps = MaxPs this.player1.Ps = MaxPs
this.player2.Ps = 0 this.player2.Ps = 0
if len(this.szSession) == 1 { // AI对战的话直接开始游戏
bStartGame = true bStartGame = true
} else { } else {
if this.player1.Userinfo.Uid == session.GetUserId() { if this.player1.Userinfo.Uid == session.GetUserId() {

View File

@ -620,13 +620,13 @@ func (this *MapData) CheckInitPlat() {
func (this *MapData) SetMap() { func (this *MapData) SetMap() {
sz2 := []int32{ sz2 := []int32{
5, 5, 4, 1, 1, 2, 5, 3, 3, 2, 2, 1, 3, 1,
3, 6, 3, 4, 6, 2, 1, 5, 1, 2, 3, 1, 2, 2,
3, 5, 6, 3, 1, 6, 1, 3, 4, 3, 5, 6, 1, 6,
1, 2, 6, 5, 4, 1, 3, 1, 4, 6, 4, 2, 3, 6,
4, 4, 3, 5, 4, 6, 4, 1, 5, 6, 5, 6, 1, 4,
5, 6, 1, 4, 3, 3, 6, 5, 3, 4, 1, 4, 3, 3,
5, 3, 5, 3, 6, 1, 5, 3, 3, 5, 1, 1, 2, 5,
// 1, 4, 2, 5, 4, 5, 2, // 1, 4, 2, 5, 4, 5, 2,
// 3, 2, 3, 5, 2, 1, 4, // 3, 2, 3, 5, 2, 1, 4,
// 2, 5, 5, 4, 5, 4, 1, // 2, 5, 5, 4, 5, 4, 1,
@ -655,15 +655,15 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
if v.Color == 0 { if v.Color == 0 {
continue continue
} }
x := int32(k % Height) // x x := int32(k % Height)
y := int32(k / Height) // y y := int32(k / Height)
if x+2 < Height { // 上 if x+2 < Height { // 上
k1 := this.Plat[k].Color k1 := this.Plat[k].Color
k2 := this.Plat[k+1].Color k2 := this.Plat[k+1].Color
if k1 == k2 { // 校验k3 左边和右边 if k1 == k2 { // 校验k3 左边和右边
if true { if true {
pos := k + 2 pos := k + 2
if pos/Width-1 >= 0 { // if pos/Width-1 >= 0 { //
p := this.Plat[pos-Width].Color p := this.Plat[pos-Width].Color
if p == k1 { if p == k1 {
bEliminate = true bEliminate = true
@ -687,6 +687,7 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
} }
// xia // xia
pos := k - 1 pos := k - 1
if x > 0 {
if pos%Height > 0 { // 左右 if pos%Height > 0 { // 左右
if pos/Width-1 >= 0 { //左 if pos/Width-1 >= 0 { //左
p := this.Plat[pos-Width].Color p := this.Plat[pos-Width].Color
@ -703,7 +704,8 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
} }
} }
} }
if pos%Height-1 >= 0 { }
if x > 1 {
p := this.Plat[pos-1].Color p := this.Plat[pos-1].Color
if p == k1 { if p == k1 {
bEliminate = true bEliminate = true
@ -772,13 +774,17 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
} }
} }
for index := Width - 1; index >= 0; index-- { for k, v := range this.Plat {
for j := 0; j < Height; j++ { if v.Color == 0 {
k := index + j*7 continue
if j+3 < Width { }
// x := int32(k % Height) // x
y := int32(k / Height) // y
if y+2 < Width {
k1 := this.Plat[k].Color k1 := this.Plat[k].Color
k2 := this.Plat[k+2*Width].Color k2 := this.Plat[k+2*Width].Color
pos := index + (j+1)*7 pos := k + Width
if k1 == k2 { if k1 == k2 {
// 上 // 上
if pos%Height+1 < Height { if pos%Height+1 < Height {
@ -798,12 +804,13 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
} }
} }
} }
}
// 上下检测中间元素左右互换 // 上下检测中间元素左右互换
for i := 0; i < Height; i++ { for k, v := range this.Plat {
for j := 0; j < Height; j++ { if v.Color == 0 {
k := j + i*7 continue
if k%Height+3 < Height { }
if k%Height+2 < Height {
k1 := this.Plat[k].Color k1 := this.Plat[k].Color
k2 := this.Plat[k+2].Color k2 := this.Plat[k+2].Color
pos := k + 1 pos := k + 1
@ -825,8 +832,8 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
} }
} }
} }
}
if !bEliminate { if !bEliminate {
fmt.Printf("=====地图数据不能交换===========\n")
this.Debugf() this.Debugf()
} }
@ -905,5 +912,5 @@ func (this *MapData) RedsetPlatData() {
} }
this.SetIndelibilityPlat() this.SetIndelibilityPlat()
this.Debugf() //this.Debugf()
} }

View File

@ -84,9 +84,10 @@ func Test_Main(t *testing.T) {
}() }()
m := new(entertainment.MapData) m := new(entertainment.MapData)
m.InitMap(nil) m.InitMap(nil)
//m.SkillUp(24, 1, 3, 7, true)
m.SetMap()
m.Debugf() m.Debugf()
m.SkillUp(24, 1, 3, 7, true)
// m.SetMap()
b := m.CheckAndRefreshPlat() b := m.CheckAndRefreshPlat()
fmt.Printf("xxxx%v", b) fmt.Printf("xxxx%v", b)
m.RedsetPlatData() m.RedsetPlatData()