feat(xmlres): 更新 BOSS 配置结构并优化字段注释
新增多个 BOSS 相关配置字段,包括任务关联、奖励机制与挑战限制等, 增强 BOSS 精灵的可配置性与业务表达能力。同时完善字段注释以对齐 XML 实际使用情况,并保留原有部分字段用于兼容历史配置。 fix(fight): 调整战斗胜利回调执行顺序以确保数据一致性 将战斗结束回调移至广播之前执行,保证在发送战斗结果前已完成所有状态 更新,尤其是针对胜利宠物的信息同步
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
package player
|
||||
|
||||
import (
|
||||
"github.com/badu/bus"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
type Done struct {
|
||||
*Player //对玩家进行操作
|
||||
*bus.Topic[*model.MilestoneEX]
|
||||
// *bus.Topic[*model.MilestoneEX]
|
||||
}
|
||||
|
||||
func NewDone(P *Player) Done {
|
||||
return Done{
|
||||
Player: P,
|
||||
Topic: bus.NewTopic[*model.MilestoneEX](),
|
||||
/// Topic: bus.NewTopic[*model.MilestoneEX](),
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,37 +22,46 @@ func NewDone(P *Player) Done {
|
||||
// BOSSID 地图BOSSID
|
||||
// 注册胜利次数
|
||||
// 监听器返回奖励是否发送完成,完成就done
|
||||
func (d *Done) SPT(mapid, bossid, count uint32, fn func() bool) *bus.Listener[*model.MilestoneEX] {
|
||||
return d.Topic.Sub(func(v *model.MilestoneEX) {
|
||||
//然后每次触发使用前缀匹配,只要前缀满足就触发
|
||||
if v.DoneType == model.MilestoneMode.BOSS && IsPrefixBasicSlice(v.Args, []uint32{mapid, bossid}) && v.Count == count {
|
||||
// func (d *Done) SPT(mapid, bossid, count uint32, fn func() bool) *bus.Listener[*model.MilestoneEX] {
|
||||
// return d.Topic.Sub(func(v *model.MilestoneEX) {
|
||||
// //然后每次触发使用前缀匹配,只要前缀满足就触发
|
||||
// if v.DoneType == model.MilestoneMode.BOSS && IsPrefixBasicSlice(v.Args, []uint32{mapid, bossid}) && v.Count == count {
|
||||
|
||||
_, ok := lo.Find(v.Args, func(v1 uint32) bool { //寻找是否触发过
|
||||
//大于触发值就触发,然后1的返回false,因为没有奖励,这样就可以一直触发
|
||||
return v1 >= count //大于等于就触发
|
||||
})
|
||||
if !ok { //说明没有触发过
|
||||
// _, ok := lo.Find(v.Args, func(v1 uint32) bool { //寻找是否触发过
|
||||
// //大于触发值就触发,然后1的返回false,因为没有奖励,这样就可以一直触发
|
||||
// return v1 >= count //大于等于就触发
|
||||
// })
|
||||
// if !ok { //说明没有触发过
|
||||
|
||||
if fn() {
|
||||
v.Results = append(v.Results, count) //把本次的记录添加
|
||||
}
|
||||
// if fn() {
|
||||
// v.Results = append(v.Results, count) //把本次的记录添加
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
})
|
||||
// })
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// 分发事件 ,指定事件+1 并触发是否完成
|
||||
func (d *Done) Exec(Donetype model.EnumMilestone, id []uint32) {
|
||||
func (d *Player) Exec(Donetype model.EnumMilestone, id []uint32, fn func(*model.MilestoneEX) uint32) {
|
||||
|
||||
d.Service.Done.Exec(Donetype, id, func(t *model.MilestoneEX) bool {
|
||||
|
||||
d.Topic.Pub(t) //异步发送,然后给事件+1
|
||||
|
||||
//这里给予即时奖励,并将用户计数+1
|
||||
t.Count++
|
||||
//然后有需要自动发送奖励地方,发送完奖励给置真
|
||||
|
||||
if fn != nil {
|
||||
t1 := fn(t)
|
||||
if t1 != 0 {
|
||||
t.Results = append(t.Results, t1) //把本次的记录添加
|
||||
}
|
||||
}
|
||||
|
||||
// d.Topic.Pub(t) //异步发送,然后给事件+1
|
||||
|
||||
// d.Topic.PubAsyncCallBack(s, func() { //如果没执行完,说明奖励没发完,直接掉线
|
||||
// d.Service.Done.Exec(s) //给计数器加1
|
||||
// }) //提交触发里程碑奖励
|
||||
|
||||
Reference in New Issue
Block a user