From c8db8bbfe6bdc65f5d0aca01519d8150ac6cb9c1 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 14 Oct 2022 15:06:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/library/module.go | 52 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/modules/library/module.go b/modules/library/module.go index 4052f1631..0d61d6442 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -136,33 +136,35 @@ func (this *Library) QueryOneHeroFetter(uid string, cid string) *pb.DBHeroFetter // 创建一条羁绊信息 func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.ErrorCode) { - // 推送 + _conf := this.configure.GetLibraryHero(heroConfId) // 配置表中没有这个英雄数据 直接返回 + if _conf == nil { + return + } + var ( + objFetter *pb.DBHeroFetter // 详细羁绊信息数据 + ) rsp := &pb.LibraryChangePush{} _data := this.QueryOneHeroFetter(uid, heroConfId) - this.Debugf("%v", _data) if _data == nil { - objFetter, c := this.createHeroFetter(uid, heroConfId) - if c != pb.ErrorCode_Success { - code = c + objFetter, code = this.createHeroFetter(uid, heroConfId) + if code == pb.ErrorCode_Success { + rsp.Fetter = append(rsp.Fetter, objFetter) + } else { this.Errorf("createHeroFetter failed:%v,uid:%s,heroid:%s", code, uid, heroConfId) } - _conf := this.configure.GetLibraryHero(heroConfId) - if _conf != nil { - szFid := _conf.Fid - for _, fid := range szFid { - // 查询是否存在这个羁绊对象 - obj := this.GetLibraryListByFid(uid, fid) - if obj == nil { // 没有羁绊信息 - code, obj = this.CreateLibrary(uid, fid, heroConfId) - if code != pb.ErrorCode_Success { - this.Errorf("CreateLibrary failed: %v,uid:%s,fid:%d", code, uid, fid) - } - } else { // 羁绊信息中没有这个heroid 也需要加进来 - for k, v := range obj.Hero { - if v == 0 && k == heroConfId { - obj.Hero[k] = 1 - } - } + } + for _, fid := range _conf.Fid { + // 查询是否存在这个羁绊对象 + obj := this.GetLibraryListByFid(uid, fid) + if obj == nil { // 没有羁绊信息 + code, obj = this.CreateLibrary(uid, fid, heroConfId) + if code != pb.ErrorCode_Success { + this.Errorf("CreateLibrary failed: %v,uid:%s,fid:%d", code, uid, fid) + } + } else { // 羁绊信息中没有这个heroid 也需要加进来 + for k, v := range obj.Hero { + if v == 0 && k == heroConfId { + obj.Hero[k] = 1 // 重新计算最低等级 var minLv int32 for _, v := range obj.Hero { @@ -176,11 +178,13 @@ func (this *Library) AddHeroFetterData(uid string, heroConfId string) (code pb.E mapData["hero"] = obj.Hero mapData["fetterlv"] = obj.Fetterlv this.modelLibrary.modifyLibraryDataByObjId(uid, obj.Id, mapData) + rsp.Data = append(rsp.Data, obj) + break } - rsp.Data = append(rsp.Data, obj) } } - rsp.Fetter = append(rsp.Fetter, objFetter) + } + if len(rsp.Data) != 0 || len(rsp.Fetter) != 0 { this.SendMsgToUser(string(this.GetType()), LibraryChangePush, rsp, uid) } From f109832c7a4d59fd88a70bf8e5108e856fdd827b Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 14 Oct 2022 16:03:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/items/module.go | 4 +- modules/rtask/api_choose.go | 100 +------------------------------ modules/rtask/api_getrecord.go | 2 + modules/rtask/api_list.go | 7 ++- modules/rtask/api_reward.go | 6 +- modules/rtask/condiFindHandle.go | 1 - modules/rtask/model_record.go | 75 ++++++----------------- modules/rtask/module.go | 4 -- modules/user/api_create.go | 31 ++++------ modules/user/api_login.go | 1 + modules/user/api_modifyavatar.go | 1 + modules/user/api_modifybgp.go | 1 + modules/user/api_modifyfigure.go | 1 + modules/user/api_modifyname.go | 5 +- modules/user/api_modifysign.go | 5 +- pb/rtask_db.pb.go | 78 +++++++++++------------- 16 files changed, 87 insertions(+), 235 deletions(-) diff --git a/modules/items/module.go b/modules/items/module.go index b62df821c..3eef4551f 100644 --- a/modules/items/module.go +++ b/modules/items/module.go @@ -131,9 +131,9 @@ func (this *Items) AddItems(source *comm.ModuleCallSource, session comm.IUserSes change []*pb.DB_UserItemData ) - defer this.Debugf("给用户添加物品 uId:%s items:%d items:%v", session.GetUserId(), items, err == nil) + defer this.Debugf("给用户添加物品 uId:%s items:%v items:%v", session.GetUserId(), items, err == nil) if change, err = this.modelItems.AddItemsToUserPack(session.GetUserId(), items); err != nil { - this.Errorf("给用户添加物品 uId:%s items:%d err:%v", session.GetUserId(), items, err) + this.Errorf("给用户添加物品 uId:%s items:%v err:%v", session.GetUserId(), items, err) if err == ItemNotEnoughError { code = pb.ErrorCode_ItemsNoEnough } else if err == PackGridNumUpper { diff --git a/modules/rtask/api_choose.go b/modules/rtask/api_choose.go index 19c5dbfcf..1106752a4 100644 --- a/modules/rtask/api_choose.go +++ b/modules/rtask/api_choose.go @@ -14,110 +14,12 @@ func (this *apiComp) ChooseCheck(session comm.IUserSession, req *pb.RtaskChooseR return } +// Deprecated: Use func (this *apiComp) Choose(session comm.IUserSession, req *pb.RtaskChooseReq) (code pb.ErrorCode, data proto.Message) { if code = this.ChooseCheck(session, req); code != pb.ErrorCode_Success { return } - // 获取玩家的任务 - // rtask := &pb.DBRtask{} - // if err := this.moduleRtask.modelRtask.Get(session.GetUserId(), rtask); err != nil { - // return - // } - - // // 获取当前任务配置 - // conf := this.moduleRtask.configure.getRtaskById(req.RtaskId) - // if conf == nil { - // code = pb.ErrorCode_ConfigNoFound - // return - // } - - // // 获取支线任务配置 - // sideConf := this.moduleRtask.configure.getRtaskSidById(req.RtaskSubId) - // if sideConf == nil { - // code = pb.ErrorCode_ConfigNoFound - // return - // } - - // //获取选项配置 - // chooseCnf := this.moduleRtask.configure.getRtaskChooseCfg(req.ChooseId) - // if chooseCnf == nil { - // code = pb.ErrorCode_ConfigNoFound - // return - // } - - // // 校验限定条件 - // if chooseCnf.PreTid != 0 { - // if err, ok := this.moduleRtask.modelRtask.checkCondi(session.GetUserId(), chooseCnf.PreTid); !ok { - // this.moduleRtask.Errorf("no reach condi err: %v", err) - // code = pb.ErrorCode_RtaskCondiNoReach - // return - // } - // } - - // var ( - // frtaskArr *pb.FrtaskIds //完成的任务 - // ok bool - // ) - - // if frtaskArr, ok = rtask.FrtaskIds[conf.Group]; !ok { - // frtaskArr = &pb.FrtaskIds{} - // } - - // //验证该任务是否已完成 - // if _, ok := utils.Findx(frtaskArr.RtaskIds, req.RtaskId); ok { - // code = pb.ErrorCode_RtaskFinished - // return - // } - - // if chooseCnf.NextTid != 0 { - // // 校验完成条件 - // for _, v := range sideConf.EndTid { - // if v == -1 { - // continue - // } - // if err, ok := this.moduleRtask.modelRtask.checkCondi(session.GetUserId(), v); !ok { - // if err != nil { - // this.moduleRtask.Error(err.Error()) - // } - // code = pb.ErrorCode_RtaskCondiNoReach - // return - // } - // } - // // 更新完成的任务 - // frtaskArr.RtaskIds = append(frtaskArr.RtaskIds, req.RtaskId) - // if rtask.FrtaskIds == nil { - // rtask.FrtaskIds = make(map[int32]*pb.FrtaskIds) - // } - // rtask.FrtaskIds[conf.Group] = frtaskArr - // update := map[string]interface{}{ - // "frtaskIds": rtask.FrtaskIds, - // } - // if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil { - // code = pb.ErrorCode_SystemError - // return - // } - - // // userexpand update - // if err := this.moduleRtask.modelRtask.updateUserRtaskId(session.GetUserId(), req.RtaskId); err != nil { - // this.moduleRtask.Errorf("update user rtaskId err %v", err) - // } - - // // 发奖励 - // for _, v := range sideConf.Reward { - // if v.ChooseId == req.ChooseId { - // code = this.moduleRtask.DispenseRes(session, v.Reward, true) - // } - // } - - // rsp := &pb.RtaskFinishPush{ - // RtaskId: req.RtaskId, - // } - // if err := session.SendMsg(string(this.moduleRtask.GetType()), "finish", rsp); err != nil { - // code = pb.ErrorCode_SystemError - // } - // } - rsp := &pb.RtaskChooseResp{ RtaskId: req.RtaskId, ChooseId: req.ChooseId, diff --git a/modules/rtask/api_getrecord.go b/modules/rtask/api_getrecord.go index dbefc176a..7ca93abaa 100644 --- a/modules/rtask/api_getrecord.go +++ b/modules/rtask/api_getrecord.go @@ -11,6 +11,8 @@ func (this *apiComp) GetrecordCheck(session comm.IUserSession, req *pb.RtaskGetr return } +// 获取玩家任务条件记录 +// 客户端会在登录时拉取此数据 func (this *apiComp) Getrecord(session comm.IUserSession, req *pb.RtaskGetrecordReq) (code pb.ErrorCode, data proto.Message) { rsp := &pb.RtaskGetrecordResp{} record := this.moduleRtask.modelRtaskRecord.getRecord(session.GetUserId()) diff --git a/modules/rtask/api_list.go b/modules/rtask/api_list.go index 2059f4ea7..883e77bb6 100644 --- a/modules/rtask/api_list.go +++ b/modules/rtask/api_list.go @@ -12,8 +12,7 @@ func (this *apiComp) ListCheck(session comm.IUserSession, req *pb.RtasklistReq) } func (this *apiComp) List(session comm.IUserSession, req *pb.RtasklistReq) (code pb.ErrorCode, data proto.Message) { - - // 获取当前玩家 + // 获取当前玩家随机任务 rtask := this.moduleRtask.modelRtask.GetRtask(session.GetUserId()) if rtask == nil { code = pb.ErrorCode_RtaskNoRtask @@ -22,6 +21,7 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.RtasklistReq) (code ids := make([]int32, 0) + // 查询分组ID对应的任务 if v, ok := rtask.FrtaskIds[req.GroupId]; ok { ids = v.RtaskIds } @@ -30,9 +30,10 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.RtasklistReq) (code RtaskIds: ids, GroupId: req.GroupId, } + if err := session.SendMsg(string(this.moduleRtask.GetType()), RtaskSubTypeList, rsp); err != nil { code = pb.ErrorCode_SystemError - return } + return } diff --git a/modules/rtask/api_reward.go b/modules/rtask/api_reward.go index e88a3ee11..85845e30c 100644 --- a/modules/rtask/api_reward.go +++ b/modules/rtask/api_reward.go @@ -2,7 +2,6 @@ package rtask import ( "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -24,7 +23,7 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.RtaskGetReward sideConf := this.moduleRtask.configure.getRtaskSidById(req.RtaskSubId) if sideConf == nil { code = pb.ErrorCode_ConfigNoFound - log.Errorf("rdtask_side %v no found", req.RtaskSubId) + this.moduleRtask.Errorf("uid:%v rdtask_side:%v config no found", session.GetUserId(), req.RtaskSubId) return } @@ -50,13 +49,16 @@ func (this *apiComp) GetReward(session comm.IUserSession, req *pb.RtaskGetReward //发奖励 for _, v := range sideConf.Reward { code = this.moduleRtask.DispenseRes(session, v.Reward, true) + this.moduleRtask.Infof("uid:%v 发奖励:%v code:%v", session.GetUserId(), v.Reward, code) } + // 更新奖励领取状态 update := map[string]interface{}{ "isReward": true, } if err := this.moduleRtask.modelRtask.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_SystemError + return } rsp := &pb.RtaskGetRewardResp{ diff --git a/modules/rtask/condiFindHandle.go b/modules/rtask/condiFindHandle.go index 5316592e9..5c52fb04e 100644 --- a/modules/rtask/condiFindHandle.go +++ b/modules/rtask/condiFindHandle.go @@ -1,4 +1,3 @@ -// 匹配类型和参数,返回任务条件ID package rtask import ( diff --git a/modules/rtask/model_record.go b/modules/rtask/model_record.go index c8db2859b..eb2891c23 100644 --- a/modules/rtask/model_record.go +++ b/modules/rtask/model_record.go @@ -10,6 +10,7 @@ import ( "github.com/pkg/errors" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" ) type ModelRtaskRecord struct { @@ -36,34 +37,37 @@ func (this *ModelRtaskRecord) GetVerifyData(uid string, condiId int32) (*pb.Rtas return record.Vals[condiId], nil } -// 获取玩家随机任务记录 +// 获取玩家任务条件记录 +// 配置表: rdtask_condi func (this *ModelRtaskRecord) getRecord(uid string) *pb.DBRtaskRecord { record := &pb.DBRtaskRecord{} if err := this.Get(uid, record); err != nil { - log.Warnf("get rtask record err:%v", err) + if err != mongo.ErrNoDocuments { + log.Warnf("获取玩家任务条件 err:%v", err) + } } return record } // 初始化任务条件数据 +// 玩家登录时调用 func (this *ModelRtaskRecord) initCondiData(uid string) error { - // t := time.Now() - // defer func() { - // log.Debugf("初始化条件耗时:%v", time.Since(t)) - // }() dr := this.getRecord(uid) + // 获取rdtask_condi配置表数据 grc, err := this.moduleRtask.configure.getRtaskCondiCfg() if err != nil { return err } if grc == nil { - return errors.New("getRtaskCondiCfg err") + return errors.New("配置空[rdtaskcondi] err") } - if dr != nil && dr.Vals == nil { + // 判断是否有记录 + if dr.Vals == nil || len(dr.Vals) == 0 { record := &pb.DBRtaskRecord{Uid: uid} record.Id = primitive.NewObjectID().Hex() record.Vals = make(map[int32]*pb.RtaskData) + //遍历所有配置数据 for _, v := range grc.GetDataList() { // 不符合参数配置长度则不初始化 if len(v.Inited) != 5 { @@ -71,12 +75,13 @@ func (this *ModelRtaskRecord) initCondiData(uid string) error { } vals := []int32{} + // 遍历初始化参数字段 for _, p := range v.Inited { - if p == 1 { + if p == 1 { // 1表示需要初始0 vals = append(vals, 0) - } else if p == 0 { - vals = append(vals) - } else if p == -1 { + } else if p == 0 { // 0表示需要初始实际值 + vals = append(vals, p) + } else if p == -1 { //-1 表示不初始任何值 break } } @@ -91,52 +96,6 @@ func (this *ModelRtaskRecord) initCondiData(uid string) error { if err := this.Add(uid, record); err != nil { return err } - } - // else { - // //遍历所有配置 - // for _, v := range grc.GetDataList() { - // if len(v.Inited) != 5 { - // continue - // } - // if _, ok := dr.Vals[v.Id]; ok { - // continue - // } - // vals := []int32{} - // // 遍历需要初始化的配置 - // for i, p := range v.Inited { - // if p == 1 { - // vals = append(vals, 0) - // } else if p == 0 { - // sv := int32(0) - // switch i { - // case 0: - // sv = v.Data1 - // case 1: - // sv = v.Data2 - // case 2: - // sv = v.Data3 - // case 3: - // sv = v.Data4 - // case 4: - // sv = v.Data5 - // } - // vals = append(vals, sv) - // } else if p == -1 { - // break - // } - // } - // dr.Vals[v.Id] = &pb.RtaskData{ - // Data: toMap(vals...), - // Rtype: v.Type, - // Timestamp: time.Now().Unix(), - // } - - // } - // update := map[string]interface{}{ - // "vals": dr.Vals, - // } - // err = this.Change(uid, update) - // } return nil } diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 9948448e1..7dbee44b8 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -199,10 +199,6 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { } func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) { - // t := time.Now() - // defer func() { - // log.Debugf("任务发送耗时:%v", time.Since(t)) - // }() this.Debug("任务事件触发", log.Field{"uid", session.GetUserId()}, log.Field{"taskType", rtaskType}, log.Field{"params", params}) var ( err error diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 4e65b9f93..e4d664c41 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -4,12 +4,14 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" + "strings" "google.golang.org/protobuf/proto" ) func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateReq) (code pb.ErrorCode) { - if req.NickName == "" { + name := strings.TrimSpace(req.NickName) + if name == "" || len(name) > 30 { code = pb.ErrorCode_UserNickNameEmpty } @@ -22,13 +24,6 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c return } - defer func() { - err := session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{IsSucc: true}) - if err != nil { - code = pb.ErrorCode_SystemError - } - }() - //获取用户 self := this.module.modelUser.GetUser(session.GetUserId()) if self == nil { @@ -55,6 +50,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_DBError + this.module.Errorf("创角失败 uid:%v name:%v err:%v", session.GetUserId(), req.NickName, err) return } @@ -64,31 +60,26 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c } if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), initUpdate); err != nil { code = pb.ErrorCode_DBError + this.module.Errorf("更新修改名称次数失败 uid:%v err:%v", session.GetUserId(), err) return } var ( res []*cfg.Gameatn ) + //初始化英雄卡 if val, err := this.module.configure.GetGlobalInitConf(); err == nil { for _, v := range val.GetDataList() { res = append(res, v.Var...) - } - code = this.module.DispenseRes(session, res, true) - if code != pb.ErrorCode_Success { - this.module.Errorf("资源发放失败,%v", code) - } - //defaultHero := utils.TrInt32(val) - // err = this.hero.CreateHeroes(session.GetUserId(), defaultHero...) - // if err != nil { - // code = pb.ErrorCode_HeroInitCreat - // return - // } + _ = this.module.DispenseRes(session, res, true) } + //初始化用户设置 this.module.modelSetting.InitSetting(session.GetUserId()) - + if err := session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{IsSucc: true}); err != nil { + code = pb.ErrorCode_SystemError + } return } diff --git a/modules/user/api_login.go b/modules/user/api_login.go index a75409f83..a603bb1a0 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -143,6 +143,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod } // 初始化随机任务数据 + // TODO: 判断次功能开启时再初始化 go this.module.ModuleRtask.InitCondiData(user.Uid) // 日常登录任务 diff --git a/modules/user/api_modifyavatar.go b/modules/user/api_modifyavatar.go index 270cadceb..62aa2aea3 100644 --- a/modules/user/api_modifyavatar.go +++ b/modules/user/api_modifyavatar.go @@ -34,6 +34,7 @@ func (this *apiComp) Modifyavatar(session comm.IUserSession, req *pb.UserModifya if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_DBError + this.module.Errorf("更新头像失败 uid:%v avatarId:%v err:%v", session.GetUserId(), req.AvatarId, err) return } diff --git a/modules/user/api_modifybgp.go b/modules/user/api_modifybgp.go index dd6ca3101..609c41334 100644 --- a/modules/user/api_modifybgp.go +++ b/modules/user/api_modifybgp.go @@ -32,6 +32,7 @@ func (this *apiComp) Modifybgp(session comm.IUserSession, req *pb.UserModifybgpR if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_DBError + this.module.Errorf("更新背景失败 uid:%v bgpId:%v err:%v", session.GetUserId(), req.BgpId, err) return } diff --git a/modules/user/api_modifyfigure.go b/modules/user/api_modifyfigure.go index 13f7b8ec8..5b146201e 100644 --- a/modules/user/api_modifyfigure.go +++ b/modules/user/api_modifyfigure.go @@ -32,6 +32,7 @@ func (this *apiComp) Modifyfigure(session comm.IUserSession, req *pb.UserModifyf if err := this.module.modelUser.Change(session.GetUserId(), update); err != nil { code = pb.ErrorCode_DBError + this.module.Errorf("更新形象失败 uid:%v figureId:%v err:%v", session.GetUserId(), req.FigureId, err) return } diff --git a/modules/user/api_modifyname.go b/modules/user/api_modifyname.go index 41e3cb44d..4906b769a 100644 --- a/modules/user/api_modifyname.go +++ b/modules/user/api_modifyname.go @@ -41,9 +41,11 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam //校验名称修改次数 if expand.ModifynameCount <= 0 { - if code = this.module.ConsumeRes(session, globalCnf.Var, true); code != pb.ErrorCode_Success { + code = this.module.ConsumeRes(session, globalCnf.Var, true) + if code != pb.ErrorCode_Success { return } + this.module.Infof("修改昵称 uid:%v 消耗:%v code:%v", session.GetUserId(), globalCnf.Var, code) } //修改名称次数 @@ -56,6 +58,7 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam } if err := this.module.modelExpand.ChangeUserExpand(session.GetUserId(), mc); err != nil { code = pb.ErrorCode_DBError + this.module.Errorf("更新昵称失败 uid:%v name:%v err:%v", session.GetUserId(), req.Name, err) return } diff --git a/modules/user/api_modifysign.go b/modules/user/api_modifysign.go index a1df5434f..17637cc9d 100644 --- a/modules/user/api_modifysign.go +++ b/modules/user/api_modifysign.go @@ -31,7 +31,10 @@ func (this *apiComp) Modifysign(session comm.IUserSession, req *pb.UserModifysig update := map[string]interface{}{ "sign": req.Sign, } - this.module.ChangeUserExpand(session.GetUserId(), update) + if err := this.module.ChangeUserExpand(session.GetUserId(), update); err != nil { + code = pb.ErrorCode_DBError + this.module.Errorf("更新签名失败 uid:%v sign:%v err:%v", session.GetUserId(), req.Sign, err) + } } if err = session.SendMsg(string(this.module.GetType()), UserSubTypeModifySign, &pb.UserModifysignResp{ diff --git a/pb/rtask_db.pb.go b/pb/rtask_db.pb.go index d729e69d4..9fa2be7d3 100644 --- a/pb/rtask_db.pb.go +++ b/pb/rtask_db.pb.go @@ -73,11 +73,10 @@ type DBRtask struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID - FrtaskIds map[int32]*FrtaskIds `protobuf:"bytes,3,rep,name=frtaskIds,proto3" json:"frtaskIds" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bson:"frtaskIds"` //已完成的任务Id - NextRtaskId int32 `protobuf:"varint,4,opt,name=nextRtaskId,proto3" json:"nextRtaskId" bson:"nextRtaskId"` //下个任务Id - IsReward bool `protobuf:"varint,5,opt,name=isReward,proto3" json:"isReward" bson:"isReward"` //接收奖励 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + FrtaskIds map[int32]*FrtaskIds `protobuf:"bytes,3,rep,name=frtaskIds,proto3" json:"frtaskIds" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bson:"frtaskIds"` //已完成的任务Id + IsReward bool `protobuf:"varint,5,opt,name=isReward,proto3" json:"isReward" bson:"isReward"` //接收奖励 } func (x *DBRtask) Reset() { @@ -133,13 +132,6 @@ func (x *DBRtask) GetFrtaskIds() map[int32]*FrtaskIds { return nil } -func (x *DBRtask) GetNextRtaskId() int32 { - if x != nil { - return x.NextRtaskId - } - return 0 -} - func (x *DBRtask) GetIsReward() bool { if x != nil { return x.IsReward @@ -281,43 +273,41 @@ var file_rtask_rtask_db_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x27, 0x0a, 0x09, 0x66, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x08, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x22, - 0xea, 0x01, 0x0a, 0x07, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0xc8, 0x01, 0x0a, 0x07, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x35, 0x0a, 0x09, 0x66, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x46, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x66, 0x72, 0x74, 0x61, 0x73, - 0x6b, 0x49, 0x64, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x52, 0x74, 0x61, 0x73, - 0x6b, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x52, - 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x52, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x52, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x1a, 0x48, 0x0a, 0x0e, 0x46, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x66, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, - 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa2, 0x01, 0x0a, - 0x09, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x74, 0x61, 0x73, 0x6b, - 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0xa4, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x2e, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x76, - 0x61, 0x6c, 0x73, 0x1a, 0x43, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6b, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, + 0x1a, 0x48, 0x0a, 0x0e, 0x46, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x66, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x73, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa2, 0x01, 0x0a, 0x09, 0x72, + 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, + 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x72, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x37, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0xa4, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x04, 0x76, 0x61, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42, 0x52, 0x74, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x2e, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x76, 0x61, 0x6c, + 0x73, 0x1a, 0x43, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, + 0x12, 0x20, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0a, 0x2e, 0x72, 0x74, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( From 43b5f9c798ed7ac28c9e6e97f93b7e60a6b7762e Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Fri, 14 Oct 2022 18:30:33 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=83=8C=E6=99=AFID?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/user/api_modifybgp.go | 2 +- pb/user_msg.pb.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/user/api_modifybgp.go b/modules/user/api_modifybgp.go index 609c41334..b63570df9 100644 --- a/modules/user/api_modifybgp.go +++ b/modules/user/api_modifybgp.go @@ -8,7 +8,7 @@ import ( ) func (this *apiComp) ModifybgpCheck(session comm.IUserSession, req *pb.UserModifybgpReq) (code pb.ErrorCode) { - if req.BgpId == 0 { + if req.BgpId == "" { code = pb.ErrorCode_ReqParameterError } return diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index 556830ecb..1bda7c1be 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -1217,7 +1217,7 @@ type UserModifybgpReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - BgpId int32 `protobuf:"varint,1,opt,name=bgpId,proto3" json:"bgpId"` //背景图片ID + BgpId string `protobuf:"bytes,1,opt,name=bgpId,proto3" json:"bgpId"` //背景图片ID } func (x *UserModifybgpReq) Reset() { @@ -1252,11 +1252,11 @@ func (*UserModifybgpReq) Descriptor() ([]byte, []int) { return file_user_user_msg_proto_rawDescGZIP(), []int{24} } -func (x *UserModifybgpReq) GetBgpId() int32 { +func (x *UserModifybgpReq) GetBgpId() string { if x != nil { return x.BgpId } - return 0 + return "" } type UserModifybgpResp struct { @@ -1265,7 +1265,7 @@ type UserModifybgpResp struct { unknownFields protoimpl.UnknownFields Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` - BgpId int32 `protobuf:"varint,2,opt,name=bgpId,proto3" json:"bgpId"` //背景图片ID + BgpId string `protobuf:"bytes,2,opt,name=bgpId,proto3" json:"bgpId"` //背景图片ID } func (x *UserModifybgpResp) Reset() { @@ -1307,11 +1307,11 @@ func (x *UserModifybgpResp) GetUid() string { return "" } -func (x *UserModifybgpResp) GetBgpId() int32 { +func (x *UserModifybgpResp) GetBgpId() string { if x != nil { return x.BgpId } - return 0 + return "" } // 修改形象 @@ -2045,11 +2045,11 @@ var file_user_user_msg_proto_rawDesc = []byte{ 0x76, 0x61, 0x74, 0x61, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x49, 0x64, 0x22, 0x28, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x62, 0x67, 0x70, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x62, - 0x67, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x67, 0x70, 0x49, + 0x67, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x67, 0x70, 0x49, 0x64, 0x22, 0x3b, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x62, 0x67, 0x70, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x67, 0x70, 0x49, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x67, 0x70, 0x49, 0x64, 0x22, 0x31, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x62, 0x67, 0x70, 0x49, 0x64, 0x22, 0x31, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x49, From 6e65b33560d63461930a43170619401f7535f0e2 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 14 Oct 2022 18:32:47 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=A3=85=E5=A4=87?= =?UTF-8?q?=E5=87=BA=E5=94=AE=E7=AE=97=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_dreamlandboos.json | 26 +++++- bin/json/game_msgdistrib.json | 2 +- modules/equipment/api_sellI.go | 25 ++++-- modules/equipment/modelEquipment.go | 4 +- modules/moonfantasy/api_ask.go | 75 +++++++--------- modules/moonfantasy/api_battle.go | 7 +- modules/moonfantasy/api_getlist.go | 29 +++++-- modules/moonfantasy/api_receive.go | 4 +- modules/moonfantasy/api_trigger.go | 87 ------------------- modules/moonfantasy/modelDream.go | 36 ++++++-- modules/moonfantasy/modelUserMF.go | 2 +- pb/moonfantasy_db.pb.go | 74 ++++++++-------- .../structs/Game.DreamlandBoosData.go | 36 +++++++- sys/db/dbconn.go | 24 ++++- 14 files changed, 222 insertions(+), 209 deletions(-) delete mode 100644 modules/moonfantasy/api_trigger.go diff --git a/bin/json/game_dreamlandboos.json b/bin/json/game_dreamlandboos.json index a499e4a52..9d660002e 100644 --- a/bin/json/game_dreamlandboos.json +++ b/bin/json/game_dreamlandboos.json @@ -4,15 +4,33 @@ "pro": 30, "fightnum": 5, "challengenum": 40, - "prize": 1001, - "monsterformatid": 201011 + "prize": [ + { + "a": "item", + "t": "30001", + "n": 1 + } + ], + "monsterformatid": [ + 201011 + ], + "dreamland_limit": 3600 }, { "bossid": "35001", "pro": 30, "fightnum": 5, "challengenum": 30, - "prize": 1002, - "monsterformatid": 201012 + "prize": [ + { + "a": "item", + "t": "30001", + "n": 1 + } + ], + "monsterformatid": [ + 201012 + ], + "dreamland_limit": 3600 } ] \ No newline at end of file diff --git a/bin/json/game_msgdistrib.json b/bin/json/game_msgdistrib.json index 31eea6ba7..5341d1d15 100644 --- a/bin/json/game_msgdistrib.json +++ b/bin/json/game_msgdistrib.json @@ -37,7 +37,7 @@ }, { "msgid": "moonfantasy", - "open": true, + "open": false, "routrules": "~/worker", "describe": "月之秘境" } diff --git a/modules/equipment/api_sellI.go b/modules/equipment/api_sellI.go index 2594b571c..593259191 100644 --- a/modules/equipment/api_sellI.go +++ b/modules/equipment/api_sellI.go @@ -4,6 +4,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" + "math" "google.golang.org/protobuf/proto" ) @@ -22,7 +23,7 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( err error equipments []*pb.DB_Equipment confs []*cfg.GameEquipData - sale []*cfg.Gameatn + sale [][]*cfg.Gameatn ) if code = this.SellCheck(session, req); code != pb.ErrorCode_Success { return @@ -32,6 +33,7 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( return } confs = make([]*cfg.GameEquipData, len(equipments)) + sale = make([][]*cfg.Gameatn, len(equipments)) for i, v := range equipments { if v.HeroId != "" || v.Islock { code = pb.ErrorCode_EquipmentNoCanSell @@ -47,15 +49,22 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.EquipmentSellReq) ( code = pb.ErrorCode_EquipmentNoCanSell return } - } - - sale = make([]*cfg.Gameatn, 0) - for _, v := range confs { - for _, s := range v.Sale { - sale = append(sale, s) + sale[i] = make([]*cfg.Gameatn, len(confs[i].Sale)) + for n, s := range confs[i].Sale { + _s := &cfg.Gameatn{ + A: s.A, + T: s.T, + N: s.N + int32(math.Floor(float64(s.N*(v.Lv-1))*float64(confs[i].Salecoef))), + } + sale[i][n] = _s } } - if code = this.module.DispenseRes(session, sale, true); code != pb.ErrorCode_Success { + + sales := make([]*cfg.Gameatn, 0) + for _, v := range sale { + sales = append(sales, v...) + } + if code = this.module.DispenseRes(session, sales, true); code != pb.ErrorCode_Success { return } if code = this.module.DelEquipments(session, req.EquipIds, true); code != pb.ErrorCode_Success { diff --git a/modules/equipment/modelEquipment.go b/modules/equipment/modelEquipment.go index 62aac4bc2..9be4367a5 100644 --- a/modules/equipment/modelEquipment.go +++ b/modules/equipment/modelEquipment.go @@ -43,7 +43,9 @@ func (this *modelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipme //查询用户装备数据 func (this *modelEquipmentComp) QueryUserEquipmentsByIds(uId string, ids []string) (equipments []*pb.DB_Equipment, err error) { equipments = []*pb.DB_Equipment{} - err = this.GetListObjs(uId, ids, &equipments) + if err = this.GetListObjs(uId, ids, &equipments); err != nil { + this.module.Errorf("err:%v", err) + } return } diff --git a/modules/moonfantasy/api_ask.go b/modules/moonfantasy/api_ask.go index cfae50ff6..1ce2fa592 100644 --- a/modules/moonfantasy/api_ask.go +++ b/modules/moonfantasy/api_ask.go @@ -4,8 +4,6 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/redis" "go_dreamfactory/pb" - cfg "go_dreamfactory/sys/configure/structs" - "time" "google.golang.org/protobuf/proto" ) @@ -18,13 +16,13 @@ func (this *apiComp) AskCheck(session comm.IUserSession, req *pb.MoonfantasyAskR ///询问怪物是否可以挑战 func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (code pb.ErrorCode, data proto.Message) { var ( - globalconf *cfg.GameGlobalData - mdata *pb.DBMoonFantasy - lock *redis.RedisMutex - umfantasy *pb.DBUserMFantasy - user *pb.DBUser - cd pb.ErrorCode - err error + mdata *pb.DBMoonFantasy + lock *redis.RedisMutex + // umfantasy *pb.DBUserMFantasy + user *pb.DBUser + cd pb.ErrorCode + isjson bool + err error ) defer func() { session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd, Info: mdata}) @@ -51,46 +49,39 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) ( cd = pb.ErrorCode_MoonfantasyHasExpired return } - if len(mdata.Join) >= int(mdata.Numup) { - cd = pb.ErrorCode_MoonfantasyJoinUp - return - } - - globalconf = this.module.configure.GetGlobalConf() - - if time.Now().Sub(time.Unix(mdata.Ctime, 0)).Seconds() >= float64(globalconf.DreamlandLimit) { - this.module.modelDream.Del(mdata.Id) + if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期 cd = pb.ErrorCode_MoonfantasyHasExpired return } - if v, ok := mdata.Record[session.GetUserId()]; ok { - if v >= mdata.Unitmup { - cd = pb.ErrorCode_MoonfantasyDareUp - return - } - } - if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { - code = pb.ErrorCode_CacheReadError - return - } - umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) - this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ - "mfantasys": umfantasy.Mfantasys, - }) - for _, v := range mdata.Join { if v.Uid == session.GetUserId() { - return + isjson = true + break } } - if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { - this.module.Errorf("no found uer:%d", session.GetUserId()) - code = pb.ErrorCode_DBError - return + + if !isjson { + if len(mdata.Join) >= int(mdata.Numup) { + cd = pb.ErrorCode_MoonfantasyJoinUp + return + } + // if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil { + // code = pb.ErrorCode_CacheReadError + // return + // } + // umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + // this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ + // "mfantasys": umfantasy.Mfantasys, + // }) + if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { + this.module.Errorf("no found uer:%d", session.GetUserId()) + code = pb.ErrorCode_DBError + return + } + mdata.Join = append(mdata.Join, &pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}) + this.module.modelDream.Change(mdata.Id, map[string]interface{}{ + "join": mdata.Join, + }) } - mdata.Join = append(mdata.Join, &pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}) - this.module.modelDream.Change(mdata.Id, map[string]interface{}{ - "join": mdata.Join, - }) return } diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go index 9bf9a97a7..fda19da4b 100644 --- a/modules/moonfantasy/api_battle.go +++ b/modules/moonfantasy/api_battle.go @@ -66,7 +66,10 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle cd = pb.ErrorCode_MoonfantasyHasExpired return } - + if this.module.modelDream.checkMFantasyExpiration(mdata) { //已过期 + cd = pb.ErrorCode_MoonfantasyHasExpired + return + } for _, v := range mdata.Join { if v.Uid == session.GetUserId() { isjoin = true @@ -114,7 +117,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle Ptype: pb.PlayType_moonfantasy, Leadpos: req.Leadpos, Teamids: req.Teamids, - Mformat: []int32{boss.Monsterformatid}, + Mformat: boss.Monsterformatid, }) return } diff --git a/modules/moonfantasy/api_getlist.go b/modules/moonfantasy/api_getlist.go index f9385b44a..b2d006fa7 100644 --- a/modules/moonfantasy/api_getlist.go +++ b/modules/moonfantasy/api_getlist.go @@ -4,6 +4,8 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + "time" "google.golang.org/protobuf/proto" ) @@ -14,21 +16,34 @@ func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.Moonfantasy return } -///获取用户装备列表 +///获取用户秘境列表 func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetListReq) (code pb.ErrorCode, data proto.Message) { var ( - err error - umfantasy *pb.DBUserMFantasy - mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0) + err error + globalconf *cfg.GameGlobalData + umfantasy *pb.DBUserMFantasy + mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0) ) if umfantasy, err = this.module.modelUserMF.queryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil { code = pb.ErrorCode_CacheReadError return } - if len(umfantasy.Mfantasys) > 0 { - mfantasys, err = this.module.modelDream.querymfantasys(umfantasy.Mfantasys) + globalconf = this.module.configure.GetGlobalConf() + if time.Unix(umfantasy.LastTrigger, 0).Day() != time.Now().Day() { + umfantasy.TriggerNum = 0 + umfantasy.LastTrigger = time.Now().Unix() + umfantasy.BuyNum = 0 + if umfantasy.BattleNum < globalconf.DreamlandFightnum { + umfantasy.BattleNum = globalconf.DreamlandFightnum + } + this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ + "triggerNum": umfantasy.TriggerNum, + "lastTrigger": umfantasy.LastTrigger, + "buyNum": umfantasy.BuyNum, + "battleNum": umfantasy.BattleNum, + }) } - + mfantasys, err = this.module.modelDream.querymfantasys(session.GetUserId()) session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{ BattleNum: umfantasy.BattleNum, BuyNum: umfantasy.BuyNum, diff --git a/modules/moonfantasy/api_receive.go b/modules/moonfantasy/api_receive.go index 98849ee4d..28f159f89 100644 --- a/modules/moonfantasy/api_receive.go +++ b/modules/moonfantasy/api_receive.go @@ -20,7 +20,6 @@ func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.Moonfantasy func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode, data proto.Message) { var ( boss *cfg.GameDreamlandBoosData - award []*cfg.Gameatn = make([]*cfg.Gameatn, 0) iswin bool err error ) @@ -39,8 +38,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei code = pb.ErrorCode_MoonfantasyBattleNoWin return } - this.module.configure.GetDropReward(boss.Prize, award) - this.module.DispenseRes(session, award, true) + this.module.DispenseRes(session, boss.Prize, true) session.SendMsg(string(this.module.GetType()), "receive", &pb.MoonfantasyReceiveResp{Issucc: true}) return } diff --git a/modules/moonfantasy/api_trigger.go b/modules/moonfantasy/api_trigger.go deleted file mode 100644 index 8985ca918..000000000 --- a/modules/moonfantasy/api_trigger.go +++ /dev/null @@ -1,87 +0,0 @@ -package moonfantasy - -// //参数校验 -// func (this *apiComp) TriggerCheck(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode) { -// return -// } - -// ///获取本服聊天消息记录 -// func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode, data proto.Message) { -// var ( -// user *pb.DBUser -// umfantasy *pb.DBUserMFantasy -// globalconf *cfg.GameGlobalData -// uexpand *pb.DBUserExpand -// boss *cfg.GameDreamlandBoosData -// mdata *pb.DBMoonFantasy -// chat *pb.DBChat -// issucc bool -// err error -// ) - -// if code = this.TriggerCheck(session, req); code != pb.ErrorCode_Success { -// return -// } -// globalconf = this.module.configure.GetGlobalConf() -// n, _ := rand.Int(rand.Reader, big.NewInt(100)) -// if int32(n.Int64()) < globalconf.DreamlandPro { -// issucc = true -// } else { -// issucc = false -// } -// if issucc { -// if uexpand, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil { -// code = pb.ErrorCode_DBError -// this.module.Errorln(err) -// return -// } -// if time.Unix(uexpand.MoonfantasyLastTrigger, 0).Day() != time.Now().Day() { -// uexpand.MoonfantasyTriggerNum = 0 -// } - -// if uexpand.MoonfantasyTriggerNum >= globalconf.DreamlandTriggernum { -// return -// } - -// if boss, err = this.module.configure.GetMonster(); err != nil { -// code = pb.ErrorCode_ConfigNoFound -// return -// } -// if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil { -// this.module.Errorf("no found uer:%d", session.GetUserId()) -// code = pb.ErrorCode_DBError -// return -// } -// if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil { -// code = pb.ErrorCode_CacheReadError -// return -// } -// if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar}, boss); err != nil { -// code = pb.ErrorCode_DBError -// return -// } -// umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) -// this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ -// "mfantasys": umfantasy.Mfantasys, -// }) -// this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{ -// "moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1, -// "moonfantasyLastTrigger": time.Now().Unix(), -// }) -// chat = &pb.DBChat{ -// Ctype: pb.ChatType_Moonfantasy, -// Suid: session.GetUserId(), -// Avatar: req.Avatar, -// Uname: req.Uname, -// Slv: req.Ulv, -// Stag: session.GetServiecTag(), -// Content: mdata.Monster, -// AppendStr: mdata.Id, -// } -// this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), mdata.Id, chat) -// session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster}) -// } else { -// session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false}) -// } -// return -// } diff --git a/modules/moonfantasy/modelDream.go b/modules/moonfantasy/modelDream.go index e9d124f7e..cf8027851 100644 --- a/modules/moonfantasy/modelDream.go +++ b/modules/moonfantasy/modelDream.go @@ -40,21 +40,29 @@ func (this *modelDreamComp) newDreamLock(mid string) (result *redis.RedisMutex, return this.module.modelDream.NewRedisMutex(fmt.Sprintf("%s-%s_lock", this.TableName, mid), 5) } -///添加月之秘境记录 +///查询月之秘境记录 func (this *modelDreamComp) querymfantasy(mid string) (result *pb.DBMoonFantasy, err error) { result = &pb.DBMoonFantasy{} - if err = this.Get(mid, result); err != nil && err != mongo.ErrNilDocument { + if err = this.GetListObj("", mid, result); err != nil && err != mongo.ErrNilDocument { this.module.Errorln(err) } return } ///插叙用户秘境列表 -func (this *modelDreamComp) querymfantasys(mids []string) (fantasys []*pb.DBMoonFantasy, err error) { - fantasys = make([]*pb.DBMoonFantasy, 0) - if err = this.Gets(mids, &fantasys); err != nil { +func (this *modelDreamComp) querymfantasys(uid string) (result []*pb.DBMoonFantasy, err error) { + fantasys := make([]*pb.DBMoonFantasy, 0) + if err = this.GetList("", &fantasys); err != nil { this.module.Errorf("err:%v", err) } + result = make([]*pb.DBMoonFantasy, 0, len(fantasys)) + for _, v := range fantasys { + for _, u := range v.Join { + if u.Uid == uid { + result = append(result, v) + } + } + } return } @@ -68,9 +76,10 @@ func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreaml Join: []*pb.UserInfo{user}, Numup: boss.Challengenum, Unitmup: boss.Fightnum, + Expir: time.Now().Add(time.Second * time.Duration(boss.DreamlandLimit)).Unix(), Record: make(map[string]int32), } - if err = this.Add(result.Id, result); err != nil { + if err = this.AddList("", result.Id, result); err != nil { this.module.Errorln(err) } return @@ -104,7 +113,7 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle if umfantasy.TriggerNum >= globalconf.DreamlandTriggernum { return } - umfantasy.TriggerNum++ + if boss, err = this.module.configure.GetMonster(); err != nil { this.module.Errorln(err) return @@ -117,9 +126,10 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar, Lv: user.Lv}, boss); err != nil { return } - umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + // umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id) + umfantasy.TriggerNum++ this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{ - "mfantasys": umfantasy.Mfantasys, + // "mfantasys": umfantasy.Mfantasys, "triggerNum": umfantasy.TriggerNum, "lastTrigger": umfantasy.LastTrigger, "buyNum": umfantasy.BuyNum, @@ -185,3 +195,11 @@ func (this *modelDreamComp) delaynoticeWorld(stag, mid string, chat *pb.DBChat) this.module.chat.SendWorldChat(_chat) }, mid, chat) } + +func (this *modelDreamComp) checkMFantasyExpiration(mf *pb.DBMoonFantasy) bool { + if time.Now().After(time.Unix(mf.Expir, 0)) { //已过期 + this.DelListlds("", mf.Id) + return true + } + return false +} diff --git a/modules/moonfantasy/modelUserMF.go b/modules/moonfantasy/modelUserMF.go index 5af4293c5..5063e94b6 100644 --- a/modules/moonfantasy/modelUserMF.go +++ b/modules/moonfantasy/modelUserMF.go @@ -39,7 +39,7 @@ func (this *modelUserMF) queryUsermfantasy(uId string) (fantasy *pb.DBUserMFanta if err == mgo.MongodbNil { fantasy.Id = primitive.NewObjectID().Hex() fantasy.Uid = uId - fantasy.Mfantasys = make([]string, 0) + // fantasy.Mfantasys = make([]string, 0) if err = this.Add(uId, fantasy); err != nil { this.module.Errorf("err:%v", err) } diff --git a/pb/moonfantasy_db.pb.go b/pb/moonfantasy_db.pb.go index 249128ca9..35e0859e4 100644 --- a/pb/moonfantasy_db.pb.go +++ b/pb/moonfantasy_db.pb.go @@ -104,7 +104,8 @@ type DBMoonFantasy struct { Join []*UserInfo `protobuf:"bytes,5,rep,name=join,proto3" json:"join"` //参与人数 Numup int32 `protobuf:"varint,6,opt,name=numup,proto3" json:"numup"` //人数上限 Unitmup int32 `protobuf:"varint,7,opt,name=unitmup,proto3" json:"unitmup"` //单人可挑战次数 - Record map[string]int32 `protobuf:"bytes,8,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录 + Expir int64 `protobuf:"varint,8,opt,name=expir,proto3" json:"expir"` //过期时间 + Record map[string]int32 `protobuf:"bytes,9,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录 } func (x *DBMoonFantasy) Reset() { @@ -188,6 +189,13 @@ func (x *DBMoonFantasy) GetUnitmup() int32 { return 0 } +func (x *DBMoonFantasy) GetExpir() int64 { + if x != nil { + return x.Expir + } + return 0 +} + func (x *DBMoonFantasy) GetRecord() map[string]int32 { if x != nil { return x.Record @@ -201,13 +209,12 @@ type DBUserMFantasy struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id - Mfantasys []string `protobuf:"bytes,3,rep,name=mfantasys,proto3" json:"mfantasys"` //月之秘境列表 - TriggerNum int32 `protobuf:"varint,4,opt,name=triggerNum,proto3" json:"triggerNum" bson:"triggerNum"` // 月之秘境触发次数 - BattleNum int32 `protobuf:"varint,5,opt,name=battleNum,proto3" json:"battleNum" bson:"battleNum"` // 月之秘境挑战次数 - BuyNum int32 `protobuf:"varint,6,opt,name=buyNum,proto3" json:"buyNum" bson:"buyNum"` // 月之秘境挑战次数 - LastTrigger int64 `protobuf:"varint,7,opt,name=lastTrigger,proto3" json:"lastTrigger" bson:"lastTrigger"` // 月之秘境最后触发时间 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id + TriggerNum int32 `protobuf:"varint,3,opt,name=triggerNum,proto3" json:"triggerNum" bson:"triggerNum"` // 月之秘境触发次数 + BattleNum int32 `protobuf:"varint,4,opt,name=battleNum,proto3" json:"battleNum" bson:"battleNum"` // 月之秘境挑战次数 + BuyNum int32 `protobuf:"varint,5,opt,name=buyNum,proto3" json:"buyNum" bson:"buyNum"` // 月之秘境挑战次数 + LastTrigger int64 `protobuf:"varint,6,opt,name=lastTrigger,proto3" json:"lastTrigger" bson:"lastTrigger"` // 月之秘境最后触发时间 } func (x *DBUserMFantasy) Reset() { @@ -256,13 +263,6 @@ func (x *DBUserMFantasy) GetUid() string { return "" } -func (x *DBUserMFantasy) GetMfantasys() []string { - if x != nil { - return x.Mfantasys - } - return nil -} - func (x *DBUserMFantasy) GetTriggerNum() int32 { if x != nil { return x.TriggerNum @@ -301,7 +301,7 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, - 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x9f, 0x02, 0x0a, + 0x6c, 0x76, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0xb5, 0x02, 0x0a, 0x0d, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, @@ -313,27 +313,27 @@ var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{ 0x14, 0x0a, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70, 0x12, - 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2e, - 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x63, - 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc8, - 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, - 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, - 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, - 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12, - 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, - 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, - 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x14, 0x0a, 0x05, 0x65, 0x78, 0x70, 0x69, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x65, 0x78, 0x70, 0x69, 0x72, 0x12, 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, + 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, + 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0xaa, 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x4d, + 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x72, 0x69, + 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, + 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x62, 0x61, + 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, + 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x12, + 0x20, 0x0a, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, + 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/sys/configure/structs/Game.DreamlandBoosData.go b/sys/configure/structs/Game.DreamlandBoosData.go index ba2fdf07e..dd914bab2 100644 --- a/sys/configure/structs/Game.DreamlandBoosData.go +++ b/sys/configure/structs/Game.DreamlandBoosData.go @@ -15,8 +15,9 @@ type GameDreamlandBoosData struct { Pro int32 Fightnum int32 Challengenum int32 - Prize int32 - Monsterformatid int32 + Prize []*Gameatn + Monsterformatid []int32 + DreamlandLimit int32 } const TypeId_GameDreamlandBoosData = -1451313715 @@ -30,8 +31,35 @@ func (_v *GameDreamlandBoosData)Deserialize(_buf map[string]interface{}) (err er { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pro"].(float64); !_ok_ { err = errors.New("pro error"); return }; _v.Pro = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["fightnum"].(float64); !_ok_ { err = errors.New("fightnum error"); return }; _v.Fightnum = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["challengenum"].(float64); !_ok_ { err = errors.New("challengenum error"); return }; _v.Challengenum = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["prize"].(float64); !_ok_ { err = errors.New("prize error"); return }; _v.Prize = int32(_tempNum_) } - { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["monsterformatid"].(float64); !_ok_ { err = errors.New("monsterformatid error"); return }; _v.Monsterformatid = int32(_tempNum_) } + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["prize"].([]interface{}); !_ok_ { err = errors.New("prize error"); return } + + _v.Prize = make([]*Gameatn, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ *Gameatn + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } } + _v.Prize = append(_v.Prize, _list_v_) + } + } + + { + var _arr_ []interface{} + var _ok_ bool + if _arr_, _ok_ = _buf["monsterformatid"].([]interface{}); !_ok_ { err = errors.New("monsterformatid error"); return } + + _v.Monsterformatid = make([]int32, 0, len(_arr_)) + + for _, _e_ := range _arr_ { + var _list_v_ int32 + { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) } + _v.Monsterformatid = append(_v.Monsterformatid, _list_v_) + } + } + + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["dreamland_limit"].(float64); !_ok_ { err = errors.New("dreamland_limit error"); return }; _v.DreamlandLimit = int32(_tempNum_) } return } diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index fa31e6c12..976929af4 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -89,9 +89,15 @@ type DBModel struct { } func (this *DBModel) ukey(uid string) string { + if uid == "" { + return fmt.Sprintf("%s:member", this.TableName) + } return fmt.Sprintf("%s:%s", this.TableName, uid) } func (this *DBModel) ukeylist(uid string, id string) string { + if uid == "" { + return fmt.Sprintf("%s:%s", this.TableName, id) + } return fmt.Sprintf("%s:%s-%s", this.TableName, uid, id) } func (this *DBModel) InsertModelLogs(table string, uID string, target interface{}) (err error) { @@ -516,8 +522,12 @@ func (this *DBModel) GetList(uid string, data interface{}) (err error) { } } if err == lgredis.RedisNil { + var f = bson.M{} + if uid != "" { + f = bson.M{"uid": uid} + } //query from mgo - if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil { + if c, err = this.DB.Find(core.SqlTable(this.TableName), f); err != nil { return err } else { if encoder, ok = codec.EncoderOf(sliceelemType, defconf).(codecore.IEncoderMapJson); !ok { @@ -794,8 +804,8 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er onfound = ids } - if err == lgredis.RedisNil { - if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": ids}}); err != nil { + if len(onfound) > 0 { + if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": onfound}}); err != nil { return err } else { if encoder, ok = codec.EncoderOf(sliceelemType, defconf).(codecore.IEncoderMapJson); !ok { @@ -818,6 +828,11 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er if tempdata, err = encoder.EncodeToMapJson(*((*unsafe.Pointer)(elemPtr)), json.GetWriter()); err != nil { return } + for i, v := range onfound { + if v == _id { + onfound = append(onfound[0:i], onfound[i+1:]...) + } + } key := this.ukeylist(uid, _id) pipe.HMSetForMap(key, tempdata) keys[_id] = key @@ -829,6 +844,9 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er } } } + if len(onfound) > 0 { + err = fmt.Errorf("onfound:%v data!", onfound) + } if this.Expired > 0 { childs := make(map[string]struct{}, len(keys)) for _, v := range keys {