diff --git a/comm/imodule.go b/comm/imodule.go index 5e4dae2ff..dc80a6c57 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -150,13 +150,18 @@ type ( } IMainline interface { ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) - // 修改章节信息 - ModifyMainlineData(uid string, id int32) (code pb.ErrorCode) /// 查询章节ID GetUsermainLineData(uid string) (mainlineId int32) ///红点 IReddot } + IMline interface { + ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) + /// 查询章节ID + GetUsermLineData(uid string, chapterType int32) (chapterId int32) + ///红点 + IReddot + } //任务 ITask interface { //初始化 日常/周常/成就 diff --git a/modules/gm/api_cmd.go b/modules/gm/api_cmd.go index fd2a59e20..d8fc75b12 100644 --- a/modules/gm/api_cmd.go +++ b/modules/gm/api_cmd.go @@ -11,7 +11,7 @@ import ( //bingo:item,10001,1 //bingo:attr,gold,1000000 //bingo:equi,xxx,1 // xxx 装备id -2、修改主线关卡进度:bingo:mapid,102(102代表关卡位置) + 3、修改心魔塔进度:bingo:pataid,10(10代表层数) diff --git a/modules/gm/module.go b/modules/gm/module.go index e0e8ed45b..b34bf5d5b 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -91,23 +91,6 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC log.Field{Key: "T", Value: datas[1]}, log.Field{Key: "N", Value: int32(num)}, ) - } else if len(datas) == 2 && (datas[0] == "mapid") { - module1, err := this.service.GetModule(comm.ModuleMainline) - if err != nil { - return - } - num, err := strconv.Atoi(datas[1]) - if err != nil { - code = pb.ErrorCode_ReqParameterError - return - } - code = module1.(comm.IMainline).ModifyMainlineData(session.GetUserId(), int32(num)) - - this.Debug("使用bingo命令", - log.Field{Key: "uid", Value: session.GetUserId()}, - log.Field{Key: "0", Value: datas[0]}, - log.Field{Key: "N", Value: int32(num)}, - ) } else if len(datas) == 2 && (datas[0] == "pataid") { module1, err := this.service.GetModule(comm.ModulePagoda) if err != nil { diff --git a/modules/mainline/module.go b/modules/mainline/module.go index e1d151c54..2cbd62996 100644 --- a/modules/mainline/module.go +++ b/modules/mainline/module.go @@ -40,42 +40,6 @@ func (this *Mainline) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } -// 接口信息 给其他模块调用 用来修改主线关卡信息 -func (this *Mainline) ModifyMainlineData(uid string, id int32) (code pb.ErrorCode) { - - conf := this.configure.GetMainlineConfigData(id, 1) - list, err := this.modelMainline.getMainlineList(uid) - if err != nil { - code = pb.ErrorCode_DBError - return - } - for _, v := range list { - if v.ChapterId == conf.Chapter { - data := make(map[string]interface{}, 0) - data["mainlineId"] = id - data["chapterId"] = v.ChapterId - this.modelMainline.modifyMainlineData(uid, v.Id, data) - if err != nil { - code = pb.ErrorCode_DBError - } - - return - } - } - //add - _data := &pb.DBMainline{} - _data.Id = primitive.NewObjectID().Hex() - _data.ChapterId = conf.Chapter - _data.MainlineId = conf.Id - _mData := make(map[string]interface{}, 0) - _data.Uid = uid - _data.Intensity = 1 // 难度1 - _mData[_data.Id] = _data - - this.modelMainline.addNewChapter(uid, _mData) - return -} - func (this *Mainline) GetUsermainLineData(uid string) (mainlineId int32) { _szData, err := this.modelMainline.getMainlineList(uid) diff --git a/modules/mline/api_challenge.go b/modules/mline/api_challenge.go index 5e29cee8f..2b3c8637e 100644 --- a/modules/mline/api_challenge.go +++ b/modules/mline/api_challenge.go @@ -43,16 +43,13 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge } if curChapter == nil { // 校验是不是新的数据 if stageConf.Previoustage == 0 { // 创建一条新的章节数据 - // 新章节数据校验 - chapter := this.module.configure.GetPreMainChapter(req.StageId) + chapter := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验 bCheck := false if chapter == 0 { bCheck = true } else { for _, v := range list { if chapter == v.ChapterId { // 有上一章节数据 - // 获取该章节最后一关卡ID - //stage := this.module.configure.GetLastStageIDByChapter(chapter) if _, ok := v.Star[stageConf.Previoustage]; ok { bCheck = true } diff --git a/modules/mline/api_getlist.go b/modules/mline/api_getlist.go index 2d532794b..f7b3fd57a 100644 --- a/modules/mline/api_getlist.go +++ b/modules/mline/api_getlist.go @@ -36,20 +36,21 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.MlineGetListReq) } } if len(rsp.Data) == 0 { // 什么数据都没有 创建一条 - stageConf := this.module.configure.GetFirstStageIDByChapter(req.CType) - if stageConf != nil { // 配置文件校验 - newData := &pb.DBMline{ - Id: primitive.NewObjectID().Hex(), - Uid: session.GetUserId(), - CType: stageConf.Episodetype, - ChapterId: stageConf.Chapterid, - StageId: stageConf.Id, - Star: map[int32]int32{}, - Award: map[int32]bool{}, - Ps: map[int32]int32{}, + if chapterConf := this.module.configure.GetFirstChapterIDByType(req.CType); chapterConf != nil { // 配置文件校验 + if stageConf := this.module.configure.GetFirstStageIDByChapter(chapterConf.Id); stageConf != nil { + newData := &pb.DBMline{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + CType: stageConf.Episodetype, + ChapterId: stageConf.Chapterid, + StageId: stageConf.Id, + Star: map[int32]int32{}, + Award: map[int32]bool{}, + Ps: map[int32]int32{}, + } + rsp.Data = append(rsp.Data, newData) + this.module.modelMline.addNewChapter(session.GetUserId(), newData) } - rsp.Data = append(rsp.Data, newData) - this.module.modelMline.addNewChapter(session.GetUserId(), newData) } else { code = pb.ErrorCode_ConfigNoFound return diff --git a/modules/mline/comp_configure.go b/modules/mline/comp_configure.go index 1f03e4a87..3c7208525 100644 --- a/modules/mline/comp_configure.go +++ b/modules/mline/comp_configure.go @@ -75,7 +75,6 @@ func (this *configureComp) GetMainStageConf(id int32) (data *cfg.GameMainStageDa // 获取上一章节信息 func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) { - if v, err := this.GetConfigure(game_mainchapter); err == nil { if configure, ok := v.(*cfg.GameMainChapter); ok { for index, v1 := range configure.GetDataList() { @@ -95,12 +94,25 @@ func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) { } return } +func (this *configureComp) GetFirstChapterIDByType(iType int32) *cfg.GameMainChapterData { + if v, err := this.GetConfigure(game_mainchapter); err == nil { + if configure, ok := v.(*cfg.GameMainChapter); ok { + for _, v := range configure.GetDataList() { + if v.ChapterType == iType { + return v + } + } + } + } + return nil -func (this *configureComp) GetFirstStageIDByChapter(iType int32) *cfg.GameMainStageData { +} + +func (this *configureComp) GetFirstStageIDByChapter(chapterID int32) *cfg.GameMainStageData { if v, err := this.GetConfigure(game_mainstage); err == nil { if configure, ok := v.(*cfg.GameMainStage); ok { for _, v := range configure.GetDataList() { - if v.Episodetype == iType { + if v.Chapterid == chapterID { return v } } @@ -108,3 +120,51 @@ func (this *configureComp) GetFirstStageIDByChapter(iType int32) *cfg.GameMainSt } return nil } + +// 红点用 获取所有章节数据 +func (this *configureComp) GetAllChapterID() (chapter []int32) { + if v, err := this.GetConfigure(game_mainchapter); err == nil { + if configure, ok := v.(*cfg.GameMainChapter); ok { + for _, v1 := range configure.GetDataList() { + chapter = append(chapter, v1.Id) + } + } + } + return +} + +// 红点用 获取所有类型为1 的小关ID +func (this *configureComp) GetAllStageByChapterID(chapterID int32) (stage []int32) { + if v, err := this.GetConfigure(game_mainstage); err == nil { + if configure, ok := v.(*cfg.GameMainStage); ok { + for _, v1 := range configure.GetDataList() { + if v1.Episodetype == 1 { + stage = append(stage, v1.Id) + } + + } + } + } + return +} + +// gm 专用 +func (this *configureComp) GetGMChapter(chapterID, itype int32) (d map[int32][]int32) { + // var d map[int32][]int32 + d = make(map[int32][]int32, 0) + if v, err := this.GetConfigure(game_mainstage); err == nil { + if configure, ok := v.(*cfg.GameMainStage); ok { + for _, v1 := range configure.GetDataList() { + if v1.Episodetype == itype && v1.Id <= chapterID { + //chapter = append(chapter, v1.Id) + stage := this.GetAllStageByChapterID(v1.Id) + if len(stage) > 0 { + d[v1.Id] = stage + } + } + } + } + } + + return +} diff --git a/modules/mline/model_mainline.go b/modules/mline/model_mainline.go index 0e23ecc94..a08eafe45 100644 --- a/modules/mline/model_mainline.go +++ b/modules/mline/model_mainline.go @@ -62,3 +62,12 @@ func (this *ModelMline) cleanChapter(uId string) (err error) { } return nil } + +// 清除数据 +func (this *ModelMline) cleanChapterDataById(uId string, ids ...string) (err error) { + if err = this.DelListlds(uId, ids...); err != nil { + this.module.Errorf("err:%v", err) + return + } + return nil +} diff --git a/modules/mline/module.go b/modules/mline/module.go index 886847da7..124d59dad 100644 --- a/modules/mline/module.go +++ b/modules/mline/module.go @@ -5,6 +5,9 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + "sort" + + "go.mongodb.org/mongo-driver/bson/primitive" ) type Mline struct { @@ -62,24 +65,78 @@ func (this *Mline) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (re // 红点检测 func (this *Mline) CheckPoint(uid string) bool { - // list, err := this.modelMainline.getMainlineList(uid) - // if err != nil { - // return false - // } - // for _, v := range list { - // conf := this.configure.GetMainlineChapter(v.ChapterId) - // if conf == nil { - // continue - // } - // if len(conf.Episode) != len(v.BranchID) { - // return true - // } - // } + list, err := this.modelMline.getMainlineList(uid) + if err != nil { + return false + } + for _, v := range list { + b := false + for _, v1 := range this.configure.GetAllChapterID() { + if v.ChapterId == v1 { + b = true + continue + } + } + if !b { + return false + } + // 查看所有小关是否通关 + szStage := this.configure.GetAllStageByChapterID(v.ChapterId) + if len(szStage) != len(v.Star) { + return false + } + } return false } -// 参数 难度 + 关卡id -func (this *Mline) ModifyMainlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) { +// 参数 难度 + 章节id +func (this *Mline) ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) { + var del []string + list, err := this.modelMline.getMainlineList(uid) + if err != nil { + code = pb.ErrorCode_DBError + return + } + for _, v := range list { + if v.CType == nandu { + del = append(del, v.Id) + } + } + // 清除 + this.modelMline.cleanChapterDataById(uid, del...) + d := this.configure.GetGMChapter(id, nandu) + for k, v := range d { + newData := &pb.DBMline{ + Id: primitive.NewObjectID().Hex(), + Uid: uid, + CType: nandu, + ChapterId: k, + StageId: 0, + Star: map[int32]int32{}, + Award: map[int32]bool{}, + Ps: map[int32]int32{}, + } + for _, v1 := range v { + newData.Star[v1] = 3 // gm 全给3星 + } + this.modelMline.addNewChapter(uid, newData) + } + return +} +func (this *Mline) GetUsermLineData(uid string, chapterType int32) (chapterId int32) { + var sz []*pb.DBMline + _szData, err := this.modelMline.getMainlineList(uid) + if err == nil { + for _, v := range _szData { + if v.ChapterId == chapterId { + sz = append(sz, _szData...) + } + } + + sort.SliceStable(sz, func(i, j int) bool { // 排序 + return sz[i].ChapterId > sz[j].ChapterId + }) + } return } diff --git a/modules/reddot/module.go b/modules/reddot/module.go index 7bf6c3f26..759fed827 100644 --- a/modules/reddot/module.go +++ b/modules/reddot/module.go @@ -91,6 +91,7 @@ func (this *Reddot) Start() (err error) { return } this.hunting = module.(comm.IHunting) + return } diff --git a/modules/rtask/verifyHandle.go b/modules/rtask/verifyHandle.go index 0c8af4086..dadfc30e6 100644 --- a/modules/rtask/verifyHandle.go +++ b/modules/rtask/verifyHandle.go @@ -127,8 +127,8 @@ func (this *ModelRtask) verifyRtype2(uid string, cfg *cfg.GameRdtaskCondiData) ( return } - if ml, y := m.(comm.IMainline); y { - qjId := ml.GetUsermainLineData(uid) + if ml, y := m.(comm.IMline); y { + qjId := ml.GetUsermLineData(uid, 1) return soEqual(qjId, cfg.Data1) } return