三消卡片技能:将随机6个宝石染成当前盘面上颜色最多的宝石

This commit is contained in:
meixiongfeng 2024-01-10 11:13:39 +08:00
parent 9b300608f6
commit 9f1f365a48
2 changed files with 51 additions and 19 deletions

View File

@ -721,9 +721,17 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32,
ids []int
)
x = make(map[int]struct{})
if skillid == 1 { // 随机消除盘面上X个方块
switch skillid {
case 1:
ids = utils.RandomNumbers(0, Total-1, int(value))
} else if skillid == 4 { // 找到pos 位置的所有方块
case 2:
for i := 0; i < Height; i++ {
ids = append(ids, 3*Width+i)
}
case 3: // 将随机6个宝石染成当前盘面上颜色最多的宝石
this.SkillChangeColor(value)
case 4:
x := int(pos / Width)
y := int(pos % Height)
for i := 1; i < 7; i++ {
@ -742,7 +750,7 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32,
ids = append(ids, (x+i)*Width+(y-i))
}
}
} else if skillid == 5 { //选中一个方块,消除周围一圈
case 5:
ids = append(ids, int(pos)) // 包含自己
x := int(pos / Width)
y := int(pos % Height)
@ -771,16 +779,16 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32,
if x+1 < Width && y-1 >= 0 { // 右下
ids = append(ids, (x+1)*Width+(y-1))
}
} else if skillid == 2 { // 消除中间的一列宝石
for i := 0; i < Height; i++ {
ids = append(ids, 3*Width+i)
}
} else if skillid == 3 { // 四周蔓延 第一次100% 第二次 60% 第三次 30% 第四次 10% 最多4次
for k := range this.Skill3(pos, 0) {
case 8:
for k := range this.SkillManYan(pos, 0) {
ids = append(ids, k) // 转换成最终消除的坐标
}
ids = append(ids, int(pos)) // 包含自己
default:
this.module.Errorf("not found skill:%d", skillid)
return
}
for _, id := range ids {
if s := this.Plat[id].Special; s != 0 {
for k := range this.SpecialElem(id, s) {
@ -1085,7 +1093,7 @@ func (this *MapData) RedsetPlatData() {
}
//四周蔓延 第一次100% 第二次 60% 第三次 30% 第四次 10% 最多4次
func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) {
func (this *MapData) SkillManYan(pos int32, count int32) (m map[int]struct{}) {
m = make(map[int]struct{}, 0)
var sz []int
var percent int32
@ -1125,12 +1133,8 @@ func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) {
}
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) { // 递归蔓延
for k1 := range this.SkillManYan(int32(k), count) { // 递归蔓延
m[k1] = struct{}{}
}
}
@ -1471,3 +1475,31 @@ func (this *MapData) CheckElem(pos int) (xc []int) {
}
return
}
// 将随机6个宝石染成当前盘面上颜色最多的宝石 (count 替换的数量)
func (this *MapData) SkillChangeColor(count int32) {
var (
// 替换成的颜色
color int32
elemCount map[int32]int32
)
elemCount = make(map[int32]int32, 0)
for _, v := range this.Plat {
elemCount[v.Color] += 1
}
for k := range elemCount {
if color < k {
color = k
}
}
for i := 0; i < int(count); i++ {
targetId := comm.GetRandNum(0, Total-1)
if this.Plat[targetId].Color == color {
i--
} else {
this.Plat[targetId].Color = color // 变更颜色
}
}
return
}

View File

@ -119,7 +119,7 @@ func Test_Main(t *testing.T) {
m.SetMap()
m.Debugf()
fmt.Printf("xxxx %v\n", m.Skill3(24, 0))
fmt.Printf("xxxx %v\n", m.SkillManYan(24, 0))
//m.SkillUp(24, 1, 3, 7, true)
b := m.GetFireBoom(1, 7)
@ -139,12 +139,12 @@ func Test_Main(t *testing.T) {
}
var mids map[int]struct{}
mids = make(map[int]struct{}, 0)
m.Skill3(35, 0)
m.SkillManYan(35, 0)
for i := 0; i < 4; i++ {
dd := m.Skill3(24, int32(i))
dd := m.SkillManYan(24, int32(i))
for k := range dd {
for s := range m.Skill3(int32(k), int32(i)) {
for s := range m.SkillManYan(int32(k), int32(i)) {
mids[s] = struct{}{}
}
}