diff --git a/bin/json/game_daddy.json b/bin/json/game_daddy.json new file mode 100644 index 000000000..64f5e0f15 --- /dev/null +++ b/bin/json/game_daddy.json @@ -0,0 +1,962 @@ +[ + { + "index": "1", + "var": [ + { + "a": "hero", + "t": "25001", + "n": 5 + } + ] + }, + { + "index": "2", + "var": [ + { + "a": "attr", + "t": "gold", + "n": 5000000 + } + ] + }, + { + "index": "3", + "var": [ + { + "a": "hero", + "t": "25004", + "n": 5 + } + ] + }, + { + "index": "13", + "var": [ + { + "a": "equi", + "t": "10051", + "n": 100 + } + ] + }, + { + "index": "14", + "var": [ + { + "a": "equi", + "t": "10052", + "n": 100 + } + ] + }, + { + "index": "15", + "var": [ + { + "a": "equi", + "t": "10053", + "n": 100 + } + ] + }, + { + "index": "16", + "var": [ + { + "a": "equi", + "t": "10054", + "n": 100 + } + ] + }, + { + "index": "17", + "var": [ + { + "a": "equi", + "t": "10055", + "n": 100 + } + ] + }, + { + "index": "18", + "var": [ + { + "a": "equi", + "t": "10056", + "n": 100 + } + ] + }, + { + "index": "19", + "var": [ + { + "a": "hero", + "t": "42911", + "n": 100 + } + ] + }, + { + "index": "20", + "var": [ + { + "a": "hero", + "t": "43911", + "n": 100 + } + ] + }, + { + "index": "21", + "var": [ + { + "a": "hero", + "t": "44911", + "n": 100 + } + ] + }, + { + "index": "23", + "var": [ + { + "a": "attr", + "t": "diamond", + "n": 500000 + } + ] + }, + { + "index": "24", + "var": [ + { + "a": "item", + "t": "10006", + "n": 5 + } + ] + }, + { + "index": "25", + "var": [ + { + "a": "item", + "t": "10009", + "n": 1 + } + ] + }, + { + "index": "26", + "var": [ + { + "a": "item", + "t": "10010", + "n": 45 + } + ] + }, + { + "index": "27", + "var": [ + { + "a": "item", + "t": "10011", + "n": 1 + } + ] + }, + { + "index": "28", + "var": [ + { + "a": "item", + "t": "10012", + "n": 1250 + } + ] + }, + { + "index": "29", + "var": [ + { + "a": "item", + "t": "10013", + "n": 1000 + } + ] + }, + { + "index": "30", + "var": [ + { + "a": "item", + "t": "10014", + "n": 1 + } + ] + }, + { + "index": "31", + "var": [ + { + "a": "item", + "t": "10015", + "n": 1 + } + ] + }, + { + "index": "32", + "var": [ + { + "a": "item", + "t": "10016", + "n": 1 + } + ] + }, + { + "index": "33", + "var": [ + { + "a": "item", + "t": "50001", + "n": 200 + } + ] + }, + { + "index": "34", + "var": [ + { + "a": "item", + "t": "50002", + "n": 200 + } + ] + }, + { + "index": "35", + "var": [ + { + "a": "item", + "t": "50003", + "n": 200 + } + ] + }, + { + "index": "36", + "var": [ + { + "a": "item", + "t": "50004", + "n": 200 + } + ] + }, + { + "index": "37", + "var": [ + { + "a": "item", + "t": "50005", + "n": 200 + } + ] + }, + { + "index": "38", + "var": [ + { + "a": "item", + "t": "50006", + "n": 200 + } + ] + }, + { + "index": "39", + "var": [ + { + "a": "item", + "t": "50007", + "n": 200 + } + ] + }, + { + "index": "40", + "var": [ + { + "a": "item", + "t": "50008", + "n": 200 + } + ] + }, + { + "index": "41", + "var": [ + { + "a": "item", + "t": "50009", + "n": 200 + } + ] + }, + { + "index": "42", + "var": [ + { + "a": "item", + "t": "50010", + "n": 200 + } + ] + }, + { + "index": "43", + "var": [ + { + "a": "item", + "t": "50011", + "n": 200 + } + ] + }, + { + "index": "44", + "var": [ + { + "a": "item", + "t": "50012", + "n": 200 + } + ] + }, + { + "index": "45", + "var": [ + { + "a": "item", + "t": "30001", + "n": 999 + } + ] + }, + { + "index": "46", + "var": [ + { + "a": "item", + "t": "30002", + "n": 999 + } + ] + }, + { + "index": "47", + "var": [ + { + "a": "item", + "t": "30003", + "n": 999 + } + ] + }, + { + "index": "48", + "var": [ + { + "a": "item", + "t": "30004", + "n": 999 + } + ] + }, + { + "index": "49", + "var": [ + { + "a": "item", + "t": "30005", + "n": 999 + } + ] + }, + { + "index": "50", + "var": [ + { + "a": "item", + "t": "10002", + "n": 1000 + } + ] + }, + { + "index": "51", + "var": [ + { + "a": "hero", + "t": "43921", + "n": 50 + } + ] + }, + { + "index": "52", + "var": [ + { + "a": "hero", + "t": "44921", + "n": 50 + } + ] + }, + { + "index": "53", + "var": [ + { + "a": "hero", + "t": "45921", + "n": 50 + } + ] + }, + { + "index": "54", + "var": [ + { + "a": "hero", + "t": "44006", + "n": 5 + } + ] + }, + { + "index": "55", + "var": [ + { + "a": "hero", + "t": "35001", + "n": 5 + } + ] + }, + { + "index": "56", + "var": [ + { + "a": "hero", + "t": "44005", + "n": 5 + } + ] + }, + { + "index": "57", + "var": [ + { + "a": "hero", + "t": "15004", + "n": 5 + } + ] + }, + { + "index": "59", + "var": [ + { + "a": "hero", + "t": "14007", + "n": 5 + } + ] + }, + { + "index": "60", + "var": [ + { + "a": "hero", + "t": "45003", + "n": 5 + } + ] + }, + { + "index": "61", + "var": [ + { + "a": "hero", + "t": "24004", + "n": 5 + } + ] + }, + { + "index": "65", + "var": [ + { + "a": "hero", + "t": "34006", + "n": 5 + } + ] + }, + { + "index": "66", + "var": [ + { + "a": "hero", + "t": "24003", + "n": 5 + } + ] + }, + { + "index": "67", + "var": [ + { + "a": "item", + "t": "10004", + "n": 5 + } + ] + }, + { + "index": "68", + "var": [ + { + "a": "hero", + "t": "43901", + "n": 5 + } + ] + }, + { + "index": "69", + "var": [ + { + "a": "hero", + "t": "43902", + "n": 5 + } + ] + }, + { + "index": "70", + "var": [ + { + "a": "hero", + "t": "43903", + "n": 5 + } + ] + }, + { + "index": "71", + "var": [ + { + "a": "hero", + "t": "14003", + "n": 5 + } + ] + }, + { + "index": "72", + "var": [ + { + "a": "hero", + "t": "24002", + "n": 5 + } + ] + }, + { + "index": "73", + "var": [ + { + "a": "hero", + "t": "15005", + "n": 5 + } + ] + }, + { + "index": "74", + "var": [ + { + "a": "hero", + "t": "35003", + "n": 5 + } + ] + }, + { + "index": "75", + "var": [ + { + "a": "equi", + "t": "10001", + "n": 1 + } + ] + }, + { + "index": "76", + "var": [ + { + "a": "equi", + "t": "10002", + "n": 1 + } + ] + }, + { + "index": "77", + "var": [ + { + "a": "equi", + "t": "10003", + "n": 1 + } + ] + }, + { + "index": "78", + "var": [ + { + "a": "equi", + "t": "10004", + "n": 1 + } + ] + }, + { + "index": "79", + "var": [ + { + "a": "equi", + "t": "10005", + "n": 1 + } + ] + }, + { + "index": "80", + "var": [ + { + "a": "equi", + "t": "10006", + "n": 1 + } + ] + }, + { + "index": "81", + "var": [ + { + "a": "equi", + "t": "10011", + "n": 1 + } + ] + }, + { + "index": "82", + "var": [ + { + "a": "equi", + "t": "10012", + "n": 1 + } + ] + }, + { + "index": "83", + "var": [ + { + "a": "equi", + "t": "10013", + "n": 1 + } + ] + }, + { + "index": "84", + "var": [ + { + "a": "equi", + "t": "10014", + "n": 1 + } + ] + }, + { + "index": "85", + "var": [ + { + "a": "equi", + "t": "10015", + "n": 1 + } + ] + }, + { + "index": "86", + "var": [ + { + "a": "equi", + "t": "10016", + "n": 1 + } + ] + }, + { + "index": "87", + "var": [ + { + "a": "equi", + "t": "10021", + "n": 1 + } + ] + }, + { + "index": "88", + "var": [ + { + "a": "equi", + "t": "10022", + "n": 1 + } + ] + }, + { + "index": "89", + "var": [ + { + "a": "equi", + "t": "10023", + "n": 1 + } + ] + }, + { + "index": "90", + "var": [ + { + "a": "equi", + "t": "10024", + "n": 1 + } + ] + }, + { + "index": "91", + "var": [ + { + "a": "equi", + "t": "10025", + "n": 1 + } + ] + }, + { + "index": "92", + "var": [ + { + "a": "equi", + "t": "10026", + "n": 1 + } + ] + }, + { + "index": "93", + "var": [ + { + "a": "equi", + "t": "10031", + "n": 1 + } + ] + }, + { + "index": "94", + "var": [ + { + "a": "equi", + "t": "10032", + "n": 1 + } + ] + }, + { + "index": "95", + "var": [ + { + "a": "equi", + "t": "10033", + "n": 1 + } + ] + }, + { + "index": "96", + "var": [ + { + "a": "equi", + "t": "10034", + "n": 1 + } + ] + }, + { + "index": "97", + "var": [ + { + "a": "equi", + "t": "10035", + "n": 1 + } + ] + }, + { + "index": "98", + "var": [ + { + "a": "equi", + "t": "10036", + "n": 1 + } + ] + }, + { + "index": "99", + "var": [ + { + "a": "equi", + "t": "10041", + "n": 1 + } + ] + }, + { + "index": "100", + "var": [ + { + "a": "equi", + "t": "10042", + "n": 1 + } + ] + }, + { + "index": "101", + "var": [ + { + "a": "equi", + "t": "10043", + "n": 1 + } + ] + }, + { + "index": "102", + "var": [ + { + "a": "equi", + "t": "10044", + "n": 1 + } + ] + }, + { + "index": "103", + "var": [ + { + "a": "equi", + "t": "10045", + "n": 1 + } + ] + }, + { + "index": "104", + "var": [ + { + "a": "equi", + "t": "10046", + "n": 1 + } + ] + }, + { + "index": "105", + "var": [ + { + "a": "equi", + "t": "10051", + "n": 1 + } + ] + }, + { + "index": "106", + "var": [ + { + "a": "equi", + "t": "10052", + "n": 1 + } + ] + }, + { + "index": "107", + "var": [ + { + "a": "equi", + "t": "10053", + "n": 1 + } + ] + }, + { + "index": "108", + "var": [ + { + "a": "equi", + "t": "10054", + "n": 1 + } + ] + }, + { + "index": "109", + "var": [ + { + "a": "equi", + "t": "10055", + "n": 1 + } + ] + }, + { + "index": "110", + "var": [ + { + "a": "equi", + "t": "10056", + "n": 1 + } + ] + } +] \ No newline at end of file diff --git a/modules/gm/api_cmd.go b/modules/gm/api_cmd.go index b81f0befe..0542700e3 100644 --- a/modules/gm/api_cmd.go +++ b/modules/gm/api_cmd.go @@ -3,9 +3,6 @@ package gm import ( "go_dreamfactory/comm" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" - "strconv" - "strings" "google.golang.org/protobuf/proto" ) @@ -32,53 +29,7 @@ func (this *apiComp) Cmd(session comm.IUserSession, req *pb.GMCmdReq) (code pb.E if code = this.CmdCheck(session, req); code != pb.ErrorCode_Success { return } - keys := strings.Split(req.Cmod, ":") - if len(keys) == 2 { - if keys[0] == "bingo" { - datas := strings.Split(keys[1], ",") - if len(datas) == 3 && (datas[0] == comm.AttrType || datas[0] == comm.ItemType || - datas[0] == comm.HeroType || datas[0] == comm.EquipmentType) { - num, err := strconv.Atoi(datas[2]) - if err != nil { - code = pb.ErrorCode_ReqParameterError - return - } - code = this.module.DispenseRes(session, []*cfg.Gameatn{ // 添加资源 - { - A: datas[0], - T: datas[1], - N: int32(num), - }, - }, true) - if code == pb.ErrorCode_Success { // 成功直接返回 - session.SendMsg(string(this.module.GetType()), "cmd", &pb.GMCmdResp{IsSucc: true}) - return - } - } else if len(datas) == 2 && (datas[0] == "mapid") { - module1, err := this.service.GetModule(comm.ModuleMainline) - if err != nil { - return - } - num, err := strconv.Atoi(datas[1]) - if err != nil { - code = pb.ErrorCode_ReqParameterError - return - } - code = module1.(comm.IMainline).ModifyMainlineData(session.GetUserId(), int32(num)) - } else if len(datas) == 2 && (datas[0] == "pataid") { - module1, err := this.service.GetModule(comm.ModulePagoda) - if err != nil { - return - } - num, err := strconv.Atoi(datas[1]) - if err != nil { - code = pb.ErrorCode_ReqParameterError - return - } - code = module1.(comm.IPagoda).ModifyPagodaFloor(session, int32(num)) - } - } - } + this.module.CreateCmd(session, req.Cmod) //this.module.ModuleHero.GetSpecifiedHero(session.GetUserId(), heroid, star, lv) session.SendMsg(string(this.module.GetType()), "cmd", &pb.GMCmdResp{IsSucc: false}) diff --git a/modules/gm/comp_configure.go b/modules/gm/comp_configure.go new file mode 100644 index 000000000..fee5fd80d --- /dev/null +++ b/modules/gm/comp_configure.go @@ -0,0 +1,60 @@ +package gm + +import ( + "fmt" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + "sync" +) + +const ( + game_daddy = "game_daddy.json" +) + +///配置管理基础组件 +type configureComp struct { + hlock sync.RWMutex + modules.MCompConfigure +} + +//组件初始化接口 +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) + err = this.LoadConfigure(game_daddy, cfg.NewGameInitial) + return +} + +//加载多个配置文件 +func (this *configureComp) LoadMultiConfigure(confs map[string]interface{}) (err error) { + for k, v := range confs { + err = configure.RegisterConfigure(k, v, nil) + if err != nil { + log.Errorf("配置文件:%s解析失败!", k) + break + } + } + return +} + +//读取配置数据 +func (this *configureComp) GetConfigure(name string) (v interface{}, err error) { + return configure.GetConfigure(name) +} +func (this *configureComp) GetYouDaddyConf() (configure *cfg.GameInitial, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_daddy); err != nil { + return + } else { + if configure, ok = v.(*cfg.GameInitial); !ok { + err = fmt.Errorf("%T no is *cfg.Game_comInitial", v) + return + } + } + return +} diff --git a/modules/gm/module.go b/modules/gm/module.go index 785c342e1..64a7af01c 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -22,8 +22,9 @@ func NewModule() core.IModule { type GM struct { modules.ModuleBase - api_comp *apiComp - service core.IService + api_comp *apiComp + service core.IService + configure *configureComp } //模块名 @@ -42,9 +43,10 @@ func (this *GM) Init(service core.IService, module core.IModule, options core.IM func (this *GM) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) - + this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } +//bingo:Iamyoudad func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorCode) { code = pb.ErrorCode_ReqParameterError keys := strings.Split(cmd, ":") @@ -91,6 +93,20 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC return } code = module1.(comm.IPagoda).ModifyPagodaFloor(session, int32(num)) + } else if len(datas) == 1 && (datas[0] == "Iamyoudad" || datas[0] == "iamyoudad") { + var ( + res []*cfg.Gameatn + ) + if val, err := this.configure.GetYouDaddyConf(); err == nil { + for _, v := range val.GetDataList() { + res = append(res, v.Var...) + + } + code = this.DispenseRes(session, res, true) + if code != pb.ErrorCode_Success { + this.Errorf("资源发放失败,%v", code) + } + } } } }