Files
bl/modules/blazing/model/done.go
昔念 0ea1a24419 feat(fight): 实现 boss 战斗中精灵特性的支持与多个新魂印效果
- 在 `fight_boss.go` 中为 Boss 的每只宠物增加了 CatchTime 字段以区分不同精灵,
  并修复了技能特效参数解析的问题。
- 新增多个魂印(NewSeIdx)实现,包括:
  * 无限 PP、伤害倍率控制、命中屏蔽、属性克制、暴击率调整等。
- 调整了部分已有 NewSeIdx 文件中的方法调用方式,统一使用 `ID().GetCatchTime()`
  来判断精灵是否在场。
- 修改了 EffectIDCombiner 的字段访问方式,改为通过 Get/Set 方法操作。
- 优化战斗逻辑,在 NPC 战斗中加入 AI 自动出招机制。
2025-11-26 15:25:10 +08:00

89 lines
3.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"blazing/cool"
"github.com/samber/lo"
"github.com/tnnmigga/enum"
)
type EnumMilestone int
var MilestoneMode = enum.New[struct {
BOSS EnumMilestone //boss类 地图ID->BOSSID ,胜利次数 mapid bossid petid防止换boss后数据不可用
ITEM EnumMilestone //物品类 物品ID 使用精灵
Fight EnumMilestone //挑战类 对战模式->对战类型->1是赢,0是总局数
Moster EnumMilestone //野怪统计 地图ID->怪物ID
Task EnumMilestone
}]()
// 里程碑数据结构与DoneEvent对应记录单条里程碑的详细信息
// type MilestoneData struct {
// DoneType EnumMilestone `json:"done_type"` // 里程碑类型0-地图解锁1-BOSS击杀2-物品收集等)
// Args []uint32 `json:"args"` // 关联ID列表如地图ID、BOSSID、物品ID等
// Results []uint32 `json:"results"` // 完成情况参数(如:击杀次数、收集数量阈值等)
// Count uint32 `json:"count"` // 累计完成次数某BOSS累计击杀3次
// //IsCompleted bool `json:"is_completed"` // 是否完全达成(用于区分阶段性里程碑)
// }
const TableNameMilestone = "milestone"
// Milestone 数据库存储结构体映射milestone表
type Milestone struct {
*cool.Model
PlayerID uint64 `gorm:"not null;index:idx_milestone_by_player_id;comment:'所属玩家ID'" json:"player_id"`
DoneType EnumMilestone `gorm:"not null;comment:'里程碑类型'" json:"done_type"`
Args string `gorm:"type:text;not null;comment:'里程碑ID'" json:"args"`
// 注:不单独设置"里程碑ID",通过 PlayerID + DoneType + IDs 组合唯一标识一个里程碑(更灵活)
Results string `gorm:"type:jsonb;not null;comment:'里程碑参数'" json:"results"`
Count uint32 `gorm:"not null;comment:'里程碑完成次数'" json:"count"`
}
// MilestoneEX 里程碑扩展结构体,用于业务层解析后的数据操作
type MilestoneEX struct {
Milestone
Args []uint32 // 解析后的里程碑详细数据
Results []uint32 `json:"results"` // 解析后的里程碑详细数据
}
// 检查是否触发过,成功返回触发的次数,失败返回0
func (m *MilestoneEX) CheakNoNumber(count uint32) bool {
// if v.DoneType == model.MilestoneMode.BOSS && IsPrefixBasicSlice(v.Args, []uint32{mapid, bossid}) && v.Count == count {
_, ok := lo.Find(m.Results, func(v1 uint32) bool { //寻找是否触发过
//大于触发值就触发然后1的返回false因为没有奖励这样就可以一直触发
return v1 == count //大于等于就触发
})
//没找到且次数满足才能返回真
if !ok && m.Count >= count {
return true
}
//已经触发过
return false
// }
}
// TableName 返回表名
func (*Milestone) TableName() string {
return TableNameMilestone
}
// GroupName 返回表组名
func (*Milestone) GroupName() string {
return "default"
}
// NewMilestone 创建新里程碑实例
func NewMilestone() *Milestone {
return &Milestone{
Model: cool.NewModel(),
}
}
// init 初始化表
func init() {
cool.CreateTable(&Milestone{})
}