上传代码
This commit is contained in:
parent
f0bae825b4
commit
65b62a400b
@ -20,7 +20,7 @@ type (
|
|||||||
}
|
}
|
||||||
//功能开启通知
|
//功能开启通知
|
||||||
IOpenCmdNotice interface {
|
IOpenCmdNotice interface {
|
||||||
OpenCmdNotice(session IUserSession, keys ...string)
|
OpenCmdNotice(uid string, keys ...string)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -214,6 +214,9 @@ type (
|
|||||||
isepic:是否史诗 与 dyweight 互斥
|
isepic:是否史诗 与 dyweight 互斥
|
||||||
*/
|
*/
|
||||||
GetForgeEquip(session IUserSession, suiteId int32, pos int32, lv int32, dyweight []int32, isepic bool) (eruip *pb.DB_Equipment, errdata *pb.ErrorData)
|
GetForgeEquip(session IUserSession, suiteId int32, pos int32, lv int32, dyweight []int32, isepic bool) (eruip *pb.DB_Equipment, errdata *pb.ErrorData)
|
||||||
|
|
||||||
|
//GM接口 获取全部装备
|
||||||
|
GMGetAllEquip(session IUserSession, ismaxlv bool) (errdata *pb.ErrorData)
|
||||||
}
|
}
|
||||||
|
|
||||||
IMline interface {
|
IMline interface {
|
||||||
@ -373,6 +376,7 @@ type (
|
|||||||
ComputeHeroNumeric(uid string, hero ...*pb.DBHero)
|
ComputeHeroNumeric(uid string, hero ...*pb.DBHero)
|
||||||
///红点
|
///红点
|
||||||
IGetReddot
|
IGetReddot
|
||||||
|
GMFulllevel(session IUserSession) (errdata *pb.ErrorData)
|
||||||
}
|
}
|
||||||
IPrivilege interface {
|
IPrivilege interface {
|
||||||
// 创建一个新的特权卡
|
// 创建一个新的特权卡
|
||||||
|
@ -23,7 +23,7 @@ const (
|
|||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
///背包配置管理组件
|
// /背包配置管理组件
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
module *Equipment
|
module *Equipment
|
||||||
@ -31,7 +31,7 @@ type configureComp struct {
|
|||||||
suit map[int32][]*cfg.GameEquipData
|
suit map[int32][]*cfg.GameEquipData
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
// 组件初始化接口
|
||||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MCompConfigure.Init(service, module, comp, options)
|
this.MCompConfigure.Init(service, module, comp, options)
|
||||||
this.module = module.(*Equipment)
|
this.module = module.(*Equipment)
|
||||||
@ -62,7 +62,16 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备配置数据
|
// 获取全部资源
|
||||||
|
func (this *configureComp) GetAllEquipmentConfigure() (configure []*cfg.GameEquipData) {
|
||||||
|
if v, err := this.GetConfigure(game_equip); err == nil {
|
||||||
|
configure = v.(*cfg.GameEquip).GetDataList()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取装备配置数据
|
||||||
func (this *configureComp) GetEquipmentConfigure() (configure *cfg.GameEquip, err error) {
|
func (this *configureComp) GetEquipmentConfigure() (configure *cfg.GameEquip, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -81,7 +90,7 @@ func (this *configureComp) GetEquipmentConfigure() (configure *cfg.GameEquip, er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备配置数据
|
// 获取装备配置数据
|
||||||
func (this *configureComp) GetSuitEquipmentConfigure(suitid int32) (configures []*cfg.GameEquipData, err error) {
|
func (this *configureComp) GetSuitEquipmentConfigure(suitid int32) (configures []*cfg.GameEquipData, err error) {
|
||||||
var ok bool
|
var ok bool
|
||||||
this.equiplock.RLock()
|
this.equiplock.RLock()
|
||||||
@ -93,7 +102,7 @@ func (this *configureComp) GetSuitEquipmentConfigure(suitid int32) (configures [
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备配置数据
|
// 获取装备配置数据
|
||||||
func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (configure *cfg.GameEquipData, err error) {
|
func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (configure *cfg.GameEquipData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -112,7 +121,7 @@ func (this *configureComp) GetEquipmentConfigureById(equipmentId string) (config
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备配置数据
|
// 获取装备配置数据
|
||||||
func (this *configureComp) GetEquipmentConfigureByIds(equipmentId []string) (configure []*cfg.GameEquipData, err error) {
|
func (this *configureComp) GetEquipmentConfigureByIds(equipmentId []string) (configure []*cfg.GameEquipData, err error) {
|
||||||
var (
|
var (
|
||||||
t interface{}
|
t interface{}
|
||||||
@ -134,7 +143,7 @@ func (this *configureComp) GetEquipmentConfigureByIds(equipmentId []string) (con
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备属性表
|
// 获取装备属性表
|
||||||
func (this *configureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.GameEquipAttrlibraryS, err error) {
|
func (this *configureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.GameEquipAttrlibraryS, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -153,7 +162,7 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Ga
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取属性词列表
|
// 获取属性词列表
|
||||||
func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.GameEquipAttrlibrarySData, err error) {
|
func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.GameEquipAttrlibrarySData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -173,7 +182,7 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (con
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取属性词列表
|
// 获取属性词列表
|
||||||
func (this *configureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.GameEquipAttrlibrarySData, err error) {
|
func (this *configureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.GameEquipAttrlibrarySData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -197,7 +206,7 @@ func (this *configureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (confi
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取武器等级消耗表
|
// 获取武器等级消耗表
|
||||||
func (this *configureComp) GetEquipmentIntensifyConfigure() (configure *cfg.GameEquipIntensify, err error) {
|
func (this *configureComp) GetEquipmentIntensifyConfigure() (configure *cfg.GameEquipIntensify, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -216,7 +225,7 @@ func (this *configureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取武器等级消耗表
|
// 获取武器等级消耗表
|
||||||
func (this *configureComp) GetEquipmentIntensifyConfigureById(etype, star, lv int32) (configure *cfg.GameEquipIntensifyData, err error) {
|
func (this *configureComp) GetEquipmentIntensifyConfigureById(etype, star, lv int32) (configure *cfg.GameEquipIntensifyData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -239,7 +248,32 @@ func (this *configureComp) GetEquipmentIntensifyConfigureById(etype, star, lv in
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备锻造数据
|
// 获取武器等级消耗表
|
||||||
|
func (this *configureComp) GetEquipmentMaxIntensifyConfigureById(etype, star int32) (configure *cfg.GameEquipIntensifyData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
lv int32
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(equip_intensify); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
for _, v1 := range v.(*cfg.GameEquipIntensify).GetDataList() {
|
||||||
|
if v1.TypeId == etype && v1.Star == star && len(v1.Need) > 0 && v1.Level > lv {
|
||||||
|
lv = v1.Level
|
||||||
|
configure = v1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if configure == nil {
|
||||||
|
err = fmt.Errorf("EquipmentConfigure not found star :%d lv:%d", star, lv)
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取装备锻造数据
|
||||||
func (this *configureComp) GetEquipCompose(id int32) (result *cfg.GameEquipSComposeData, err error) {
|
func (this *configureComp) GetEquipCompose(id int32) (result *cfg.GameEquipSComposeData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -258,7 +292,7 @@ func (this *configureComp) GetEquipCompose(id int32) (result *cfg.GameEquipSComp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备锻造数据
|
// 获取装备锻造数据
|
||||||
func (this *configureComp) getEquipAttribute(sid string) (result *cfg.GameEquipAttributeData, err error) {
|
func (this *configureComp) getEquipAttribute(sid string) (result *cfg.GameEquipAttributeData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -278,7 +312,7 @@ func (this *configureComp) getEquipAttribute(sid string) (result *cfg.GameEquipA
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取附魔数据
|
// 获取附魔数据
|
||||||
func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipEnchantingData, err error) {
|
func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipEnchantingData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -297,7 +331,7 @@ func (this *configureComp) getEquipenchanting(id string) (result *cfg.GameEquipE
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//读取装备出售系数配置
|
// 读取装备出售系数配置
|
||||||
func (this *configureComp) getSellcoefficient(id int32) (result *cfg.GameSellCoefficientData, err error) {
|
func (this *configureComp) getSellcoefficient(id int32) (result *cfg.GameSellCoefficientData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -316,7 +350,7 @@ func (this *configureComp) getSellcoefficient(id int32) (result *cfg.GameSellCoe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取装备套装配置
|
// 获取装备套装配置
|
||||||
func (this *configureComp) getEquipSuit(sid int32) (result *cfg.GameEquipSuitData, err error) {
|
func (this *configureComp) getEquipSuit(sid int32) (result *cfg.GameEquipSuitData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
|
@ -448,3 +448,90 @@ func (this *modelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equ
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建满级装备数据
|
||||||
|
func (this *modelEquipmentComp) newMaxEquipment(uid string, conf *cfg.GameEquipData) (equipment *pb.DB_Equipment, err error) {
|
||||||
|
var (
|
||||||
|
mattr []*cfg.GameEquipAttrlibrarySData
|
||||||
|
sattr []*cfg.GameEquipAttrlibrarySData
|
||||||
|
equipatt *cfg.GameEquipAttributeData
|
||||||
|
intensify *cfg.GameEquipIntensifyData
|
||||||
|
satterNum int32
|
||||||
|
)
|
||||||
|
if intensify, err = this.module.configure.GetEquipmentMaxIntensifyConfigureById(conf.EquipId, conf.Color); err != nil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
equipment = &pb.DB_Equipment{
|
||||||
|
Id: primitive.NewObjectID().Hex(),
|
||||||
|
CId: conf.Id,
|
||||||
|
Lv: intensify.Level + 1,
|
||||||
|
UId: uid,
|
||||||
|
OverlayNum: 1,
|
||||||
|
IsInitialState: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
if mattr, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(conf.Leadlibrary); err != nil || len(mattr) == 0 {
|
||||||
|
err = fmt.Errorf("no found mattr%d", conf.Leadlibrary)
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
equipment.MainEntry = &pb.EquipmentAttributeEntry{
|
||||||
|
Id: mattr[0].Key,
|
||||||
|
Libraryid: mattr[0].Libraryid,
|
||||||
|
Lv: intensify.Level + 1,
|
||||||
|
AttrName: mattr[0].Attrkey,
|
||||||
|
Value: mattr[0].Attrvar,
|
||||||
|
BaseValue: mattr[0].Attrvar,
|
||||||
|
}
|
||||||
|
equipment.MainEntry.Value = equipment.MainEntry.BaseValue + int32(math.Floor(float64(equipment.MainEntry.BaseValue*intensify.Bonus)/1000.0))
|
||||||
|
if sattr, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(conf.Addlibrary); err != nil || len(mattr) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, v := range sattr { //移除主属性
|
||||||
|
if v.Attrkey == equipment.MainEntry.AttrName {
|
||||||
|
sattr = append(sattr[0:i], sattr[i+1:]...)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
satterNum = int32(len(sattr))
|
||||||
|
if satterNum > 0 && satterNum <= 4 {
|
||||||
|
equipment.Star = satterNum
|
||||||
|
if conf.EquipId == 1 {
|
||||||
|
equipment.AdverbEntry = make([]*pb.EquipmentAttributeEntry, 0)
|
||||||
|
|
||||||
|
for _, v := range comm.RandShuffle(len(sattr))[:satterNum] {
|
||||||
|
adverbEntry := &pb.EquipmentAttributeEntry{
|
||||||
|
Id: sattr[v].Key,
|
||||||
|
Libraryid: sattr[v].Libraryid,
|
||||||
|
Lv: 5,
|
||||||
|
AttrName: sattr[v].Attrkey,
|
||||||
|
Value: sattr[v].Attrvar,
|
||||||
|
BaseValue: sattr[v].Attrvar,
|
||||||
|
}
|
||||||
|
value := adverbEntry.BaseValue + int32(float64(sattr[v].Addition[adverbEntry.Lv-1])/1000.0*float64(adverbEntry.BaseValue))
|
||||||
|
if adverbEntry.Value < value {
|
||||||
|
adverbEntry.Value = value
|
||||||
|
}
|
||||||
|
equipment.AdverbEntry = append(equipment.AdverbEntry, adverbEntry)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
equipment.Adverbskill = make([]*pb.EquipmentSkillEntry, 0)
|
||||||
|
for _, v := range comm.RandShuffle(len(sattr))[:satterNum] {
|
||||||
|
if equipatt, err = this.module.configure.getEquipAttribute(sattr[v].Attrkey); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
equipment.Adverbskill = append(equipment.Adverbskill, &pb.EquipmentSkillEntry{
|
||||||
|
Id: sattr[v].Key,
|
||||||
|
Libraryid: sattr[v].Libraryid,
|
||||||
|
AttrName: sattr[v].Attrkey,
|
||||||
|
SkillId: equipatt.SkillId,
|
||||||
|
Lv: 5,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
@ -36,20 +37,20 @@ type Equipment struct {
|
|||||||
modelEquipment *modelEquipmentComp
|
modelEquipment *modelEquipmentComp
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块名
|
// 模块名
|
||||||
func (this *Equipment) GetType() core.M_Modules {
|
func (this *Equipment) GetType() core.M_Modules {
|
||||||
return comm.ModuleEquipment
|
return comm.ModuleEquipment
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块初始化接口 注册用户创建角色事件
|
// 模块初始化接口 注册用户创建角色事件
|
||||||
func (this *Equipment) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *Equipment) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
err = this.ModuleBase.Init(service, module, options)
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块启动接口
|
// 模块启动接口
|
||||||
//模块启动
|
// 模块启动
|
||||||
func (this *Equipment) Start() (err error) {
|
func (this *Equipment) Start() (err error) {
|
||||||
err = this.ModuleBase.Start()
|
err = this.ModuleBase.Start()
|
||||||
var module core.IModule
|
var module core.IModule
|
||||||
@ -61,7 +62,7 @@ func (this *Equipment) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//装备组件
|
// 装备组件
|
||||||
func (this *Equipment) OnInstallComp() {
|
func (this *Equipment) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
@ -69,13 +70,13 @@ func (this *Equipment) OnInstallComp() {
|
|||||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Event------------------------------------------------------------------------------------------------------------
|
// Event------------------------------------------------------------------------------------------------------------
|
||||||
func (this *Equipment) EventUserOffline(uid, sessionid string) {
|
func (this *Equipment) EventUserOffline(uid, sessionid string) {
|
||||||
this.modelEquipment.BatchDelLists(uid)
|
this.modelEquipment.BatchDelLists(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
//IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
// IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
||||||
//查询武器信息
|
// 查询武器信息
|
||||||
func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_Equipment, errdata *pb.ErrorData) {
|
func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||||
var err error
|
var err error
|
||||||
if uid == "" || id == "" {
|
if uid == "" || id == "" {
|
||||||
@ -104,7 +105,7 @@ func (this *Equipment) QueryEquipment(uid string, id string) (equipment *pb.DB_E
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询服务资源数量
|
// 查询服务资源数量
|
||||||
func (this *Equipment) QueryEquipments(uid string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData) {
|
func (this *Equipment) QueryEquipments(uid string) (equipment []*pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||||
var err error
|
var err error
|
||||||
if uid == "" {
|
if uid == "" {
|
||||||
@ -127,13 +128,13 @@ func (this *Equipment) QueryEquipments(uid string) (equipment []*pb.DB_Equipment
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询卡片数量
|
// 查询卡片数量
|
||||||
func (this *Equipment) QueryEquipmentAmount(uid string, equipmentId string) (amount uint32) {
|
func (this *Equipment) QueryEquipmentAmount(uid string, equipmentId string) (amount uint32) {
|
||||||
amount = this.modelEquipment.QueryEquipmentAmount(uid, equipmentId)
|
amount = this.modelEquipment.QueryEquipmentAmount(uid, equipmentId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加武器
|
// 添加武器
|
||||||
func (this *Equipment) AddNewEquipments(session comm.IUserSession, cIds map[string]uint32, bPush bool) (change []*pb.DB_Equipment, errdata *pb.ErrorData) {
|
func (this *Equipment) AddNewEquipments(session comm.IUserSession, cIds map[string]uint32, bPush bool) (change []*pb.DB_Equipment, errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -175,7 +176,7 @@ func (this *Equipment) AddAllEquipments(session comm.IUserSession) (errdata *pb.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除武器
|
// 删除武器
|
||||||
func (this *Equipment) DelEquipments(session comm.IUserSession, equipIds []string, bPush bool) (errdata *pb.ErrorData) {
|
func (this *Equipment) DelEquipments(session comm.IUserSession, equipIds []string, bPush bool) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -196,7 +197,7 @@ func (this *Equipment) DelEquipments(session comm.IUserSession, equipIds []strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建新的装备
|
// 创建新的装备
|
||||||
func (this *Equipment) NewEquipment(uid, cid string) (errdata *pb.ErrorData, equip *pb.DB_Equipment) {
|
func (this *Equipment) NewEquipment(uid, cid string) (errdata *pb.ErrorData, equip *pb.DB_Equipment) {
|
||||||
var (
|
var (
|
||||||
conf *cfg.GameEquipData
|
conf *cfg.GameEquipData
|
||||||
@ -221,7 +222,7 @@ func (this *Equipment) NewEquipment(uid, cid string) (errdata *pb.ErrorData, equ
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//创建新的装备
|
// 创建新的装备
|
||||||
func (this *Equipment) AddEquipment(session comm.IUserSession, equip *pb.DB_Equipment) (errdata *pb.ErrorData) {
|
func (this *Equipment) AddEquipment(session comm.IUserSession, equip *pb.DB_Equipment) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -265,7 +266,7 @@ func (this *Equipment) AddEquipment(session comm.IUserSession, equip *pb.DB_Equi
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
///出售装备
|
// /出售装备
|
||||||
func (this *Equipment) SellEquipments(session comm.IUserSession, equs []string) (errdata *pb.ErrorData, atno []*pb.UserAtno) {
|
func (this *Equipment) SellEquipments(session comm.IUserSession, equs []string) (errdata *pb.ErrorData, atno []*pb.UserAtno) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -333,7 +334,7 @@ func (this *Equipment) SellEquipments(session comm.IUserSession, equs []string)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//回收装备接口
|
// 回收装备接口
|
||||||
func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []string, discount int32) (errdata *pb.ErrorData, atno []*pb.UserAtno) {
|
func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []string, discount int32) (errdata *pb.ErrorData, atno []*pb.UserAtno) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -408,7 +409,7 @@ func (this *Equipment) RecycleEquipments(session comm.IUserSession, equs []strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获得可操作用户装备列表
|
// 获得可操作用户装备列表
|
||||||
func (this *Equipment) GetActionableEquipments(uid string) (errdata *pb.ErrorData, eruips []*pb.DB_Equipment) {
|
func (this *Equipment) GetActionableEquipments(uid string) (errdata *pb.ErrorData, eruips []*pb.DB_Equipment) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -426,7 +427,7 @@ func (this *Equipment) GetActionableEquipments(uid string) (errdata *pb.ErrorDat
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取可用套装 (铁匠铺使用)
|
// 获取可用套装 (铁匠铺使用)
|
||||||
func (this *Equipment) GetActionableSuit(uid string) (errdata *pb.ErrorData, Suit []int32) {
|
func (this *Equipment) GetActionableSuit(uid string) (errdata *pb.ErrorData, Suit []int32) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
@ -526,8 +527,61 @@ func (this *Equipment) GetForgeEquip(session comm.IUserSession, suiteId int32, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Evens--------------------------------------------------------------------------------------------------------------------------------
|
/*
|
||||||
//推送道具变化消息
|
GM 命令接口
|
||||||
|
获取全部装备
|
||||||
|
*/
|
||||||
|
func (this *Equipment) GMGetAllEquip(session comm.IUserSession, ismaxlv bool) (errdata *pb.ErrorData) {
|
||||||
|
|
||||||
|
var (
|
||||||
|
configure *cfg.GameEquip
|
||||||
|
equipments []*pb.DB_Equipment = make([]*pb.DB_Equipment, 0)
|
||||||
|
equipment *pb.DB_Equipment
|
||||||
|
model *db.DBModel
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if configure, err = this.configure.GetEquipmentConfigure(); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range configure.GetDataList() {
|
||||||
|
if equipment, err = this.modelEquipment.newMaxEquipment(session.GetUserId(), v); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
equipments = append(equipments, equipment)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(equipments) > 0 {
|
||||||
|
if this.IsCross() {
|
||||||
|
if model, err = this.GetDBModelByUid(session.GetUserId(), comm.TableEquipment); err != nil {
|
||||||
|
this.Errorln(err)
|
||||||
|
} else {
|
||||||
|
if err = model.AddLists(session.GetUserId(), equipments); err != nil {
|
||||||
|
this.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err = this.modelEquipment.AddLists(session.GetUserId(), equipments); err != nil {
|
||||||
|
this.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.equipmentsChangePush(session, equipments)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Evens--------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// 推送道具变化消息
|
||||||
func (this *Equipment) equipmentsChangePush(session comm.IUserSession, items []*pb.DB_Equipment) (err error) {
|
func (this *Equipment) equipmentsChangePush(session comm.IUserSession, items []*pb.DB_Equipment) (err error) {
|
||||||
session.SendMsg(string(this.GetType()), "change", &pb.EquipmentChangePush{Equipments: items})
|
session.SendMsg(string(this.GetType()), "change", &pb.EquipmentChangePush{Equipments: items})
|
||||||
return
|
return
|
||||||
|
@ -12,13 +12,13 @@ const (
|
|||||||
game_hero = "game_hero.json" //英雄
|
game_hero = "game_hero.json" //英雄
|
||||||
)
|
)
|
||||||
|
|
||||||
///竞技场配置管理组件
|
// /竞技场配置管理组件
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
module *Horoscope
|
module *Horoscope
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
// 组件初始化接口
|
||||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MCompConfigure.Init(service, module, comp, options)
|
this.MCompConfigure.Init(service, module, comp, options)
|
||||||
this.module = module.(*Horoscope)
|
this.module = module.(*Horoscope)
|
||||||
@ -27,7 +27,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询阵容表
|
// 查询阵容表
|
||||||
func (this *configureComp) getHoroscope(id int32) (result *cfg.GameHoroscopeData, err error) {
|
func (this *configureComp) getHoroscope(id int32) (result *cfg.GameHoroscopeData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -44,7 +44,28 @@ func (this *configureComp) getHoroscope(id int32) (result *cfg.GameHoroscopeData
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询星座信息
|
// 查询星座信息
|
||||||
|
func (this *configureComp) getMaxHoroscopes() (result map[int32]*cfg.GameHoroscopeData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_horoscope); err != nil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
} else {
|
||||||
|
for _, v := range v.(*cfg.GameHoroscope).GetDataMap() {
|
||||||
|
if _, ok = result[v.NodeId]; !ok {
|
||||||
|
result[v.NodeId] = v
|
||||||
|
}
|
||||||
|
if v.Lv > result[v.NodeId].Lv {
|
||||||
|
result[v.NodeId] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询星座信息
|
||||||
func (this *configureComp) getHoroscopebylv(nodeid, lv int32) (result *cfg.GameHoroscopeData, err error) {
|
func (this *configureComp) getHoroscopebylv(nodeid, lv int32) (result *cfg.GameHoroscopeData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -63,7 +84,7 @@ func (this *configureComp) getHoroscopebylv(nodeid, lv int32) (result *cfg.GameH
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取英雄配置
|
// 获取英雄配置
|
||||||
func (this *configureComp) getHeroConfig(id string) (result *cfg.GameHeroData, err error) {
|
func (this *configureComp) getHeroConfig(id string) (result *cfg.GameHeroData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
@ -80,7 +101,7 @@ func (this *configureComp) getHeroConfig(id string) (result *cfg.GameHeroData, e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询下一个节点
|
// 查询下一个节点
|
||||||
func (this *configureComp) getHoroscopes() (result *cfg.GameHoroscope, err error) {
|
func (this *configureComp) getHoroscopes() (result *cfg.GameHoroscope, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -30,12 +31,12 @@ type Horoscope struct {
|
|||||||
modelHoroscope *modelHoroscope
|
modelHoroscope *modelHoroscope
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块名
|
// 模块名
|
||||||
func (this *Horoscope) GetType() core.M_Modules {
|
func (this *Horoscope) GetType() core.M_Modules {
|
||||||
return comm.ModuleHoroscope
|
return comm.ModuleHoroscope
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块初始化接口 注册用户创建角色事件
|
// 模块初始化接口 注册用户创建角色事件
|
||||||
func (this *Horoscope) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
func (this *Horoscope) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||||
err = this.ModuleBase.Init(service, module, options)
|
err = this.ModuleBase.Init(service, module, options)
|
||||||
this.service = service.(base.IRPCXService)
|
this.service = service.(base.IRPCXService)
|
||||||
@ -47,7 +48,7 @@ func (this *Horoscope) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//装备组件
|
// 装备组件
|
||||||
func (this *Horoscope) OnInstallComp() {
|
func (this *Horoscope) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
@ -55,13 +56,13 @@ func (this *Horoscope) OnInstallComp() {
|
|||||||
this.modelHoroscope = this.RegisterComp(new(modelHoroscope)).(*modelHoroscope)
|
this.modelHoroscope = this.RegisterComp(new(modelHoroscope)).(*modelHoroscope)
|
||||||
}
|
}
|
||||||
|
|
||||||
//计算英雄数值
|
// 计算英雄数值
|
||||||
func (this *Horoscope) ComputeHeroNumeric(uid string, hero ...*pb.DBHero) {
|
func (this *Horoscope) ComputeHeroNumeric(uid string, hero ...*pb.DBHero) {
|
||||||
this.modelHoroscope.computeHeroNumeric(uid, hero...)
|
this.modelHoroscope.computeHeroNumeric(uid, hero...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//红点需求
|
// 红点需求
|
||||||
func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (result map[comm.ReddotType]*pb.ReddotItem) {
|
func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (result map[comm.ReddotType]*pb.ReddotItem) {
|
||||||
result = make(map[comm.ReddotType]*pb.ReddotItem)
|
result = make(map[comm.ReddotType]*pb.ReddotItem)
|
||||||
for _, v := range rid {
|
for _, v := range rid {
|
||||||
@ -76,3 +77,42 @@ func (this *Horoscope) Reddot(session comm.IUserSession, rid ...comm.ReddotType)
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GM 满级星座图
|
||||||
|
func (this *Horoscope) GMFulllevel(session comm.IUserSession) (errdata *pb.ErrorData) {
|
||||||
|
var (
|
||||||
|
confs map[int32]*cfg.GameHoroscopeData
|
||||||
|
info *pb.DBHoroscope
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if confs, err = this.configure.getMaxHoroscopes(); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if info, err = this.modelHoroscope.queryInfo(session.GetUserId()); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range confs {
|
||||||
|
info.Nodes[k] = v.Lv
|
||||||
|
}
|
||||||
|
if err = this.modelHoroscope.updateInfo(session, info); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -203,16 +203,16 @@ func (this *Practice) TaskComplete(session comm.IUserSession, taskid int32) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
func (this *Practice) OpenCmdNotice(uid string, keys ...string) {
|
||||||
this.Debug("OpenCmdNotice",
|
this.Debug("OpenCmdNotice",
|
||||||
log.Field{Key: "session", Value: session.GetUserId()},
|
log.Field{Key: "session", Value: uid},
|
||||||
log.Field{Key: "key", Value: keys},
|
log.Field{Key: "key", Value: keys},
|
||||||
)
|
)
|
||||||
if !this.IsCross() {
|
if !this.IsCross() {
|
||||||
for _, v := range keys {
|
for _, v := range keys {
|
||||||
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(),
|
||||||
comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar),
|
comm.Service_Worker, string(comm.RPC_ModulePracticeUnLockPillar),
|
||||||
&pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
&pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.Errorln(err)
|
this.Errorln(err)
|
||||||
return
|
return
|
||||||
@ -221,7 +221,7 @@ func (this *Practice) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
for _, v := range keys {
|
for _, v := range keys {
|
||||||
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v}, &pb.EmptyResp{})
|
this.RPC_ModulePracticeUnLockPillar(context.Background(), &pb.RPCGeneralReqA2{Param1: uid, Param2: v}, &pb.EmptyResp{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func (this *apiComp) FuncActivate(session comm.IUserSession, req *pb.SysFuncActi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
if ic, ok := i.(comm.IOpenCmdNotice); ok {
|
||||||
ic.OpenCmdNotice(session, req.Cid)
|
go ic.OpenCmdNotice(session.GetUserId(), req.Cid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -231,14 +231,13 @@ func (this *ModelWorldtask) taskFinishPush(session comm.IUserSession, userTask *
|
|||||||
userTask.Chapters = make(map[int32]int32)
|
userTask.Chapters = make(map[int32]int32)
|
||||||
}
|
}
|
||||||
userTask.Chapters[curTaskConf.Group] = 1 //已解锁待领取
|
userTask.Chapters[curTaskConf.Group] = 1 //已解锁待领取
|
||||||
update := map[string]interface{}{
|
|
||||||
"chapters": userTask.Chapters,
|
|
||||||
"currentTasks": userTask.CurrentTasks,
|
|
||||||
}
|
|
||||||
this.Change(session.GetUserId(), update)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
update := map[string]interface{}{
|
||||||
|
"chapters": userTask.Chapters,
|
||||||
|
"currentTasks": userTask.CurrentTasks,
|
||||||
|
}
|
||||||
|
this.Change(session.GetUserId(), update)
|
||||||
// 任务完成推送
|
// 任务完成推送
|
||||||
session.SendMsg(string(this.moduleWorldtask.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
|
session.SendMsg(string(this.moduleWorldtask.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{
|
||||||
NextTask: nextTask,
|
NextTask: nextTask,
|
||||||
|
@ -53,7 +53,7 @@ func (this *Worldtask) Start() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 功能开启
|
// 功能开启
|
||||||
func (this *Worldtask) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
func (this *Worldtask) OpenCmdNotice(uid string, keys ...string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,10 +20,12 @@ const (
|
|||||||
|
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
module *WTask
|
module *WTask
|
||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
condlTask map[int32][]*cfg.GameWorldTaskData //key 条件ID
|
condlTask map[int32][]*cfg.GameWorldTaskData //key 条件ID
|
||||||
groupTask map[int32][]*cfg.GameWorldTaskData //key 任务组
|
desTask map[int32][]*cfg.GameWorldTaskData //key 分类
|
||||||
|
groupTask map[int32][]*cfg.GameWorldTaskData //key 任务组
|
||||||
|
opencmdTask map[string][]*cfg.GameWorldTaskData //key 功能开启
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
@ -66,12 +68,27 @@ func (this *configureComp) updateconfigure() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
worldtaskConf := make(map[int32][]*cfg.GameWorldTaskData)
|
worldtaskConf := make(map[int32][]*cfg.GameWorldTaskData)
|
||||||
groupaskConf := make(map[int32][]*cfg.GameWorldTaskData)
|
destaskConf := make(map[int32][]*cfg.GameWorldTaskData)
|
||||||
|
grouptaskConf := make(map[int32][]*cfg.GameWorldTaskData)
|
||||||
|
opencmdConf := make(map[string][]*cfg.GameWorldTaskData)
|
||||||
for _, v := range gwt.GetDataList() {
|
for _, v := range gwt.GetDataList() {
|
||||||
if _, ok := groupaskConf[v.Group]; !ok {
|
|
||||||
groupaskConf[v.Group] = make([]*cfg.GameWorldTaskData, 0)
|
if _, ok := destaskConf[v.Des]; !ok {
|
||||||
|
destaskConf[v.Des] = make([]*cfg.GameWorldTaskData, 0)
|
||||||
|
}
|
||||||
|
destaskConf[v.Des] = append(destaskConf[v.Des], v)
|
||||||
|
|
||||||
|
if _, ok := grouptaskConf[v.Group]; !ok {
|
||||||
|
grouptaskConf[v.Group] = make([]*cfg.GameWorldTaskData, 0)
|
||||||
|
}
|
||||||
|
grouptaskConf[v.Group] = append(grouptaskConf[v.Group], v)
|
||||||
|
|
||||||
|
if v.Opencond != "" {
|
||||||
|
if _, ok := opencmdConf[v.Opencond]; !ok {
|
||||||
|
opencmdConf[v.Opencond] = make([]*cfg.GameWorldTaskData, 0)
|
||||||
|
}
|
||||||
|
opencmdConf[v.Opencond] = append(opencmdConf[v.Opencond], v)
|
||||||
}
|
}
|
||||||
groupaskConf[v.Group] = append(groupaskConf[v.Group], v)
|
|
||||||
|
|
||||||
for _, condl := range v.Completetask {
|
for _, condl := range v.Completetask {
|
||||||
if _, ok := worldtaskConf[condl]; !ok {
|
if _, ok := worldtaskConf[condl]; !ok {
|
||||||
@ -83,7 +100,9 @@ func (this *configureComp) updateconfigure() {
|
|||||||
|
|
||||||
this.lock.Lock()
|
this.lock.Lock()
|
||||||
this.condlTask = worldtaskConf
|
this.condlTask = worldtaskConf
|
||||||
this.groupTask = groupaskConf
|
this.desTask = destaskConf
|
||||||
|
this.groupTask = grouptaskConf
|
||||||
|
this.opencmdTask = opencmdConf
|
||||||
this.lock.Unlock()
|
this.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,12 +112,28 @@ func (this *configureComp) getcondlTask() map[int32][]*cfg.GameWorldTaskData {
|
|||||||
return this.condlTask
|
return this.condlTask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) getdesTask(des int32) []*cfg.GameWorldTaskData {
|
||||||
|
this.lock.RLock()
|
||||||
|
defer this.lock.RUnlock()
|
||||||
|
if _, ok := this.desTask[des]; ok {
|
||||||
|
return this.desTask[des]
|
||||||
|
} else {
|
||||||
|
return make([]*cfg.GameWorldTaskData, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *configureComp) getgroupTask() map[int32][]*cfg.GameWorldTaskData {
|
func (this *configureComp) getgroupTask() map[int32][]*cfg.GameWorldTaskData {
|
||||||
this.lock.RLock()
|
this.lock.RLock()
|
||||||
defer this.lock.RUnlock()
|
defer this.lock.RUnlock()
|
||||||
return this.groupTask
|
return this.groupTask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *configureComp) getopencmdTask() map[string][]*cfg.GameWorldTaskData {
|
||||||
|
this.lock.RLock()
|
||||||
|
defer this.lock.RUnlock()
|
||||||
|
return this.opencmdTask
|
||||||
|
}
|
||||||
|
|
||||||
func (this *configureComp) gettaskconfconfigure(tid int32) (conf *cfg.GameWorldTaskData, err error) {
|
func (this *configureComp) gettaskconfconfigure(tid int32) (conf *cfg.GameWorldTaskData, err error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -150,8 +150,129 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 功能开启
|
// 功能开启
|
||||||
func (this *WTask) OpenCmdNotice(session comm.IUserSession, keys ...string) {
|
func (this *WTask) OpenCmdNotice(uid string, keys ...string) {
|
||||||
|
var (
|
||||||
|
opencmdTask map[string][]*cfg.GameWorldTaskData
|
||||||
|
user *pb.DBUser
|
||||||
|
wtask *pb.DBWTask
|
||||||
|
err error
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
//初步校验
|
||||||
|
opencmdTask = this.configure.getopencmdTask()
|
||||||
|
for _, key := range keys {
|
||||||
|
if _, ok = opencmdTask[key]; ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if user = this.ModuleUser.GetUser(uid); user == nil {
|
||||||
|
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: uid})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if wtask, err = this.modelwtask.getUserWTasks(uid); err != nil {
|
||||||
|
this.Error("获取世界任务数据 失败!", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
session, _ := this.GetUserSession(uid)
|
||||||
|
defer func() {
|
||||||
|
session.Push()
|
||||||
|
this.PutUserSession(session)
|
||||||
|
}()
|
||||||
|
this.inquireActivations(session, wtask, user.Lv, keys, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取商队任务
|
||||||
|
func (this *WTask) AcceptCaravanTask(session comm.IUserSession, groupId int32) (task *pb.Worldtask, errdata *pb.ErrorData) {
|
||||||
|
var (
|
||||||
|
alltasks []*cfg.GameWorldTaskData
|
||||||
|
grouptask []*cfg.GameWorldTaskData = make([]*cfg.GameWorldTaskData, 0)
|
||||||
|
completeMap map[int32]struct{} = make(map[int32]struct{})
|
||||||
|
target *cfg.GameWorldTaskData
|
||||||
|
wtask *pb.DBWTask
|
||||||
|
err error
|
||||||
|
ok bool
|
||||||
|
changeActiva bool
|
||||||
|
changeAccept bool
|
||||||
|
)
|
||||||
|
alltasks = this.configure.getdesTask(5)
|
||||||
|
for _, v := range alltasks {
|
||||||
|
if v.Group == groupId {
|
||||||
|
grouptask = append(grouptask, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(grouptask) == 0 {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: fmt.Sprintf("no found des:%d groud:%d tasks", 5, groupId),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if wtask, err = this.modelwtask.getUserWTasks(session.GetUserId()); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range wtask.Completes {
|
||||||
|
completeMap[v] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range grouptask {
|
||||||
|
if _, ok = completeMap[v.Key]; !ok { //找到一个为完成任务
|
||||||
|
target = v
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if target != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: fmt.Sprintf("no found des:%d groud:%d nocomplete tasks", 5, groupId),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//有新任务接取
|
||||||
|
|
||||||
|
if target.AutoAccept == 0 {
|
||||||
|
wtask.Activations = append(wtask.Activations, target.Key)
|
||||||
|
changeActiva = true
|
||||||
|
|
||||||
|
} else if target.AutoAccept == 1 { //自动接取任务
|
||||||
|
wtask.Accepts = append(wtask.Accepts, target.Key)
|
||||||
|
changeAccept = true
|
||||||
|
}
|
||||||
|
|
||||||
|
//有新任务接取
|
||||||
|
if changeActiva {
|
||||||
|
session.SendMsg(string(this.GetType()), "activations", &pb.WTaskActivationsChangePush{Activations: wtask.Activations})
|
||||||
|
}
|
||||||
|
|
||||||
|
if changeAccept {
|
||||||
|
if _, errdata = this.pushtaskprogress(session, wtask, true); errdata != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = this.modelwtask.updateUserWTasks(session.GetUserId(), wtask); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验任务进度
|
// 校验任务进度
|
||||||
@ -258,6 +379,7 @@ func (this *WTask) checkgroupState(session comm.IUserSession, wtask *pb.DBWTask,
|
|||||||
var (
|
var (
|
||||||
groupTask map[int32][]*cfg.GameWorldTaskData
|
groupTask map[int32][]*cfg.GameWorldTaskData
|
||||||
completeMap map[int32]struct{} = make(map[int32]struct{})
|
completeMap map[int32]struct{} = make(map[int32]struct{})
|
||||||
|
des int32
|
||||||
ok bool
|
ok bool
|
||||||
)
|
)
|
||||||
groupTask = this.configure.getgroupTask()
|
groupTask = this.configure.getgroupTask()
|
||||||
@ -268,8 +390,12 @@ func (this *WTask) checkgroupState(session comm.IUserSession, wtask *pb.DBWTask,
|
|||||||
if _, ok = completeMap[v.Key]; !ok {
|
if _, ok = completeMap[v.Key]; !ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
des = v.Des
|
||||||
}
|
}
|
||||||
wtask.Groups[group] = 1
|
wtask.Groups[group] = 1
|
||||||
|
if des == 5 { //商队任务
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询可接取任务列表
|
// 查询可接取任务列表
|
||||||
|
Loading…
Reference in New Issue
Block a user