feat(fight): 优化战斗逻辑与奖励事件处理
- 在 `fight_boss.go` 中,调整了玩家挑战 Boss 的奖励事件注册逻辑, 并在战斗结束后正确取消事件监听。 - 修改了多个技能效果文件(`effect_13.go`、`effect_38.go`、`effect_49.go`), 增强状态持续时间计算和数据安全性。 - 更新 `player/done.go` 中的 `SPT` 方法签名以返回监听器实例。 - 调整数据库操作方法,将 `Update` 替换为 `Save` 以确保数据一致性。 - 修复菜单排序语法问题,统一使用字符串形式的排序表达式。
This commit is contained in:
@@ -101,11 +101,12 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla
|
||||
}
|
||||
ai := player.NewAI_player(moinfo)
|
||||
//给予打过一次的奖励
|
||||
c.Done.SPT(c.Info.MapID, data.BossId, 1, func() {
|
||||
event := c.Done.SPT(c.Info.MapID, data.BossId, 1, func() {
|
||||
|
||||
})
|
||||
fight.NewFight(c, ai, func(foi *info.FightOverInfo) {
|
||||
c.Done.Exec(model.MilestoneMode.BOSS, []uint32{data.BossId})
|
||||
event.Cancel() //取消事件
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ func (e *Effect13) OnSkill() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
duration := e.EffectNode.SideEffectArgs[0]
|
||||
duration := e.EffectNode.SideEffectArgs[0] - 1
|
||||
//duration++
|
||||
// 获取状态效果
|
||||
eff := input.Geteffect(input.EffectType.Status, int(info.PetStatus.DrainedHP))
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
"sync"
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -30,9 +31,15 @@ func (e *Effect38) OnSkill() bool {
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect38_sub) Turn_Start(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) {
|
||||
|
||||
if uint32(e.Args()[0]) < e.Ctx().Our.CurrentPet.Info.MaxHp {
|
||||
e.oldtype = e.Ctx().Our.CurrentPet.Info.MaxHp
|
||||
e.Ctx().Our.CurrentPet.Info.MaxHp -= uint32(e.Args()[0])
|
||||
|
||||
e.l.Do(func() {
|
||||
e.oldtype = e.Ctx().Our.CurrentPet.Info.MaxHp
|
||||
e.Ctx().Our.CurrentPet.Info.MaxHp -= uint32(e.Args()[0])
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +50,7 @@ func (e *Effect38_sub) Switch(in *input.Input, at info.AttackValue, oldpet *info
|
||||
type Effect38_sub struct {
|
||||
node.EffectNode
|
||||
oldtype uint32
|
||||
l sync.Once
|
||||
}
|
||||
|
||||
func (e *Effect38_sub) Alive(t ...bool) bool {
|
||||
|
||||
@@ -27,8 +27,9 @@ func (e *Effect49) Damage_SUB_ex(t *info.DamageZone) bool {
|
||||
|
||||
//fmt.Println("Effect49_o", t.Damage)
|
||||
if t.Type == info.DamageType.Red {
|
||||
|
||||
t.Damage = t.Damage.Sub(decimal.NewFromInt(int64(e.Args()[0])))
|
||||
if decimal.NewFromInt(int64(e.Args()[0])).Cmp(t.Damage) == -1 {
|
||||
t.Damage = t.Damage.Sub(decimal.NewFromInt(int64(e.Args()[0])))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ func NewDone(P *Player) Done {
|
||||
// MAPID 地图ID
|
||||
// BOSSID 地图BOSSID
|
||||
// 注册胜利次数
|
||||
func (d *Done) SPT(mapid, bossid, count uint32, fn func()) {
|
||||
d.Topic.Sub(func(v *model.MilestoneEX) {
|
||||
func (d *Done) SPT(mapid, bossid, count uint32, fn func()) *bus.Listener[*model.MilestoneEX] {
|
||||
return d.Topic.Sub(func(v *model.MilestoneEX) {
|
||||
|
||||
if v.DoneType == model.MilestoneMode.BOSS && EqualBasicSlice(v.Args, []uint32{mapid, bossid}) && v.Count == count {
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ func (s *BaseSysMenuService) GetMenus(roleIds []string, isAdmin bool) (result gd
|
||||
m := cool.DBM(s.Model).As("a").Fields("a.*")
|
||||
var err error
|
||||
if isAdmin {
|
||||
result, err = m.Group("a.id").Order(`a.ordernum`, "asc").All()
|
||||
result, err = m.Group("a.id").Order(`a.ordernum asc`).All()
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
result, _ = m.InnerJoin("base_sys_role_menu b", `a.id=b."menuId"`).Where(`b."roleId" IN (?)`, roleIds).Group("a.id").Order("a.ordernum asc").All()
|
||||
|
||||
@@ -36,7 +36,7 @@ func (s *PetService) PetInfo_One_exec(cachetime uint32, t func(*model.PetEX)) {
|
||||
}
|
||||
tt.Data.CatchTime = tt.CatchTime
|
||||
t(&tt)
|
||||
m.Update(tt)
|
||||
m.Save(tt)
|
||||
}
|
||||
func (s *PetService) PetInfo_One(cachetime uint32) model.PetEX {
|
||||
|
||||
|
||||
@@ -31,19 +31,8 @@ func (s *TalkService) Exec(t func(map[uint32]uint32) bool) {
|
||||
|
||||
ok := t(talks.Data)
|
||||
if ok {
|
||||
m1.Update(talks)
|
||||
talks.PlayerID = uint64(s.userid)
|
||||
m1.Save(talks)
|
||||
}
|
||||
|
||||
}
|
||||
func (s *TalkService) Talk_Reset() {
|
||||
|
||||
m1 := s.GModel(s.Model)
|
||||
|
||||
var talks model.TalkEX
|
||||
m1.Scan(&talks)
|
||||
|
||||
talks.Data = make(map[uint32]uint32)
|
||||
|
||||
m1.Update(talks)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user