This commit is contained in:
liwei1dao 2022-08-31 11:06:39 +08:00
commit 058712919b
6 changed files with 34 additions and 32 deletions

View File

@ -35,26 +35,28 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com
err = this.LoadConfigure(game_playerlv, cfg.NewGamePlayerlv)
err = this.LoadConfigure(game_facemod, cfg.NewGameFacemod)
this._dropMap = make(map[int32][]*cfg.GameDropData, 0)
configure.RegisterConfigure(game_drop, cfg.NewGameDrop, func() {
if v, err := this.GetConfigure(game_drop); err == nil {
if configure, ok := v.(*cfg.GameDrop); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
this._dropMap[value.Dropid] = append(this._dropMap[value.Dropid], value)
}
return
}
}
log.Errorf("get game_pagoda conf err:%v", err)
return
})
configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData)
return
}
func (this *MCompConfigure) LoadConfigure(name string, fn interface{}) (err error) {
return configure.RegisterConfigure(name, fn, nil)
}
//加载一个配置文件
func (this *MCompConfigure) LoadConfigure(name string, fn interface{}) (err error) {
return configure.RegisterConfigure(name, fn, nil)
func (this *MCompConfigure) LoadDropData() {
if v, err := this.GetConfigure(game_drop); err == nil {
if configure, ok := v.(*cfg.GameDrop); ok {
this.hlock.Lock()
defer this.hlock.Unlock()
for _, value := range configure.GetDataList() {
this._dropMap[value.Dropid] = append(this._dropMap[value.Dropid], value)
}
return
}
} else {
log.Errorf("get game_pagoda conf err:%v", err)
}
return
}
//加载多个配置文件

View File

@ -2,7 +2,6 @@ package gourmet
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
@ -17,7 +16,6 @@ const (
///配置管理基础组件
type configureComp struct {
cbase.ModuleCompBase
hlock sync.RWMutex
modules.MCompConfigure
_gourmetMap map[int64]*cfg.GameGourmetData
@ -26,7 +24,7 @@ type configureComp struct {
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
err = this.MCompConfigure.Init(service, module, comp, options)
this._gourmetMap = make(map[int64]*cfg.GameGourmetData, 0)
configure.RegisterConfigure(game_gourmet, cfg.NewGameGourmet, func() {

View File

@ -2,8 +2,8 @@ package pagoda
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
@ -17,14 +17,14 @@ const (
///配置管理基础组件
type configureComp struct {
cbase.ModuleCompBase
modules.MCompConfigure
hlock sync.RWMutex
_pagodaMap map[int64]*cfg.GamePagodaData
}
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
err = this.MCompConfigure.Init(service, module, comp, options)
err = this.LoadMultiConfigure(map[string]interface{}{
//game_pagoda: cfg.NewGame_pagoda,
game_pagodaseasonreward: cfg.NewGamePagodaSeasonReward,

View File

@ -2,7 +2,6 @@ package smithy
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
@ -17,16 +16,14 @@ const (
///配置管理基础组件
type configureComp struct {
cbase.ModuleCompBase
hlock sync.RWMutex
modules.MCompConfigure
hlock sync.RWMutex
_smithyMap map[int64]*cfg.GameSmithyData
}
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
err = this.MCompConfigure.Init(service, module, comp, options)
this._smithyMap = make(map[int64]*cfg.GameSmithyData, 0)
configure.RegisterConfigure(game_smithy, cfg.NewGameSmithy, func() {
if v, err := this.GetConfigure(game_smithy); err == nil {

View File

@ -67,6 +67,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
costTime int32
curTime int32
)
mapData := make(map[string]interface{}, 0)
if Smithy.Clang != nil && Smithy.Clang.ETime > 0 {
costTime = int32(time.Now().Unix() - Smithy.Clang.ETime) // 当前过去的时间
@ -103,7 +104,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
}
order.Count--
this.module.configure.GetMultipleDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励
mapData["items"] = Smithy.Items
if curTime > costTime {
Smithy.OrderCostTime += int32(curTime - costTime)
// 转时间戳
@ -127,7 +128,13 @@ func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
if !bCooking { // 经过计算没有烹饪食物的时候
Smithy.Clang = nil
}
sz := make([]*pb.OrderClang, 0)
for _, v := range Smithy.Orders {
if v.Count != 0 {
sz = append(sz, v)
}
}
Smithy.Orders = sz
// 保存信息
mapData["orders"] = Smithy.Orders
mapData["orderCostTime"] = Smithy.OrderCostTime

View File

@ -2,7 +2,6 @@ package viking
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
@ -17,7 +16,6 @@ const (
///配置管理基础组件
type configureComp struct {
cbase.ModuleCompBase
hlock sync.RWMutex
modules.MCompConfigure
_vikingMap map[int64]*cfg.GameVikingBossData
@ -25,7 +23,7 @@ type configureComp struct {
//组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
err = this.MCompConfigure.Init(service, module, comp, options)
this._vikingMap = make(map[int64]*cfg.GameVikingBossData, 0)
configure.RegisterConfigure(game_vikingboss, cfg.NewGameVikingBoss, func() {