diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 04584091..a640969e 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -193,24 +193,30 @@ func (f *FightC) collectAttackValues(inputs []*input.Input) []model.AttackValue return values } -func (f *FightC) collectAttackValueByAction(act *action.SelectSkillAction) []model.AttackValue { - if act == nil { - return nil +func (f *FightC) buildAttackValueForBroadcast(fighter *input.Input, fallbackActorIndex int) model.AttackValue { + if fighter == nil { + return model.AttackValue{} } - fighter := f.GetInputByAction(act, false) - if fighter == nil || fighter.AttackValue == nil || fighter.AttackValue.SkillID == 0 { - return nil + if fighter.AttackValue == nil { + empty := info.NewAttackValue(fighter.UserID) + fighter.AttackValue = empty } attackValue := *fighter.AttackValue - attackValue.ActorIndex = uint32(act.GetActorIndex()) - return []model.AttackValue{attackValue} + attackValue.ActorIndex = uint32(fallbackActorIndex) + if attackValue.UserID == 0 && fighter.Player != nil && fighter.Player.GetInfo() != nil { + attackValue.UserID = fighter.Player.GetInfo().UserID + } + return attackValue } -func (f *FightC) buildNoteUseSkillOutboundInfo(firstAttack, secondAttack *action.SelectSkillAction) info.NoteUseSkillOutboundInfo { +func (f *FightC) buildNoteUseSkillOutboundInfo() info.NoteUseSkillOutboundInfo { result := info.NoteUseSkillOutboundInfo{} - result.FirstAttackInfo = append(result.FirstAttackInfo, f.collectAttackValueByAction(firstAttack)...) - result.SecondAttackInfo = append(result.SecondAttackInfo, f.collectAttackValueByAction(secondAttack)...) - + if f.First != nil { + result.FirstAttackInfo = f.buildAttackValueForBroadcast(f.First, f.First.TeamSlotIndex()) + } + if f.Second != nil { + result.SecondAttackInfo = f.buildAttackValueForBroadcast(f.Second, f.Second.TeamSlotIndex()) + } return result } @@ -453,7 +459,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction) f.sendLegacyRoundBroadcast(firstAttack, secondAttack) } - attackValueResult := f.buildNoteUseSkillOutboundInfo(firstAttack, secondAttack) + attackValueResult := f.buildNoteUseSkillOutboundInfo() //因为切完才能广播,所以必须和回合结束分开结算 f.BroadcastPlayers(func(p common.PlayerI) { for _, switchAction := range f.Switch { @@ -481,7 +487,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction) // }) return } - if len(attackValueResult.FirstAttackInfo) > 0 || len(attackValueResult.SecondAttackInfo) > 0 { + if attackValueResult.FirstAttackInfo.UserID != 0 || attackValueResult.SecondAttackInfo.UserID != 0 { f.BroadcastPlayers(func(p common.PlayerI) { if !f.LegacyGroupProtocol { f.sendFightPacket(p, fightPacketSkillResult, &attackValueResult) diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index fbaf1c73..61ad2943 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -196,10 +196,8 @@ type PropDict struct { // NoteUseSkillOutboundInfo 战斗技能使用通知的出站信息结构体 type NoteUseSkillOutboundInfo struct { - FirstAttackInfoLen uint32 `struc:"sizeof=FirstAttackInfo"` - FirstAttackInfo []model.AttackValue // 本轮先手方精灵在释放技能结束后的状态 - SecondAttackInfoLen uint32 `struc:"sizeof=SecondAttackInfo"` - SecondAttackInfo []model.AttackValue // 本轮后手方精灵在释放技能结束后的状态 + FirstAttackInfo model.AttackValue // 本轮先手方精灵在释放技能结束后的状态 + SecondAttackInfo model.AttackValue // 本轮后手方精灵在释放技能结束后的状态 } type FightStartOutboundInfo struct { diff --git a/logic/service/fight/unified_test.go b/logic/service/fight/unified_test.go index 88459d58..2fcd768b 100644 --- a/logic/service/fight/unified_test.go +++ b/logic/service/fight/unified_test.go @@ -5,7 +5,6 @@ import ( "blazing/common/socket/errorcode" "blazing/logic/service/common" - "blazing/logic/service/fight/action" fightinfo "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" spaceinfo "blazing/logic/service/space/info" @@ -130,20 +129,18 @@ func TestBuildNoteUseSkillOutboundInfoUsesActionOrder(t *testing.T) { opp.AttackValue.MaxHp = 100 fc := &FightC{ - Our: []*input.Input{our}, - Opp: []*input.Input{opp}, + Our: []*input.Input{our}, + Opp: []*input.Input{opp}, + First: opp, + Second: our, } - firstAttack := &action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: 2002, ActorIndex: 0}} - result := fc.buildNoteUseSkillOutboundInfo(firstAttack, nil) + result := fc.buildNoteUseSkillOutboundInfo() - if len(result.FirstAttackInfo) != 1 { - t.Fatalf("expected only first attack info, got first=%d second=%d", len(result.FirstAttackInfo), len(result.SecondAttackInfo)) + if result.FirstAttackInfo.UserID != 2002 || result.FirstAttackInfo.SkillID != 222 { + t.Fatalf("expected first attack info to belong to acting opponent, got %+v", result.FirstAttackInfo) } - if len(result.SecondAttackInfo) != 0 { - t.Fatalf("expected no second attack info, got %d", len(result.SecondAttackInfo)) - } - if result.FirstAttackInfo[0].UserID != 2002 || result.FirstAttackInfo[0].SkillID != 222 { - t.Fatalf("expected first attack info to belong to acting opponent, got %+v", result.FirstAttackInfo[0]) + if result.SecondAttackInfo.UserID != 1001 || result.SecondAttackInfo.SkillID != 111 { + t.Fatalf("expected second attack info to keep the idle side placeholder, got %+v", result.SecondAttackInfo) } } diff --git a/modules/config/service/server.go b/modules/config/service/server.go index 99e8e551..1a87afd4 100644 --- a/modules/config/service/server.go +++ b/modules/config/service/server.go @@ -53,7 +53,7 @@ func NewServerService() *ServerService { var rr []g.MapStrAny r, _ := gconv.Map(data)["list"].(gdb.Result) - now := time.Now() + // now := time.Now() serverIDs := make([]uint32, 0, len(r)) for i := 0; i < len(r); i++ { serverID := gconv.Uint32(r[i].Map()["online_id"]) @@ -62,12 +62,12 @@ func NewServerService() *ServerService { } serverIDs = append(serverIDs, serverID) } - showMap := cf.getPrimaryActiveServerShowMap(serverIDs, now) + //showMap := cf.getPrimaryActiveServerShowMap(serverIDs, now) for i := 0; i < len(r); i++ { t, ok := cool.GetClient(gconv.Uint32(r[i].Map()["online_id"]), gconv.Uint32(r[i].Map()["port"])) subm := r[i].GMap() - cf.applyServerShowMap(subm, gconv.Uint32(r[i].Map()["online_id"]), showMap) + //cf.applyServerShowMap(subm, gconv.Uint32(r[i].Map()["online_id"]), showMap) if ok { err := t.KickPerson(0) //实现指定服务器踢人