玩家技能

This commit is contained in:
meixiongfeng 2023-10-24 18:09:58 +08:00
parent 88dd4aea0e
commit a640c50d22
3 changed files with 14 additions and 7 deletions

View File

@ -190,7 +190,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
}
if this.player1.Energy >= conf.Skillload {
this.player1.Energy = conf.Skillload // 清零
this.chessboard.SkillUp(conf.Skilleffect, conf.Skillvalue)
curScore, szMap = this.chessboard.SkillUp(conf.Skilleffect, conf.Skillvalue)
}
}
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{

View File

@ -4,6 +4,7 @@ import (
"crypto/rand"
"fmt"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"math/big"
)
@ -463,7 +464,7 @@ func (this *MapData) CheckMap(color int32) (score int32, szMap []*pb.MapData) {
score += curScore // 总分
if this.DropGirde() {
szMap = append(szMap, &pb.MapData{
Data: this.GetPalat(),
Data: this.GetPalatData(),
CurSocre: curScore,
Xgrid: count,
})
@ -507,7 +508,7 @@ func (this *MapData) DropGirde() bool {
return bDrop
}
func (this *MapData) GetPalat() (data []*pb.GirdeData) {
func (this *MapData) GetPalatData() (data []*pb.GirdeData) {
for _, v := range this.Plat {
data = append(data, &pb.GirdeData{
Oid: v.Oid,
@ -563,11 +564,16 @@ func (this *MapData) AiSwapGirde() (score int32, szMap []*pb.MapData, oid1 int32
}
// 释放技能 技能id 和参数
func (this *MapData) SkillUp(skillid int32, value int32) (plat *pb.MapData) {
func (this *MapData) SkillUp(skillid int32, value int32) (score int32, szMap []*pb.MapData) {
if skillid == 1 { // 随机消除盘面上X个方块
ids := utils.RandomNumbers(0, Total-1, int(value))
for _, id := range ids {
this.Plat[id] = &pb.GirdeData{}
}
if this.DropGirde() {
score, szMap = this.CheckMap(1)
}
}
return &pb.MapData{
Data: this.Plat,
}
return
}

View File

@ -90,6 +90,7 @@ func Test_Main(t *testing.T) {
// if bSwap, m := m.AiSwapGirde(); bSwap {
// szMap = append(szMap, m...)
// }
m.SkillUp(1, 7)
m.SwapGirde(1, 8)
m.CheckMap(1)