From a8b90eecac57e072e78471e738bff1f5495dcb60 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Wed, 2 Aug 2023 18:45:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BA=A2=E7=82=B9=E9=9C=80?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 2 +- comm/imodule.go | 2 ++ modules/equipment/modelEquipment.go | 34 ++++++++++++++++++++--------- modules/reddot/api_getall.go | 30 ++++++++++++++++++++++--- modules/reddot/module.go | 7 ++++++ modules/user/module.go | 30 +++++++++++++++++++++++++ 6 files changed, 91 insertions(+), 14 deletions(-) diff --git a/comm/const.go b/comm/const.go index b441fff63..570e6ef02 100644 --- a/comm/const.go +++ b/comm/const.go @@ -581,7 +581,7 @@ const ( Reddot26201 ReddotType = 26201 // 今日剩余训练次数:x //云朵签到 Reddot27101 ReddotType = 27101 // 签到进度 - //巨怪商队跑商 + //巨怪商队跑商 前端处理 Reddot28101 ReddotType = 28101 // 剩余车票 //种族塔 Reddot29101 ReddotType = 29101 // 今日剩余可挑战关卡:x diff --git a/comm/imodule.go b/comm/imodule.go index f23646bbf..46be7f854 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -159,6 +159,7 @@ type ( //玩家 IUser interface { + IGetReddot //获取本服用户数据 GetUser(uid string) *pb.DBUser //获取用户回话 @@ -496,6 +497,7 @@ type ( } //练功房 IPractice interface { + IGetReddot ITaskComplete IOpenCmdNotice //添加武馆资源 diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index d9c56b952..dac6a384f 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -257,6 +257,7 @@ func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData sattr []*cfg.GameEquipAttrlibrarySData equipatt *cfg.GameEquipAttributeData weight []int32 + index int32 total int64 maxindex int satterNum int32 @@ -274,13 +275,19 @@ func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData this.module.Errorln(err) return } + + weight = make([]int32, len(mattr)) + for i, v := range mattr { + weight[i] = v.Probability + } + index = comm.GetRandW(weight) equipment.MainEntry = &pb.EquipmentAttributeEntry{ - Id: mattr[0].Key, - Libraryid: mattr[0].Libraryid, + Id: mattr[index].Key, + Libraryid: mattr[index].Libraryid, Lv: 1, - AttrName: mattr[0].Attrkey, - Value: mattr[0].Attrvar, - BaseValue: mattr[0].Attrvar, + AttrName: mattr[index].Attrkey, + Value: mattr[index].Attrvar, + BaseValue: mattr[index].Attrvar, } if sattr, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(conf.Addlibrary); err != nil || len(mattr) == 0 { return @@ -454,6 +461,8 @@ func (this *modelEquipmentComp) newMaxEquipment(uid string, conf *cfg.GameEquipD var ( mattr []*cfg.GameEquipAttrlibrarySData sattr []*cfg.GameEquipAttrlibrarySData + weight []int32 + index int32 equipatt *cfg.GameEquipAttributeData intensify *cfg.GameEquipIntensifyData satterNum int32 @@ -477,13 +486,18 @@ func (this *modelEquipmentComp) newMaxEquipment(uid string, conf *cfg.GameEquipD this.module.Errorln(err) return } + weight = make([]int32, len(mattr)) + for i, v := range mattr { + weight[i] = v.Probability + } + index = comm.GetRandW(weight) equipment.MainEntry = &pb.EquipmentAttributeEntry{ - Id: mattr[0].Key, - Libraryid: mattr[0].Libraryid, + Id: mattr[index].Key, + Libraryid: mattr[index].Libraryid, Lv: intensify.Level + 1, - AttrName: mattr[0].Attrkey, - Value: mattr[0].Attrvar, - BaseValue: mattr[0].Attrvar, + AttrName: mattr[index].Attrkey, + Value: mattr[index].Attrvar, + BaseValue: mattr[index].Attrvar, } equipment.MainEntry.Value = equipment.MainEntry.BaseValue + int32(math.Floor(float64(equipment.MainEntry.BaseValue*intensify.Bonus)/1000.0)) if sattr, err = this.module.configure.GetEquipmentAttrlibraryConfigureById(conf.Addlibrary); err != nil || len(mattr) == 0 { diff --git a/modules/reddot/api_getall.go b/modules/reddot/api_getall.go index 0786222e4..f72f5ce2f 100644 --- a/modules/reddot/api_getall.go +++ b/modules/reddot/api_getall.go @@ -5,13 +5,13 @@ import ( "go_dreamfactory/pb" ) -//参数校验 +// 参数校验 func (this *apiComp) GetAllCheck(session comm.IUserSession, req *pb.ReddotGetAllReq) (errdata *pb.ErrorData) { return } -///获取系统公告 +// /获取系统公告 func (this *apiComp) GetAll(session comm.IUserSession, req *pb.ReddotGetAllReq) (errdata *pb.ErrorData) { var ( reddot map[int32]*pb.ReddotItem = make(map[int32]*pb.ReddotItem) @@ -28,6 +28,13 @@ func (this *apiComp) GetAll(session comm.IUserSession, req *pb.ReddotGetAllReq) comm.Reddot10301) { reddot[int32(k)] = v } + + //每日任务 + for k, v := range this.module.dailytask.Reddot(session, + comm.Reddot25101) { + reddot[int32(k)] = v + } + //主线 for k, v := range this.module.mline.Reddot(session, comm.Reddot24101) { reddot[int32(k)] = v @@ -40,17 +47,34 @@ func (this *apiComp) GetAll(session comm.IUserSession, req *pb.ReddotGetAllReq) ) { reddot[int32(k)] = v } + + //武馆 + for k, v := range this.module.practice.Reddot(session, + comm.Reddot26101, + comm.Reddot26201, + ) { + reddot[int32(k)] = v + } + //竞技场 for k, v := range this.module.arena.Reddot(session, comm.Reddot22102) { reddot[int32(k)] = v } + //用户 + for k, v := range this.module.ModuleUser.Reddot(session, comm.Reddot27101) { + reddot[int32(k)] = v + } + for k, v := range this.module.friend.Reddot(session, comm.Reddot21101) { reddot[int32(k)] = v } for k, v := range this.module.gourmet.Reddot(session, comm.Reddot23101) { reddot[int32(k)] = v } - for k, v := range this.module.pagoda.Reddot(session, comm.Reddot6) { + for k, v := range this.module.pagoda.Reddot(session, + comm.Reddot6, + comm.Reddot29101, + ) { reddot[int32(k)] = v } for k, v := range this.module.horoscope.Reddot(session, comm.Reddot17) { diff --git a/modules/reddot/module.go b/modules/reddot/module.go index 5f8755f26..0d7392025 100644 --- a/modules/reddot/module.go +++ b/modules/reddot/module.go @@ -29,6 +29,7 @@ type Reddot struct { pagoda comm.IPagoda horoscope comm.IHoroscope arena comm.IArena //竞技场 + practice comm.IPractice //武馆 dailytask comm.IDailytask //每日任务 friend comm.IFriend gourmet comm.IGourmet @@ -79,6 +80,12 @@ func (this *Reddot) Start() (err error) { return } this.arena = module.(comm.IArena) + + if module, err = this.service.GetModule(comm.ModulePractice); err != nil { + return + } + this.practice = module.(comm.IPractice) + if module, err = this.service.GetModule(comm.ModuleGourmet); err != nil { return } diff --git a/modules/user/module.go b/modules/user/module.go index 171f4baae..55f5b9f53 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -1173,3 +1173,33 @@ func (this *User) RemainingPS(uid string) (ps int32) { func (this *User) AddUserProfit(uid string, score int64) error { return this.modelUser.AddUserProfit(uid, score) } + +// 查询每日红点信息 +func (this *User) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { + var ( + info *pb.DBSign + progress int32 + err error + ) + reddot = make(map[comm.ReddotType]*pb.ReddotItem) + if info, err = this.modelSign.GetUserSign(session.GetUserId()); err != nil { + this.Errorln(err) + return + } + for _, v := range rid { + switch v { + case comm.Reddot27101: + if info.Puzzle[info.Day] == 1 { + progress = 1 + } + reddot[comm.Reddot27101] = &pb.ReddotItem{ + Rid: int32(comm.Reddot27101), + Activated: true, + Progress: progress, + Total: 1, + } + break + } + } + return +}