一些优化
This commit is contained in:
parent
31258667c8
commit
66997a30ca
@ -37,18 +37,13 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
return
|
||||
}
|
||||
|
||||
AwakenConfig, err1 := this.module.configure.GetHeroAwakenConfig()
|
||||
if err1 != nil {
|
||||
awakenData = this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv)
|
||||
if awakenData == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
for _, v := range AwakenConfig.GetDataMap() {
|
||||
if v.Hid == _hero.HeroID && v.Phase == _hero.JuexingLv+1 {
|
||||
awakenData = v
|
||||
break
|
||||
}
|
||||
}
|
||||
if awakenData == nil {
|
||||
nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
|
||||
if nextAwaken == nil {
|
||||
code = pb.ErrorCode_HeroMaxAwaken // 达到最大觉醒等级
|
||||
return
|
||||
}
|
||||
@ -87,10 +82,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
"isOverlying": false,
|
||||
}
|
||||
// 保存数据
|
||||
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err1 != nil {
|
||||
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
return
|
||||
}
|
||||
} else { // 加属性
|
||||
@ -107,10 +102,10 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
"isOverlying": false,
|
||||
}
|
||||
// 保存数据
|
||||
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err1 != nil {
|
||||
err = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -126,6 +121,14 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c
|
||||
cfg := this.module.configure.GetHero(_hero.HeroID)
|
||||
if cfg != nil {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv)
|
||||
//xx英雄满级、共鸣、觉醒至最高状态
|
||||
nextAwaken := this.module.configure.GetHeroAwakenConfig(_hero.HeroID, _hero.JuexingLv+1)
|
||||
if nextAwaken == nil { // 达到满级觉醒
|
||||
resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star+1)
|
||||
if resonConfig == nil { // 满星
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
}
|
||||
|
||||
// 共鸣次数判断
|
||||
resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||
if errr != nil {
|
||||
resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star)
|
||||
if resonConfig == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
@ -84,12 +84,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
ChangeList = append(ChangeList, _costMaphero[k])
|
||||
}
|
||||
|
||||
resonConfig, err1 := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
|
||||
code = this.module.ConsumeRes(session, resonConfig.Need, true)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
@ -108,9 +102,9 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
"isOverlying": false,
|
||||
"sameCount": 1,
|
||||
}
|
||||
err1 = this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err1 != nil {
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
err := this.module.modelHero.ChangeList(session.GetUserId(), req.HeroObjID, _heroMap) // 修改英雄信息
|
||||
if err != nil {
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
@ -129,6 +123,6 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR
|
||||
|
||||
// 任务相关
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype40, 1, 1)
|
||||
return
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson
|
||||
}
|
||||
|
||||
// 共鸣次数判断
|
||||
resonConfig, errr := this.module.configure.GetHeroResonanceConfig(_hero.HeroID)
|
||||
if errr != nil {
|
||||
resonConfig := this.module.configure.GetHeroResonanceConfig(_hero.HeroID, _hero.Star)
|
||||
if resonConfig == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
|
@ -51,31 +51,17 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
|
||||
}
|
||||
|
||||
// 校验指定英雄
|
||||
tagHeroConfig, err1 := this.module.configure.GetHeroStarupConfig()
|
||||
if err1 != nil {
|
||||
tagHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star)
|
||||
if tagHeroConfig == nil {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
|
||||
for _, value := range tagHeroConfig.GetDataList() {
|
||||
if _hero.HeroID == value.Id && _hero.Star == value.Star {
|
||||
// 校验等级
|
||||
if _hero.Lv < _hero.Star*comm.HeroStarLvRatio {
|
||||
code = pb.ErrorCode_HeroStarLvErr
|
||||
return
|
||||
}
|
||||
if value.Needhero == "" && value.Needracenum == 0 && value.Gold == 0 { // 不能再升星了
|
||||
code = pb.ErrorCode_HeroMaxStarLv
|
||||
return
|
||||
}
|
||||
target = value
|
||||
break
|
||||
}
|
||||
}
|
||||
if target == nil {
|
||||
code = pb.ErrorCode_HeroStarErr //升星条件不满足
|
||||
nextHeroConfig := this.module.configure.GetHeroStarupConfig(_hero.HeroID, _hero.Star+1)
|
||||
if nextHeroConfig == nil {
|
||||
code = pb.ErrorCode_HeroMaxStarLv
|
||||
return
|
||||
}
|
||||
|
||||
// 优先校验数量对不对
|
||||
if target.Needheronum != costNeedHeroCount || target.Needracenum != costRaceHeroCount {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
@ -159,10 +145,10 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
|
||||
// 触发星级任务
|
||||
this.module.ModuleTask.SendToTask(session, comm.TaskTypeUpHeroStar, &pb.TaskParam{First: _hero.Star})
|
||||
// 保存数据
|
||||
err1 = this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err1 != nil {
|
||||
err := this.module.modelHero.ChangeList(session.GetUserId(), _hero.Id, _heroMap)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
this.module.Errorf("update hero skill failed:%v", err1)
|
||||
this.module.Errorf("update hero skill failed:%v", err)
|
||||
}
|
||||
this.module.modelHero.ChangeHeroProperty(session, _hero) // 重新计算属性
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -31,6 +32,9 @@ type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
drawCardCfg map[string]map[int32][]*cfg.GameDrawCardData // 第一个key 卡池id 第二个key 星级
|
||||
//map["base_pool1"]map[3]*cfg.Game_drawCardData
|
||||
awakenMap map[int64]*cfg.GameHeroAwakenData
|
||||
resonanceMap map[int64]*cfg.GameHeroResonanceData
|
||||
starMap map[int64]*cfg.GameHeroStarupData
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
@ -41,28 +45,83 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
new_hero: cfg.NewGameHero,
|
||||
hero_stargrow: cfg.NewGameHeroStargrow,
|
||||
hero_levelgrow: cfg.NewGameHeroLevelgrow,
|
||||
hero_starup: cfg.NewGameHeroStarup,
|
||||
hero_levelup: cfg.NewGameHeroLevelup,
|
||||
hero_exp: cfg.NewGameHeroExp,
|
||||
hero_skillup: cfg.NewGameHeroSkillLevel,
|
||||
game_skillatk: cfg.NewGameSkillAtk,
|
||||
hero_resonance: cfg.NewGameHeroResonance,
|
||||
hero_comatn: cfg.NewGameComAtn,
|
||||
hero_awaken: cfg.NewGameHeroAwaken,
|
||||
hero_drawcard: cfg.NewGameDrawCard,
|
||||
})
|
||||
this.drawCardCfg = make(map[string]map[int32][]*cfg.GameDrawCardData, 0)
|
||||
|
||||
configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, func() {
|
||||
this.SetHeroDrawConfig()
|
||||
configure.RegisterConfigure(hero_drawcard, cfg.NewGameDrawCard, this.SetHeroDrawConfig)
|
||||
this.awakenMap = make(map[int64]*cfg.GameHeroAwakenData, 0)
|
||||
configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, func() {
|
||||
if v, err := this.GetConfigure(hero_awaken); err == nil {
|
||||
if _configure, ok := v.(*cfg.GameHeroAwaken); ok {
|
||||
for _, v := range _configure.GetDataList() {
|
||||
this.awakenMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Phase)] = v
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_drawCard", v)
|
||||
}
|
||||
})
|
||||
// 共鸣
|
||||
this.resonanceMap = make(map[int64]*cfg.GameHeroResonanceData, 0)
|
||||
configure.RegisterConfigure(hero_resonance, cfg.NewGameHeroResonance, func() {
|
||||
if v, err := this.GetConfigure(hero_resonance); err == nil {
|
||||
if _configure, ok := v.(*cfg.GameHeroResonance); ok {
|
||||
for _, v := range _configure.GetDataList() {
|
||||
this.resonanceMap[int64(utils.ToInt32(v.Hid)<<8)+int64(v.Star)] = v
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_drawCard", v)
|
||||
}
|
||||
})
|
||||
// 升星
|
||||
//: cfg.,
|
||||
this.starMap = make(map[int64]*cfg.GameHeroStarupData, 0)
|
||||
configure.RegisterConfigure(hero_starup, cfg.NewGameHeroStarup, func() {
|
||||
if v, err := this.GetConfigure(hero_starup); err == nil {
|
||||
if _configure, ok := v.(*cfg.GameHeroStarup); ok {
|
||||
for _, v := range _configure.GetDataList() {
|
||||
this.starMap[int64(utils.ToInt32(v.Id)<<8)+int64(v.Star)] = v
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.Game_drawCard", v)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取英雄升星相关配置数据
|
||||
func (this *configureComp) GetHeroStarupConfig(hid string, star int32) *cfg.GameHeroStarupData {
|
||||
return this.starMap[int64(utils.ToInt32(hid)<<8)+int64(star)]
|
||||
}
|
||||
|
||||
// 通过英雄配置ID获取共鸣配置信息
|
||||
func (this *configureComp) GetHeroResonanceConfig(hid string, star int32) *cfg.GameHeroResonanceData {
|
||||
return this.resonanceMap[int64(utils.ToInt32(hid)<<8)+int64(star)]
|
||||
}
|
||||
|
||||
func (this *configureComp) GetHeroAwakenConfig(hid string, phase int32) *cfg.GameHeroAwakenData {
|
||||
return this.awakenMap[int64(utils.ToInt32(hid)<<8)+int64(phase)]
|
||||
}
|
||||
|
||||
// 抽卡配置表
|
||||
func (this *configureComp) SetHeroDrawConfig() (err error) {
|
||||
func (this *configureComp) SetHeroDrawConfig() {
|
||||
var (
|
||||
v interface{}
|
||||
v interface{}
|
||||
err error
|
||||
)
|
||||
if v, err = this.GetConfigure(hero_drawcard); err == nil {
|
||||
if _configure, ok := v.(*cfg.GameDrawCard); !ok {
|
||||
@ -140,23 +199,6 @@ func (this *configureComp) GetHeroLevelgrowConfig() (configure *cfg.GameHeroLeve
|
||||
return
|
||||
}
|
||||
|
||||
// 获取英雄升星相关配置数据
|
||||
func (this *configureComp) GetHeroStarupConfig() (configure *cfg.GameHeroStarup, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(hero_starup); err == nil {
|
||||
if configure, ok = v.(*cfg.GameHeroStarup); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHeroStarup", v)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHeroStarup", v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 获取英雄升级相关配置数据
|
||||
func (this *configureComp) GetHeroLevelUpConfig() (configure *cfg.GameHeroLevelup, err error) {
|
||||
var (
|
||||
@ -334,25 +376,6 @@ func (this *configureComp) GetHeroSkillMaxLvConfig(skillId uint32) int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// 通过英雄配置ID获取共鸣配置信息
|
||||
func (this *configureComp) GetHeroResonanceConfig(cardConfigID string) (data *cfg.GameHeroResonanceData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
)
|
||||
if v, err = this.GetConfigure(hero_resonance); err == nil {
|
||||
if configure, ok := v.(*cfg.GameHeroResonance); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHeroResonance", v)
|
||||
return
|
||||
} else {
|
||||
data = configure.Get(cardConfigID)
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHeroResonance", v)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
@ -370,19 +393,3 @@ func (this *configureComp) GetHeroResonanceRestConfig() (data *cfg.GameComAtnDat
|
||||
|
||||
return
|
||||
}
|
||||
func (this *configureComp) GetHeroAwakenConfig() (configure *cfg.GameHeroAwaken, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(hero_awaken); err == nil {
|
||||
if configure, ok = v.(*cfg.GameHeroAwaken); !ok {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHeroAwaken", v)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("%T no is *cfg.GameHeroAwaken", v)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -253,8 +253,8 @@ func (this *ModelHero) getHeroList(uid string) []*pb.DBHero {
|
||||
|
||||
// 设置共鸣能量点数属性
|
||||
func (this *ModelHero) setEnergyProperty(hero *pb.DBHero) {
|
||||
resonConfig, err := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID)
|
||||
if err != nil {
|
||||
resonConfig := this.moduleHero.configure.GetHeroResonanceConfig(hero.HeroID, hero.Star)
|
||||
if resonConfig == nil {
|
||||
return
|
||||
}
|
||||
EnergyProperty := make(map[string]int32) //副属性
|
||||
|
@ -126,10 +126,39 @@ func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, eq
|
||||
|
||||
this.modelHero.setEquipProperty(hero, equip)
|
||||
session.SendMsg("hero", "change", &pb.HeroChangePush{List: list})
|
||||
// 随机任务统计
|
||||
if hero.SuiteId != 0 || hero.SuiteExtId != 0 {
|
||||
this.SendRdTask(session)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Hero) SendRdTask(session comm.IUserSession) {
|
||||
equipmap := make(map[int32]map[int32]int32, 0) // k 套装id k1 xx星 v 数量
|
||||
list := this.GetHeroList(session.GetUserId())
|
||||
for _, v := range list {
|
||||
if v.SuiteId != 0 || v.SuiteExtId != 0 {
|
||||
if _, ok := equipmap[v.SuiteId]; !ok {
|
||||
equipmap[v.SuiteId] = make(map[int32]int32, 0)
|
||||
}
|
||||
equipmap[v.SuiteId][v.Suite1Star]++
|
||||
}
|
||||
if v.SuiteExtId != 0 {
|
||||
if _, ok := equipmap[v.SuiteExtId]; !ok {
|
||||
equipmap[v.SuiteExtId] = make(map[int32]int32, 0)
|
||||
}
|
||||
equipmap[v.SuiteExtId][v.Suite2Star]++
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range equipmap {
|
||||
for k1, v1 := range v {
|
||||
this.ModuleRtask.SendToRtask(session, comm.Rtype46, v1, k1, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//英雄列表
|
||||
func (this *Hero) GetHeroList(uid string) []*pb.DBHero {
|
||||
return this.modelHero.getHeroList(uid)
|
||||
|
@ -119,7 +119,10 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PagodaChalleng
|
||||
pagoda.Reward = seasonPagoda.Reward
|
||||
session.SendMsg(string(this.module.GetType()), PagodaChallengeResp, &pb.PagodaChallengeResp{Data: pagoda})
|
||||
}
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId)
|
||||
|
||||
if req.PagodaType == comm.PagodaType {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -35,11 +35,15 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.SmithyGetRewar
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
// 随机任务
|
||||
this.module.SendRdTask(session, _gourmet.Items)
|
||||
|
||||
_gourmet.Items = nil
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
mapData["items"] = nil
|
||||
code = this.module.ModifySmithyData(session.GetUserId(), mapData)
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), SmithyGetRewardResp, &pb.SmithyGetRewardResp{Data: _gourmet})
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package smithy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
@ -12,11 +13,13 @@ import (
|
||||
const (
|
||||
game_smithy = "game_smithy.json"
|
||||
game_smithystove = "game_smithystove.json"
|
||||
game_equip = "game_equip.json" //装备信息表
|
||||
)
|
||||
|
||||
///配置管理基础组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Smithy
|
||||
hlock sync.RWMutex
|
||||
_smithyMap map[int64]*cfg.GameSmithyData
|
||||
}
|
||||
@ -25,6 +28,7 @@ type configureComp struct {
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
this._smithyMap = make(map[int64]*cfg.GameSmithyData, 0)
|
||||
this.module = module.(*Smithy)
|
||||
configure.RegisterConfigure(game_smithy, cfg.NewGameSmithy, func() {
|
||||
if v, err := this.GetConfigure(game_smithy); err == nil {
|
||||
if configure, ok := v.(*cfg.GameSmithy); ok {
|
||||
@ -40,6 +44,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
return
|
||||
})
|
||||
err = this.LoadConfigure(game_smithystove, cfg.NewGameSmithyStove)
|
||||
err = this.LoadConfigure(game_equip, cfg.NewGameEquip)
|
||||
return
|
||||
}
|
||||
|
||||
@ -90,3 +95,21 @@ func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err
|
||||
func (this *configureComp) GetConfigure(name string) (v interface{}, err error) {
|
||||
return configure.GetConfigure(name)
|
||||
}
|
||||
|
||||
func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (configure *cfg.GameEquipData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_equip); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
if configure, ok = v.(*cfg.GameEquip).GetDataMap()[equipmentId]; !ok {
|
||||
err = fmt.Errorf("EquipmentConfigure not found:%s ", equipmentId)
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -48,3 +48,17 @@ func (this *Smithy) ModifySmithyData(uid string, data map[string]interface{}) (c
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Smithy) SendRdTask(session comm.IUserSession, Items []*pb.UserAssets) {
|
||||
var equip map[int32]int32 // key xingji value 数量
|
||||
equip = make(map[int32]int32, 0)
|
||||
for _, v := range Items {
|
||||
cfg, err := this.configure.GetEquipmentConfigureById(v.T)
|
||||
if err == nil {
|
||||
equip[cfg.Star]++
|
||||
}
|
||||
}
|
||||
for k, v := range equip {
|
||||
this.ModuleRtask.SendToRtask(session, comm.Rtype51, v, k)
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"go_dreamfactory/utils"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@ -22,21 +21,13 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
list, err := this.module.modelViking.getVikingList(session.GetUserId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
if list == nil {
|
||||
list.Id = primitive.NewObjectID().Hex()
|
||||
list.Uid = session.GetUserId()
|
||||
list.Boos = make(map[int32]int32)
|
||||
_mapType := this.configure.GetVikingBossTypeConfigData()
|
||||
for k := range _mapType {
|
||||
list.Boos[k] = 0 // 默认难度0
|
||||
}
|
||||
this.module.modelViking.Add(session.GetUserId(), list) // 写缓存
|
||||
}
|
||||
|
||||
// 校验 是不是当天
|
||||
if !utils.IsToday(list.CTime) {
|
||||
list.CTime = time.Now().Unix()
|
||||
|
@ -3,10 +3,11 @@ package viking
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||
)
|
||||
@ -28,10 +29,19 @@ func (this *modelViking) Init(service core.IService, module core.IModule, comp c
|
||||
}
|
||||
|
||||
func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err error) {
|
||||
result = &pb.DBViking{}
|
||||
if err = this.Get(uid, result); err != nil && redis.RedisNil != err {
|
||||
result = &pb.DBViking{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
Boos: make(map[int32]int32),
|
||||
ChallengeTime: make(map[int32]int32),
|
||||
}
|
||||
if err = this.Get(uid, result); err != nil && mgo.MongodbNil != err {
|
||||
|
||||
return
|
||||
}
|
||||
if mgo.MongodbNil == err {
|
||||
this.module.modelViking.Add(uid, result)
|
||||
}
|
||||
err = nil
|
||||
return result, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user