From 4a8c9566d6c4b3782319df9a39e858a9358a5b61 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 13 Apr 2023 17:46:36 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 1 + comm/imodule.go | 5 + modules/arena/api_challenge.go | 6 +- modules/arena/api_info.go | 2 +- modules/arena/api_plot.go | 6 +- modules/arena/modelarena.go | 6 +- modules/arena/module.go | 2 +- modules/combat/api_drop.go | 5 +- modules/comp_configure.go | 32 +- modules/dispatch/api_do.go | 2 +- modules/dispatch/api_notice.go | 8 +- modules/dispatch/api_refresh.go | 4 +- modules/dispatch/api_week.go | 2 +- modules/dispatch/model_dispatch.go | 2 +- modules/equipment/api_wash.go | 2 +- modules/friend/api_cross_getreward.go | 2 +- modules/friend/module.go | 2 +- modules/hero/api_buy.go | 2 +- modules/hero/api_drawCard.go | 10 +- modules/hero/api_talentlearn.go | 2 +- modules/hero/api_talentreset.go | 2 +- modules/hero/model_hero.go | 2 +- modules/hero/module.go | 18 +- modules/horoscope/api_rest.go | 2 +- modules/items/api_buyphysical.go | 2 +- modules/items/configure.go | 4 +- modules/items/modelitems.go | 4 +- modules/modulebase.go | 5 + modules/moonfantasy/api_battle.go | 4 +- modules/moonfantasy/modelDream.go | 4 +- modules/moonfantasy/modelUserMF.go | 4 +- modules/pagoda/api_challengeover.go | 13 +- modules/practice/api_gymrefresh.go | 2 +- modules/practice/api_info.go | 2 +- modules/practice/api_npcbattklefinish.go | 2 +- modules/practice/module.go | 8 +- modules/smithy/api_forgeequip.go | 6 +- modules/smithy/api_getCustomer.go | 2 +- modules/smithy/api_rise.go | 4 +- modules/sociaty/api_cross_Formation.go | 2 +- modules/sociaty/api_cross_bossmain.go | 2 +- modules/sociaty/api_cross_buy.go | 2 +- modules/sociaty/module.go | 2 +- modules/tools/comp_configure.go | 589 +++++++++++++++++++++++ modules/tools/module.go | 50 ++ modules/user/model_expand.go | 2 +- modules/user/module.go | 6 +- modules/viking/module.go | 2 +- modules/worldtask/model_worldtask.go | 4 +- services/worker/main.go | 2 + 50 files changed, 755 insertions(+), 101 deletions(-) create mode 100644 modules/tools/comp_configure.go create mode 100644 modules/tools/module.go diff --git a/comm/const.go b/comm/const.go index f92fcb518..90ce3e853 100644 --- a/comm/const.go +++ b/comm/const.go @@ -83,6 +83,7 @@ const ( ModulePractice core.M_Modules = "practice" //熊猫武馆 练功系统 ModulePandaAtlas core.M_Modules = "atlas" //熊猫图鉴 ModuleParkour core.M_Modules = "parkour" //跑酷系统 + ModuleTools core.M_Modules = "tools" //工具 ) // 数据表名定义处 diff --git a/comm/imodule.go b/comm/imodule.go index e70d68a58..1255ae87e 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -451,4 +451,9 @@ type ( //pvp切磋结果通知 ChallengeResults(bid, red, bule string, winSide int32) } + + ITools interface { + GetGroupDataByLottery(lotteryId int32, vipLv int32, lv int32) (items []*cfg.Gameatn) + GetGlobalConf() *cfg.GameGlobalData + } ) diff --git a/modules/arena/api_challenge.go b/modules/arena/api_challenge.go index 70e3b1a7f..e4a37d4ab 100644 --- a/modules/arena/api_challenge.go +++ b/modules/arena/api_challenge.go @@ -55,11 +55,11 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge return } this.module.modelArena.recoverTicket(session, red) - if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.configure.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success { + if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success { return } - // if red.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos { - // red.Ticket -= this.module.configure.GetGlobalConf().ArenaTicketCos + // if red.Ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos { + // red.Ticket -= this.module.ModuleTools.GetGlobalConf().ArenaTicketCos // } else { // code = pb.ErrorCode_ArenaTicketNotEnough // return diff --git a/modules/arena/api_info.go b/modules/arena/api_info.go index e62ea5c21..5ace53d97 100644 --- a/modules/arena/api_info.go +++ b/modules/arena/api_info.go @@ -34,7 +34,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (code return } if err == mgo.MongodbNil { - global = this.module.configure.GetGlobalConf() + global = this.module.ModuleTools.GetGlobalConf() if model, err = this.module.GetDBNodule(session, comm.TableUser, time.Hour); err != nil { code = pb.ErrorCode_DBError this.module.Errorln(err) diff --git a/modules/arena/api_plot.go b/modules/arena/api_plot.go index b1f5d8a60..b9af3f8ea 100644 --- a/modules/arena/api_plot.go +++ b/modules/arena/api_plot.go @@ -59,11 +59,11 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (code return } this.module.modelArena.recoverTicket(session, info) - if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.configure.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success { + if cd = this.module.ConsumeRes(session, []*cfg.Gameatn{this.module.ModuleTools.GetGlobalConf().ArenaTicketCos}, true); cd != pb.ErrorCode_Success { return } - // if info.Ticket > this.module.configure.GetGlobalConf().ArenaTicketCos { - // info.Ticket -= this.module.configure.GetGlobalConf().ArenaTicketCos + // if info.Ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos { + // info.Ticket -= this.module.ModuleTools.GetGlobalConf().ArenaTicketCos // } else { // code = pb.ErrorCode_ArenaTicketNotEnough // return diff --git a/modules/arena/modelarena.go b/modules/arena/modelarena.go index 0d7da5fbf..3e2073f05 100644 --- a/modules/arena/modelarena.go +++ b/modules/arena/modelarena.go @@ -394,7 +394,7 @@ func (this *modelArena) recoverTicket(session comm.IUserSession, info *pb.DBAren ticket int32 ticketNum int32 ) - global := this.module.configure.GetGlobalConf() + global := this.module.ModuleTools.GetGlobalConf() ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.ArenaTicket)) if ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 { duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0)) @@ -422,14 +422,14 @@ func (this *modelArena) reddot(session comm.IUserSession) bool { return false } if err == mgo.MongodbNil { - global := this.module.configure.GetGlobalConf() + global := this.module.ModuleTools.GetGlobalConf() if global.ArenaTicketMax >= global.ArenaTicketCos.N { return true } return false } ticket := int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.ArenaTicket)) - if ticket > this.module.configure.GetGlobalConf().ArenaTicketCos.N { + if ticket > this.module.ModuleTools.GetGlobalConf().ArenaTicketCos.N { return true } return false diff --git a/modules/arena/module.go b/modules/arena/module.go index b046245e2..45c9d0f45 100644 --- a/modules/arena/module.go +++ b/modules/arena/module.go @@ -130,7 +130,7 @@ func (this *Arena) GetMatcheBattleRoles(uid string) (captain int32, rules []*pb. ais []*pb.ArenaPlayer code pb.ErrorCode ) - global = this.configure.GetGlobalConf() + global = this.ModuleTools.GetGlobalConf() if info, err = this.modelArena.queryPlayerInfo(uid); err != nil && err != mgo.MongodbNil { return } diff --git a/modules/combat/api_drop.go b/modules/combat/api_drop.go index 75d1b60c4..63bcb8a23 100644 --- a/modules/combat/api_drop.go +++ b/modules/combat/api_drop.go @@ -59,8 +59,9 @@ func (this *apiComp) Drop(session comm.IUserSession, req *pb.CombatDropReq) (cod code = pb.ErrorCode_DBError return } - - reward := this.module.configure.GetDropReward(box.Drop) + user := this.module.ModuleUser.GetUser(session.GetUserId()) + reward := this.module.ModuleTools.GetGroupDataByLottery(box.Drop, user.Vip, user.Lv) + //reward := this.module.configure.GetDropReward(box.Drop) this.module.DispenseRes(session, reward, true) atns = make([]*pb.UserAssets, len(reward)) for i, v := range reward { diff --git a/modules/comp_configure.go b/modules/comp_configure.go index 97acd945d..adfae337b 100644 --- a/modules/comp_configure.go +++ b/modules/comp_configure.go @@ -324,22 +324,22 @@ func (this *MCompConfigure) GetConfigure(name string) (v interface{}, err error) } //全局配置 -func (this *MCompConfigure) GetGlobalConf() *cfg.GameGlobalData { - var ( - configure *cfg.GameGlobal - ok bool - ) - if v, err := this.GetConfigure(game_global); err != nil { - log.Errorf("get global conf err:%v", err) - return nil - } else { - if configure, ok = v.(*cfg.GameGlobal); !ok { - log.Errorf("%T no is *cfg.Game_global", v) - return nil - } - } - return configure.GetDataList()[0] // 返回对象信息 -} +// func (this *MCompConfigure) GetGlobalConf() *cfg.GameGlobalData { +// var ( +// configure *cfg.GameGlobal +// ok bool +// ) +// if v, err := this.GetConfigure(game_global); err != nil { +// log.Errorf("get global conf err:%v", err) +// return nil +// } else { +// if configure, ok = v.(*cfg.GameGlobal); !ok { +// log.Errorf("%T no is *cfg.Game_global", v) +// return nil +// } +// } +// return configure.GetDataList()[0] // 返回对象信息 +// } func (this *MCompConfigure) GetGlobalInitConf() (configure *cfg.GameInitial, err error) { var ( diff --git a/modules/dispatch/api_do.go b/modules/dispatch/api_do.go index f37736421..11ece36f3 100644 --- a/modules/dispatch/api_do.go +++ b/modules/dispatch/api_do.go @@ -56,7 +56,7 @@ func (a *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (code pb. } //校验门票 - ticketAtn := a.module.configure.GetGlobalConf().DispatchNumtools + ticketAtn := a.module.ModuleTools.GetGlobalConf().DispatchNumtools if code = a.module.CheckRes(session, []*cfg.Gameatn{ticketAtn}); code != pb.ErrorCode_Success { code = pb.ErrorCode_DispatchTicketNoEnough return diff --git a/modules/dispatch/api_notice.go b/modules/dispatch/api_notice.go index f80529975..26b956bd0 100644 --- a/modules/dispatch/api_notice.go +++ b/modules/dispatch/api_notice.go @@ -35,7 +35,7 @@ func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) ( return } - freeCount := a.module.configure.GetGlobalConf().DispatchFreecheck + freeCount := a.module.ModuleTools.GetGlobalConf().DispatchFreecheck nb := &pb.Noticeboard{ Lv: 1, //公告初始升级 FreeCount: freeCount, @@ -55,9 +55,9 @@ func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) ( //恢复门票 one := utils.DiffDays(d.Nb.UpdateTime, configure.Now().Unix()) if one >= 1 { - itemId := a.module.configure.GetGlobalConf().DispatchNumtools.T + itemId := a.module.ModuleTools.GetGlobalConf().DispatchNumtools.T left := a.module.ModuleItems.QueryItemAmount(uid, itemId) - limit := a.module.configure.GetGlobalConf().DispatchNumoftimes + limit := a.module.ModuleTools.GetGlobalConf().DispatchNumoftimes if int32(left) < limit { add := limit - int32(left) atn := &cfg.Gameatn{A: "item", T: itemId, N: add} @@ -66,7 +66,7 @@ func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) ( } //周任务重置 n := utils.DiffDays(d.Nb.UpdateTime, configure.Now().Unix()) - day := a.module.configure.GetGlobalConf().DispatchWeektaskcheck + day := a.module.ModuleTools.GetGlobalConf().DispatchWeektaskcheck if int32(n) >= day { d.Nb.WeekCount = 0 d.Nb.WeekReceived = []int32{} diff --git a/modules/dispatch/api_refresh.go b/modules/dispatch/api_refresh.go index 75bc6ebda..c2d21acf2 100644 --- a/modules/dispatch/api_refresh.go +++ b/modules/dispatch/api_refresh.go @@ -36,13 +36,13 @@ func (a *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshReq) return } } else { - refreshCount := a.module.configure.GetGlobalConf().DispatchRefreshtimes + refreshCount := a.module.ModuleTools.GetGlobalConf().DispatchRefreshtimes if d.Nb.RefreshCount >= refreshCount { code = pb.ErrorCode_DispatchRefreshMax return } //消耗金币 - money := a.module.configure.GetGlobalConf().DispatchCheckmoney + money := a.module.ModuleTools.GetGlobalConf().DispatchCheckmoney if code = a.module.CheckRes(session, []*cfg.Gameatn{money}); code != pb.ErrorCode_Success { return } diff --git a/modules/dispatch/api_week.go b/modules/dispatch/api_week.go index fd7dbf2f9..e8e7fe997 100644 --- a/modules/dispatch/api_week.go +++ b/modules/dispatch/api_week.go @@ -27,7 +27,7 @@ func (a *apiComp) Weekrecive(session comm.IUserSession, req *pb.DispatchWeekReci } //派发奖励 - wr := a.module.configure.GetGlobalConf().DispatchWeektaskreward + wr := a.module.ModuleTools.GetGlobalConf().DispatchWeektaskreward for i, v := range wr { if req.Idx == int32(i+1) { if d.Nb.WeekCount >= v.N { diff --git a/modules/dispatch/model_dispatch.go b/modules/dispatch/model_dispatch.go index 1cffd0d68..07733d246 100644 --- a/modules/dispatch/model_dispatch.go +++ b/modules/dispatch/model_dispatch.go @@ -42,7 +42,7 @@ func (this *modelDispatch) initDispatch(uid string, dispatch *pb.DBDispatch) *pb return nil } - freeCount := this.module.configure.GetGlobalConf().DispatchFreecheck + freeCount := this.module.ModuleTools.GetGlobalConf().DispatchFreecheck dis := &pb.DBDispatch{ Uid: uid, Nb: &pb.Noticeboard{ diff --git a/modules/equipment/api_wash.go b/modules/equipment/api_wash.go index 49aeebf0c..e7888f1e5 100644 --- a/modules/equipment/api_wash.go +++ b/modules/equipment/api_wash.go @@ -40,7 +40,7 @@ func (this *apiComp) Wash(session comm.IUserSession, req *pb.EquipmentWashReq) ( code = pb.ErrorCode_ConfigNoFound return } - gole := this.module.configure.GetGlobalConf().EquipmentConsumption[conf.Color-1] + gole := this.module.ModuleTools.GetGlobalConf().EquipmentConsumption[conf.Color-1] if code = this.module.ConsumeRes(session, []*cfg.Gameatn{{A: comm.AttrType, T: comm.ResGold, N: gole}}, true); code != pb.ErrorCode_Success { return } diff --git a/modules/friend/api_cross_getreward.go b/modules/friend/api_cross_getreward.go index 9e2d99ff3..19825cd08 100644 --- a/modules/friend/api_cross_getreward.go +++ b/modules/friend/api_cross_getreward.go @@ -40,7 +40,7 @@ func (this *apiComp) Getreward(session comm.IUserSession, req *pb.FriendGetrewar return } - globalConf := this.moduleFriend.configure.GetGlobalConf() + globalConf := this.moduleFriend.ModuleTools.GetGlobalConf() if code = this.moduleFriend.DispenseRes(session, globalConf.FriendPeize, true); code != pb.ErrorCode_Success { this.moduleFriend.Error("好友领奖励", log.Field{Key: "uid", Value: uid}, diff --git a/modules/friend/module.go b/modules/friend/module.go index f5babd2f7..98280e65d 100644 --- a/modules/friend/module.go +++ b/modules/friend/module.go @@ -61,7 +61,7 @@ func (this *Friend) Start() (err error) { err = this.ModuleBase.Start() this.service.RegisterFunctionName(string(comm.Rpc_ModuleFriendUseAssitHero), this.RpcUseAssisHero) this.service.RegisterFunctionName(string(comm.Rpc_ModuleFriendDB), this.RpcFriendDB) - this.globalConf = this.configure.GetGlobalConf() + this.globalConf = this.ModuleTools.GetGlobalConf() if this.globalConf == nil { err = errors.New("global config not found") } diff --git a/modules/hero/api_buy.go b/modules/hero/api_buy.go index 5f59ae77c..ae7da09b7 100644 --- a/modules/hero/api_buy.go +++ b/modules/hero/api_buy.go @@ -52,7 +52,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb code = pb.ErrorCode_SystemError return } - global = this.module.configure.GetGlobalConf() + global = this.module.ModuleTools.GetGlobalConf() for _, v := range conf.Salelist { price = append(price, v) } diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index c479a3eb9..ebf4a8703 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -36,7 +36,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq normalDraw bool // 是否是普通抽 ) update = make(map[string]interface{}) - cfgDraw = this.module.configure.GetGlobalConf() // 读取抽卡配置文件 + cfgDraw = this.module.ModuleTools.GetGlobalConf() // 读取抽卡配置文件 if cfgDraw == nil { return } @@ -81,7 +81,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq starIndex := this.module.modelHero.GetRandW(starWeight) // 3 4 5 星索引 // 特殊规则 DrawCard_5StarsInRange 第2-30次抽奖必出一个5星英雄(普通卡池) - inRangeConf := this.module.configure.GetGlobalConf().DrawCard5StarsInRange + inRangeConf := this.module.ModuleTools.GetGlobalConf().DrawCard5StarsInRange if len(inRangeConf) == 3 { iStart := inRangeConf[0] // 抽卡开始 iEnd := inRangeConf[1] // 抽卡结束 @@ -121,7 +121,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq } } } - inRangeConf1 := this.module.configure.GetGlobalConf().DrawCard5StarsInRange1 + inRangeConf1 := this.module.ModuleTools.GetGlobalConf().DrawCard5StarsInRange1 if len(inRangeConf1) == 3 { iStart := inRangeConf1[0] // 抽卡开始 iEnd := inRangeConf1[1] // 抽卡结束 @@ -142,7 +142,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq heroRecord.Star5 = 0 } // 修改卡池 - newPoll := this.module.configure.GetGlobalConf().DrawCard5StarsInRange1Pool + newPoll := this.module.ModuleTools.GetGlobalConf().DrawCard5StarsInRange1Pool if newPoll != "" { strPool[len(strPool)-1] = newPoll } @@ -163,7 +163,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq heroRecord.Star5 = 0 } // 修改卡池 - newPoll := this.module.configure.GetGlobalConf().DrawCard5StarsInRange1Pool + newPoll := this.module.ModuleTools.GetGlobalConf().DrawCard5StarsInRange1Pool if newPoll != "" { strPool[len(strPool)-1] = newPoll } diff --git a/modules/hero/api_talentlearn.go b/modules/hero/api_talentlearn.go index fd387c690..bb2aa3abb 100644 --- a/modules/hero/api_talentlearn.go +++ b/modules/hero/api_talentlearn.go @@ -89,7 +89,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe curItemCount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), t)) if curItemCount < talentConf.Point { // 如果数量不够 则取找其他物品替代 leftCount := talentConf.Point - curItemCount // 需要其他物品的数量 - generaltp := this.module.configure.GetGlobalConf().Generaltp + generaltp := this.module.ModuleTools.GetGlobalConf().Generaltp fp := &cfg.Gameatn{ A: generaltp.A, T: generaltp.T, diff --git a/modules/hero/api_talentreset.go b/modules/hero/api_talentreset.go index 5560293d1..2e5e70a7f 100644 --- a/modules/hero/api_talentreset.go +++ b/modules/hero/api_talentreset.go @@ -39,7 +39,7 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe chanegCard = make([]*pb.DBHero, 0) // 检查消耗够不够 - if code = this.module.ConsumeRes(session, this.module.configure.GetGlobalConf().TalentReset, true); code != pb.ErrorCode_Success { + if code = this.module.ConsumeRes(session, this.module.ModuleTools.GetGlobalConf().TalentReset, true); code != pb.ErrorCode_Success { return } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 7126ad553..43e8a47ba 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -879,7 +879,7 @@ func (this *ModelHero) createHero(session comm.IUserSession, heroCfgId string, c // 如果技能是满级 则转成其他道具 if this.checkHeroAllSkillMax(hero) { - list := this.moduleHero.configure.GetGlobalConf().Moonshopmoney + list := this.moduleHero.ModuleTools.GetGlobalConf().Moonshopmoney if list != nil { for pos, v := range list { diff --git a/modules/hero/module.go b/modules/hero/module.go index 196c242ee..f8f99f29f 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -460,7 +460,7 @@ func (this *Hero) PushHeroProperty(session comm.IUserSession, heros []*pb.DBHero // 充值了多少钱 func (this *Hero) RechargeMoney(uid string, money int32) { - conf := this.configure.GetGlobalConf() + conf := this.ModuleTools.GetGlobalConf() if conf != nil { if len(conf.DrawCardRechargeReward) != 2 { return @@ -489,7 +489,7 @@ func (this *Hero) RechargeMoney(uid string, money int32) { // 多少天没登录 func (this *Hero) NoLoginDay(uid string, day int32) { - conf := this.configure.GetGlobalConf() + conf := this.ModuleTools.GetGlobalConf() if conf != nil { if len(conf.DrawCardRegressionReward) != 2 { return @@ -533,7 +533,7 @@ func (this *Hero) ContinuousRestriction(uid string, heroCid string, drawCount in } for heroid, index := range record.Star5Hero { if heroid == heroCid { - conf := this.configure.GetGlobalConf() //. + conf := this.ModuleTools.GetGlobalConf() //. iMaxCOunt := conf.DrawCardContinuousRestrictionStar5 if drawCount-index <= iMaxCOunt { // 连续n次还获得该英雄 直接替换其他英雄 @@ -577,7 +577,7 @@ func (this *Hero) CheckCondition(uid string) bool { defer this.modelRecord.ChangeHeroRecord(uid, update) record, _ := this.modelRecord.GetHeroRecord(uid) if v, ok := record.Condition["recharge"]; ok { - conf := this.configure.GetGlobalConf() //. + conf := this.ModuleTools.GetGlobalConf() //. if len(conf.DrawCardRechargeReward) == 2 { curCount = conf.DrawCardRechargeReward[1] } @@ -597,7 +597,7 @@ func (this *Hero) CheckCondition(uid string) bool { } } if v, ok := record.Condition["login"]; ok { - conf := this.configure.GetGlobalConf() //. + conf := this.ModuleTools.GetGlobalConf() //. if len(conf.DrawCardRegressionReward) == 2 { curCount = conf.DrawCardRegressionReward[1] } @@ -763,7 +763,7 @@ func (this *Hero) SendTaskMsg(session comm.IUserSession, szStar []int32, drawCou } func (this *Hero) newCondition(heroRecord *pb.DBHeroRecord) (get bool, starIndex int32) { - inRangeConf := this.configure.GetGlobalConf().DrawCard5StarsInRange + inRangeConf := this.ModuleTools.GetGlobalConf().DrawCard5StarsInRange if len(inRangeConf) == 3 { iStart := inRangeConf[0] // 抽卡开始 iEnd := inRangeConf[1] // 抽卡结束 @@ -796,8 +796,8 @@ func (this *Hero) newCondition(heroRecord *pb.DBHeroRecord) (get bool, starIndex func (this *Hero) InRange(heroRecord *pb.DBHeroRecord, strPool []string, update map[string]interface{}) (starIndex int32, pool string) { starIndex = 3 // 默认3星 - inRangeConf1 := this.configure.GetGlobalConf().DrawCard5StarsInRange1 - pool = this.configure.GetGlobalConf().DrawCard5StarsInRange1Pool + inRangeConf1 := this.ModuleTools.GetGlobalConf().DrawCard5StarsInRange1 + pool = this.ModuleTools.GetGlobalConf().DrawCard5StarsInRange1Pool if len(inRangeConf1) == 3 { iStart := inRangeConf1[0] // 抽卡开始 iEnd := inRangeConf1[1] // 抽卡结束 @@ -914,7 +914,7 @@ func (this *Hero) RegisterInstructor(session comm.IUserSession, heroOid []string //DrawCard_ContinuousRestriction_Camp func (this *Hero) DrawCardContinuousRestrictionCamp(cardId string, race map[int32]int32, sz []int32, data []*cfg.GameDrawCardData) (card string) { card = cardId - cfgDraw := this.configure.GetGlobalConf() // 读取抽卡配置文件 + cfgDraw := this.ModuleTools.GetGlobalConf() // 读取抽卡配置文件 if cfgDraw == nil || race == nil { return } diff --git a/modules/horoscope/api_rest.go b/modules/horoscope/api_rest.go index a5c7cffb5..bfecf18ff 100644 --- a/modules/horoscope/api_rest.go +++ b/modules/horoscope/api_rest.go @@ -30,7 +30,7 @@ func (this *apiComp) Reset(session comm.IUserSession, req *pb.HoroscopeResetReq) code = pb.ErrorCode_DBError return } - conf = this.module.configure.GetGlobalConf() + conf = this.module.ModuleTools.GetGlobalConf() if info.Lastrest > 0 { if configure.Now().Sub(time.Unix(info.Lastrest, 0)).Seconds() < float64(conf.HoroscopeResetCd) { code = pb.ErrorCode_HoroscopeRestCDNoEnd diff --git a/modules/items/api_buyphysical.go b/modules/items/api_buyphysical.go index 9882b10a5..883e638e1 100644 --- a/modules/items/api_buyphysical.go +++ b/modules/items/api_buyphysical.go @@ -34,7 +34,7 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys return } - if needs = this.module.configure.GetGlobalConf().PsBuy; needs == nil && len(needs) == 0 { + if needs = this.module.ModuleTools.GetGlobalConf().PsBuy; needs == nil && len(needs) == 0 { code = pb.ErrorCode_ConfigNoFound return } diff --git a/modules/items/configure.go b/modules/items/configure.go index 26b9d60d5..8f25e72ab 100644 --- a/modules/items/configure.go +++ b/modules/items/configure.go @@ -137,12 +137,12 @@ func (this *ConfigureComp) GetPackItemByType(itmes []*pb.DB_UserItemData, bagtyp } func (this *ConfigureComp) GetchallengeDataCount() (count int, err error) { - count = len(this.GetGlobalConf().CopsBuy) + count = len(this.module.ModuleTools.GetGlobalConf().CopsBuy) return } func (this *ConfigureComp) GetchallengeData(buy int) (result *cfg.Gameatn) { - for i, v := range this.GetGlobalConf().CopsBuy { + for i, v := range this.module.ModuleTools.GetGlobalConf().CopsBuy { if i == buy-1 { result = v return diff --git a/modules/items/modelitems.go b/modules/items/modelitems.go index 1b517bda3..ce0ff9b87 100644 --- a/modules/items/modelitems.go +++ b/modules/items/modelitems.go @@ -502,7 +502,7 @@ func (this *ModelItemsComp) buyTicket(session comm.IUserSession, buy int32) (inf return } - atn := this.module.configure.GetGlobalConf().CopsBuyGet + atn := this.module.ModuleTools.GetGlobalConf().CopsBuyGet res := &cfg.Gameatn{ A: atn.A, @@ -543,7 +543,7 @@ func (this *ModelItemsComp) recoverTicket(session comm.IUserSession) (code pb.Er info.Lasttimeunifiedticket = configure.Now().Unix() info.Buyunifiedticket = 0 } - global := this.module.configure.GetGlobalConf() + global := this.module.ModuleTools.GetGlobalConf() playerlv := this.module.configure.GetPlayerlvConf(user.Lv) ticket = int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), comm.UnifiedTicket)) if ticket < global.DreamlandFightnum && info.Recovertimeunifiedticket > 0 { diff --git a/modules/modulebase.go b/modules/modulebase.go index 2375d7cda..9fd820803 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -40,6 +40,7 @@ type ModuleBase struct { ModulePrivilege comm.IPrivilege // 月卡 ModuleSmithy comm.ISmithy // ModulePractice comm.IPractice //练功房 + ModuleTools comm.ITools //工具类 获取一些通用配置 } //重构模块配置对象 @@ -125,6 +126,10 @@ func (this *ModuleBase) Start() (err error) { return } this.ModulePractice = module.(comm.IPractice) + if module, err = this.service.GetModule(comm.ModuleTools); err != nil { + return + } + this.ModuleTools = module.(comm.ITools) return } diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index 89f00e630..a5acd22c2 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -84,10 +84,10 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle // cd = pb.ErrorCode_CacheReadError // } - // if umfantasy.Ticket < this.module.configure.GetGlobalConf().DreamlandCos { + // if umfantasy.Ticket < this.module.ModuleTools.GetGlobalConf().DreamlandCos { // cd = pb.ErrorCode_MoonfantasyNotEnoughbattles // } - // umfantasy.Ticket -= this.module.configure.GetGlobalConf().DreamlandCos + // umfantasy.Ticket -= this.module.ModuleTools.GetGlobalConf().DreamlandCos if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil { cd = pb.ErrorCode_ConfigNoFound return diff --git a/modules/moonfantasy/modelDream.go b/modules/moonfantasy/modelDream.go index 7938b0785..bfc3d3b6e 100644 --- a/modules/moonfantasy/modelDream.go +++ b/modules/moonfantasy/modelDream.go @@ -95,7 +95,7 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) { chat *pb.DBChat err error ) - globalconf = this.module.configure.GetGlobalConf() + globalconf = this.module.ModuleTools.GetGlobalConf() if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { return @@ -149,7 +149,7 @@ func (this *modelDreamComp) triggerbyid(session comm.IUserSession, boosid string mdata *pb.DBMoonFantasy chat *pb.DBChat ) - globalconf = this.module.configure.GetGlobalConf() + globalconf = this.module.ModuleTools.GetGlobalConf() if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { return diff --git a/modules/moonfantasy/modelUserMF.go b/modules/moonfantasy/modelUserMF.go index b7373f29c..4efe691e5 100644 --- a/modules/moonfantasy/modelUserMF.go +++ b/modules/moonfantasy/modelUserMF.go @@ -41,7 +41,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (info *pb.DBUserMFantasy, this.module.Errorf("err:%v", err) } if err == mgo.MongodbNil { - global := this.module.configure.GetGlobalConf() + global := this.module.ModuleTools.GetGlobalConf() info = &pb.DBUserMFantasy{ Id: primitive.NewObjectID().Hex(), Uid: uId, @@ -83,7 +83,7 @@ func (this *modelUserMF) recoverTicket(session comm.IUserSession, info *pb.DBUse info.BuyNum = 0 } // this.module.ModuleItems.RecoverTicket(session) - global := this.module.configure.GetGlobalConf() + global := this.module.ModuleTools.GetGlobalConf() ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.MoonFantasyTicket)) if ticket < global.DreamlandFightnum && info.Lastrtickettime > 0 { duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0)) diff --git a/modules/pagoda/api_challengeover.go b/modules/pagoda/api_challengeover.go index 4a7d1173e..08b65df54 100644 --- a/modules/pagoda/api_challengeover.go +++ b/modules/pagoda/api_challengeover.go @@ -107,14 +107,14 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal // 记录爬塔明细数据 if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { - sz := make([]*pb.LineUp, 5) - for i, v := range req.Report.Info.Redflist[0].Team { + szLine := make([]*pb.LineUp, 0) + for _, v := range req.Report.Info.Redflist[0].Team { if v != nil { - sz[i] = &pb.LineUp{ + szLine = append(szLine, &pb.LineUp{ Cid: v.HeroID, Star: v.Star, Lv: v.Lv, - } + }) } } // 数据直接插入跨服数据库中 @@ -126,9 +126,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal PagodaId: pagoda.PagodaId, Type: pagoda.Type, Nickname: userinfo.Name, - Icon: "", // icon 暂无 + Icon: "", Lv: userinfo.Lv, - CostTime: req.Report.Costtime, + Leadpos: 0, + Line: szLine, //[]*pb.LineUp{}, } costTime = newData.CostTime // 数据写到跨服中 diff --git a/modules/practice/api_gymrefresh.go b/modules/practice/api_gymrefresh.go index 53221c5e1..186dc1039 100644 --- a/modules/practice/api_gymrefresh.go +++ b/modules/practice/api_gymrefresh.go @@ -30,7 +30,7 @@ func (this *apiComp) GymRefresh(session comm.IUserSession, req *pb.PracticeGymRe code = pb.ErrorCode_DBError return } - refreshAtns = this.module.configure.GetGlobalConf().MrylFlushed + refreshAtns = this.module.ModuleTools.GetGlobalConf().MrylFlushed if len(refreshAtns) == 0 { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/practice/api_info.go b/modules/practice/api_info.go index d8b83b922..db173e497 100644 --- a/modules/practice/api_info.go +++ b/modules/practice/api_info.go @@ -45,7 +45,7 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.PracticeInfoReq) (c if room.Npcstate == 3 { //CD中 cd := int32(configure.Now().Sub(time.Unix(room.Refresh, 0)).Seconds()) - if cd >= this.module.configure.GetGlobalConf().PandamasChallengeCd { + if cd >= this.module.ModuleTools.GetGlobalConf().PandamasChallengeCd { if err = this.module.modelPandata.refreshnpc(room); err != nil { this.module.Errorln(err) code = pb.ErrorCode_DBError diff --git a/modules/practice/api_npcbattklefinish.go b/modules/practice/api_npcbattklefinish.go index 5e5686dc0..df7fe408e 100644 --- a/modules/practice/api_npcbattklefinish.go +++ b/modules/practice/api_npcbattklefinish.go @@ -51,7 +51,7 @@ func (this *apiComp) NPCBattkleFinish(session comm.IUserSession, req *pb.Practic room.Npcstate = 1 room.Battlenum++ - if room.Battlenum >= this.module.configure.GetGlobalConf().PandamasFightNum { + if room.Battlenum >= this.module.ModuleTools.GetGlobalConf().PandamasFightNum { room.Npcstate = 3 room.Refresh = configure.Now().Unix() this.module.modelPandata.Change(session.GetUserId(), map[string]interface{}{ diff --git a/modules/practice/module.go b/modules/practice/module.go index fb6d24153..70b8acb85 100644 --- a/modules/practice/module.go +++ b/modules/practice/module.go @@ -252,7 +252,7 @@ func (this *Practice) ChallengeResults(bid, red, bule string, winSide int32) { if v.Uid == red { v.Unionname = redsociaty v.Figure = reduser.Figure - v.End = configure.Now().Add(time.Minute * time.Duration(this.configure.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix() + v.End = configure.Now().Add(time.Minute * time.Duration(this.ModuleTools.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix() keep = true break } @@ -263,7 +263,7 @@ func (this *Practice) ChallengeResults(bid, red, bule string, winSide int32) { Name: reduser.Name, Unionname: redsociaty, Figure: reduser.Figure, - End: configure.Now().Add(time.Minute * time.Duration(this.configure.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix(), + End: configure.Now().Add(time.Minute * time.Duration(this.ModuleTools.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix(), }) } @@ -280,7 +280,7 @@ func (this *Practice) ChallengeResults(bid, red, bule string, winSide int32) { if v.Uid == bule { v.Unionname = bulesociaty v.Figure = buleuser.Figure - v.End = configure.Now().Add(time.Minute * time.Duration(this.configure.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix() + v.End = configure.Now().Add(time.Minute * time.Duration(this.ModuleTools.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix() keep = true break } @@ -291,7 +291,7 @@ func (this *Practice) ChallengeResults(bid, red, bule string, winSide int32) { Name: buleuser.Name, Unionname: bulesociaty, Figure: buleuser.Figure, - End: configure.Now().Add(time.Minute * time.Duration(this.configure.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix(), + End: configure.Now().Add(time.Minute * time.Duration(this.ModuleTools.GetGlobalConf().PandamasTiguandiaoxiangCd)).Unix(), }) } for i, v := range buleroom.Statuers { diff --git a/modules/smithy/api_forgeequip.go b/modules/smithy/api_forgeequip.go index f26306c76..378a51ae5 100644 --- a/modules/smithy/api_forgeequip.go +++ b/modules/smithy/api_forgeequip.go @@ -88,8 +88,8 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq needTemperatureCos = reelcfg.TemperatureCos * (1000 - t) / 1000 // 千分比 if req.Lava > 0 { // 熔岩打造 - exemption := this.module.configure.GetGlobalConf().ExemptionTemperatureCos // 预计消耗温度 - gloabNum := this.module.configure.GetGlobalConf().ExemptionTemperatureCosNum + exemption := this.module.ModuleTools.GetGlobalConf().ExemptionTemperatureCos // 预计消耗温度 + gloabNum := this.module.ModuleTools.GetGlobalConf().ExemptionTemperatureCosNum if needTemperatureCos > req.Lava*gloabNum { code = pb.ErrorCode_SmithyLackLava // 缺少熔岩 return @@ -155,7 +155,7 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq } // 总次数校验 - maxHitCount := this.module.configure.GetGlobalConf().GameMakeTunkNum + maxHitCount := this.module.ModuleTools.GetGlobalConf().GameMakeTunkNum if hitLen > maxHitCount { code = pb.ErrorCode_ReqParameterError this.module.Errorf("铁匠铺小游戏打造次数超过上限,当前打造次数:%d, 配置总次数:%d", hitLen, maxHitCount) diff --git a/modules/smithy/api_getCustomer.go b/modules/smithy/api_getCustomer.go index 69c844f4e..abb0838a4 100644 --- a/modules/smithy/api_getCustomer.go +++ b/modules/smithy/api_getCustomer.go @@ -14,7 +14,7 @@ func (this *apiComp) CustomerCheck(session comm.IUserSession, req *pb.SmithyCust } func (this *apiComp) Customer(session comm.IUserSession, req *pb.SmithyCustomerReq) (code pb.ErrorCode, data proto.Message) { - customerCount := this.module.configure.GetGlobalConf().SmithyMaxNpc + customerCount := this.module.ModuleTools.GetGlobalConf().SmithyMaxNpc if customerCount <= 0 { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/smithy/api_rise.go b/modules/smithy/api_rise.go index f80aaf14b..2a704ba84 100644 --- a/modules/smithy/api_rise.go +++ b/modules/smithy/api_rise.go @@ -36,8 +36,8 @@ func (this *apiComp) Rise(session comm.IUserSession, req *pb.SmithyRiseReq) (cod code = pb.ErrorCode_SmithyMaxTemperature return } - raise := this.module.configure.GetGlobalConf().RaiseTemperature - raise_temperatureNum := this.module.configure.GetGlobalConf().RaiseTemperatureNum + raise := this.module.ModuleTools.GetGlobalConf().RaiseTemperature + raise_temperatureNum := this.module.ModuleTools.GetGlobalConf().RaiseTemperatureNum cost = append(cost, &cfg.Gameatn{ A: raise.A, T: raise.T, diff --git a/modules/sociaty/api_cross_Formation.go b/modules/sociaty/api_cross_Formation.go index 100945174..c335c87e9 100644 --- a/modules/sociaty/api_cross_Formation.go +++ b/modules/sociaty/api_cross_Formation.go @@ -28,7 +28,7 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat return } - ggd := this.module.configure.GetGlobalConf() + ggd := this.module.ModuleTools.GetGlobalConf() if ggd == nil { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/sociaty/api_cross_bossmain.go b/modules/sociaty/api_cross_bossmain.go index f3c1905de..f7b2b847e 100644 --- a/modules/sociaty/api_cross_bossmain.go +++ b/modules/sociaty/api_cross_bossmain.go @@ -18,7 +18,7 @@ func (this *apiComp) BossmainCheck(session comm.IUserSession, req *pb.SociatyBMa func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() - ggd := this.module.configure.GetGlobalConf() + ggd := this.module.ModuleTools.GetGlobalConf() if ggd == nil { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/sociaty/api_cross_buy.go b/modules/sociaty/api_cross_buy.go index 2b0a22cca..e3a83f9af 100644 --- a/modules/sociaty/api_cross_buy.go +++ b/modules/sociaty/api_cross_buy.go @@ -21,7 +21,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (code return } - ggd := this.module.configure.GetGlobalConf() + ggd := this.module.ModuleTools.GetGlobalConf() if ggd == nil { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index 1edcf36d4..51d7f64fa 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -68,7 +68,7 @@ func (this *Sociaty) Start() (err error) { this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyUpdate), this.RpcUpdateSociaty) this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyTask), this.RpcUpdateUserTask) this.service.RegisterFunctionName(string(comm.Rpc_ModuleSociatyGetTask), this.RpcGetUserTask) - this.globalConf = this.configure.GetGlobalConf() + this.globalConf = this.ModuleTools.GetGlobalConf() if this.globalConf == nil { err = errors.New("global config not found") return diff --git a/modules/tools/comp_configure.go b/modules/tools/comp_configure.go new file mode 100644 index 000000000..b073fe192 --- /dev/null +++ b/modules/tools/comp_configure.go @@ -0,0 +1,589 @@ +package tools + +import ( + "fmt" + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" + "sync" +) + +const ( + game_global = "game_global.json" //全局配置表 + game_initial = "game_initial.json" //初始化表 + game_gamecolor = "game_gamecolor.json" //颜色表 + game_playerlv = "game_playerlv.json" //玩家等级 + game_facemod = "game_facemod.json" //形象配置表 + game_drop = "game_drop.json" //掉落 + new_hero = "game_hero.json" + // 签到 + game_signreset = "game_signreset.json" + game_sign = "game_sign.json" + + game_item = "game_item.json" + game_vip = "game_vip.json" + + game_equip = "game_equip.json" //装备信息表 + + game_lottery = "game_lottery.json" +) + +///配置管理基础组件 +type MCompConfigure struct { + cbase.ModuleCompBase + hlock sync.RWMutex + _dropMap map[int32][]*cfg.GameDropData // 掉落表 key 是DiropId + _sign map[int32]*cfg.GameSignData + + _group map[int64][]int32 // key 小组ID value cid + + // 类型为1 的数据 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组 + _lotteryType1 map[int32][]int32 // key 大组ID value cid + // 类型为2 的数据 有多个小组ID + _lotteryType2 map[int32][]int32 // key 大组ID value 小组ID + // 小组类型为1 + _groupType1 map[int64][]int32 //value cid + // 小组类型为2 + _groupType2 map[int64][]int32 //value cid + Btype map[int32]int32 + Stype map[int64]int32 // subtype + SNum map[int64]int32 // 小组产出数量 +} + +//组件初始化接口 +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.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_signreset, cfg.NewGameSignReset) + err = this.LoadConfigure(game_equip, cfg.NewGameEquip) + //err = this.LoadConfigure(game_sign, cfg.NewGameSign) + err = this.LoadConfigure(game_item, cfg.NewGameItem) + err = this.LoadConfigure(game_vip, cfg.NewGameVip) + err = this.LoadConfigure(game_lottery, cfg.NewGameLottery) + this._dropMap = make(map[int32][]*cfg.GameDropData, 0) + this._sign = make(map[int32]*cfg.GameSignData, 0) + configure.RegisterConfigure(game_drop, cfg.NewGameDrop, this.LoadDropData) + configure.RegisterConfigure(game_sign, cfg.NewGameSign, this.LoadSignData) + + this._group = make(map[int64][]int32, 0) + this._lotteryType1 = make(map[int32][]int32, 0) + this._lotteryType2 = make(map[int32][]int32, 0) + this._groupType1 = make(map[int64][]int32, 0) + this._groupType2 = make(map[int64][]int32, 0) + this.Btype = make(map[int32]int32, 0) + this.Stype = make(map[int64]int32, 0) + this.SNum = make(map[int64]int32, 0) + configure.RegisterConfigure(game_lottery, cfg.NewGameLottery, this.LoadGroupData) + + return +} + +func (this *MCompConfigure) LoadGroupData() { + if v, err := this.GetConfigure(game_lottery); err == nil { + if configure, ok := v.(*cfg.GameLottery); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + this._group = make(map[int64][]int32, 0) + this._lotteryType1 = make(map[int32][]int32, 0) + this._lotteryType2 = make(map[int32][]int32, 0) + this._groupType1 = make(map[int64][]int32, 0) + this._groupType2 = make(map[int64][]int32, 0) + this.Btype = make(map[int32]int32, 0) + this.Stype = make(map[int64]int32, 0) + this.SNum = make(map[int64]int32, 0) + for _, value := range configure.GetDataList() { + key := int64(value.Lotteryid)<<31 + int64(value.Groupid) + this._group[key] = append(this._group[key], value.Id) + + if _, ok := this.Btype[value.Lotteryid]; !ok { + this.Btype[value.Lotteryid] = value.Type + } + + if _, ok := this.Stype[key]; !ok { + this.Stype[key] = value.Subtype + } + if _, ok := this.SNum[key]; !ok { + this.SNum[key] = value.Groupnum + } + if this.Btype[value.Lotteryid] == 1 { + this._lotteryType1[value.Lotteryid] = append(this._lotteryType1[value.Lotteryid], value.Id) + } else if this.Btype[value.Lotteryid] == 2 { + this._lotteryType2[value.Lotteryid] = append(this._lotteryType2[value.Lotteryid], value.Id) + } + + if this.Stype[key] == 1 { // 小组ID为1 + this._groupType1[key] = append(this._groupType1[key], value.Id) + } else if this.Stype[key] == 2 { + this._groupType2[key] = append(this._groupType2[key], value.Id) + } + } + return + } + } else { + log.Errorf("get LoadGroupData conf err:%v", err) + } + return +} + +// 实际掉落逻辑 (传入 掉落组ID vip等级 玩家等级 返回获得的道具) +func (this *MCompConfigure) GetGroupDataByLottery(lotteryId int32, vipLv int32, lv int32) (items []*cfg.Gameatn) { + + if _, ok := this._lotteryType1[lotteryId]; !ok { + if _, ok := this._lotteryType2[lotteryId]; !ok { + fmt.Printf("not found config lotterId:%d", lotteryId) + return + } + } + // 优先校验大组ID 的类型 + if this.Btype[lotteryId] == 1 { // 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组 + var ( + szW []int32 // 权重数组 + szID []int32 // 小组ID 数组 + groupID int32 + gourp map[int32]int32 // key 小组ID value 权重 + ) + + gourp = make(map[int32]int32, 0) + // 随机小组id + for _, v := range this._lotteryType1[lotteryId] { + if _data := this.GetLotterConfById(v); _data != nil { + if (_data.Playerlvmax == 0 || _data.Playerlvmin <= lv && lv <= _data.Playerlvmax) && (_data.VIPmax == 0 || _data.VIPmin <= vipLv && vipLv <= _data.VIPmax) { // 过滤等级等条件 + if _, ok := gourp[_data.Groupid]; !ok { + gourp[_data.Groupid] = _data.Groupwt // 小组ID 权重赋值 + szW = append(szW, _data.Groupwt) + szID = append(szID, _data.Groupid) + } + } + } + } + + groupID = szID[comm.GetRandW(szW)] // 获得小组ID + fmt.Printf("大组类型为1的,获得小组ID :%d,dropID:%d", groupID, lotteryId) + key := int64(lotteryId)<<31 + int64(groupID) + // 小组ID 类型判断 + if this.Stype[key] == 1 { // 该小组的道具为权重掉落,必定从N个道具中随机出1个道具 + for i := 0; i < int(this.SNum[key]); i++ { + szW = make([]int32, 0) + szID = make([]int32, 0) + gourp = make(map[int32]int32, 0) + for _, v := range this._groupType1[key] { + if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值 + if _, ok := gourp[_data.Groupid]; !ok { + szW = append(szW, _data.Itemwt) + szID = append(szID, _data.Id) + } + } + } + index := comm.GetRandW(szW) + _data := this.GetLotterConfById(szID[index]) + fmt.Printf("获得最终的道具 :%d", _data.Id) + count := comm.GetRandNum(_data.Min, _data.Max) + // 随机获得的数量 + items = append(items, &cfg.Gameatn{ + A: _data.Itemid.A, + T: _data.Itemid.T, + N: _data.Itemid.N * count, + }) + } + return + } else if this.Stype[key] == 2 { // 该小组中的道具为概率掉落,每个道具都会随机一次是否会掉落(单位为千分比) + for _, v := range this._groupType2[key] { + if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值 + fmt.Printf("大组类型1小组类型2获得道具 :%v, 该道具Cid:%d", _data.Itemid, v) + if _data.Itemwt >= comm.GetRandNum(1, 1000) { // 命中 + count := comm.GetRandNum(_data.Min, _data.Max) + items = append(items, &cfg.Gameatn{ + A: _data.Itemid.A, + T: _data.Itemid.T, + N: _data.Itemid.N * count, // 小组产出数量 + }) + } + } + } + return + } + } else if this.Btype[lotteryId] == 2 { // 该大组中的小组为概率掉落,每个小组都会随机一次是否会掉落(单位为千分比) + // 每个小组id 都随机取一次 + var szGroupID []int32 // 获得的权重数组 + gourp := make(map[int32]*cfg.GameLotteryData, 0) // key 小组ID value 权重 + for _, v := range this._lotteryType2[lotteryId] { + if _data := this.GetLotterConfById(v); _data != nil { + if (_data.Playerlvmax == 0 || _data.Playerlvmin <= lv && lv <= _data.Playerlvmax) && (_data.VIPmax == 0 || _data.VIPmin <= vipLv && vipLv <= _data.VIPmax) { // 过滤等级等条件 + if _, ok := gourp[_data.Groupid]; !ok { + gourp[_data.Groupid] = _data // 小组ID 权重赋值 + } + } + } + } + + // 类型为2 可能会同时获得多个组id + for k, v := range gourp { + fmt.Printf("大组类型为2的,获得小组ID :%d,dropID:%d", k, v.Id) + if v.Itemwt >= comm.GetRandNum(0, 1000) { // 命中 + szGroupID = append(szGroupID, k) + key := int64(lotteryId)<<31 + int64(k) + if this.Stype[key] == 1 { // 随机一组数据 + for i := 0; i < int(this.SNum[key]); i++ { + szW := make([]int32, 0) + szID := make([]int32, 0) + gourp := make(map[int32]int32, 0) + for _, v := range this._groupType1[key] { + if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值 + if _, ok := gourp[_data.Groupid]; !ok { + szW = append(szW, _data.Itemwt) + szID = append(szID, _data.Id) + } + } + } + index := comm.GetRandW(szW) + _data := this.GetLotterConfById(szID[index]) + fmt.Printf("获得最终的道具 :%d", _data.Id) + count := comm.GetRandNum(_data.Min, _data.Max) + // 随机获得的数量 + items = append(items, &cfg.Gameatn{ + A: _data.Itemid.A, + T: _data.Itemid.T, + N: _data.Itemid.N * count, + }) + } + } else if this.Stype[key] == 2 { + for _, v := range this._groupType2[key] { + if _data := this.GetLotterConfById(v); _data != nil { // 权重赋值 + fmt.Printf("大组类型2小组类型2获得道具 :%v,该道具Cid:%d", _data.Itemid, v) + if _data.Itemwt >= comm.GetRandNum(1, 1000) { // 命中 + count := comm.GetRandNum(_data.Min, _data.Max) + items = append(items, &cfg.Gameatn{ + A: _data.Itemid.A, + T: _data.Itemid.T, + N: _data.Itemid.N * count, // 小组产出数量 + }) + } + } + } + } + } + } + } + return +} + +func (this *MCompConfigure) LoadConfigure(name string, fn interface{}) (err error) { + return configure.RegisterConfigure(name, fn, nil) +} + +//加载一个配置文件 +func (this *MCompConfigure) LoadDropData() { + if v, err := this.GetConfigure(game_drop); err == nil { + if configure, ok := v.(*cfg.GameDrop); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + for _, value := range configure.GetDataList() { + + if value.Condition == 0 { + this._dropMap[value.Dropid] = append(this._dropMap[value.Dropid], value) + } else { + key := value.Condition + key = value.Dropid*100 + key + this._dropMap[key] = append(this._dropMap[key], value) + for _, v1 := range this._dropMap[value.Dropid] { + this._dropMap[key] = append(this._dropMap[key], v1) + } + } + } + return + } + } else { + log.Errorf("get game_pagoda conf err:%v", err) + } + return +} + +//加载多个配置文件 +func (this *MCompConfigure) 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 *MCompConfigure) GetConfigure(name string) (v interface{}, err error) { + return configure.GetConfigure(name) +} + +//全局配置 +func (this *MCompConfigure) GetGlobalConf() *cfg.GameGlobalData { + var ( + configure *cfg.GameGlobal + ok bool + ) + if v, err := this.GetConfigure(game_global); err != nil { + log.Errorf("get global conf err:%v", err) + return nil + } else { + if configure, ok = v.(*cfg.GameGlobal); !ok { + log.Errorf("%T no is *cfg.Game_global", v) + return nil + } + } + return configure.GetDataList()[0] // 返回对象信息 +} + +func (this *MCompConfigure) GetGlobalInitConf() (configure *cfg.GameInitial, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_initial); err == nil { + if configure, ok = v.(*cfg.GameInitial); !ok { + err = fmt.Errorf("%T no is *cfg.Game_comInitial", v) + return + } + } + return +} + +// 主角等级经验配置列表 +func (this *MCompConfigure) GetPlayerlvConfList() (list []*cfg.GamePlayerlvData) { + if v, err := this.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 { + list = configure.GetDataList() + } + } + } + return +} + +// 玩家等级经验配置表 +func (this *MCompConfigure) GetPlayerlvConf(lv int32) (data *cfg.GamePlayerlvData) { + if v, err := this.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 +} + +// 玩家形象预设配置 +func (this *MCompConfigure) GetPlayerFigureConf() (list []*cfg.GameFacemodData) { + if v, err := this.GetConfigure(game_facemod); err != nil { + return + } else { + if configure, ok := v.(*cfg.GameFacemod); !ok { + err = fmt.Errorf("%T no is *cfg.Game_playerlv", v) + return + } else { + if configure != nil { + list = configure.GetDataList() + } + } + } + return +} + +func (this *MCompConfigure) GetDropData(dropId int32) (data []*cfg.GameDropData) { + data = this._dropMap[dropId] + return +} + +func (this *MCompConfigure) GetDropReward(dropId int32) (result []*cfg.Gameatn) { + result = make([]*cfg.Gameatn, 0) + + data := this.GetDropData(dropId) + if len(data) == 0 { + return + } + szW := make([]int32, 0) + for _, value := range data { + szW = append(szW, value.P) + } + index := comm.GetRandW(szW) + result = append(result, data[index].Prize...) + + return +} + +func (this *MCompConfigure) GetColor(id int32) (item *cfg.GameGameColorData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_gamecolor); err == nil { + return + } else { + if item, ok = v.(*cfg.GameGameColor).GetDataMap()[id]; !ok { + err = fmt.Errorf("on found color:%d", id) + } + } + return +} + +// 获取英雄原始星级 +func (this *MCompConfigure) 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 + } + } + } + return nil +} + +// 获取英雄原始星级 +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 +} + +// 获取签到信息 +func (this *MCompConfigure) GetSignConf(day, group int32) *cfg.GameSignData { + if v, ok := this._sign[day<<8+group]; ok { + return v + } + return nil +} + +// 获取组id +func (this *MCompConfigure) GetSignResetConf(id int32) int32 { + if v, err := this.GetConfigure(game_signreset); err == nil { + if configure, ok := v.(*cfg.GameSignReset); ok { + if configure != nil { + return configure.Get(id).Groups + } + } + } + return -1 +} +func (this *MCompConfigure) LoadSignData() { + if v, err := this.GetConfigure(game_sign); err == nil { + if configure, ok := v.(*cfg.GameSign); ok { + this.hlock.Lock() + defer this.hlock.Unlock() + for _, value := range configure.GetDataList() { + this._sign[value.Day<<8+value.Group] = value + } + return + } + } else { + log.Errorf("get game_sign conf err:%v", err) + } + return +} +func (this *MCompConfigure) GetHeroConfigData() (data []*cfg.GameHeroData) { + if v, err := this.GetConfigure(new_hero); err == nil { + if configure, ok := v.(*cfg.GameHero); ok { + return configure.GetDataList() + } + } + return nil +} + +//读取物品配置 +func (this *MCompConfigure) GetItemConfigureData(id string) (item *cfg.GameItemData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_item); err != nil { + log.Errorf("err:%v", err) + return + } else { + if item, ok = v.(*cfg.GameItem).GetDataMap()[id]; !ok { + err = fmt.Errorf("no found item:%s configure", id) + log.Errorf("err:%v", err) + return + } + } + return +} + +func (this *MCompConfigure) GetVipConfigureData(lv int32) (item *cfg.GameVipData) { + + if v, err := this.GetConfigure(game_vip); err == nil { + + if configure, ok := v.(*cfg.GameVip); ok { + item = configure.Get(lv) + } + } + + return +} + +func (this *MCompConfigure) GetItemConfigureByType(useType int32) (item []*cfg.GameItemData) { + if v, err := this.GetConfigure(game_item); err == nil { + for _, v1 := range v.(*cfg.GameItem).GetDataMap() { + if v1.Usetype == useType { + item = append(item, v1) + } + } + } + return +} +func (this *MCompConfigure) GetEquipmentConfigureById(equipmentId string) (configure *cfg.GameEquipData) { + + if v, err := this.GetConfigure(game_equip); err == nil { + configure = v.(*cfg.GameEquip).Get(equipmentId) + return + } + return +} +func (this *MCompConfigure) GetAllItemConfigure() (item []*cfg.GameItemData) { + if v, err := this.GetConfigure(game_item); err == nil { + for _, v1 := range v.(*cfg.GameItem).GetDataMap() { + item = append(item, v1) + } + } + return +} + +func (this *MCompConfigure) GetAllEquipmentConfigure() (configure []*cfg.GameEquipData) { + + if v, err := this.GetConfigure(game_equip); err == nil { + for _, v1 := range v.(*cfg.GameEquip).GetDataMap() { + configure = append(configure, v1) + } + return + } + return +} + +func (this *MCompConfigure) GetLotterConfById(id int32) (data *cfg.GameLotteryData) { + if v, err := this.GetConfigure(game_lottery); err == nil { + if configure, ok := v.(*cfg.GameLottery); ok { + return configure.Get(id) + } + } + return +} diff --git a/modules/tools/module.go b/modules/tools/module.go new file mode 100644 index 000000000..11d649801 --- /dev/null +++ b/modules/tools/module.go @@ -0,0 +1,50 @@ +package tools + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" + cfg "go_dreamfactory/sys/configure/structs" +) + +func NewModule() core.IModule { + m := new(Tools) + return m +} + +type Tools struct { + modules.ModuleBase + configure *MCompConfigure +} + +//模块名 +func (this *Tools) GetType() core.M_Modules { + return comm.ModuleTools +} + +//模块初始化接口 注册用户创建角色事件 +func (this *Tools) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + err = this.ModuleBase.Init(service, module, options) + return +} + +//模块初始化接口 注册用户创建角色事件 +func (this *Tools) Start() (err error) { + err = this.ModuleBase.Start() + return +} + +//装备组件 +func (this *Tools) OnInstallComp() { + this.ModuleBase.OnInstallComp() + this.configure = this.RegisterComp(new(MCompConfigure)).(*MCompConfigure) +} + +func (this *Tools) GetGroupDataByLottery(lotteryId int32, vipLv int32, lv int32) (items []*cfg.Gameatn) { + items = this.configure.GetGroupDataByLottery(lotteryId, vipLv, lv) + return +} + +func (this *Tools) GetGlobalConf() *cfg.GameGlobalData { + return this.configure.GetGlobalConf() +} diff --git a/modules/user/model_expand.go b/modules/user/model_expand.go index 4e156e495..e3c6af25c 100644 --- a/modules/user/model_expand.go +++ b/modules/user/model_expand.go @@ -44,7 +44,7 @@ func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err } } else { if err = this.Get(uid, result); err != nil && mongo.ErrNoDocuments == err { - globalConf := this.module.configure.GetGlobalConf() + globalConf := this.module.ModuleTools.GetGlobalConf() initUpdate := map[string]interface{}{ "uid": uid, "modifynameCount": 1, //修改名称1次 diff --git a/modules/user/module.go b/modules/user/module.go index 63afa0af7..c920bcac8 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -85,7 +85,7 @@ func (this *User) Start() (err error) { this.service.RegisterFunctionName(Rpc_QueryUser, this.RpcQueryUser) //date 3.10 this.service.RegisterFunctionName(Rpc_CreateSociaty, this.RpcCreateSociaty) - this.globalConf = this.configure.GetGlobalConf() + this.globalConf = this.ModuleTools.GetGlobalConf() if this.globalConf == nil { err = errors.New("global config not found") } @@ -479,7 +479,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha return } } - ggd := this.configure.GetGlobalConf() + ggd := this.ModuleTools.GetGlobalConf() if ggd == nil { return } @@ -808,7 +808,7 @@ func (this *User) recoverUserPs(uid string) { if u == nil { return } - ggd := this.configure.GetGlobalConf() + ggd := this.ModuleTools.GetGlobalConf() if ggd == nil { return } diff --git a/modules/viking/module.go b/modules/viking/module.go index 46974d199..0e6d5c56a 100644 --- a/modules/viking/module.go +++ b/modules/viking/module.go @@ -256,7 +256,7 @@ func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleR atno = make([]*pb.UserAtno, 0) conf := this.configure.GetVikingBossConfigData(bossId, difficulty) tasks := make([]*comm.TaskParam, 0) - // costRes := this.configure.GetGlobalConf().VikingExpeditionCos + // costRes := this.ModuleTools.GetGlobalConf().VikingExpeditionCos // if costRes == nil { // code = pb.ErrorCode_ConfigNoFound // return diff --git a/modules/worldtask/model_worldtask.go b/modules/worldtask/model_worldtask.go index 3a3041dfd..397da73c1 100644 --- a/modules/worldtask/model_worldtask.go +++ b/modules/worldtask/model_worldtask.go @@ -329,9 +329,9 @@ func (this *ModelWorldtask) filterTask(userLv, des int32, wt *pb.DBWorldtask) (t func (this *ModelWorldtask) randomTask(userLv, des int32, wt *pb.DBWorldtask) (taskIds []int32) { var num int32 if des == 1 { - num = this.moduleWorldtask.configure.GetGlobalConf().DailyNum + num = this.moduleWorldtask.ModuleTools.GetGlobalConf().DailyNum } else if des == 4 { - num = this.moduleWorldtask.configure.GetGlobalConf().WeekNum + num = this.moduleWorldtask.ModuleTools.GetGlobalConf().WeekNum } tIds := this.filterTask(userLv, des, wt) diff --git a/services/worker/main.go b/services/worker/main.go index 49a5ccb78..c976ff828 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -39,6 +39,7 @@ import ( "go_dreamfactory/modules/sociaty" "go_dreamfactory/modules/sys" "go_dreamfactory/modules/task" + "go_dreamfactory/modules/tools" "go_dreamfactory/modules/troll" "go_dreamfactory/modules/user" "go_dreamfactory/modules/viking" @@ -115,6 +116,7 @@ func main() { dispatch.NewModule(), atlas.NewModule(), practice.NewModule(), + tools.NewModule(), ) } From 5cac675495de327a6f747cb8fdd3988c82855e8d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 13 Apr 2023 18:41:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=98=9F=E9=95=BF=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_info.go | 3 ++- modules/pagoda/api_challengeover.go | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/hero/api_info.go b/modules/hero/api_info.go index 389298fc8..582d38da9 100644 --- a/modules/hero/api_info.go +++ b/modules/hero/api_info.go @@ -42,11 +42,12 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.HeroInfoReq) (code if err = dbModel.GetListObj(uid, v, hero); err == nil { rsp.Base = append(rsp.Base, hero) } else { - this.module.Errorf("err:%v", err) + this.module.Errorf("err:%v,heroid:%s,uid:%s", err, v, uid) } } } } + rsp.Uid = uid session.SendMsg(string(this.module.GetType()), HeroSubTypeInfo, rsp) return diff --git a/modules/pagoda/api_challengeover.go b/modules/pagoda/api_challengeover.go index 08b65df54..6bb44a27d 100644 --- a/modules/pagoda/api_challengeover.go +++ b/modules/pagoda/api_challengeover.go @@ -107,6 +107,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal // 记录爬塔明细数据 if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + leadpos := req.Report.Info.Redflist[0].Leadpos szLine := make([]*pb.LineUp, 0) for _, v := range req.Report.Info.Redflist[0].Team { if v != nil { @@ -128,8 +129,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PagodaChal Nickname: userinfo.Name, Icon: "", Lv: userinfo.Lv, - Leadpos: 0, - Line: szLine, //[]*pb.LineUp{}, + Leadpos: leadpos, + Line: szLine, } costTime = newData.CostTime // 数据写到跨服中 From 946c3dc2b20edc9de033dd3ad17dff4f739ab5f9 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 13 Apr 2023 18:41:34 +0800 Subject: [PATCH 3/3] update --- cmd/v2/ui/views/sociaty_mine.go | 103 +++++++++++++++++----------- modules/gateway/agent.go | 4 +- modules/sociaty/api_cross_sign.go | 2 +- modules/sociaty/model_sociaty.go | 2 +- modules/sociaty/model_sociatylog.go | 3 +- 5 files changed, 69 insertions(+), 45 deletions(-) diff --git a/cmd/v2/ui/views/sociaty_mine.go b/cmd/v2/ui/views/sociaty_mine.go index 074c1c80e..7a9174275 100644 --- a/cmd/v2/ui/views/sociaty_mine.go +++ b/cmd/v2/ui/views/sociaty_mine.go @@ -1,6 +1,7 @@ package formview import ( + "errors" "fmt" "go_dreamfactory/cmd/v2/lib/common" "go_dreamfactory/cmd/v2/model" @@ -288,48 +289,62 @@ func (this *SociatyMineView) dataListener(item *entryItem) { this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{ OnNotify: func(d interface{}, args ...interface{}) { data := d.(*pb.UserMessage) - if !(data.MainType == string(comm.ModuleSociaty) && - data.SubType == sociaty.SociatySubTypeMine) { - return - } - rsp := &pb.SociatyMineResp{} + if data.MainType == string(comm.ModuleSociaty) { + switch data.SubType { + case sociaty.SociatySubTypeMine: + rsp := &pb.SociatyMineResp{} - if !comm.ProtoUnmarshal(data, rsp) { - logrus.Error("unmarshal err") - return - } + if !comm.ProtoUnmarshal(data, rsp) { + logrus.Error("unmarshal err") + return + } - if rsp.Sociaty == nil { - logrus.Debug("公会信息 nil") - // item = &entryItem{} - dialog.ShowInformation("提示", "未加入公会", this.w) - return - } + if rsp.Sociaty == nil { + logrus.Debug("公会信息 nil") + // item = &entryItem{} + dialog.ShowInformation("提示", "未加入公会", this.w) + return + } - this.sociaty = rsp.Sociaty - this.master = rsp.Master - // this.ticket = rsp.Ticket + this.sociaty = rsp.Sociaty + this.master = rsp.Master + // this.ticket = rsp.Ticket - //设置成员职位 - for _, m := range rsp.Sociaty.Members { - if m.Uid == this.uid { - logrus.Debug(m.Uid) - this.job = m.Job - break + //设置成员职位 + for _, m := range rsp.Sociaty.Members { + if m.Uid == this.uid { + logrus.Debug(m.Uid) + this.job = m.Job + break + } + } + + logrus.Debugf("公会:%v", rsp.Sociaty) + + item.sociatyName.Text = rsp.Sociaty.Name + item.notice.Text = rsp.Sociaty.Notice + item.icon.Text = rsp.Sociaty.Icon + item.isApplyCheck.Checked = rsp.Sociaty.IsApplyCheck + item.applyLv.Text = cast.ToString(rsp.Sociaty.ApplyLv) + item.lv.Text = cast.ToString(rsp.Sociaty.Lv) + item.exp.Text = cast.ToString(rsp.Sociaty.Exp) + item.activity.Text = cast.ToString(rsp.Sociaty.Activity) + this.form.Refresh() + + //踢人 + case sociaty.SociatySubTypeDischarge: + rsp := &pb.SociatyDischargeResp{} + if !comm.ProtoUnmarshal(data, rsp) { + logrus.Error("unmarshal err") + return + } + if rsp.SociatyId == "" { + dialog.ShowError(errors.New("踢人失败"), this.w) + } else { + common.ShowTip("踢人成功") + } } } - - logrus.Debugf("公会:%v", rsp.Sociaty) - - item.sociatyName.Text = rsp.Sociaty.Name - item.notice.Text = rsp.Sociaty.Notice - item.icon.Text = rsp.Sociaty.Icon - item.isApplyCheck.Checked = rsp.Sociaty.IsApplyCheck - item.applyLv.Text = cast.ToString(rsp.Sociaty.ApplyLv) - item.lv.Text = cast.ToString(rsp.Sociaty.Lv) - item.exp.Text = cast.ToString(rsp.Sociaty.Exp) - item.activity.Text = cast.ToString(rsp.Sociaty.Activity) - this.form.Refresh() }, }) this.flag_mine = true @@ -628,15 +643,23 @@ func (this *SociatyMineView) memberListen() { // 签到 func (this *SociatyMineView) showSignWin() { + this.loadSociaty() var lastCount int32 if this.sociaty == nil { logrus.Error("公会 is nil") return } - lastCount = this.sociaty.LastSignCount - card := canvas.NewText(cast.ToString(lastCount), nil) - card.TextSize = 50 + // 昨日签到 + lastCount = this.sociaty.LastSignCount + lastSignCard := canvas.NewText(cast.ToString(lastCount), nil) + lastSignCard.TextSize = 50 + + // 已签到数 + todaySignCount := len(this.sociaty.SignIds) + signedCard := canvas.NewText(cast.ToString(todaySignCount), nil) + signedCard.TextSize = 50 + btn := widget.NewButton("签到", nil) btn.OnTapped = func() { defer btn.Disable() @@ -655,7 +678,7 @@ func (this *SociatyMineView) showSignWin() { btn.Disable() } - l := container.NewVBox(container.NewCenter(card), btn) + l := container.NewVBox(container.NewCenter(lastSignCard), btn, container.NewCenter(signedCard)) dconf := dialog.NewCustom("签到", "关闭", l, this.w) dconf.Resize(fyne.NewSize(400, 600)) dconf.Show() diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 7727988be..5b759c9ed 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -321,8 +321,8 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { } stime := time.Now() // this.gateway.Debugf("----------3 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) - // ctx, _ := context.WithTimeout(context.Background(), time.Second*5) - ctx := context.Background() + ctx, _ := context.WithTimeout(context.Background(), time.Second*5) + // ctx := context.Background() if len(serviceTag) == 0 { // this.gateway.Debugf("----------4 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) if err = this.gateway.Service().RpcCall(ctx, servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil { diff --git a/modules/sociaty/api_cross_sign.go b/modules/sociaty/api_cross_sign.go index 970f26666..fc75544cb 100644 --- a/modules/sociaty/api_cross_sign.go +++ b/modules/sociaty/api_cross_sign.go @@ -40,7 +40,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co // 签到 if err := this.module.modelSociaty.sign(uid, sociaty); err != nil { - code = pb.ErrorCode_SociatyAgree + code = pb.ErrorCode_SociatySign this.module.Error("签到失败", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociaty.Id}, log.Field{Key: "err", Value: err.Error()}) return } diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index c47212f3b..54976bc45 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -332,7 +332,7 @@ func (this *ModelSociaty) isRight(uid string, sociaty *pb.DBSociaty, jobs ...pb. return false } -// 更新公会经验 +// 更新公会 func (this *ModelSociaty) updateSociaty(sociatyId string, update map[string]interface{}) error { if this.module.IsCross() { return this.ChangeList(comm.RDS_EMPTY, sociatyId, update) diff --git a/modules/sociaty/model_sociatylog.go b/modules/sociaty/model_sociatylog.go index c16dfcae5..5b03ae8eb 100644 --- a/modules/sociaty/model_sociatylog.go +++ b/modules/sociaty/model_sociatylog.go @@ -162,7 +162,8 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string) func (this *ModelSociatyLog) logList(sociatyId string) (slist []*pb.SociatyLog) { sociatyLog := &pb.DBSociatyLog{} if err := this.Get(sociatyId, sociatyLog); err != nil { - log.Error("公会日志列表", log.Field{Key: "sociatyId", Value: sociatyId}) + log.Error("公会日志列表", log.Field{Key: "sociatyId", Value: sociatyId}, + log.Field{Key: "err", Value: err}) return nil }