From 62d93f65e7b806f554c09e3c698d9ef51ec6bb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Mon, 13 Apr 2026 22:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=8F=90=E4=BE=9B=E7=9A=84co?= =?UTF-8?q?de=20differences=E4=BF=A1=E6=81=AF=EF=BC=8C=E7=94=B1=E4=BA=8E?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=85=B7=E4=BD=93=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=86=85=E5=AE=B9=EF=BC=8C=E6=88=91=E5=B0=86?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=80=E4=B8=AA=E9=80=9A=E7=94=A8=E7=9A=84?= =?UTF-8?q?commit=20message=E6=A8=A1=E6=9D=BF=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` docs(readme): 更新文档说明 - 添加项目使用指南 - 完善API接口说明 - 修正错误的配置示例 ``` 注意:由于未提供具体的代码差异信息,以上为示例格式。实际使用时请根据具体的代码变更内容填写相应的type、scope、subject和body信息。 --- logic/service/fight/fightc.go | 34 +++++++++++++++++------------ logic/service/fight/info/info.go | 6 ++--- logic/service/fight/unified_test.go | 21 ++++++++---------- modules/config/service/server.go | 6 ++--- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 04584091d..a640969e4 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 fbaf1c73e..61ad29430 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 88459d58c..2fcd768b4 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 99e8e5513..1a87afd4e 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) //实现指定服务器踢人