refactor: 重构战斗系统为统一动作包结构
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
102
logic/service/fight/info/unified_info.go
Normal file
102
logic/service/fight/info/unified_info.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package info
|
||||
|
||||
import "blazing/modules/player/model"
|
||||
|
||||
// FightStatePhase 表示统一战斗状态包的阶段。
|
||||
type FightStatePhase string
|
||||
|
||||
const (
|
||||
// FightStatePhaseStart 表示开战快照。
|
||||
FightStatePhaseStart FightStatePhase = "start"
|
||||
// FightStatePhaseSkillHurt 表示技能结算后的伤害快照。
|
||||
FightStatePhaseSkillHurt FightStatePhase = "skill_hurt"
|
||||
// FightStatePhaseChange 表示切宠快照。
|
||||
FightStatePhaseChange FightStatePhase = "change"
|
||||
// FightStatePhaseOver 表示战斗结束快照。
|
||||
FightStatePhaseOver FightStatePhase = "over"
|
||||
// FightStatePhaseLoad 表示加载进度快照。
|
||||
FightStatePhaseLoad FightStatePhase = "load"
|
||||
// FightStatePhaseChat 表示战斗内聊天快照。
|
||||
FightStatePhaseChat FightStatePhase = "chat"
|
||||
)
|
||||
|
||||
// FighterState 是统一的战位快照。
|
||||
// position 表示该 side 下的槽位编号;actorIndex/targetIndex 与其一一对应。
|
||||
type FighterState struct {
|
||||
// Side 阵营标识:1=我方,2=敌方。
|
||||
Side int `json:"side"`
|
||||
// Position 战位下标;在各自 side 内部从 0 开始编号。
|
||||
Position int `json:"position"`
|
||||
// UserID 当前战位所属玩家 ID;野怪/NPC 通常为 0。
|
||||
UserID uint32 `json:"userId"`
|
||||
// ControllerUserID 当前上场精灵的实际操作者 ID;组队时可与 UserID 联合定位操作者和战位归属。
|
||||
ControllerUserID uint32 `json:"controllerUserId"`
|
||||
// PetID 当前上场精灵的物种/配置 ID。
|
||||
PetID uint32 `json:"petId"`
|
||||
// CatchTime 当前上场精灵的唯一实例 ID,可理解为这只精灵在玩家背包中的唯一标识。
|
||||
CatchTime uint32 `json:"catchTime"`
|
||||
// Name 当前上场精灵名字。
|
||||
Name string `json:"name,omitempty"`
|
||||
// HP 当前生命值。
|
||||
HP uint32 `json:"hp"`
|
||||
// MaxHP 最大生命值。
|
||||
MaxHP uint32 `json:"maxHp"`
|
||||
// Level 当前等级。
|
||||
Level uint32 `json:"level"`
|
||||
// Anger 怒气值;当前服务端主链路暂未实际填充时默认为 0,先为协议对齐预留。
|
||||
Anger uint32 `json:"anger"`
|
||||
// Status 当前异常/增益状态回合数组;下标语义沿用现有战斗状态定义。
|
||||
Status [20]int8 `json:"status"`
|
||||
// Prop 当前能力等级变化数组:攻击、防御、特攻、特防、速度、命中。
|
||||
Prop [6]int8 `json:"prop"`
|
||||
// Skills 当前可见技能列表,包含技能 ID 和当前 PP 等信息。
|
||||
Skills []model.SkillInfo `json:"skills,omitempty"`
|
||||
}
|
||||
|
||||
// FightStateMeta 是统一状态包的公共元数据。
|
||||
type FightStateMeta struct {
|
||||
Round uint32 `json:"round"`
|
||||
Weather uint32 `json:"weather,omitempty"`
|
||||
WinnerID uint32 `json:"winnerId,omitempty"`
|
||||
Reason model.EnumBattleOverReason `json:"reason,omitempty"`
|
||||
LegacyCmd uint32 `json:"legacyCmd,omitempty"`
|
||||
}
|
||||
|
||||
// FightSkillHurtState 保存技能结算后的左右两侧战报快照。
|
||||
type FightSkillHurtState struct {
|
||||
Left []model.AttackValue `json:"left,omitempty"`
|
||||
Right []model.AttackValue `json:"right,omitempty"`
|
||||
}
|
||||
|
||||
// FightLoadState 保存加载进度信息。
|
||||
type FightLoadState struct {
|
||||
UserID uint32 `json:"userId"`
|
||||
Percent uint32 `json:"percent"`
|
||||
}
|
||||
|
||||
// FightChatState 保存战斗内聊天信息。
|
||||
type FightChatState struct {
|
||||
SenderID uint32 `json:"senderId"`
|
||||
SenderNickname string `json:"senderNickname"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// FightStateEnvelope 是统一出站状态结构。
|
||||
type FightStateEnvelope struct {
|
||||
// Phase 当前下发阶段,例如 start、skill_hurt、change、over、load、chat。
|
||||
Phase FightStatePhase `json:"phase"`
|
||||
// Left 我方阵营当前所有战位快照。
|
||||
Left []FighterState `json:"left,omitempty"`
|
||||
// Right 敌方阵营当前所有战位快照。
|
||||
Right []FighterState `json:"right,omitempty"`
|
||||
// Meta 当前阶段共用的元数据,如回合号、胜方、结束原因、旧协议命令号。
|
||||
Meta FightStateMeta `json:"meta"`
|
||||
// SkillHurt 技能结算阶段附带的详细战报;仅 phase=skill_hurt 时使用。
|
||||
SkillHurt *FightSkillHurtState `json:"skillHurt,omitempty"`
|
||||
// Change 切宠阶段附带的切宠详情;仅 phase=change 时使用。
|
||||
Change *ChangePetInfo `json:"change,omitempty"`
|
||||
// Load 加载阶段附带的进度信息;仅 phase=load 时使用。
|
||||
Load *FightLoadState `json:"load,omitempty"`
|
||||
// Chat 聊天阶段附带的聊天内容;仅 phase=chat 时使用。
|
||||
Chat *FightChatState `json:"chat,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user