根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

```
docs(readme): 更新文档说明

- 添加项目使用指南
- 完善API接口说明
- 修正错误的配置示例
```

注意:由于未提供具体的代码差异信息,以上为示例格式。实际使用时请根据具体的代码变更内容填写相应的type、scope、subject和body信息。
This commit is contained in:
昔念
2026-04-13 22:53:02 +08:00
parent 7dfa9c297e
commit 62d93f65e7
4 changed files with 34 additions and 33 deletions

View File

@@ -193,24 +193,30 @@ func (f *FightC) collectAttackValues(inputs []*input.Input) []model.AttackValue
return values return values
} }
func (f *FightC) collectAttackValueByAction(act *action.SelectSkillAction) []model.AttackValue { func (f *FightC) buildAttackValueForBroadcast(fighter *input.Input, fallbackActorIndex int) model.AttackValue {
if act == nil { if fighter == nil {
return nil return model.AttackValue{}
} }
fighter := f.GetInputByAction(act, false) if fighter.AttackValue == nil {
if fighter == nil || fighter.AttackValue == nil || fighter.AttackValue.SkillID == 0 { empty := info.NewAttackValue(fighter.UserID)
return nil fighter.AttackValue = empty
} }
attackValue := *fighter.AttackValue attackValue := *fighter.AttackValue
attackValue.ActorIndex = uint32(act.GetActorIndex()) attackValue.ActorIndex = uint32(fallbackActorIndex)
return []model.AttackValue{attackValue} 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 := info.NoteUseSkillOutboundInfo{}
result.FirstAttackInfo = append(result.FirstAttackInfo, f.collectAttackValueByAction(firstAttack)...) if f.First != nil {
result.SecondAttackInfo = append(result.SecondAttackInfo, f.collectAttackValueByAction(secondAttack)...) result.FirstAttackInfo = f.buildAttackValueForBroadcast(f.First, f.First.TeamSlotIndex())
}
if f.Second != nil {
result.SecondAttackInfo = f.buildAttackValueForBroadcast(f.Second, f.Second.TeamSlotIndex())
}
return result return result
} }
@@ -453,7 +459,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
f.sendLegacyRoundBroadcast(firstAttack, secondAttack) f.sendLegacyRoundBroadcast(firstAttack, secondAttack)
} }
attackValueResult := f.buildNoteUseSkillOutboundInfo(firstAttack, secondAttack) attackValueResult := f.buildNoteUseSkillOutboundInfo()
//因为切完才能广播,所以必须和回合结束分开结算 //因为切完才能广播,所以必须和回合结束分开结算
f.BroadcastPlayers(func(p common.PlayerI) { f.BroadcastPlayers(func(p common.PlayerI) {
for _, switchAction := range f.Switch { for _, switchAction := range f.Switch {
@@ -481,7 +487,7 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
// }) // })
return 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) { f.BroadcastPlayers(func(p common.PlayerI) {
if !f.LegacyGroupProtocol { if !f.LegacyGroupProtocol {
f.sendFightPacket(p, fightPacketSkillResult, &attackValueResult) f.sendFightPacket(p, fightPacketSkillResult, &attackValueResult)

View File

@@ -196,10 +196,8 @@ type PropDict struct {
// NoteUseSkillOutboundInfo 战斗技能使用通知的出站信息结构体 // NoteUseSkillOutboundInfo 战斗技能使用通知的出站信息结构体
type NoteUseSkillOutboundInfo struct { type NoteUseSkillOutboundInfo struct {
FirstAttackInfoLen uint32 `struc:"sizeof=FirstAttackInfo"` FirstAttackInfo model.AttackValue // 本轮先手方精灵在释放技能结束后的状态
FirstAttackInfo []model.AttackValue // 本轮手方精灵在释放技能结束后的状态 SecondAttackInfo model.AttackValue // 本轮手方精灵在释放技能结束后的状态
SecondAttackInfoLen uint32 `struc:"sizeof=SecondAttackInfo"`
SecondAttackInfo []model.AttackValue // 本轮后手方精灵在释放技能结束后的状态
} }
type FightStartOutboundInfo struct { type FightStartOutboundInfo struct {

View File

@@ -5,7 +5,6 @@ import (
"blazing/common/socket/errorcode" "blazing/common/socket/errorcode"
"blazing/logic/service/common" "blazing/logic/service/common"
"blazing/logic/service/fight/action"
fightinfo "blazing/logic/service/fight/info" fightinfo "blazing/logic/service/fight/info"
"blazing/logic/service/fight/input" "blazing/logic/service/fight/input"
spaceinfo "blazing/logic/service/space/info" spaceinfo "blazing/logic/service/space/info"
@@ -130,20 +129,18 @@ func TestBuildNoteUseSkillOutboundInfoUsesActionOrder(t *testing.T) {
opp.AttackValue.MaxHp = 100 opp.AttackValue.MaxHp = 100
fc := &FightC{ fc := &FightC{
Our: []*input.Input{our}, Our: []*input.Input{our},
Opp: []*input.Input{opp}, Opp: []*input.Input{opp},
First: opp,
Second: our,
} }
firstAttack := &action.SelectSkillAction{BaseAction: action.BaseAction{PlayerID: 2002, ActorIndex: 0}} result := fc.buildNoteUseSkillOutboundInfo()
result := fc.buildNoteUseSkillOutboundInfo(firstAttack, nil)
if len(result.FirstAttackInfo) != 1 { if result.FirstAttackInfo.UserID != 2002 || result.FirstAttackInfo.SkillID != 222 {
t.Fatalf("expected only first attack info, got first=%d second=%d", len(result.FirstAttackInfo), len(result.SecondAttackInfo)) t.Fatalf("expected first attack info to belong to acting opponent, got %+v", result.FirstAttackInfo)
} }
if len(result.SecondAttackInfo) != 0 { if result.SecondAttackInfo.UserID != 1001 || result.SecondAttackInfo.SkillID != 111 {
t.Fatalf("expected no second attack info, got %d", len(result.SecondAttackInfo)) t.Fatalf("expected second attack info to keep the idle side placeholder, got %+v", 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])
} }
} }

View File

@@ -53,7 +53,7 @@ func NewServerService() *ServerService {
var rr []g.MapStrAny var rr []g.MapStrAny
r, _ := gconv.Map(data)["list"].(gdb.Result) r, _ := gconv.Map(data)["list"].(gdb.Result)
now := time.Now() // now := time.Now()
serverIDs := make([]uint32, 0, len(r)) serverIDs := make([]uint32, 0, len(r))
for i := 0; i < len(r); i++ { for i := 0; i < len(r); i++ {
serverID := gconv.Uint32(r[i].Map()["online_id"]) serverID := gconv.Uint32(r[i].Map()["online_id"])
@@ -62,12 +62,12 @@ func NewServerService() *ServerService {
} }
serverIDs = append(serverIDs, serverID) serverIDs = append(serverIDs, serverID)
} }
showMap := cf.getPrimaryActiveServerShowMap(serverIDs, now) //showMap := cf.getPrimaryActiveServerShowMap(serverIDs, now)
for i := 0; i < len(r); i++ { for i := 0; i < len(r); i++ {
t, ok := cool.GetClient(gconv.Uint32(r[i].Map()["online_id"]), gconv.Uint32(r[i].Map()["port"])) t, ok := cool.GetClient(gconv.Uint32(r[i].Map()["online_id"]), gconv.Uint32(r[i].Map()["port"]))
subm := r[i].GMap() 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 { if ok {
err := t.KickPerson(0) //实现指定服务器踢人 err := t.KickPerson(0) //实现指定服务器踢人