From 7ecade27a633ecabef0fbc9728368560d7f15154 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 28 Aug 2023 15:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=85=BB=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/robot/configure.go | 6 +- modules/robot/modulerobot_hero.go | 98 +++++++++++++++++++++++++++---- 2 files changed, 90 insertions(+), 14 deletions(-) diff --git a/modules/robot/configure.go b/modules/robot/configure.go index 9b627cf8a..47303f61e 100644 --- a/modules/robot/configure.go +++ b/modules/robot/configure.go @@ -25,8 +25,9 @@ const ( // gamesearchitembox = "game_searchitembox.json" // game_worlddeal = "game_worlddeal.json" // game_worldrd = "game_worldrd.json" - game_pagoda = "game_pagoda.json" - hero_talent = "game_herotalent.json" // 天赋详细数据 + game_pagoda = "game_pagoda.json" + hero_talent = "game_herotalent.json" // 天赋详细数据 + game_playerlv = "game_playerlv.json" ) type configureComp struct { @@ -46,6 +47,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, nil) configure.RegisterConfigure(equip_suit, cfg.NewGameEquipSuit, nil) configure.RegisterConfigure(hero_talent, cfg.NewGameHeroTalent, nil) + configure.RegisterConfigure(game_playerlv, cfg.NewGamePlayerlv, nil) return } diff --git a/modules/robot/modulerobot_hero.go b/modules/robot/modulerobot_hero.go index 69feed11d..f57ca94f7 100644 --- a/modules/robot/modulerobot_hero.go +++ b/modules/robot/modulerobot_hero.go @@ -75,7 +75,7 @@ func (this *ModuleRobot_Hero) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskDa } case comm.Rtype199: - resp := &pb.HeroTalentLearnReq{ + req := &pb.HeroTalentLearnReq{ TalentID: 0, ObjId: "", Heroid: "", @@ -83,12 +83,11 @@ func (this *ModuleRobot_Hero) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskDa // check 该英雄天赋满级 bMax := false // 获取英雄数据 - var bFound bool for _, v := range this.heros { if c, err := this.GMGetTalentByHeroId(v.HeroID); err == nil { if this.talent == nil { - resp.TalentID = c[0].Skillid - resp.Heroid = v.HeroID + req.TalentID = c[0].Skillid + req.Heroid = v.HeroID } else { for _, v1 := range this.talent { if len(v1.Talent) == len(c) { @@ -96,18 +95,16 @@ func (this *ModuleRobot_Hero) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskDa break } if v1.HeroId == v.HeroID { - bFound = true - resp.ObjId = v1.Id - resp.Heroid = v.HeroID + req.ObjId = v1.Id + req.Heroid = v.HeroID // 依次往后学 if len(v1.Talent) < len(c) { - resp.TalentID = c[len(v1.Talent)].Skillid + req.TalentID = c[len(v1.Talent)].Skillid } break } } } - } if !bMax { // 当前英雄全满共鸣后 继续找下一个英雄 continue @@ -115,10 +112,70 @@ func (this *ModuleRobot_Hero) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskDa break } - if !bFound { - resp.ObjId = "" + if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "talentlearn", req); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return } - if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "talentlearn", resp); errdata != nil { + case comm.Rtype6: // 升星 + req := &pb.HeroStrengthenUpStarReq{} + for _, v := range this.heros { + req.HeroObjID = v.Id + break + } + + if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "strengthenupstar", req); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + case comm.Rtype24: // 升级 + var ( + itemmodule *ModuleRobot_Item + items map[string]*pb.DB_UserItemData + use map[string]int32 + heroMaxLv int32 // 当前英雄最大等级 + ) + use = make(map[string]int32) + req := &pb.HeroStrengthenUplvReq{ + HeroObjID: "", + Item: map[string]int32{}, + } + // 取任务等级 + usermodule := robot.GetModule(comm.ModuleUser).(*ModuleRobot_User) + + if c := this.GetPlayerlvConf(usermodule.user.Lv); c != nil { + heroMaxLv = c.HeroLv + } + // 找最大等级的英雄 + for _, v := range this.heros { + if v.Lv > 1 && v.Lv < heroMaxLv { + req.HeroObjID = v.Id + } + break + } + if req.HeroObjID == "" { // 随机找一个1级的英雄进行升级 + for _, v := range this.heros { + if v.Lv == 1 { + req.HeroObjID = v.Id + break + } + } + } + + itemmodule = robot.GetModule(comm.ModuleItems).(*ModuleRobot_Item) + items = itemmodule.items + if _, ok := items["10000008"]; ok { + use["10000008"] = 1 + } + if _, ok := items["10000009"]; ok && len(use) == 0 { + use["10000009"] = 1 + } + if _, ok := items["10000010"]; ok && len(use) == 0 { + use["10000010"] = 1 + } + if len(use) > 0 { + req.Item = use + } + if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "strengthenuplv", req); errdata != nil { err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) return } @@ -179,3 +236,20 @@ func (this *ModuleRobot_Hero) GMGetTalentByHeroId(hid string) (data []*cfg.GameH return } + +// 玩家等级经验配置表 +func (this *ModuleRobot_Hero) GetPlayerlvConf(lv int32) (data *cfg.GamePlayerlvData) { + if v, err := configure.GetConfigure(game_playerlv); err != nil { + return + } else { + if configure, ok := v.(*cfg.GamePlayerlv); !ok { + err = fmt.Errorf("%T no is *cfg.Game_playerlv", v) + return + } else { + if configure != nil { + data = configure.GetDataMap()[lv] + } + } + } + return +}