上传代码
This commit is contained in:
parent
9057112fda
commit
7387b376ed
@ -110,8 +110,7 @@ func (this *Room) AiOperator() {
|
|||||||
var (
|
var (
|
||||||
curScore int32
|
curScore int32
|
||||||
szMap []*pb.MapData
|
szMap []*pb.MapData
|
||||||
curid int32
|
|
||||||
targetid int32
|
|
||||||
oid1 int32
|
oid1 int32
|
||||||
oid2 int32
|
oid2 int32
|
||||||
)
|
)
|
||||||
@ -124,12 +123,11 @@ func (this *Room) AiOperator() {
|
|||||||
this.player1.Ps = MaxPs
|
this.player1.Ps = MaxPs
|
||||||
|
|
||||||
// 交换元素
|
// 交换元素
|
||||||
_, szMap, curid, targetid = this.chessboard.AiSwapGirde()
|
_, szMap, oid1, oid2 = this.chessboard.AiSwapGirde()
|
||||||
if this.NexPower != this.curPower {
|
if this.NexPower != this.curPower {
|
||||||
this.round++
|
this.round++
|
||||||
}
|
}
|
||||||
oid1 = this.chessboard.Plat[targetid].Oid
|
|
||||||
oid2 = this.chessboard.Plat[curid].Oid
|
|
||||||
this.player2.Score += curScore
|
this.player2.Score += curScore
|
||||||
// 广播消息
|
// 广播消息
|
||||||
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||||
|
@ -512,17 +512,19 @@ func (this *MapData) DropGirde() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ai操作
|
// 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++ {
|
for pos := 0; pos < Total; pos++ {
|
||||||
y := pos % Height
|
y := pos % Height
|
||||||
if y < Height-1 {
|
if y < Height-1 {
|
||||||
if b := this.SwapGirde(int32(pos), int32(pos+1)); b {
|
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 {
|
if s, m, _ := this.CheckMap(2); s == 0 {
|
||||||
|
this.SwapGirde(int32(pos+1), int32(pos))
|
||||||
this.operElem = []int32{}
|
this.operElem = []int32{}
|
||||||
} else {
|
} else {
|
||||||
pre = int32(pos)
|
|
||||||
aft = int32(pos + 1)
|
|
||||||
szMap = append(szMap, m...)
|
szMap = append(szMap, m...)
|
||||||
bSwap = true
|
bSwap = true
|
||||||
break
|
break
|
||||||
@ -531,12 +533,12 @@ func (this *MapData) AiSwapGirde() (bSwap bool, szMap []*pb.MapData, pre int32,
|
|||||||
}
|
}
|
||||||
if pos/Width+1 < Width {
|
if pos/Width+1 < Width {
|
||||||
if b := this.SwapGirde(int32(pos), int32(pos+Width)); b {
|
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 {
|
if s, m, _ := this.CheckMap(2); s == 0 {
|
||||||
this.SwapGirde(int32(pos+Width), int32(pos))
|
this.SwapGirde(int32(pos+Width), int32(pos))
|
||||||
this.operElem = []int32{}
|
this.operElem = []int32{}
|
||||||
} else {
|
} else {
|
||||||
pre = int32(pos)
|
|
||||||
aft = int32(pos + Width)
|
|
||||||
szMap = append(szMap, m...)
|
szMap = append(szMap, m...)
|
||||||
bSwap = true
|
bSwap = true
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user