Skip to content

Commit

Permalink
fix gameserver build lose
Browse files Browse the repository at this point in the history
  • Loading branch information
gucooing committed Jul 18, 2024
1 parent 6001a50 commit 2529c69
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 23 deletions.
41 changes: 30 additions & 11 deletions gameserver/player/db_battle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
package player

import (
"strconv"
"strings"
"sync"
"time"

"github.com/gucooing/hkrpg-go/pkg/alg"
"github.com/gucooing/hkrpg-go/pkg/gdconf"
"github.com/gucooing/hkrpg-go/pkg/logger"
"github.com/gucooing/hkrpg-go/protocol/cmd"
"github.com/gucooing/hkrpg-go/protocol/proto"
spb "github.com/gucooing/hkrpg-go/protocol/server"
)
Expand Down Expand Up @@ -106,23 +109,39 @@ func (g *GamePlayer) GetOnLineAvatarBuffById(id uint32) *OnLineAvatarBuff {
return db[id]
}

func (g *GamePlayer) HandleAvatarSkill(entityId, skillIndex uint32) {
func (g *GamePlayer) HandleAvatarSkill(entityId uint32) (bool, bool) {
avatar := g.GetAvatarEntity(entityId)
isBattle := true
isDelMp := false
if avatar == nil {
return
return true, false
}
confAvatar := gdconf.GetAdventurePlayerByAvatarId(avatar.AvatarId)
if confAvatar == nil || uint32(len(confAvatar.MazeSkillIdList)) < skillIndex {
return
}
confBuff := gdconf.GetAvatarMazeBuffById(confAvatar.MazeSkillIdList[skillIndex], 1)
if confBuff == nil {
return
if confAvatar == nil {
return true, false
}
switch confBuff.UseType {
case "AddBattleBuff":
g.AddOnLineAvatarBuff(avatar.AvatarId, confBuff.ID)
for _, mazeSkillId := range confAvatar.MazeSkillIdList {
confBuff := gdconf.GetAvatarMazeBuffById(mazeSkillId, 1)
if confBuff == nil {
continue
}
switch confBuff.UseType {
case "AddBattleBuff":
g.AddOnLineAvatarBuff(avatar.AvatarId, confBuff.ID)
}
if strings.Contains(confBuff.BuffEffect, "MazeBuffEffect") {
// isBattle = false
summonId := strconv.FormatUint(uint64(mazeSkillId), 10)[:4] + strconv.FormatUint(uint64(mazeSkillId), 10)[5:]
g.Send(cmd.SceneGroupRefreshScNotify, &proto.SceneGroupRefreshScNotify{
GroupRefreshList: g.GetAddBuffSceneEntityRefreshInfo(entityId, alg.S2U32(summonId), g.GetRotPb(), g.GetPosPb()),
})
}
if confBuff.InBattleBindingKey != "" {
isDelMp = true
}
}

return isBattle, isDelMp
}

func (g *GamePlayer) AddOnLineAvatarBuff(avatarID, buffId uint32) {
Expand Down
36 changes: 24 additions & 12 deletions gameserver/player/player_battle.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func (g *GamePlayer) SceneCastSkillCostMpCsReq(payloadMsg []byte) {
CastEntityId: req.CastEntityId,
Retcode: 0,
}
g.Send(cmd.SceneCastSkillMpUpdateScNotify, &proto.SceneCastSkillMpUpdateScNotify{CastEntityId: req.CastEntityId})
g.Send(cmd.SceneCastSkillCostMpScRsp, rsp)
}

Expand All @@ -43,13 +42,11 @@ func (g *GamePlayer) SceneCastSkillCsReq(payloadMsg []byte) {
CastEntityId: req.CastEntityId, // 攻击唯一id
}
// 根据各种情况进行处理
isBattle := true
isDelMp := false
if req.SkillIndex != 0 {
// 这里的情况是角色释放技能
g.Send(cmd.SceneGroupRefreshScNotify, &proto.SceneGroupRefreshScNotify{
GroupRefreshList: g.GetAddBuffSceneEntityRefreshInfo(req.AttackedByEntityId, g.GetRotPb(), g.GetPosPb()),
})
g.DelLineUpMp(1)
g.HandleAvatarSkill(req.AttackedByEntityId, req.SkillIndex)
isBattle, isDelMp = g.HandleAvatarSkill(req.AttackedByEntityId)
}
// 添加参与此次攻击的实体
mpem := &MPEM{
Expand All @@ -59,22 +56,37 @@ func (g *GamePlayer) SceneCastSkillCsReq(payloadMsg []byte) {
PropEntityId: make([]uint32, 0),
PropId: make([]uint32, 0),
}
// 怪物协助列表
g.GetMem([]uint32{req.AttackedByEntityId}, mpem)
// 添加攻击发起者
if req.AssistMonsterEntityInfo != nil {
for _, info := range req.AssistMonsterEntityInfo {
g.GetMem(info.EntityIdList, mpem)
}
} else {
if req.AssistMonsterEntityIdList != nil {
g.GetMem(req.AssistMonsterEntityIdList, mpem)
g.GetMem([]uint32{req.AttackedByEntityId}, mpem)
}
// 添加被攻击者
if req.AssistMonsterEntityIdList != nil {
g.GetMem(req.AssistMonsterEntityIdList, mpem)
} else {
if req.HitTargetEntityIdList != nil {
g.GetMem(req.HitTargetEntityIdList, mpem)
}
}
if len(mpem.MonsterEntityId) != 0 && isBattle {
isDelMp = true
}
if isDelMp {
g.DelLineUpMp(1)
g.Send(cmd.SceneCastSkillMpUpdateScNotify, &proto.SceneCastSkillMpUpdateScNotify{
CastEntityId: req.CastEntityId,
Mp: g.GetLineUpMp(),
})
}
if mpem.PropId != nil { // 物品效果
g.SceneCastSkillProp(mpem)
}
g.SyncLineupNotify(g.GetBattleLineUp()) // 队伍同步
if !mpem.IsAvatar || len(mpem.MonsterEntityId) == 0 { // 是否满足战斗条件
g.SyncLineupNotify(g.GetBattleLineUp()) // 队伍同步
if !mpem.IsAvatar || len(mpem.MonsterEntityId) == 0 || !isBattle { // 是否满足战斗条件
g.Send(cmd.SceneCastSkillScRsp, rsp)
return
}
Expand Down

0 comments on commit 2529c69

Please sign in to comment.