创角获得道具按配置表数据填充
This commit is contained in:
parent
62000a8ef9
commit
2250c07da4
72
bin/json/game_cominitial.json
Normal file
72
bin/json/game_cominitial.json
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"index": "1",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "hero",
|
||||||
|
"t": "25001",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "2",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "item",
|
||||||
|
"t": "1",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "3",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "attr",
|
||||||
|
"t": "gold",
|
||||||
|
"n": 50000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "4",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "hero",
|
||||||
|
"t": "24003",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "5",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "hero",
|
||||||
|
"t": "25004",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "6",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "hero",
|
||||||
|
"t": "35002",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": "7",
|
||||||
|
"var": [
|
||||||
|
{
|
||||||
|
"a": "item",
|
||||||
|
"t": "2",
|
||||||
|
"n": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
@ -1,6 +1,7 @@
|
|||||||
package modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/core/cbase"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
@ -9,7 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
game_global = "game_global.json"
|
game_global = "game_global.json"
|
||||||
|
game_cominitial = "game_cominitial.json"
|
||||||
)
|
)
|
||||||
|
|
||||||
///配置管理基础组件
|
///配置管理基础组件
|
||||||
@ -21,6 +23,7 @@ type MCompConfigure struct {
|
|||||||
func (this *MCompConfigure) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *MCompConfigure) 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.ModuleCompBase.Init(service, module, comp, options)
|
||||||
err = this.LoadConfigure(game_global, cfg.NewGame_global)
|
err = this.LoadConfigure(game_global, cfg.NewGame_global)
|
||||||
|
err = this.LoadConfigure(game_cominitial, cfg.NewGame_comInitial)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +50,9 @@ func (this *MCompConfigure) GetConfigure(name string) (v interface{}, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//全局配置
|
//全局配置
|
||||||
|
|
||||||
func (this *MCompConfigure) GetGlobalConf(key string) string {
|
func (this *MCompConfigure) GetGlobalConf(key string) string {
|
||||||
if v, err := this.GetConfigure(game_global); err != nil {
|
if v, err := this.GetConfigure(game_cominitial); err != nil {
|
||||||
log.Errorf("get global conf err:%v", err)
|
log.Errorf("get global conf err:%v", err)
|
||||||
return ""
|
return ""
|
||||||
} else {
|
} else {
|
||||||
@ -67,3 +71,19 @@ func (this *MCompConfigure) GetGlobalConf(key string) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *MCompConfigure) GetGlobalInitConf() (configure *cfg.Game_comInitial, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_cominitial); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if configure, ok = v.(*cfg.Game_comInitial); !ok {
|
||||||
|
err = fmt.Errorf("%T no is *cfg.Game_comInitial", v)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -3,7 +3,6 @@ package user
|
|||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
|
||||||
|
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -76,15 +75,21 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c
|
|||||||
}
|
}
|
||||||
|
|
||||||
//初始化英雄卡
|
//初始化英雄卡
|
||||||
if val := this.module.configure.GetGlobalConf("init_hero"); val != "" {
|
if val, err := this.module.configure.GetGlobalInitConf(); err == nil {
|
||||||
defaultHero := utils.TrInt32(val)
|
for _, v := range val.GetDataList() {
|
||||||
err = this.hero.CreateHeroes(session.GetUserId(), defaultHero...)
|
|
||||||
if err != nil {
|
|
||||||
code = pb.ErrorCode_HeroInitCreat
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
code = this.module.DispenseRes(session, v.Var, false)
|
||||||
|
if code != pb.ErrorCode_Success {
|
||||||
|
this.module.Errorf("资源发放失败,%v", code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//defaultHero := utils.TrInt32(val)
|
||||||
|
// err = this.hero.CreateHeroes(session.GetUserId(), defaultHero...)
|
||||||
|
// if err != nil {
|
||||||
|
// code = pb.ErrorCode_HeroInitCreat
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
}
|
||||||
//初始化用户设置
|
//初始化用户设置
|
||||||
this.module.modelSetting.InitSetting(session.GetUserId())
|
this.module.modelSetting.InitSetting(session.GetUserId())
|
||||||
|
|
||||||
|
42
sys/configure/structs/game.comInitial.go
Normal file
42
sys/configure/structs/game.comInitial.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
package cfg
|
||||||
|
|
||||||
|
type Game_comInitial struct {
|
||||||
|
_dataMap map[string]*Game_comInitialData
|
||||||
|
_dataList []*Game_comInitialData
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGame_comInitial(_buf []map[string]interface{}) (*Game_comInitial, error) {
|
||||||
|
_dataList := make([]*Game_comInitialData, 0, len(_buf))
|
||||||
|
dataMap := make(map[string]*Game_comInitialData)
|
||||||
|
for _, _ele_ := range _buf {
|
||||||
|
if _v, err2 := NewGame_comInitialData(_ele_); err2 != nil {
|
||||||
|
return nil, err2
|
||||||
|
} else {
|
||||||
|
_dataList = append(_dataList, _v)
|
||||||
|
dataMap[_v.Index] = _v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &Game_comInitial{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *Game_comInitial) GetDataMap() map[string]*Game_comInitialData {
|
||||||
|
return table._dataMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *Game_comInitial) GetDataList() []*Game_comInitialData {
|
||||||
|
return table._dataList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (table *Game_comInitial) Get(key string) *Game_comInitialData {
|
||||||
|
return table._dataMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
40
sys/configure/structs/game.comInitialData.go
Normal file
40
sys/configure/structs/game.comInitialData.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
package cfg
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
type Game_comInitialData struct {
|
||||||
|
Index string
|
||||||
|
Var []*Game_atn
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Game_comInitialData) GetTypeId() int {
|
||||||
|
return 1849654857
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGame_comInitialData(_buf map[string]interface{}) (_v *Game_comInitialData, err error) {
|
||||||
|
_v = &Game_comInitialData{}
|
||||||
|
{ var _ok_ bool; if _v.Index, _ok_ = _buf["index"].(string); !_ok_ { err = errors.New("index error"); return } }
|
||||||
|
{
|
||||||
|
var _arr_ []interface{}
|
||||||
|
var _ok_ bool
|
||||||
|
if _arr_, _ok_ = _buf["var"].([]interface{}); !_ok_ { err = errors.New("var error"); return }
|
||||||
|
|
||||||
|
_v.Var = make([]*Game_atn, 0, len(_arr_))
|
||||||
|
|
||||||
|
for _, _e_ := range _arr_ {
|
||||||
|
var _list_v_ *Game_atn
|
||||||
|
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = NewGame_atn(_x_); err != nil { return } }
|
||||||
|
_v.Var = append(_v.Var, _list_v_)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user