From 46f9b0065c3f9b851dc3cb9cc7b5d57529f425b2 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sun, 9 Oct 2022 16:07:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=81=E7=BB=8A=E6=96=B0=E5=A2=9E=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 3 +- comm/imodule.go | 7 ++++ modules/gourmet/model_gourmet.go | 15 +++++--- modules/hero/module.go | 30 +++++++++++++--- modules/library/model_fetter.go | 21 ++++++------ modules/library/model_library.go | 4 +-- modules/library/module.go | 59 +++++++++++++++++++++++++++++--- 7 files changed, 114 insertions(+), 25 deletions(-) diff --git a/comm/const.go b/comm/const.go index d1c2917a4..59f46eff6 100644 --- a/comm/const.go +++ b/comm/const.go @@ -62,7 +62,7 @@ const ( ModuleLinestory core.M_Modules = "linestory" //支线剧情 ModuleBattle core.M_Modules = "battle" //战斗 ModuleLibrary core.M_Modules = "library" // - + //ModuleFetter core.M_Modules = "herofetter" //好友模块 ) //数据表名定义处 @@ -142,6 +142,7 @@ const ( TableLinestory = "linestory" TableLibrary = "library" + TableFetter = "herofetter" ) //RPC服务接口定义处 diff --git a/comm/imodule.go b/comm/imodule.go index 1a376fde8..d3536e89a 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -167,4 +167,11 @@ type ( IPagoda interface { ModifyPagodaFloor(session IUserSession, level int32) (code pb.ErrorCode) } + + IHeroFetter interface { + ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) // 修改羁绊信息 + QueryHeroFetter(session IUserSession) (data []*pb.DBHeroFetter) // 查询所有的羁绊信息 + QueryOneHeroFetter(session IUserSession, cid string) *pb.DBHeroFetter // 通过英雄配置id 查询羁绊信息 + AddHeroFetterData(session IUserSession, heroConfId string) // 创建一条羁绊信息 + } ) diff --git a/modules/gourmet/model_gourmet.go b/modules/gourmet/model_gourmet.go index d3e0afdc8..efaf6d4eb 100644 --- a/modules/gourmet/model_gourmet.go +++ b/modules/gourmet/model_gourmet.go @@ -148,9 +148,10 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) // 记录下订单时间 gourmet.Ctime = time.Now().Unix() mapData["ctime"] = gourmet.Ctime - break + } gourmet.Items = this.module.configure.GetMultipleDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励 + break } if bCooking { // 分配了正在製作的食物 @@ -213,18 +214,24 @@ func (this *modelGourmet) CalculationSpecialSkillLv(uid string, gourmet *pb.DBGo var totalTime int32 for _, v := range gourmet.Foods { if v.FoodCount > 0 { + preScaleTime := 0 + preSkillConf := this.module.configure.GetGourmetConfigData(skillType, skilllv-1) + if preSkillConf != nil { + preScaleTime = int(preSkillConf.Needtime) + } _skillCfg := this.module.configure.GetGourmetConfigData(skillType, skilllv) if _skillCfg != nil { - totalTime += _skillCfg.Needtime * v.FoodCount - v.CookTime += totalTime + scaleTime := (_skillCfg.Needtime - int32(preScaleTime)) * v.FoodCount + totalTime += scaleTime + v.CookTime += scaleTime if v.CookTime < 0 { // 担心配置错误 为负数情况 所以这里做下判断 v.CookTime = 0 } - mapData["foods"] = gourmet.Foods } } } // 总时间也减少了 + mapData["foods"] = gourmet.Foods gourmet.OrderCostTime += totalTime mapData["orderCostTime"] = gourmet.OrderCostTime mapData["specialSkill"] = gourmet.SpecialSkill diff --git a/modules/hero/module.go b/modules/hero/module.go index 871e3e7be..b74f4976d 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -17,10 +17,13 @@ func NewModule() core.IModule { type Hero struct { modules.ModuleBase - api *apiComp - configure *configureComp - modelHero *ModelHero - modelRecord *ModelRecord + api *apiComp + configure *configureComp + modelHero *ModelHero + modelRecord *ModelRecord + moduleFetter comm.IHeroFetter + + service core.IService } //模块名 @@ -31,6 +34,7 @@ func (this *Hero) GetType() core.M_Modules { //模块初始化接口 注册用户创建角色事件 func (this *Hero) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) + this.service = service return } @@ -44,6 +48,11 @@ func (this *Hero) OnInstallComp() { } func (this *Hero) Start() (err error) { + var module core.IModule + if module, err = this.service.GetModule(comm.ModuleLibrary); err != nil { + return + } + this.moduleFetter = module.(comm.IHeroFetter) err = this.ModuleBase.Start() event.RegisterGO(comm.EventUserOffline, this.EventUserOffline) return @@ -59,6 +68,13 @@ func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, _hero, err := this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) if err == nil { go func(uid string, heroCfgId string) { // 携程处理 图鉴数据 + + _data := this.moduleFetter.QueryOneHeroFetter(session, heroCfgId) // 查询获得英雄是否存在羁绊信息 + this.Debugf("%v", _data) + if _data == nil { + this.moduleFetter.AddHeroFetterData(session, heroCfgId) // 创建一个新的羁绊数据 + } + if result, err1 := this.ModuleUser.GetUserExpand(uid); err1 == nil { initUpdate := map[string]interface{}{} sz := result.GetTujian() @@ -256,6 +272,12 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string] sz = make(map[string]int32, 0) } for k := range heros { + _data := this.moduleFetter.QueryOneHeroFetter(session, k) // 查询获得英雄是否存在羁绊信息 + this.Debugf("%v", _data) + if _data == nil { + this.moduleFetter.AddHeroFetterData(session, k) // 创建一个新的羁绊数据 + } + if _, ok := result.GetTujian()[k]; !ok { sz[k] = 0 initUpdate["tujian"] = sz diff --git a/modules/library/model_fetter.go b/modules/library/model_fetter.go index 193d09258..aa144476b 100644 --- a/modules/library/model_fetter.go +++ b/modules/library/model_fetter.go @@ -16,7 +16,7 @@ type modelFetter struct { } func (this *modelFetter) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { - this.TableName = string(comm.TableLibrary) + this.TableName = string(comm.TableFetter) err = this.MCompModel.Init(service, module, comp, options) this.module = module.(*Library) // uid 创建索引 @@ -26,22 +26,23 @@ func (this *modelFetter) Init(service core.IService, module core.IModule, comp c return } -func (this *modelFetter) modifyLibraryDataByObjId(uid string, data map[string]interface{}) error { - return this.Change(uid, data) +// 修改英雄羁绊数据 +func (this *modelFetter) modifyHeroFetterDataByObjId(uid string, obj string, data map[string]interface{}) error { + return this.ChangeList(uid, obj, data) } // 获取列表信息 -func (this *modelFetter) getLibraryList(uid string) []*pb.DBLibrary { - libs := make([]*pb.DBLibrary, 0) - err := this.GetList(uid, &libs) +func (this *modelFetter) getHeroFetterList(uid string) []*pb.DBHeroFetter { + fetters := make([]*pb.DBHeroFetter, 0) + err := this.GetList(uid, &fetters) if err != nil { return nil } - return libs + return fetters } //创建一条信息 -func (this *modelFetter) createLibrary(uid string, fetter *pb.DBLibrary) (err error) { +func (this *modelFetter) createHeroFetter(uid string, fetter *pb.DBHeroFetter) (err error) { if err = this.AddList(uid, fetter.Id, fetter); err != nil { this.module.Errorf("%v", err) @@ -51,8 +52,8 @@ func (this *modelFetter) createLibrary(uid string, fetter *pb.DBLibrary) (err er } // 通过objid 找对应的数据 -func (this *modelFetter) getOneLibrary(uid, oid string) *pb.DBLibrary { - fetter := &pb.DBLibrary{} +func (this *modelFetter) getOneHeroFetter(uid, oid string) *pb.DBHeroFetter { + fetter := &pb.DBHeroFetter{} err := this.GetListObj(uid, oid, fetter) if err != nil { return nil diff --git a/modules/library/model_library.go b/modules/library/model_library.go index b5fa747b7..5bc5b22ce 100644 --- a/modules/library/model_library.go +++ b/modules/library/model_library.go @@ -26,8 +26,8 @@ func (this *modelLibrary) Init(service core.IService, module core.IModule, comp return } -func (this *modelLibrary) modifyLibraryDataByObjId(uid string, data map[string]interface{}) error { - return this.Change(uid, data) +func (this *modelLibrary) modifyLibraryDataByObjId(uid string, obj string, data map[string]interface{}) error { + return this.ChangeList(uid, obj, data) } // 获取列表信息 diff --git a/modules/library/module.go b/modules/library/module.go index 9f1226c00..d7be329c3 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -12,6 +12,7 @@ import ( type Library struct { modules.ModuleBase modelLibrary *modelLibrary + modelFetter *modelFetter api *apiComp configure *configureComp } @@ -34,20 +35,21 @@ func (this *Library) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelLibrary = this.RegisterComp(new(modelLibrary)).(*modelLibrary) + this.modelFetter = this.RegisterComp(new(modelFetter)).(*modelFetter) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } -// 接口信息 -func (this *Library) ModifyLibraryData(uid string, data map[string]interface{}) (code pb.ErrorCode) { - err := this.modelLibrary.modifyLibraryDataByObjId(uid, data) +// 接口信息 更新藏书馆数据 +func (this *Library) ModifyLibraryData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) { + err := this.modelLibrary.modifyLibraryDataByObjId(uid, obj, data) if err != nil { code = pb.ErrorCode_DBError } return } -//英雄列表 +// 获取藏书馆列表 func (this *Library) GetLibraryList(uid string) []*pb.DBLibrary { return this.modelLibrary.getLibraryList(uid) } @@ -82,3 +84,52 @@ func (this *Library) CreateLibrary(uid string, fids []int32, heroConfId string) return } +func (this *Library) ModifyHeroFetterData(uid string, obj string, data map[string]interface{}) (code pb.ErrorCode) { + err := this.modelFetter.modifyHeroFetterDataByObjId(uid, obj, data) + if err != nil { + code = pb.ErrorCode_DBError + } + return +} +func (this *Library) GetHeroFetterList(uid string) []*pb.DBHeroFetter { + return this.modelFetter.getHeroFetterList(uid) +} + +// 创建一条英雄羁绊信息 +func (this *Library) createHeroFetter(uid string, heroConfId string) (code pb.ErrorCode) { + + obj := &pb.DBHeroFetter{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + Heroid: heroConfId, + History: 0, + Favorlv: 1, // 所有好感度默认1级 + Stroyprize: 0, + } + if err := this.modelFetter.createHeroFetter(uid, obj); err != nil { + code = pb.ErrorCode_DBError + } + return +} + +func (this *Library) QueryHeroFetter(session comm.IUserSession) (data []*pb.DBHeroFetter) { + data = this.GetHeroFetterList(session.GetUserId()) + return +} + +func (this *Library) QueryOneHeroFetter(session comm.IUserSession, cid string) *pb.DBHeroFetter { + _data := this.GetHeroFetterList(session.GetUserId()) + for _, v := range _data { + if v.Heroid == cid { + return v + } + } + return nil +} + +// 创建一条羁绊信息 +func (this *Library) AddHeroFetterData(session comm.IUserSession, heroConfId string) { + this.createHeroFetter(session.GetUserId(), heroConfId) + + return +}