This commit is contained in:
liwei1dao 2023-10-24 10:55:07 +08:00
commit 0f546d1be5
2 changed files with 463 additions and 341 deletions

View File

@ -86,8 +86,8 @@ func (this *MapData) SwapGirde(oldId, newId int32) (bSwap bool) {
func (this *MapData) SetMap() { func (this *MapData) SetMap() {
sz2 := []int32{ sz2 := []int32{
5, 1, 2, 5, 1, 5, 2, 5, 1, 2, 5, 1, 5, 2,
3, 1, 5, 4, 2, 4, 4, 5, 1, 5, 4, 2, 4, 4,
4, 4, 2, 1, 6, 4, 1, 4, 5, 5, 1, 6, 4, 1,
6, 3, 1, 4, 3, 6, 3, 6, 3, 1, 4, 3, 6, 3,
6, 1, 3, 5, 1, 6, 1, 6, 1, 3, 5, 1, 6, 1,
5, 6, 5, 5, 1, 3, 1, 5, 6, 5, 5, 1, 3, 1,
@ -133,7 +133,7 @@ func (this *MapData) Check5X(color int32) (bEliminate bool, score int32, count i
} }
this.oid++ this.oid++
// 生成一个新的类型元素 // 生成一个新的类型元素
if conf, err := this.module.configure.GetGameBlock(k1, FiveType); err != nil { if conf, err := this.module.configure.GetGameBlock(k1, FiveType); err == nil {
this.Plat[k+2] = &pb.GirdeData{ this.Plat[k+2] = &pb.GirdeData{
Oid: this.oid, Oid: this.oid,
Color: k1, Color: k1,
@ -161,7 +161,7 @@ func (this *MapData) Check5X(color int32) (bEliminate bool, score int32, count i
} }
this.oid++ this.oid++
// 生成一个新的类型元素 // 生成一个新的类型元素
if conf, err := this.module.configure.GetGameBlock(k1, FiveType); err != nil { if conf, err := this.module.configure.GetGameBlock(k1, FiveType); err == nil {
this.Plat[k+2*Width] = &pb.GirdeData{ this.Plat[k+2*Width] = &pb.GirdeData{
Oid: this.oid, Oid: this.oid,
Color: k1, Color: k1,
@ -256,8 +256,8 @@ func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count i
} }
this.oid++ this.oid++
// 生成一个新的类型元素 // 生成一个新的类型元素
if this.module != nil {
if conf, err := this.module.configure.GetGameBlock(k1, FourUType); err != nil { // 上下类型 if conf, err := this.module.configure.GetGameBlock(k1, FourUType); err == nil { // 上下类型
this.Plat[newElem] = &pb.GirdeData{ this.Plat[newElem] = &pb.GirdeData{
Oid: this.oid, Oid: this.oid,
Color: k1, Color: k1,
@ -271,9 +271,6 @@ func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count i
} else { } else {
xiaochu = append(xiaochu, newElem) xiaochu = append(xiaochu, newElem)
} }
} else {
xiaochu = append(xiaochu, newElem)
}
if newElem == k+1 { if newElem == k+1 {
xiaochu = append(xiaochu, []int{k, k + 2, k + 3}...) xiaochu = append(xiaochu, []int{k, k + 2, k + 3}...)
} else { } else {
@ -305,9 +302,9 @@ func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count i
} }
this.oid++ this.oid++
if this.module != nil {
// 生成一个新的类型元素 // 生成一个新的类型元素
if conf, err := this.module.configure.GetGameBlock(k1, FourLType); err != nil { // 左右类型 if conf, err := this.module.configure.GetGameBlock(k1, FourLType); err == nil { // 左右类型
this.Plat[newElem] = &pb.GirdeData{ this.Plat[newElem] = &pb.GirdeData{
Oid: this.oid, Oid: this.oid,
Color: k1, Color: k1,
@ -321,9 +318,6 @@ func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count i
} else { } else {
xiaochu = append(xiaochu, k+Width) xiaochu = append(xiaochu, k+Width)
} }
} else {
xiaochu = append(xiaochu, k+Width)
}
if newElem == k+Width { if newElem == k+Width {
xiaochu = append(xiaochu, []int{k, k + 2*Width, k + 3*Width}...) xiaochu = append(xiaochu, []int{k, k + 2*Width, k + 3*Width}...)
} else { } else {
@ -468,10 +462,12 @@ func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData, co
score += curScore // 总分 score += curScore // 总分
this.DropGirde() this.DropGirde()
if curScore > 0 {
szMap = append(szMap, &pb.MapData{ szMap = append(szMap, &pb.MapData{
Data: this.Plat, Data: this.Plat,
CurSocre: curScore, CurSocre: curScore,
}) })
}
// 检查掉落 // 检查掉落
this.operElem = []int32{} // 初始化操作元素 this.operElem = []int32{} // 初始化操作元素
if curScore == 0 { if curScore == 0 {
@ -523,8 +519,9 @@ func (this *MapData) AiSwapGirde() (bSwap bool, szMap []*pb.MapData, oid1 int32,
if s, m, _ := this.CheckMap(2); s == 0 { if s, m, _ := this.CheckMap(2); s == 0 {
this.SwapGirde(int32(pos+1), int32(pos)) this.SwapGirde(int32(pos+1), int32(pos))
this.operElem = []int32{} this.operElem = []int32{}
oid1 = 0
oid2 = 0
} else { } else {
szMap = append(szMap, m...) szMap = append(szMap, m...)
bSwap = true bSwap = true
break break
@ -538,6 +535,8 @@ func (this *MapData) AiSwapGirde() (bSwap bool, szMap []*pb.MapData, oid1 int32,
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{}
oid1 = 0
oid2 = 0
} else { } else {
szMap = append(szMap, m...) szMap = append(szMap, m...)
bSwap = true bSwap = true

File diff suppressed because it is too large Load Diff