feat(fight): 支持勇者之塔和试炼之塔战斗功能

- 实现勇者之塔(CMD 2414)和试炼之塔(CMD 2428)的战斗逻辑
- 添加Tower500Service和Tower600Service的Boss查询功能
- 统一处理两个塔的BossId
This commit is contained in:
2026-01-01 15:37:43 +08:00
parent 4b6f2862d8
commit d88a2d19ea
11 changed files with 77 additions and 32 deletions

1
common/data/xmlres/public Symbolic link
View File

@@ -0,0 +1 @@
E:/newcode/sun/public

View File

@@ -41,25 +41,28 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
c.Info.CurrentStage = uint32((data.Level-1)*10) + 1 c.Info.CurrentStage = uint32((data.Level-1)*10) + 1
} }
} }
var boss *configmodel.BaseTowerConfig
switch data.Head.CMD { switch data.Head.CMD {
case 2428: //试炼之塔 case 2428: //试炼之塔
result.CurFightLevel = uint(c.Info.CurrentFreshStage) result.CurFightLevel = uint(c.Info.CurrentFreshStage)
boss := service.NewTower600Service().Boss(c.Info.CurrentFreshStage) boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
//next := service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
if boss != nil {
for _, v := range boss.BossIds {
r := configservice.NewBossService().Get(v)
result.BossId = append(result.BossId, uint32(r.MonID))
}
}
case 2414: //勇者之塔 case 2414: //勇者之塔
result.CurFightLevel = uint(c.Info.CurrentStage) result.CurFightLevel = uint(c.Info.CurrentStage)
boss = service.NewTower500Service().Boss(c.Info.CurrentFreshStage)
//next := service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
}
if boss != nil {
for _, v := range boss.BossIds {
r := configservice.NewBossService().Get(v)
result.BossId = append(result.BossId, uint32(r.MonID))
}
} }
// 重置玩家的Canmon标志位为0表示可以刷怪 // 重置玩家的Canmon标志位为0表示可以刷怪
atomic.StoreUint32(&c.Canmon, 0) atomic.StoreUint32(&c.Canmon, 0)
@@ -86,11 +89,12 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC c.Fightinfo.Status = fightinfo.BattleMode.FIGHT_WITH_NPC
monsterInfo := &model.PlayerInfo{} monsterInfo := &model.PlayerInfo{}
var boss *configmodel.BaseTowerConfig var boss *configmodel.BaseTowerConfig
var next *configmodel.BaseTowerConfig
result = &fight.S2C_ChoiceLevelRequestInfo{} result = &fight.S2C_ChoiceLevelRequestInfo{}
switch data.Head.CMD { switch data.Head.CMD {
case 2429: //试炼之塔 case 2429: //试炼之塔
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage) boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
next := service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1) next = service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
if next != nil { if next != nil {
for _, v := range next.BossIds { for _, v := range next.BossIds {
r := configservice.NewBossService().Get(v) r := configservice.NewBossService().Get(v)
@@ -101,10 +105,19 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
result.CurFightLevel = uint32(c.Info.CurrentFreshStage) result.CurFightLevel = uint32(c.Info.CurrentFreshStage)
case 2415: //勇者之塔 case 2415: //勇者之塔
boss = service.NewTower500Service().Boss(c.Info.CurrentStage)
next = service.NewTower500Service().Boss(c.Info.CurrentStage + 1)
result.CurFightLevel = uint32(c.Info.CurrentStage) result.CurFightLevel = uint32(c.Info.CurrentStage)
} }
if next == nil {
for _, v := range next.BossIds {
r := configservice.NewBossService().Get(v)
result.BossID = append(result.BossID, uint32(r.MonID))
}
}
for i, v := range boss.BossIds { for i, v := range boss.BossIds {
r := configservice.NewBossService().Get(v) r := configservice.NewBossService().Get(v)
if r != nil { if r != nil {
@@ -146,7 +159,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
c.Info.CurrentFreshStage++ c.Info.CurrentFreshStage++
case 2415: //勇者之塔 case 2415: //勇者之塔
c.Info.CurrentStage++
} }
} }

View File

@@ -23,7 +23,7 @@ func GetTaskInfo(id, ot uint32) *TaskResult {
pet := service.NewPetRewardService().Get(r.ElfRewardIds) pet := service.NewPetRewardService().Get(r.ElfRewardIds)
if pet != nil { if pet != nil {
ret.Pet = model.GenPetInfo(int(pet.MonID), int(pet.Lv), int(pet.Nature), int(pet.Effect), int(pet.DV), nil) ret.Pet = model.GenPetInfo(int(pet.MonID), int(pet.DV), int(pet.Nature), int(pet.Effect), int(pet.Lv), nil)
} }
for _, itemID := range r.ItemRewardIds { for _, itemID := range r.ItemRewardIds {

View File

@@ -2,9 +2,9 @@ package service
import ( import (
"blazing/common/data/share" "blazing/common/data/share"
"blazing/common/data/xmlres"
"blazing/cool" "blazing/cool"
"blazing/modules/blazing/model" "blazing/modules/blazing/model"
"blazing/modules/config/service"
"context" "context"
"time" "time"
@@ -80,19 +80,14 @@ func (s *InfoService) Personself() *model.PlayerInfo {
tt.LastResetTime = gtime.Now() tt.LastResetTime = gtime.Now()
//每天login时候检查重置时间然后把电池任务挖矿重置 //每天login时候检查重置时间然后把电池任务挖矿重置
//挖矿需要单独存,因为防止多开挖矿 //挖矿需要单独存,因为防止多开挖矿
tt.Data.TimeToday = 0 //重置电池 tt.Data.TimeToday = 0 //重置电池
for i := 400; i < 500; i++ { //每日任务区段
tttL, ok := xmlres.TaskMap[i] for _, v := range service.NewTaskService().GetDaily() {
if ok {
if tttL.Type == 1 { //日常任务
tt.Data.SetTask(i, model.Unaccepted) tt.Data.SetTask(int(v.TaskId), model.Unaccepted)
}
}
} }
for i := 0; i < 50; i++ { //每日任务区段 for i := 0; i < 50; i++ { //每日任务区段
tt.Data.DailyResArr[i] = 0 //重置每日任务 tt.Data.DailyResArr[i] = 0 //重置每日任务

View File

@@ -15,7 +15,7 @@ type PetReward struct {
IsEnabled uint32 `gorm:"not null;default:0;comment:'是否启用0-禁用 1-启用)'" json:"is_enabled"` IsEnabled uint32 `gorm:"not null;default:0;comment:'是否启用0-禁用 1-启用)'" json:"is_enabled"`
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"` MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
DV int32 `gorm:"not null;default:0;comment:'成长值'" json:"dv"` DV int32 `gorm:"not null;default:0;comment:'成长值'" json:"dv"`
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"` Nature int32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
Effect int32 `gorm:"not null;comment:'BOSS特性'" json:"effect"` Effect int32 `gorm:"not null;comment:'BOSS特性'" json:"effect"`
Lv int32 `gorm:"not null;comment:'BOSS等级LvHpMatchUser非0时此配置无效'" json:"lv"` Lv int32 `gorm:"not null;comment:'BOSS等级LvHpMatchUser非0时此配置无效'" json:"lv"`
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励 IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励

View File

@@ -18,6 +18,8 @@ type TaskConfig struct {
OutState uint32 `gorm:"not null;default:0;comment:'任务分支'" json:"out_state" description:"任务分支"` OutState uint32 `gorm:"not null;default:0;comment:'任务分支'" json:"out_state" description:"任务分支"`
//父级任务 //父级任务
ParentTaskId uint32 `gorm:"not null;default:0;comment:'父级任务ID'" json:"parent_task_id" description:"父级任务ID"` ParentTaskId uint32 `gorm:"not null;default:0;comment:'父级任务ID'" json:"parent_task_id" description:"父级任务ID"`
// type(任务类型0为常规任务1为日常任务),
TaskType uint32 `gorm:"not null;default:0;comment:'任务类型'" json:"task_type" description:"任务类型"`
// 奖励配置 // 奖励配置
ItemRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励物品ID数组关联item_gift表主键'" json:"item_reward_ids" description:"奖励物品数组"` ItemRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励物品ID数组关联item_gift表主键'" json:"item_reward_ids" description:"奖励物品数组"`

View File

@@ -13,10 +13,11 @@ type BaseTowerConfig struct {
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用ModelID/创建时间/更新时间不参与json序列化 *cool.Model `json:"-" gorm:"embedded"` // 嵌入通用ModelID/创建时间/更新时间不参与json序列化
// 核心必填字段(与勇者之塔完全一致,仅表名和标识不同) // 核心必填字段(与勇者之塔完全一致,仅表名和标识不同)
TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'试炼之塔层数(唯一标识每层配置)'" json:"tower_level" description:"试炼之塔层数"` TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'试炼之塔层数(唯一标识每层配置)'" json:"tower_level" description:"试炼之塔层数"`
BossIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定BOSS ID数组关联config_pet_boss表主键'" json:"boss_ids" description:"绑定BOSS数组"` BossIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定BOSS ID数组关联config_pet_boss表主键'" json:"boss_ids" description:"绑定BOSS数组"`
ItemRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励物品ID数组关联item_gift表主键'" json:"item_reward_ids" description:"绑定奖励物品数组"`
ElfRewardIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定奖励精灵ID数组关联config_pet_boss表主键'" json:"elf_reward_ids" description:"绑定奖励精灵数组"` //绑定任务数组BaseTowerConfig
TaskIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定任务ID数组关联config_task表主键'" json:"task_ids" description:"绑定任务数组"`
// 通用辅助字段(与勇者之塔完全一致,无额外添加) // 通用辅助字段(与勇者之塔完全一致,无额外添加)
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该层配置0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"` IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用该层配置0-禁用 1-启用)'" json:"is_enabled" description:"是否启用"`

View File

@@ -15,6 +15,7 @@ func NewTaskService() *TaskService {
return &TaskService{ return &TaskService{
&cool.Service{ &cool.Service{
Model: model.NewTaskConfig(), Model: model.NewTaskConfig(),
//UniqueKey: map[string]string{"task_id": "索引不能重复"},
}, },
} }
} }
@@ -30,3 +31,15 @@ func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
return item return item
} }
func (s *TaskService) GetDaily() []model.TaskConfig {
var item []model.TaskConfig
cool.DBM(s.Model).Where("task_type", 1).
Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
}).Scan(&item)
return item
}

View File

@@ -3,6 +3,8 @@ package service
import ( import (
"blazing/cool" "blazing/cool"
"blazing/modules/config/model" "blazing/modules/config/model"
"github.com/gogf/gf/v2/database/gdb"
) )
type Tower500Service struct { type Tower500Service struct {
@@ -16,3 +18,14 @@ func NewTower500Service() *Tower500Service {
}, },
} }
} }
func (s *Tower500Service) Boss(tower_level uint32) *model.BaseTowerConfig {
var config model.Tower600Config
cool.DBM(s.Model).Where("tower_level = ?", tower_level).
Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
}).Scan(&config)
return &config.BaseTowerConfig
}

View File

@@ -3,6 +3,8 @@ package service
import ( import (
"blazing/cool" "blazing/cool"
"blazing/modules/config/model" "blazing/modules/config/model"
"github.com/gogf/gf/v2/database/gdb"
) )
type Tower600Service struct { type Tower600Service struct {
@@ -19,7 +21,12 @@ func NewTower600Service() *Tower600Service {
func (s *Tower600Service) Boss(tower_level uint32) *model.BaseTowerConfig { func (s *Tower600Service) Boss(tower_level uint32) *model.BaseTowerConfig {
var config model.Tower600Config var config model.Tower600Config
cool.DBM(s.Model).Where("tower_level = ?", tower_level).Scan(&config) cool.DBM(s.Model).Where("tower_level = ?", tower_level).
Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
}).Scan(&config)
return &config.BaseTowerConfig return &config.BaseTowerConfig
} }

View File

@@ -134,8 +134,8 @@ var DictInfoServiceS = NewDictInfoService()
func NewDictInfoService() *DictInfoService { func NewDictInfoService() *DictInfoService {
return &DictInfoService{ return &DictInfoService{
&cool.Service{ &cool.Service{
UniqueKey: map[string]string{"name": "名称不能重复"}, //UniqueKey: map[string]string{"name": "名称不能重复"},
Model: model.NewDictInfo(), Model: model.NewDictInfo(),
ListQueryOp: &cool.QueryOp{ ListQueryOp: &cool.QueryOp{
FieldEQ: []string{"typeId"}, FieldEQ: []string{"typeId"},
KeyWordField: []string{"name"}, KeyWordField: []string{"name"},