From eca5c2e75084237207d94a603395b841cb9ed435 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 12 Oct 2022 15:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=E8=8B=B1=E9=9B=84=E8=B5=A0=E9=80=81?= =?UTF-8?q?=E7=A4=BC=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comp_configure.go | 15 +++++++++ modules/hero/api_awaken.go | 2 +- modules/hero/api_resonance.go | 4 +-- modules/hero/api_resonanceReset.go | 2 +- modules/hero/api_resonanceSelect.go | 2 +- modules/hero/api_strengthenUpSkill.go | 6 ++-- modules/hero/api_strengthenUpStar.go | 2 +- modules/hero/configure_comp.go | 37 +++++++-------------- modules/hero/model_hero.go | 10 +++--- modules/hero/module.go | 4 +-- modules/library/api_usegift.go | 46 ++++++++++++++++++++++++++- modules/library/comp_configure.go | 12 +++---- pb/errorcode.pb.go | 11 +++++-- 13 files changed, 100 insertions(+), 53 deletions(-) diff --git a/modules/comp_configure.go b/modules/comp_configure.go index 3093ca036..1ec54c2b9 100644 --- a/modules/comp_configure.go +++ b/modules/comp_configure.go @@ -20,6 +20,7 @@ const ( game_facemod = "game_facemod.json" //形象配置表 game_drop = "game_drop.json" //掉落 game_comatn = "game_comatn.json" //atn配置表 + new_hero = "game_hero.json" ) ///配置管理基础组件 @@ -35,11 +36,13 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com err = this.LoadConfigure(game_global, cfg.NewGameGlobal) err = this.LoadConfigure(game_initial, cfg.NewGameInitial) err = this.LoadConfigure(game_gamecolor, cfg.NewGameGameColor) + err = this.LoadConfigure(new_hero, cfg.NewGameHero) err = this.LoadConfigure(game_playerlv, cfg.NewGamePlayerlv) err = this.LoadConfigure(game_facemod, cfg.NewGameFacemod) err = this.LoadConfigure(game_comatn, cfg.NewGameComAtn) this._dropMap = make(map[int32][]*cfg.GameDropData, 0) configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData) + return } func (this *MCompConfigure) LoadConfigure(name string, fn interface{}) (err error) { @@ -247,3 +250,15 @@ func (this *MCompConfigure) GetColor(id int32) (item *cfg.GameGameColorData, err } return } + +// 获取英雄原始星级 +func (this *MCompConfigure) GetHeroConfigStar(heroCfgId string) int32 { + if v, err := this.GetConfigure(new_hero); err == nil { + if configure, ok := v.(*cfg.GameHero); ok { + if v, ok := configure.GetDataMap()[heroCfgId]; ok { + return v.Star + } + } + } + return 0 +} diff --git a/modules/hero/api_awaken.go b/modules/hero/api_awaken.go index ea6d5b71a..60d3ec8f8 100644 --- a/modules/hero/api_awaken.go +++ b/modules/hero/api_awaken.go @@ -107,7 +107,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (c //任务相关 this.module.ModuleRtask.SendToRtask(session, comm.Rtype34, 1, _hero.JuexingLv) this.module.ModuleRtask.SendToRtask(session, comm.Rtype35, _hero.JuexingLv, utils.ToInt32(_hero.HeroID)) - cfg := this.module.configure.GetHero(_hero.HeroID) + cfg := this.module.configure.GetHeroConfig(_hero.HeroID) if cfg != nil { this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv) //xx英雄满级、共鸣、觉醒至最高状态 diff --git a/modules/hero/api_resonance.go b/modules/hero/api_resonance.go index 7c7e1dba5..fe1e7496b 100644 --- a/modules/hero/api_resonance.go +++ b/modules/hero/api_resonance.go @@ -40,7 +40,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR return } //获取原始星级 - conf := this.module.configure.GetHero(_hero.HeroID) + conf := this.module.configure.GetHeroConfig(_hero.HeroID) if conf == nil { code = pb.ErrorCode_ConfigNoFound return @@ -151,7 +151,7 @@ func (this *apiComp) Resonance(session comm.IUserSession, req *pb.HeroResonanceR // 任务相关 this.module.ModuleRtask.SendToRtask(session, comm.Rtype39, 1) this.module.ModuleRtask.SendToRtask(session, comm.Rtype40, 1, 1) - cfg := this.module.configure.GetHero(_hero.HeroID) + cfg := this.module.configure.GetHeroConfig(_hero.HeroID) if cfg != nil { this.module.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, _hero.JuexingLv) //xx英雄满级、共鸣、觉醒至最高状态 diff --git a/modules/hero/api_resonanceReset.go b/modules/hero/api_resonanceReset.go index e19b4409f..078b752e9 100644 --- a/modules/hero/api_resonanceReset.go +++ b/modules/hero/api_resonanceReset.go @@ -40,7 +40,7 @@ func (this *apiComp) ResonanceReset(session comm.IUserSession, req *pb.HeroReson // 共鸣次数判断 //获取原始星级 - conf := this.module.configure.GetHero(_hero.HeroID) + conf := this.module.configure.GetHeroConfig(_hero.HeroID) if conf == nil { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/hero/api_resonanceSelect.go b/modules/hero/api_resonanceSelect.go index ecfcbb6d9..2f139c929 100644 --- a/modules/hero/api_resonanceSelect.go +++ b/modules/hero/api_resonanceSelect.go @@ -63,7 +63,7 @@ func (this *apiComp) ResonanceUseEnergy(session comm.IUserSession, req *pb.HeroR this.module.Errorf("update hero skill failed:%v", err1) return } - conf := this.module.configure.GetHero(_hero.HeroID) + conf := this.module.configure.GetHeroConfig(_hero.HeroID) // 计算属性 this.module.modelHero.setEnergyProperty(_hero, conf.Star) session.SendMsg(string(this.module.GetType()), ResonanceUseEnergy, &pb.HeroResonanceUseEnergyResp{Hero: _hero}) diff --git a/modules/hero/api_strengthenUpSkill.go b/modules/hero/api_strengthenUpSkill.go index 6524d7ab0..d6f6cb4b6 100644 --- a/modules/hero/api_strengthenUpSkill.go +++ b/modules/hero/api_strengthenUpSkill.go @@ -42,7 +42,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt return } // 查询配置表 找出原始品质 - heroCfg := this.module.configure.GetHero(_hero.HeroID) + heroCfg := this.module.configure.GetHeroConfig(_hero.HeroID) if heroCfg == nil { code = pb.ErrorCode_HeroNoExist return @@ -65,7 +65,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt code = pb.ErrorCode_HeroNoEnough return } - tmp := this.module.configure.GetHero(costHero.HeroID) // 星级校验 + tmp := this.module.configure.GetHeroConfig(costHero.HeroID) // 星级校验 if tmp.Color != heroCfg.Color { code = pb.ErrorCode_HeroColorErr return @@ -178,7 +178,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt this.module.ModuleRtask.SendToRtask(session, comm.Rtype54, 1) this.module.ModuleRtask.SendToRtask(session, comm.Rtype57, 1) } - cfg := this.module.configure.GetHero(_hero.HeroID) + cfg := this.module.configure.GetHeroConfig(_hero.HeroID) if cfg != nil { this.module.ModuleRtask.SendToRtask(session, comm.Rtype55, cfg.Color, 1) this.module.ModuleRtask.SendToRtask(session, comm.Rtype56, 1, 1, cfg.Job) diff --git a/modules/hero/api_strengthenUpStar.go b/modules/hero/api_strengthenUpStar.go index 5e3c4c8c9..3b2e99834 100644 --- a/modules/hero/api_strengthenUpStar.go +++ b/modules/hero/api_strengthenUpStar.go @@ -89,7 +89,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr for _, value := range starConf.Needrace { // 阵营校验 // 获取配置表英雄阵营 - cfg := this.module.configure.GetHero(tagHero.HeroID) + cfg := this.module.configure.GetHeroConfig(tagHero.HeroID) if cfg != nil { if cfg.Race == value { costRaceHeroCount += v diff --git a/modules/hero/configure_comp.go b/modules/hero/configure_comp.go index fff22336b..925c785c9 100644 --- a/modules/hero/configure_comp.go +++ b/modules/hero/configure_comp.go @@ -35,12 +35,14 @@ type configureComp struct { awakenMap map[int64]*cfg.GameHeroAwakenData resonanceMap map[int64]*cfg.GameHeroResonanceData starMap map[int64]*cfg.GameHeroStarupData + module *Hero } //组件初始化接口 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) + this.module = module.(*Hero) err = this.LoadMultiConfigure(map[string]interface{}{ new_hero: cfg.NewGameHero, hero_stargrow: cfg.NewGameHeroStargrow, @@ -85,7 +87,6 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp } }) // 升星 - //: cfg., this.starMap = make(map[int64]*cfg.GameHeroStarupData, 0) configure.RegisterConfigure(hero_starup, cfg.NewGameHeroStarup, func() { if v, err := this.GetConfigure(hero_starup); err == nil { @@ -100,6 +101,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp err = fmt.Errorf("%T no is *cfg.Game_drawCard", v) } }) + return } @@ -148,23 +150,6 @@ func (this *configureComp) GetPollByType(poosType string) map[int32][]*cfg.GameD return this.drawCardCfg[poosType] } -//获取英雄配置数据 -func (this *configureComp) getHeroConfigure() (configure *cfg.GameHero, err error) { - var ( - v interface{} - ok bool - ) - - if v, err = this.GetConfigure(new_hero); err != nil { - return - } else { - if configure, ok = v.(*cfg.GameHero); !ok { - err = fmt.Errorf("%T no is *cfg.GameHero", v) - } - } - return -} - // 获取英雄强化增加属性配置数据 func (this *configureComp) GetHeroStargrowConfig() (configure *cfg.GameHeroStargrow, err error) { var ( @@ -281,14 +266,16 @@ func (this *configureComp) GetHeroStargrow() (configure *cfg.GameHeroStargrow, e } //获取英雄配置 -func (this *configureComp) GetHero(heroCfgId string) *cfg.GameHeroData { - cfg, err := this.getHeroConfigure() - if err != nil { - return nil - } - if v, ok := cfg.GetDataMap()[heroCfgId]; ok { - return v +func (this *configureComp) GetHeroConfig(heroCfgId string) *cfg.GameHeroData { + if v, err := this.GetConfigure(new_hero); err == nil { + + if configure, ok := v.(*cfg.GameHero); ok { + if v, ok := configure.GetDataMap()[heroCfgId]; ok { + return v + } + } } + this.module.Errorf("config no is *cfg.GameHero") return nil } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index b36cdbff2..94c9189bf 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -38,7 +38,7 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor //初始化英雄 func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero { - heroCfg := this.moduleHero.configure.GetHero(heroCfgId) + heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId) if heroCfg == nil { this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId) return nil @@ -69,7 +69,7 @@ func (this *ModelHero) InitHero(uid string, heroCfgId string) *pb.DBHero { //初始化英雄技能 func (this *ModelHero) initHeroSkill(hero *pb.DBHero) []*pb.SkillData { - heroCfg := this.moduleHero.configure.GetHero(hero.HeroID) + heroCfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID) if heroCfg != nil { if heroCfg.Skill != 0 { hero.CaptainSkill = heroCfg.Skill @@ -423,7 +423,7 @@ func (this *ModelHero) PropertyCompute(hero *pb.DBHero) { } //英雄基础配置 newhero - heroCfg := this.moduleHero.configure.GetHero(hero.HeroID) + heroCfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID) if heroCfg == nil { return } @@ -579,7 +579,7 @@ func (this *ModelHero) AddCardExp(session comm.IUserSession, hero *pb.DBHero, ex this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype23, 1, hero.Star, hero.Lv) this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype24, 1) this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype29, 1, hero.Lv, utils.ToInt32(hero.HeroID)) - cfg := this.moduleHero.configure.GetHero(hero.HeroID) + cfg := this.moduleHero.configure.GetHeroConfig(hero.HeroID) if cfg != nil { this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype32, 1, cfg.Color, hero.Lv) this.moduleHero.ModuleRtask.SendToRtask(session, comm.Rtype36, 1, cfg.Color, cfg.Job, cfg.Race, hero.JuexingLv) @@ -668,7 +668,7 @@ func (this *ModelHero) GetRandHeroIdBypool(sz []int32) int32 { } func (this *ModelHero) InitTempHero(heroCfgId string, star, lv int32) *pb.DBHero { - heroCfg := this.moduleHero.configure.GetHero(heroCfgId) + heroCfg := this.moduleHero.configure.GetHeroConfig(heroCfgId) if heroCfg == nil { this.moduleHero.Errorf("%v hero not found from config %v", heroCfgId) return nil diff --git a/modules/hero/module.go b/modules/hero/module.go index 8b5d0ffa6..14805ad22 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -96,7 +96,7 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, // 统计任务 this.ModuleRtask.SendToRtask(session, comm.Rtype1, utils.ToInt32(heroCfgId)) // 查品质 - cfg := this.configure.GetHero(heroCfgId) + cfg := this.configure.GetHeroConfig(heroCfgId) if cfg != nil { this.ModuleRtask.SendToRtask(session, comm.Rtype30, 1, cfg.Color) @@ -255,7 +255,7 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string] } changeHero = append(changeHero, hero) // 查品质 - cfg := this.configure.GetHero(heroCfgId) + cfg := this.configure.GetHeroConfig(heroCfgId) if cfg != nil { this.ModuleRtask.SendToRtask(session, comm.Rtype30, 1, cfg.Color) diff --git a/modules/library/api_usegift.go b/modules/library/api_usegift.go index 21fdf58e5..37f6e6bbd 100644 --- a/modules/library/api_usegift.go +++ b/modules/library/api_usegift.go @@ -18,7 +18,10 @@ func (this *apiComp) UseGiftCheck(session comm.IUserSession, req *pb.LibraryUseG func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftReq) (code pb.ErrorCode, data proto.Message) { var ( - res []*cfg.Gameatn + res []*cfg.Gameatn + totalExp int32 + curStar int32 // 配置表星级 + maxLv int32 // 羁绊最大等级 ) code = this.UseGiftCheck(session, req) if code != pb.ErrorCode_Success { @@ -30,17 +33,58 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe code = pb.ErrorCode_HeroNoExist // 没找到对应的英雄信息 return } + // 查询该英雄原始的星级 + curStar = this.configure.GetHeroConfigStar(_heroObj.Heroid) + if curStar == 0 { + code = pb.ErrorCode_ConfigNoFound + return + } + favorConf := this.configure.GetLibraryFavor(curStar) + maxLv = int32(len(favorConf)) // 获取当前星级羁绊最大等级 + // 达到最大等级不让继续升级 + if _heroObj.Favorlv >= maxLv { + code = pb.ErrorCode_LibraryMaxLv + return + } for k, v := range req.Items { // 校验数量 res = append(res, &cfg.Gameatn{ A: "item", T: k, N: v, }) + expConf := this.configure.GetFavorNum(k) + if expConf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } + totalExp += expConf.FavorNum } if code = this.module.CheckRes(session, res); code != pb.ErrorCode_Success { // 道具不够直接返回 return } + _heroObj.Favorexp += totalExp + // 折算出等级 + for { + if _heroObj.Favorlv >= maxLv { // 达到最大等级不让继续升级 + code = pb.ErrorCode_LibraryMaxLv + break + } + if favorConf[_heroObj.Favorlv] <= _heroObj.Favorexp { + _heroObj.Favorexp -= favorConf[_heroObj.Favorlv] + _heroObj.Favorlv += 1 + } else { + break + } + } + if code = this.module.ConsumeRes(session, res, true); code != pb.ErrorCode_Success { //真正消耗 + return + } + // 修改信息 + mapData := make(map[string]interface{}) + mapData["favorexp"] = _heroObj.Favorexp + mapData["favorlv"] = _heroObj.Favorlv + this.module.modelFetter.modifyHeroFetterDataByObjId(session.GetUserId(), _heroObj.Id, mapData) session.SendMsg(string(this.module.GetType()), LibraryUseGiftResp, rsp) return diff --git a/modules/library/comp_configure.go b/modules/library/comp_configure.go index 6b9f12e19..1f906440a 100644 --- a/modules/library/comp_configure.go +++ b/modules/library/comp_configure.go @@ -36,15 +36,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp }) this.fetter = make(map[int64]*cfg.GameLibraryFetterData, 0) - configure.RegisterConfigure(game_libraryfetter, cfg.NewGameLibraryFetter, this.SetLibraryFetter) - _data := this.GetFavorNum("10016") - fmt.Printf("%v", _data) - _data1 := this.GetLibraryFavor(3) - fmt.Printf("%v", _data1) - // _data2 := this.GetLibraryHistory("350011") - // fmt.Printf("%v", _data2) return } @@ -92,11 +85,14 @@ func (this *configureComp) GetLibraryHero(hid string) (data *cfg.GameLibraryHero return } +// 获取当前星级的好感度 func (this *configureComp) GetLibraryFavor(star int32) (data []int32) { if v, err := this.GetConfigure(game_libraryfavor); err == nil { if configure, ok := v.(*cfg.GameLibraryFavor); ok { for _, v := range configure.GetDataList() { - data = append(data, v.Expneed) + if v.Star == star { + data = append(data, v.Expneed) + } } } } else { diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 94b0253bb..15549bcb3 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -188,6 +188,8 @@ const ( ErrorCode_HuntingBoosType ErrorCode = 2702 // BOSS 类型不对 ErrorCode_HuntingBuyMaxCount ErrorCode = 2703 // 购买达到最大次数 ErrorCode_HuntingMaxChallengeCount ErrorCode = 2704 // 挑战达到最大次数 + // library + ErrorCode_LibraryMaxLv ErrorCode = 2801 // 达到最大等级 ) // Enum value maps for ErrorCode. @@ -342,6 +344,7 @@ var ( 2702: "HuntingBoosType", 2703: "HuntingBuyMaxCount", 2704: "HuntingMaxChallengeCount", + 2801: "LibraryMaxLv", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -493,6 +496,7 @@ var ( "HuntingBoosType": 2702, "HuntingBuyMaxCount": 2703, "HuntingMaxChallengeCount": 2704, + "LibraryMaxLv": 2801, } ) @@ -527,7 +531,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xee, 0x19, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x81, 0x1a, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -734,8 +738,9 @@ var file_errorcode_proto_rawDesc = []byte{ 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x75, 0x79, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0x8f, 0x15, 0x12, 0x1d, 0x0a, 0x18, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, - 0x90, 0x15, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x90, 0x15, 0x12, 0x11, 0x0a, 0x0c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x4d, 0x61, 0x78, + 0x4c, 0x76, 0x10, 0xf1, 0x15, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (