元素蔓延技能

This commit is contained in:
meixiongfeng 2023-11-09 12:34:19 +08:00
parent 24bfff009d
commit 16249e20e9
2 changed files with 33 additions and 24 deletions

View File

@ -64,7 +64,6 @@ func (this *MapData) CreateGride(count int) (girdes []*pb.GirdeData) {
Score: 1,
Special: 0,
}
id = this.GetRandType()
conf, err = this.module.configure.GetGameBlockByKey(id)
if err == nil {
@ -149,6 +148,9 @@ func (this *MapData) InitMap(module *Entertainment, iType int32) {
this.SetIndelibilityPlat()
this.Plat = this.GetPalatData()
//this.SetMap() // 方便测试固定地图
fmt.Printf("=======%v=========\n", this.Skill3(24, 0))
this.Debugf()
}
// 交换之前先判断是不是特殊元素的交换
@ -227,11 +229,11 @@ func (this *MapData) SwapGirde(oldId, newId int32) (bSwap bool) {
func (this *MapData) Debugf() {
fmt.Printf("================\n")
//var v int
var v int
for index := Width - 1; index >= 0; index-- {
for j := 0; j < Height; j++ {
// v = index + j*7
fmt.Printf("%d:%d ", this.Plat[index+j*Height].Oid, this.Plat[index+j*Height].Cid)
v = index + j*7
fmt.Printf("%d:%d ", v, this.Plat[index+j*Height].Cid)
}
fmt.Printf("\n")
@ -726,19 +728,10 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32,
ids = append(ids, 3*Width+i)
}
} else if skillid == 3 { // 四周蔓延 第一次100% 第二次 60% 第三次 30% 第四次 10% 最多4次
var mids map[int]struct{}
mids = make(map[int]struct{}, 0)
for i := 0; i < 4; i++ {
dd := this.Skill3(pos, int32(i))
for k := range dd {
for s := range this.Skill3(int32(k), int32(i)) {
mids[s] = struct{}{}
}
}
}
for k := range mids {
for k := range this.Skill3(pos, 0) {
ids = append(ids, k) // 转换成最终消除的坐标
}
ids = append(ids, int(pos)) // 包含自己
}
for _, id := range ids {
if s := this.Plat[id].Special; s != 0 {
@ -810,7 +803,7 @@ func (this *MapData) CheckAndRefreshPlat() (bEliminate bool) {
// xia
pos := k - 1
if x > 0 {
if pos%Height > 0 { // 左右
if pos%Height >= 0 { // 左右
if pos/Width-1 >= 0 { //左
p := this.Plat[pos-Width].Color
if p == k1 {
@ -980,7 +973,9 @@ func (this *MapData) SetIndelibilityPlat() {
oldId := Total - 1
for i := 0; i < Total; i++ {
if this.Plat[oldId].Color == k3 { // 找到颜色不一样的
oldId -= 1
if oldId > 0 {
oldId -= 1
}
} else {
break
}
@ -1045,6 +1040,7 @@ func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) {
m = make(map[int]struct{}, 0)
var sz []int
var percent int32
var cur []int
// 先找出可以蔓延的方向
x := int(pos / Width)
y := int(pos % Height)
@ -1061,12 +1057,12 @@ func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) {
sz = append(sz, (x+1)*Width+(y))
}
if count == 0 {
if count == 0 { // 蔓延技能概率调整支持配置
percent = 100
} else if count == 1 {
percent = 100
percent = 60
} else if count == 2 || count == 3 {
percent = 100
percent = 30
} else {
return
}
@ -1075,6 +1071,18 @@ func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) {
for _, v := range szid {
if percent >= comm.GetRandNum(0, 100) {
m[sz[v]] = struct{}{}
cur = append(cur, sz[v])
}
}
count++
// for _, v := range cur {
// fmt.Printf("=======蔓延的id:%d====,count=%d====\n", v, count)
// }
// fmt.Printf("=======count=%d====\n", count)
for _, k := range cur {
for k1 := range this.Skill3(int32(k), count) { // 递归蔓延
m[k1] = struct{}{}
}
}
@ -1206,10 +1214,8 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) {
if k == id {
continue
}
sp := this.Plat[k].Special
if sp != 0 {
this.Plat[k].Special = 0
ids := this.SpecialElem(k, sp) // 递归调用
if this.Plat[k].Special != 0 {
ids := this.SpecialElem(k, this.Plat[k].Special) // 递归调用
for key := range ids {
x[key] = struct{}{}
}

View File

@ -89,7 +89,10 @@ func Test_Main(t *testing.T) {
// fmt.Printf("xxxx%v", sz)
m := new(entertainment.MapData)
m.InitMap(nil, 1)
m.SetMap()
m.Debugf()
fmt.Printf("xxxx %v\n", m.Skill3(24, 0))
//m.SkillUp(24, 1, 3, 7, true)
b := m.GetFireBoom(1, 7)