玩家技能带入

This commit is contained in:
meixiongfeng 2023-12-18 17:11:34 +08:00
parent 708ed34d28
commit 69ff573f16
3 changed files with 94 additions and 16 deletions

View File

@ -68,23 +68,20 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) {
playerSlice = append(playerSlice, v.(*pb.DBXXLMatch))
}
for pos, v := range playerSlice {
t := make(map[int32]int32, 0)
for _, v := range v.Skill {
t[v] = 1
}
if pos == 0 {
p1 = &pb.PlayerData{
Userinfo: v.Userinfo,
Cardid: v.Cardid,
Consumeexp: v.Consumeexp,
Skill: t,
Skill: v.Skill,
}
} else if pos == 1 {
p2 = &pb.PlayerData{
Userinfo: v.Userinfo,
Cardid: v.Cardid,
Consumeexp: v.Consumeexp,
Skill: t,
Skill: v.Skill,
}
} else {
break

View File

@ -196,11 +196,12 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
switch stype {
case "operator": // 操作消息
var (
curScore int32 // 该次操作的得分
oid1 int32 // 唯一id
oid2 int32
color int32 // 校验消除的颜色
bAddPs bool
curScore int32 // 该次操作的得分
oid1 int32 // 唯一id
oid2 int32
color int32 // 校验消除的颜色
bAddPs bool
curPlayer *pb.PlayerData
)
var szMap []*pb.MapData
req := msg.(*pb.EntertainOperatorReq)
@ -213,8 +214,10 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
}
if this.curPower == this.player1.Userinfo.Uid {
color = 1
curPlayer = this.player1
} else {
color = 2
curPlayer = this.player2
}
if req.Itype == 1 { //释放技能
if errdata = this.UserSkillUp(color, req.Curid); errdata != nil {
@ -237,7 +240,23 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
}
if list, err = this.module.model.getEntertainmList(session.GetUserId()); err == nil {
this.module.Debugf("%v,%v", conf, list)
}
if curPlayer.Skill[req.Itype] <= 0 {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_EntertainNoSkillCard, // 技能卡不足
Title: pb.ErrorCode_EntertainNoSkillCard.ToString(),
}
return
}
curPlayer.Skill[req.Itype] -= 1
if errdata = this.UserCardSkill(curPlayer, req.Curid); errdata != nil {
return
}
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
"skill": curPlayer.Skill,
})
return
}
if req.Itype == 0 && req.Curid == 0 && req.Targetid == 0 {
if this.curPower == this.player1.Userinfo.Uid {
@ -908,3 +927,61 @@ func (this *Room) ChangePower() {
this.player2.Ps = 0
}
}
// 玩家释放技能
func (this *Room) UserCardSkill(curPlayer *pb.PlayerData, curid int32) (errdata *pb.ErrorData) {
var (
curScore int32 // 该次操作的得分
oid1 int32 // 唯一id
oid2 int32
)
var szMap []*pb.MapData
conf, err := this.module.configure.GetGameConsumeHero(curPlayer.Cardid)
if err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_EntertainNoHeroSkill,
Title: pb.ErrorCode_EntertainNoHeroSkill.ToString(),
}
return
}
if curPlayer.Energy >= conf.Skillload {
curPlayer.Energy = 0 // 清零
if _, m := this.chessboard.SkillUp(curid, 1, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
szMap = append(szMap, m...)
} else {
szMap = append(szMap, &pb.MapData{
Data: this.chessboard.GetPalatData(),
})
}
for _, v := range szMap {
curScore += v.CurSocre
curPlayer.Score += v.CurSocre
v.CurSocre = curPlayer.Score
}
} else {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_EntertainNoEnergy,
Title: pb.ErrorCode_EntertainNoEnergy.ToString(),
}
return
}
this.NexPower = this.curPower
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
Mpadata: szMap,
Power: this.NexPower,
Curpower: this.curPower,
Score: curScore,
Round: this.round,
User1: this.player1,
User2: this.player2,
Itype: 1,
Curid: oid1,
Targetid: oid2,
}, this.szSession...); err != nil {
this.module.Errorln(err)
}
return
}

View File

@ -468,6 +468,7 @@ const (
ErrorCode_EntertainBoxEndTime ErrorCode = 5209 // 宝箱开启时间没到
ErrorCode_EntertainMaxTouxiangCount ErrorCode = 5210 // 达到每日最大投降次数
ErrorCode_EntertainNoGamePlayering ErrorCode = 5211 // 非游戏中 不能投降
ErrorCode_EntertainNoSkillCard ErrorCode = 5212 //技能卡不足
// integral
ErrorCode_TntegralDayMaxChallenge ErrorCode = 5301 // 当日挑战达上限
)
@ -875,6 +876,7 @@ var (
5209: "EntertainBoxEndTime",
5210: "EntertainMaxTouxiangCount",
5211: "EntertainNoGamePlayering",
5212: "EntertainNoSkillCard",
5301: "TntegralDayMaxChallenge",
}
ErrorCode_value = map[string]int32{
@ -1278,6 +1280,7 @@ var (
"EntertainBoxEndTime": 5209,
"EntertainMaxTouxiangCount": 5210,
"EntertainNoGamePlayering": 5211,
"EntertainNoSkillCard": 5212,
"TntegralDayMaxChallenge": 5301,
}
)
@ -1313,7 +1316,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xdf, 0x4a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0xfa, 0x4a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76,
@ -1909,10 +1912,11 @@ var file_errorcode_proto_rawDesc = []byte{
0x61, 0x69, 0x6e, 0x4d, 0x61, 0x78, 0x54, 0x6f, 0x75, 0x78, 0x69, 0x61, 0x6e, 0x67, 0x43, 0x6f,
0x75, 0x6e, 0x74, 0x10, 0xda, 0x28, 0x12, 0x1d, 0x0a, 0x18, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74,
0x61, 0x69, 0x6e, 0x4e, 0x6f, 0x47, 0x61, 0x6d, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x69,
0x6e, 0x67, 0x10, 0xdb, 0x28, 0x12, 0x1c, 0x0a, 0x17, 0x54, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61,
0x6c, 0x44, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65,
0x10, 0xb5, 0x29, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
0x6e, 0x67, 0x10, 0xdb, 0x28, 0x12, 0x19, 0x0a, 0x14, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61,
0x69, 0x6e, 0x4e, 0x6f, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x43, 0x61, 0x72, 0x64, 0x10, 0xdc, 0x28,
0x12, 0x1c, 0x0a, 0x17, 0x54, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x79, 0x4d,
0x61, 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x10, 0xb5, 0x29, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (