This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// FightI 定义 common 服务层依赖的战斗操作接口。
|
||||
type FightI interface {
|
||||
Over(c PlayerI, id model.EnumBattleOverReason) //逃跑
|
||||
UseSkill(c PlayerI, id uint32) //使用技能
|
||||
|
||||
@@ -7,24 +7,25 @@ import (
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
)
|
||||
|
||||
// MyWriter 自定义日志写入器,用于逻辑服日志转发。
|
||||
type MyWriter struct {
|
||||
logger *glog.Logger
|
||||
user uint32
|
||||
logger *glog.Logger // 底层 glog 实例。
|
||||
user uint32 // 关联的玩家 ID。
|
||||
}
|
||||
|
||||
// Write 实现 io.Writer,并将日志写入系统日志与底层 logger。
|
||||
func (w *MyWriter) Write(p []byte) (n int, err error) {
|
||||
var (
|
||||
s = string(p)
|
||||
//ctx = context.Background()
|
||||
)
|
||||
|
||||
service.NewBaseSysLogService().RecordLog(w.user, s)
|
||||
return w.logger.Write(p)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cool.Logger.SetWriter(&MyWriter{
|
||||
logger: glog.New(),
|
||||
})
|
||||
cool.Logger.SetAsync(true)
|
||||
|
||||
}
|
||||
|
||||
@@ -8,20 +8,18 @@ import (
|
||||
"github.com/lunixbochs/struc"
|
||||
)
|
||||
|
||||
// TomeeHeader 结构体字段定义
|
||||
// TomeeHeader 定义协议包头。
|
||||
type TomeeHeader struct {
|
||||
Len uint32 `json:"len"`
|
||||
Version byte `json:"version" struc:"[1]byte"`
|
||||
CMD uint32 `json:"cmdId" struc:"uint32"`
|
||||
UserID uint32 `json:"userId"`
|
||||
//Error uint32 `json:"error" struc:"skip"`
|
||||
|
||||
Result uint32 `json:"result"`
|
||||
Data []byte `json:"data" struc:"skip"` //组包忽略此字段// struc:"skip"
|
||||
Res []byte `struc:"skip"`
|
||||
//Return []byte `struc:"skip"` //返回记录
|
||||
Len uint32 `json:"len"` // 包总长度(包头 + 数据体)。
|
||||
Version byte `json:"version" struc:"[1]byte"` // 协议版本。
|
||||
CMD uint32 `json:"cmdId" struc:"uint32"` // 命令 ID。
|
||||
UserID uint32 `json:"userId"` // 玩家 ID。
|
||||
Result uint32 `json:"result"` // 结果码。
|
||||
Data []byte `json:"data" struc:"skip"` // 数据体,序列化时跳过。
|
||||
Res []byte `struc:"skip"` // 预留返回数据,序列化时跳过。
|
||||
}
|
||||
|
||||
// NewTomeeHeader 创建用于下行封包的默认 TomeeHeader。
|
||||
func NewTomeeHeader(cmd uint32, userid uint32) *TomeeHeader {
|
||||
|
||||
return &TomeeHeader{
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"blazing/modules/player/model"
|
||||
)
|
||||
|
||||
// PlayerI 定义战斗与 common 服务依赖的最小玩家能力接口。
|
||||
type PlayerI interface {
|
||||
ApplyPetDisplayInfo(*space.SimpleInfo)
|
||||
GetPlayerCaptureContext() *info.PlayerCaptureContext
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/player"
|
||||
configmodel "blazing/modules/config/model"
|
||||
playermodel "blazing/modules/player/model"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
@@ -146,6 +147,9 @@ func buildBossHookActionContext(our *Input, hookAction bool) *configmodel.BossHo
|
||||
}
|
||||
}
|
||||
|
||||
if our.AttackValue != nil {
|
||||
ctx.OurAttack = convertAttackValue(our.AttackValue)
|
||||
}
|
||||
if our.Opp != nil {
|
||||
if oppPet := our.Opp.CurrentPet(); oppPet != nil {
|
||||
ctx.Opp = &configmodel.BossHookPetContext{
|
||||
@@ -155,11 +159,42 @@ func buildBossHookActionContext(our *Input, hookAction bool) *configmodel.BossHo
|
||||
MaxHp: oppPet.Info.MaxHp,
|
||||
}
|
||||
}
|
||||
if our.Opp.AttackValue != nil {
|
||||
ctx.OppAttack = convertAttackValue(our.Opp.AttackValue)
|
||||
}
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
func convertAttackValue(src *playermodel.AttackValue) *configmodel.BossHookAttackContext {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
status := make([]int8, len(src.Status))
|
||||
for i := range src.Status {
|
||||
status[i] = src.Status[i]
|
||||
}
|
||||
prop := make([]int8, len(src.Prop))
|
||||
for i := range src.Prop {
|
||||
prop[i] = src.Prop[i]
|
||||
}
|
||||
|
||||
return &configmodel.BossHookAttackContext{
|
||||
SkillID: src.SkillID,
|
||||
AttackTime: src.AttackTime,
|
||||
IsCritical: src.IsCritical,
|
||||
LostHp: src.LostHp,
|
||||
GainHp: src.GainHp,
|
||||
RemainHp: src.RemainHp,
|
||||
MaxHp: src.MaxHp,
|
||||
State: src.State,
|
||||
Offensive: src.Offensive,
|
||||
Status: status,
|
||||
Prop: prop,
|
||||
}
|
||||
}
|
||||
|
||||
func applyBossScriptAction(our *Input, ctx *configmodel.BossHookActionContext) bool {
|
||||
if our == nil || ctx == nil {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user