refactor(fight): 优化效果执行逻辑和精灵特性信息结构

- 优化 Input 结构中的 AddEffect 和 Exec 方法,提高效果执行效率
- 重构 PetEffectInfo 结构,增加特效相关字段并调整命名
- 更新 PlayerInfo 结构中相关字段的描述和默认值
This commit is contained in:
2025-09-15 23:18:09 +08:00
parent 8cee54ad8f
commit 8bf0ea37fd
3 changed files with 29 additions and 23 deletions

View File

@@ -100,10 +100,11 @@ func getTypeName(v interface{}) string {
}
func (c *Input) AddEffect(e Effect) {
e.SetInput(c)
// 如果已有同 ID 的效果,尝试叠加
for _, eff := range c.Effects {
if eff.ID() == e.ID() {
//设置输入源
if eff.Stack(0) < eff.MaxStack() { //如果小于最大叠层
eff.Stack(eff.Stack(0)) //获取到当前叠层数然后叠加
} else {
@@ -112,7 +113,7 @@ func (c *Input) AddEffect(e Effect) {
eff.Duration(eff.Duration(0))
}
eff.SetInput(c) //设置输入源
return
}
}
@@ -136,8 +137,6 @@ func (c *Input) RemoveEffect(e Effect) {
// 返回值:所有 Effect 的方法返回值列表
func (c *Input) Exec(fn func(Effect) bool) bool {
var results bool
for _, effect := range c.Effects {
if effect.Alive() {
result := fn(effect)
@@ -149,7 +148,7 @@ func (c *Input) Exec(fn func(Effect) bool) bool {
}
return results
return true
}
// 消除回合类效果 efftype 输入是消对方的还是自己的,false是自己,true是对方

View File

@@ -274,15 +274,22 @@ type PetInfo struct {
}
// PetEffectInfo 精灵特性信息结构
// <!-- NewSeIdx: 精灵特效索引 (默认0: 无效) -->
// <!-- Type: 0 - 仅单人战斗; 1 - 仅组队战斗; 2 - both; (默认0: 仅单人) -->
// <!-- Eid: 精灵特效eid (默认0: 无效) -->
// <!-- Stat: 精灵特效Stat: 0: 无效(默认值), 1: 永久, 2: 有`有效次数'的特效 3: 爆发特效 4: 异能精灵特质-->
// <!-- Times: 精灵特效可使用次数: 当type==2时有效 (默认值:0) -->
// <!-- Args: 特效参数, 不超过8个 (注意: 每个参数不能超过 65535) -->
// <!-- AdditionType:特效加成类型 1 种族值加成 2 技能威力加成 -->
type PetEffectInfo struct {
ItemID uint32 `struc:"uint32" json:"item_id"`
Status byte `struc:"byte" json:"status"`
LeftCount byte `struc:"byte" json:"left_count"`
EID uint16 `struc:"uint16" json:"effect_id"`
Args1 byte `struc:"byte" json:"reserve1"`
Reserve2 byte `struc:"byte" json:"reserve2"`
Args2 byte `struc:"byte" json:"reserve3"`
Reserve4 [13]byte `struc:"[13]byte" json:"reserve4"`
ItemID uint32 `struc:"uint32" json:"item_id"` //如果是能量珠,就显示
Status byte `struc:"byte" json:"status"` //特性为1,能量珠为2
LeftCount byte `struc:"byte" json:"left_count"` //剩余次数
EID uint16 `struc:"uint16" json:"effect_id"` //特效ID
Args1 byte `struc:"byte" json:"reserve1"` //参数1
Args2 byte `struc:"byte" json:"reserve3"` //参数2
Args []int `struc:"skip" json:"Args"` //自定义参数装载
}
// SkillInfo 精灵技能信息结构SkillInfo

View File

@@ -74,10 +74,10 @@ type PlayerInfo struct {
NewInviteeCount uint32 `struc:"uint32" json:"new_invitee_count"` // 固定0
VipLevel uint32 `struc:"uint32" default:"8" json:"vip_level"` // 固定8
VipValue uint32 `struc:"uint32" default:"80000" json:"vip_value"` // 固定80000
VipStage uint32 `struc:"uint32" default:"1" json:"vip_stage"` // 固定1
AutoCharge uint32 `struc:"uint32" default:"1" json:"auto_charge"` // 固定1
VipEndTime uint32 `struc:"uint32" default:"4294967295" json:"vip_end_time"` // 尽可能大
FreshManBonus uint32 `struc:"uint32" json:"fresh_man_bonus"` // 固定0
VipStage uint32 `struc:"uint32" default:"1" json:"vip_stage"` // 超no的外形等级建议固定1
AutoCharge uint32 `struc:"uint32" default:"1" json:"auto_charge"` // nono是否自动充电
VipEndTime uint32 `struc:"uint32" default:"4294967295" json:"vip_end_time"` // 超no的结束时间建议尽可能大
FreshManBonus uint32 `struc:"uint32" json:"fresh_man_bonus"` // 邀请活动建议先给固定0
NonoChipList [80]byte `struc:"[80]byte" json:"nono_chip_list"` // 超no芯片列表
DailyResArr [50]byte `struc:"[50]byte" default:"0" json:"daily_res_arr"` // 每日任务状态 40+是谱尼的
TeacherID uint32 `struc:"uint32" json:"teacher_id"` // 教官id
@@ -92,12 +92,12 @@ type PlayerInfo struct {
CurrentFreshStage uint32 `struc:"uint32" json:"current_fresh_stage"` // 当前试炼层数
MaxFreshStage uint32 `struc:"uint32" json:"max_fresh_stage"` // 最高试炼层
MaxArenaWins uint32 `struc:"uint32" json:"max_arena_wins"` // 星际擂台连胜
TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 默认0
ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 默认0
AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 默认0
AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 默认0
EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 默认0
LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 默认0
TwoTimes uint32 `struc:"uint32" default:"0" json:"two_times"` // 双倍经验加速器剩余使用次数
ThreeTimes uint32 `struc:"uint32" default:"0" json:"three_times"` // 三倍经验加速器剩余使用次数
AutoFight uint32 `struc:"uint32" default:"0" json:"auto_fight"` // 是否自动战斗
AutoFightTime uint32 `struc:"uint32" default:"0" json:"auto_fight_time"` // 自动战斗剩余的场次
EnergyTime uint32 `struc:"uint32" default:"0" json:"energy_time"` // 能量吸收仪剩余次数
LearnTimes uint32 `struc:"uint32" default:"0" json:"learn_times"` // 学习力吸收仪剩余次数
MonBattleMedal uint32 `struc:"uint32" default:"0" json:"mon_battle_medal"` // 默认0
RecordCount uint32 `struc:"uint32" default:"0" json:"record_count"` // 默认0
ObtainTm uint32 `struc:"uint32" default:"0" json:"obtain_tm"` // 默认0