From 11bd3e4742e8f9edec9ced86b595341499493900 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 1 Nov 2023 11:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E6=8A=80=E8=83=BD=E4=B8=8D?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A7=AF=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/entertainment/room.go | 4 +- modules/entertainment/xxlPlat.go | 68 ++++++++++++++++++++++--------- modules/entertainment/xxl_test.go | 4 +- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 73116113e..e92401be0 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -247,7 +247,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } if this.player1.Energy >= conf.Skillload { this.player1.Energy = 0 // 清零 - if _, m := this.chessboard.SkillUp(conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 { + if _, m := this.chessboard.SkillUp(color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 { szMap = append(szMap, m...) } else { szMap = append(szMap, &pb.MapData{ @@ -279,7 +279,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr } if this.player2.Energy >= conf.Skillload { this.player2.Energy = 0 // 清零 - if _, m := this.chessboard.SkillUp(conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 { + if _, m := this.chessboard.SkillUp(color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 { szMap = append(szMap, m...) } else { szMap = append(szMap, &pb.MapData{ diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 86649a9a8..edb827e4d 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -89,11 +89,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 ", v, this.Plat[index+j*Height].Cid) + // v = index + j*7 + fmt.Printf("%d:%d ", this.Plat[index+j*Height].Oid, this.Plat[index+j*Height].Cid) } fmt.Printf("\n") @@ -351,7 +351,7 @@ func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc } else if s == FiveType { // 随机消除 // 获取配置 if c, _ := this.module.configure.GetGameBlock(this.Plat[id].Color, FiveType); c != nil { - if xc, _ := this.SkillUp(1, c.Value, false); len(xc) > 0 { + if xc, _ := this.SkillUp(color, 1, c.Value, false); len(xc) > 0 { //szMap = append(szMap, sz...) for key := range xc { x[key] = struct{}{} @@ -379,7 +379,7 @@ func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc CurSocre: curScore, CurEnergy: energy, }) - this.Debugf() + } // 检查掉落 @@ -478,7 +478,12 @@ func (this *MapData) AiSwapGirde() (szMap []*pb.MapData, oid1 int32, oid2 int32, } // 释放技能 技能id 和参数 -func (this *MapData) SkillUp(skillid int32, value int32, bDrop bool) (x map[int]struct{}, szMap []*pb.MapData) { +func (this *MapData) SkillUp(color int32, skillid int32, value int32, bDrop bool) (x map[int]struct{}, szMap []*pb.MapData) { + var ( + skillScore int32 // 技能获得的分数 + skillEnergy int32 // 技能获得的能量 + ) + if skillid == 1 { // 随机消除盘面上X个方块 x = make(map[int]struct{}) ids := utils.RandomNumbers(0, Total-1, int(value)) @@ -496,7 +501,7 @@ func (this *MapData) SkillUp(skillid int32, value int32, bDrop bool) (x map[int] } else if s == FiveType { // 随机消除 // 获取配置 if c, _ := this.module.configure.GetGameBlock(this.Plat[id].Color, FiveType); c != nil { - if xc, _ := this.SkillUp(1, c.Value, false); len(xc) > 0 { // 递归调用 + if xc, _ := this.SkillUp(color, 1, c.Value, false); len(xc) > 0 { // 递归调用 for key := range xc { x[key] = struct{}{} } @@ -508,9 +513,18 @@ func (this *MapData) SkillUp(skillid int32, value int32, bDrop bool) (x map[int] } if bDrop { for key := range x { + if this.Plat[key].Color == color { + skillEnergy += 1 + } + skillScore += this.Plat[key].Score this.Plat[key] = &pb.GirdeData{} } if this.DropGirde() { + szMap = append(szMap, &pb.MapData{ + Data: this.GetPalatData(), + CurSocre: skillScore, + CurEnergy: skillEnergy, + }) szMap, _ = this.CheckMap(1, false) } } @@ -529,13 +543,13 @@ func (this *MapData) CheckInitPlat() { func (this *MapData) SetMap() { sz2 := []int32{ - 1, 1, 2, 5, 1, 5, 2, - 3, 2, 3, 1, 2, 4, 4, - 2, 1, 1, 3, 6, 4, 1, - 4, 1, 1, 4, 3, 6, 3, - 4, 3, 4, 5, 1, 6, 1, - 5, 4, 2, 5, 3, 3, 1, - 4, 1, 5, 3, 2, 3, 4, + 1, 4, 2, 5, 4, 5, 2, + 3, 2, 3, 1, 2, 1, 4, + 2, 1, 5, 4, 6, 4, 1, + 3, 1, 3, 5, 2, 6, 3, + 4, 5, 4, 2, 4, 1, 1, + 5, 3, 1, 5, 3, 3, 4, + 4, 2, 4, 1, 2, 3, 4, } var pos int for index := Width - 1; index >= 0; index-- { @@ -663,8 +677,16 @@ func (this *MapData) SetIndelibilityPlat() { k2 := this.Plat[k+1].Color k3 := this.Plat[k+2].Color if k1 == k2 && k2 == k3 { - this.Plat[k+2].Cid = (k3+1)%5 + 1 - this.Plat[k+2].Color = (k3+1)%5 + 1 + if this.Plat[k+2].Special == 0 { + this.Plat[k+2].Cid = (k3+1)%5 + 1 + this.Plat[k+2].Color = (k3+1)%5 + 1 + } else if this.Plat[k+1].Special == 0 { + this.Plat[k+1].Cid = (k3+1)%5 + 1 + this.Plat[k+1].Color = (k3+1)%5 + 1 + } else if this.Plat[k].Special == 0 { + this.Plat[k].Cid = (k3+1)%5 + 1 + this.Plat[k].Color = (k3+1)%5 + 1 + } } } @@ -674,8 +696,16 @@ func (this *MapData) SetIndelibilityPlat() { k3 := this.Plat[k+2*Width].Color if k1 == k2 && k2 == k3 { - this.Plat[k+2*Width].Cid = (k3+1)%5 + 1 - this.Plat[k+2*Width].Color = (k3+1)%5 + 1 + if this.Plat[k+2*Width].Special == 0 { + this.Plat[k+2*Width].Cid = (k3+1)%5 + 1 + this.Plat[k+2*Width].Color = (k3+1)%5 + 1 + } else if this.Plat[k+Width].Special == 0 { + this.Plat[k+Width].Cid = (k3+1)%5 + 1 + this.Plat[k+Width].Color = (k3+1)%5 + 1 + } else if this.Plat[k].Special == 0 { + this.Plat[k].Cid = (k3+1)%5 + 1 + this.Plat[k].Color = (k3+1)%5 + 1 + } } } } @@ -683,7 +713,6 @@ func (this *MapData) SetIndelibilityPlat() { // 重新洗牌 func (this *MapData) RedsetPlatData() { - for i := 0; i < Total-1; i++ { targetId := comm.GetRandNum(0, Total-1) if i == int(targetId) { @@ -694,7 +723,6 @@ func (this *MapData) RedsetPlatData() { this.Plat[i] = this.Plat[targetId] this.Plat[targetId] = tmp } - this.Debugf() this.SetIndelibilityPlat() } diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index 3508d5d49..2de7003ee 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -84,7 +84,7 @@ func Test_Main(t *testing.T) { }() m := new(entertainment.MapData) m.InitMap(nil) - m.SetMap() + // m.SetMap() b := m.CheckAndRefreshPlat() fmt.Printf("xxxx%v", b) m.RedsetPlatData() @@ -112,7 +112,7 @@ func Test_Main(t *testing.T) { // if bSwap, m := m.AiSwapGirde(); bSwap { // szMap = append(szMap, m...) // } - m.SkillUp(1, 7, true) + m.SkillUp(1, 1, 7, true) m.SwapGirde(1, 8) //m.CheckMap(1)