diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index dc4180158..5113f1169 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -110,10 +110,9 @@ func (this *Room) AiOperator() { var ( curScore int32 szMap []*pb.MapData - curid int32 - targetid int32 - oid1 int32 - oid2 int32 + + oid1 int32 + oid2 int32 ) this.module.Debugf("AI 操作\n") @@ -124,12 +123,11 @@ func (this *Room) AiOperator() { this.player1.Ps = MaxPs // 交换元素 - _, szMap, curid, targetid = this.chessboard.AiSwapGirde() + _, szMap, oid1, oid2 = this.chessboard.AiSwapGirde() if this.NexPower != this.curPower { this.round++ } - oid1 = this.chessboard.Plat[targetid].Oid - oid2 = this.chessboard.Plat[curid].Oid + this.player2.Score += curScore // 广播消息 if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{ diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index d6a5270de..e69d5bc1a 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -512,17 +512,19 @@ func (this *MapData) DropGirde() { } // ai操作 -func (this *MapData) AiSwapGirde() (bSwap bool, szMap []*pb.MapData, pre int32, aft int32) { +func (this *MapData) AiSwapGirde() (bSwap bool, szMap []*pb.MapData, oid1 int32, oid2 int32) { for pos := 0; pos < Total; pos++ { y := pos % Height if y < Height-1 { if b := this.SwapGirde(int32(pos), int32(pos+1)); b { + oid1 = this.Plat[pos+1].Oid + oid2 = this.Plat[pos].Oid if s, m, _ := this.CheckMap(2); s == 0 { + this.SwapGirde(int32(pos+1), int32(pos)) this.operElem = []int32{} } else { - pre = int32(pos) - aft = int32(pos + 1) + szMap = append(szMap, m...) bSwap = true break @@ -531,12 +533,12 @@ func (this *MapData) AiSwapGirde() (bSwap bool, szMap []*pb.MapData, pre int32, } if pos/Width+1 < Width { if b := this.SwapGirde(int32(pos), int32(pos+Width)); b { + oid1 = this.Plat[pos+Width].Oid + oid2 = this.Plat[pos].Oid if s, m, _ := this.CheckMap(2); s == 0 { this.SwapGirde(int32(pos+Width), int32(pos)) this.operElem = []int32{} } else { - pre = int32(pos) - aft = int32(pos + Width) szMap = append(szMap, m...) bSwap = true break