```
feat(fight): 支持勇者之塔和试炼之塔战斗功能 - 实现勇者之塔(CMD 2414)和试炼之塔(CMD 2428)的战斗逻辑 - 添加Tower500Service和Tower600Service的Boss查询功能 - 统一处理两个塔的BossId
This commit is contained in:
1
common/data/xmlres/public
Symbolic link
1
common/data/xmlres/public
Symbolic link
@@ -0,0 +1 @@
|
||||
E:/newcode/sun/public
|
||||
@@ -41,25 +41,28 @@ func (h Controller) FreshChoiceFightLevel(data *fight.C2S_FRESH_CHOICE_FIGHT_LEV
|
||||
c.Info.CurrentStage = uint32((data.Level-1)*10) + 1
|
||||
}
|
||||
}
|
||||
|
||||
var boss *configmodel.BaseTowerConfig
|
||||
switch data.Head.CMD {
|
||||
case 2428: //试炼之塔
|
||||
|
||||
result.CurFightLevel = uint(c.Info.CurrentFreshStage)
|
||||
boss := service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
|
||||
//next := service.NewTower600Service().Boss(c.Info.CurrentFreshStage + 1)
|
||||
if boss != nil {
|
||||
boss = service.NewTower600Service().Boss(c.Info.CurrentFreshStage)
|
||||
|
||||
for _, v := range boss.BossIds {
|
||||
r := configservice.NewBossService().Get(v)
|
||||
result.BossId = append(result.BossId, uint32(r.MonID))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
case 2414: //勇者之塔
|
||||
|
||||
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,表示可以刷怪
|
||||
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
|
||||
monsterInfo := &model.PlayerInfo{}
|
||||
var boss *configmodel.BaseTowerConfig
|
||||
var next *configmodel.BaseTowerConfig
|
||||
result = &fight.S2C_ChoiceLevelRequestInfo{}
|
||||
switch data.Head.CMD {
|
||||
case 2429: //试炼之塔
|
||||
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 {
|
||||
for _, v := range next.BossIds {
|
||||
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)
|
||||
case 2415: //勇者之塔
|
||||
boss = service.NewTower500Service().Boss(c.Info.CurrentStage)
|
||||
next = service.NewTower500Service().Boss(c.Info.CurrentStage + 1)
|
||||
|
||||
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 {
|
||||
r := configservice.NewBossService().Get(v)
|
||||
if r != nil {
|
||||
@@ -146,7 +159,7 @@ func (h Controller) PetTawor(data *fight.StartTwarInboundInfo, c *player.Player)
|
||||
c.Info.CurrentFreshStage++
|
||||
|
||||
case 2415: //勇者之塔
|
||||
|
||||
c.Info.CurrentStage++
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func GetTaskInfo(id, ot uint32) *TaskResult {
|
||||
|
||||
pet := service.NewPetRewardService().Get(r.ElfRewardIds)
|
||||
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 {
|
||||
|
||||
@@ -2,9 +2,9 @@ package service
|
||||
|
||||
import (
|
||||
"blazing/common/data/share"
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
"blazing/modules/config/service"
|
||||
"context"
|
||||
|
||||
"time"
|
||||
@@ -80,19 +80,14 @@ func (s *InfoService) Personself() *model.PlayerInfo {
|
||||
tt.LastResetTime = gtime.Now()
|
||||
//每天login时候检查重置时间,然后把电池,任务,挖矿重置
|
||||
//挖矿需要单独存,因为防止多开挖矿
|
||||
tt.Data.TimeToday = 0 //重置电池
|
||||
for i := 400; i < 500; i++ { //每日任务区段
|
||||
tt.Data.TimeToday = 0 //重置电池
|
||||
|
||||
tttL, ok := xmlres.TaskMap[i]
|
||||
if ok {
|
||||
if tttL.Type == 1 { //日常任务
|
||||
for _, v := range service.NewTaskService().GetDaily() {
|
||||
|
||||
tt.Data.SetTask(i, model.Unaccepted)
|
||||
|
||||
}
|
||||
}
|
||||
tt.Data.SetTask(int(v.TaskId), model.Unaccepted)
|
||||
|
||||
}
|
||||
|
||||
for i := 0; i < 50; i++ { //每日任务区段
|
||||
tt.Data.DailyResArr[i] = 0 //重置每日任务
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ type PetReward struct {
|
||||
IsEnabled uint32 `gorm:"not null;default:0;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled"`
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
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"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
|
||||
@@ -18,6 +18,8 @@ type TaskConfig struct {
|
||||
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"`
|
||||
// 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:"奖励物品数组"`
|
||||
|
||||
@@ -13,10 +13,11 @@ type BaseTowerConfig struct {
|
||||
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化)
|
||||
|
||||
// 核心必填字段(与勇者之塔完全一致,仅表名和标识不同)
|
||||
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数组"`
|
||||
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:"绑定奖励精灵数组"`
|
||||
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数组"`
|
||||
|
||||
//绑定任务数组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:"是否启用"`
|
||||
|
||||
@@ -15,6 +15,7 @@ func NewTaskService() *TaskService {
|
||||
return &TaskService{
|
||||
&cool.Service{
|
||||
Model: model.NewTaskConfig(),
|
||||
//UniqueKey: map[string]string{"task_id": "索引不能重复"},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -30,3 +31,15 @@ func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type Tower600Service struct {
|
||||
@@ -19,7 +21,12 @@ func NewTower600Service() *Tower600Service {
|
||||
|
||||
func (s *Tower600Service) Boss(tower_level uint32) *model.BaseTowerConfig {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ var DictInfoServiceS = NewDictInfoService()
|
||||
func NewDictInfoService() *DictInfoService {
|
||||
return &DictInfoService{
|
||||
&cool.Service{
|
||||
UniqueKey: map[string]string{"name": "名称不能重复"},
|
||||
Model: model.NewDictInfo(),
|
||||
//UniqueKey: map[string]string{"name": "名称不能重复"},
|
||||
Model: model.NewDictInfo(),
|
||||
ListQueryOp: &cool.QueryOp{
|
||||
FieldEQ: []string{"typeId"},
|
||||
KeyWordField: []string{"name"},
|
||||
|
||||
Reference in New Issue
Block a user