feat(fight): 添加战斗前状态检查与经验获取限制判断
- 在挑战BOSS和野外怪物战斗前,增加 CanFight 状态检查,防止非法战斗 - 修复战斗胜利后经验与物品发放逻辑,增加 CanGetExp 判断避免重复获取 - 优化战斗中精灵切换逻辑与相关伤害效果处理,确保死亡标记正确设置 - 修正战斗轮次中被动切换行为及技能执行顺序问题 - 移除无用的管理员会话控制器和宠物融合模型代码 - 调整战斗输入结构体中的 Switch 类型为 Map 以提高查找效率 - 修复战斗中精灵存活判定条件,
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const (
|
||||
TableNamePetFusion = "pet_fusion" // 宠物融合配方表(主宠-副宠-材料-概率-融合结果)
|
||||
)
|
||||
|
||||
// PetFusion 宠物融合配方模型(对应尼尔+闪皮+材料1-4=卡鲁/闪尼等融合规则)
|
||||
type PetFusion struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||
|
||||
MainPetID int32 `gorm:"not null;comment:'主宠物ID(如:尼尔)'" json:"main_pet_id"`
|
||||
SubPetID int32 `gorm:"not null;comment:'副宠物ID(如:闪皮)'" json:"sub_pet_id"`
|
||||
// Material1 int32 `gorm:"not null;default:0;comment:'融合材料1ID(无则填0)'" json:"material1"`
|
||||
// Material2 int32 `gorm:"not null;default:0;comment:'融合材料2ID(无则填0)'" json:"material2"`
|
||||
// Material3 int32 `gorm:"not null;default:0;comment:'融合材料3ID(无则填0)'" json:"material3"`
|
||||
// Material4 int32 `gorm:"not null;default:0;comment:'融合材料4ID(无则填0)'" json:"material4"`
|
||||
Probability float32 `gorm:"not null;comment:'融合成功率(百分比,如80代表80%)'" json:"probability"`
|
||||
ResultPetID int32 `gorm:"not null;comment:'融合结果宠物ID(如:卡鲁、闪尼)'" json:"result_pet_id"`
|
||||
Remark string `gorm:"type:varchar(255);default:'';comment:'融合配方备注(如:尼尔+闪皮=闪尼)'" json:"remark"`
|
||||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"`
|
||||
// 新增:是否默认配方(核心逻辑:所有匹配配方都不满足时,随机选择默认配方)
|
||||
IsDefault int32 `gorm:"not null;default:0;comment:'是否默认配方(1:默认配方,0:非默认;所有配方不匹配时随机选默认配方)'" json:"is_default"`
|
||||
}
|
||||
|
||||
// PetFusionEX 宠物融合配方扩展模型(如需前端展示多维度数据时使用,如ID转名称等)
|
||||
type PetFusionEX struct {
|
||||
PetFusion
|
||||
MainPetName string `json:"main_pet_name"` // 主宠名称(前端展示用)
|
||||
SubPetName string `json:"sub_pet_name"` // 副宠名称(前端展示用)
|
||||
ResultPetName string `json:"result_pet_name"` // 结果宠名称(前端展示用)
|
||||
}
|
||||
|
||||
// TableName 指定PetFusion对应的数据库表名
|
||||
func (*PetFusion) TableName() string {
|
||||
return TableNamePetFusion
|
||||
}
|
||||
|
||||
// GroupName 指定表所属的分组(保持和MonsterRefresh一致)
|
||||
func (*PetFusion) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPetFusion 创建一个新的PetFusion实例(初始化通用Model)
|
||||
func NewPetFusion() *PetFusion {
|
||||
return &PetFusion{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 初始化表结构(程序启动时自动创建/同步表)
|
||||
func init() {
|
||||
cool.CreateTable(&PetFusion{})
|
||||
}
|
||||
47
modules/blazing/model/pet_fusion.go
Normal file
47
modules/blazing/model/pet_fusion.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const (
|
||||
TableNamePetFusion = "pet_fusion" // 宠物融合配方表(主表)
|
||||
)
|
||||
|
||||
// PetFusion 宠物融合配方主模型(核心配方规则)
|
||||
type PetFusion struct {
|
||||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||||
|
||||
MainPetID int32 `gorm:"not null;comment:'主宠物ID(如:尼尔)'" json:"main_pet_id"`
|
||||
SubPetID int32 `gorm:"not null;comment:'副宠物ID(如:闪皮)'" json:"sub_pet_id"`
|
||||
Probability float32 `gorm:"not null;comment:'融合成功率(百分比,如80代表80%)'" json:"probability"`
|
||||
ResultPetID int32 `gorm:"not null;comment:'融合结果宠物ID(如:卡鲁、闪尼)'" json:"result_pet_id"`
|
||||
Remark string `gorm:"type:varchar(255);default:'';comment:'融合配方备注(如:尼尔+闪皮=闪尼)'" json:"remark"`
|
||||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"`
|
||||
IsDefault int32 `gorm:"not null;default:0;comment:'是否默认配方(1:默认配方,0:非默认;所有配方不匹配时随机选默认配方)'" json:"is_default"`
|
||||
|
||||
// 关联:一个配方对应多个材料(gorm 一对多关联,查询时可预加载)
|
||||
//Materials []*PetFusionMaterial `gorm:"foreignKey:PetFusionID;references:ID" json:"materials,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定主表名
|
||||
func (*PetFusion) TableName() string {
|
||||
return TableNamePetFusion
|
||||
}
|
||||
|
||||
// GroupName 表分组(与原逻辑一致)
|
||||
func (*PetFusion) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPetFusion 创建主表实例
|
||||
func NewPetFusion() *PetFusion {
|
||||
return &PetFusion{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 初始化主表结构
|
||||
func init() {
|
||||
cool.CreateTable(&PetFusion{})
|
||||
}
|
||||
48
modules/blazing/model/pet_fusion_material.go
Normal file
48
modules/blazing/model/pet_fusion_material.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
import "blazing/cool"
|
||||
|
||||
const (
|
||||
TableNamePetFusionMaterial = "pet_fusion_material" // 宠物融合材料表(子表)
|
||||
)
|
||||
|
||||
// PetFusionMaterial 融合材料模型(与配方主表一对一关联)
|
||||
type PetFusionMaterial struct {
|
||||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||||
|
||||
// 4个材料ID(对应XML ItemGroup的Idx=1-4,无材料填0)
|
||||
Material1 int64 `gorm:"not null;comment:'材料1ID(如400030)'" json:"material1"`
|
||||
Material2 int64 `gorm:"not null;comment:'材料2ID(如400030)'" json:"material2"`
|
||||
Material3 int64 `gorm:"not null;comment:'材料3ID(如400028)'" json:"material3"`
|
||||
Material4 int64 `gorm:"not null;comment:'材料4ID(如400030)'" json:"material4"`
|
||||
|
||||
// 4个特性ID(对应XML MaterialGroup的特性索引,4-4对应)
|
||||
Trait1Idx int32 `gorm:"not null;comment:'特性1索引(如1008)'" json:"trait1_idx"`
|
||||
Trait2Idx int32 `gorm:"not null;comment:'特性2索引(如1018)'" json:"trait2_idx"`
|
||||
Trait3Idx int32 `gorm:"not null;comment:'特性3索引(如1023)'" json:"trait3_idx"`
|
||||
Trait4Idx int32 `gorm:"not null;comment:'特性4索引(如1031)'" json:"trait4_idx"`
|
||||
|
||||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用该组合(1:启用,0:禁用)'" json:"is_enable"`
|
||||
}
|
||||
|
||||
// TableName 指定子表名
|
||||
func (*PetFusionMaterial) TableName() string {
|
||||
return TableNamePetFusionMaterial
|
||||
}
|
||||
|
||||
// GroupName 表分组(与主表一致)
|
||||
func (*PetFusionMaterial) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPetFusionMaterial 创建材料实例
|
||||
func NewPetFusionMaterial() *PetFusionMaterial {
|
||||
return &PetFusionMaterial{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 初始化子表结构
|
||||
func init() {
|
||||
cool.CreateTable(&PetFusionMaterial{})
|
||||
}
|
||||
Reference in New Issue
Block a user