From d87f822e2faee7978a97b4e1ca3f00a43f4cbc02 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 16 Jan 2023 10:27:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=B8=8D=E6=8F=90=E4=BE=9B=E5=AF=B9=E5=A4=96=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 -- modules/hero/api_drawCard.go | 25 +++++++++++++++++++++++-- modules/hero/api_fusion.go | 13 ++++++++----- modules/hero/module.go | 4 ++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 8a6b89724..c996d9edc 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -48,8 +48,6 @@ type ( //查询用户卡片数量 QueryHeroAmount(uId string, heroCfgId string) (amount uint32) - //创建指定数量 - CreateRepeatHero(session IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) // 批量创建英雄 CreateRepeatHeros(session IUserSession, heros map[string]int32, bPush bool) (hero *pb.DBHero, code pb.ErrorCode) // 获取英雄 diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index dd287e780..51a6bd3d1 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -276,12 +276,33 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq update["totalcount"] = heroRecord.Totalcount update["daycount"] = heroRecord.Daycount this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update) + szNewCards := make([]*cfg.Gameatn, 0) for _, heroId := range szCards { - + bFind := false _mapAddHero[heroId]++ + for _, v := range szNewCards { + if v.T == heroId { + v.N++ + bFind = true + break + } + } + if !bFind { + res := &cfg.Gameatn{ + A: "hero", + T: heroId, + N: 1, + } + szNewCards = append(szNewCards, res) + } } - _, code = this.module.CreateRepeatHeros(session, _mapAddHero, true) + // 获得新卡 + if code = this.module.DispenseRes(session, szNewCards, true); code != pb.ErrorCode_Success { + + this.module.Errorf("err:%v,create heros:%v,uid,%s", code, szNewCards, session.GetUserId()) + code = pb.ErrorCode_HeroCreate // 创建新英雄失败 + } ///英雄招募 【玩家名称】在招募中获得了【英雄名称】! this.module.SendChatMsg(session, _mapAddHero, szCards) diff --git a/modules/hero/api_fusion.go b/modules/hero/api_fusion.go index 0e87064e0..665c8bce2 100644 --- a/modules/hero/api_fusion.go +++ b/modules/hero/api_fusion.go @@ -3,6 +3,7 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/utils" "google.golang.org/protobuf/proto" @@ -74,12 +75,14 @@ func (this *apiComp) Fusion(session comm.IUserSession, req *pb.HeroFusionReq) (c } // 获得新卡 - var new map[string]int32 - new = make(map[string]int32) - new[conf.Hero] = 1 - if _, err := this.module.CreateRepeatHeros(session, new, false); err != pb.ErrorCode_Success { + res := &cfg.Gameatn{ + A: "hero", + T: conf.Hero, + N: 1, + } + if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, false); code != pb.ErrorCode_Success { - this.module.Errorf("err:%v,create hero:%s,uid,%ss", err, conf.Hero, session.GetUserId()) + this.module.Errorf("err:%v,create hero:%s,uid,%ss", code, conf.Hero, session.GetUserId()) code = pb.ErrorCode_HeroCreate // 创建新英雄失败 } session.SendMsg(string(this.module.GetType()), HeroFusionResp, &pb.HeroFusionResp{Heroid: conf.Hero}) diff --git a/modules/hero/module.go b/modules/hero/module.go index 92125aad2..e771e443e 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -76,7 +76,7 @@ func (this *Hero) Start() (err error) { } //创建单个叠加英雄 -func (this *Hero) CreateRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) { +func (this *Hero) createRepeatHero(session comm.IUserSession, heroCfgId string, num int32) (hero *pb.DBHero, code pb.ErrorCode) { var err error hero, err = this.modelHero.createHeroOverlying(session.GetUserId(), heroCfgId, num) if err == nil { @@ -272,7 +272,7 @@ func (this *Hero) CreateRepeatHeros(session comm.IUserSession, heros map[string] if num == 0 { // 数量为0 不做处理 continue } - if hero, code = this.CreateRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success { + if hero, code = this.createRepeatHero(session, heroCfgId, num); code != pb.ErrorCode_Success { this.Errorf("create hero %s failed", heroCfgId) return } From c8fcee8c35b2ba42ad79e9551827cb1040c6e896 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 17 Jan 2023 12:39:45 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mline/api_challenge.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/mline/api_challenge.go b/modules/mline/api_challenge.go index 89293270a..0c9d4f56c 100644 --- a/modules/mline/api_challenge.go +++ b/modules/mline/api_challenge.go @@ -42,9 +42,9 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge } } if curChapter == nil { // 校验是不是新的数据 - preStage := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验 - preStageConf := this.module.configure.GetMainStageConf(preStage) - if stageConf == nil { // 配置文件校验 + //preStage := this.module.configure.GetMainStageConf(stageConf.Previoustage) // 新章节数据校验 + preStageConf := this.module.configure.GetMainStageConf(stageConf.Previoustage) + if preStageConf == nil { // 配置文件校验 code = pb.ErrorCode_MainlineNotFindChapter return } From acc098c441a6a967e42fcfffd7d368b11b6d1233 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 17 Jan 2023 16:24:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?GM=20=E4=BF=AE=E6=94=B9=E4=B8=BB=E7=BA=BF?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 +- modules/gm/api_cmd.go | 2 +- modules/gm/module.go | 12 +++----- modules/mline/api_challenge.go | 16 +++++------ modules/mline/comp_configure.go | 21 -------------- modules/mline/module.go | 51 +++++++++++++++++++-------------- 6 files changed, 43 insertions(+), 61 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 8a6b89724..b08a37ca2 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -156,7 +156,7 @@ type ( IReddot } IMline interface { - ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) + ModifyMlineDataByNanduID(session IUserSession, id int32) (code pb.ErrorCode) /// 查询章节ID GetUsermLineData(uid string, chapterType int32) (chapterId int32) ///红点 diff --git a/modules/gm/api_cmd.go b/modules/gm/api_cmd.go index d8fc75b12..32ac4c95b 100644 --- a/modules/gm/api_cmd.go +++ b/modules/gm/api_cmd.go @@ -24,7 +24,7 @@ import ( 9、bingo:season,10 赛季塔层数 10、bingo:viking // 解锁维京所有难度 11、bingo:hunting // 解锁狩猎所有难度 -12、bingo:mainline,1,101 // 难度 id +12、bingo:mainline,11001 // 难度 id 13、bingo:moon,1 // 触发月之秘境 14、bingo:arena,100 // 设置竞技场用户积分 15、bingo:sociatyexp,100 // 设置工会经验 diff --git a/modules/gm/module.go b/modules/gm/module.go index 52ce54393..a5708bbeb 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -194,8 +194,8 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC this.Debug("使用bingo命令:uid = %s ", log.Field{Key: "uid", Value: session.GetUserId()}, log.Field{Key: "0", Value: datas[0]}) - } else if len(datas) == 3 && (datas[0] == "mainline") { - module1, err := this.service.GetModule(comm.ModuleMainline) + } else if len(datas) == 2 && (datas[0] == "mainline") { + module1, err := this.service.GetModule(comm.ModuleMline) if err != nil { return } @@ -204,12 +204,8 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC code = pb.ErrorCode_ReqParameterError return } - num2, err := strconv.Atoi(datas[2]) - if err != nil { - code = pb.ErrorCode_ReqParameterError - return - } - code = module1.(comm.IMainline).ModifyMainlineDataByNanduID(session.GetUserId(), int32(num1), int32(num2)) + + code = module1.(comm.IMline).ModifyMlineDataByNanduID(session, int32(num1)) this.Debug("使用bingo命令", log.Field{Key: "uid", Value: session.GetUserId()}, diff --git a/modules/mline/api_challenge.go b/modules/mline/api_challenge.go index 0c9d4f56c..9ce83e36c 100644 --- a/modules/mline/api_challenge.go +++ b/modules/mline/api_challenge.go @@ -50,8 +50,8 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge } for _, v := range list { - if preStageConf.CaptainId == v.ChapterId { // 有上一章节数据 - if _, ok := v.Star[v.StageId]; ok { + if preStageConf.Chapterid == v.ChapterId { // 有上一章节数据 + if _, ok := v.Star[preStageConf.Id]; ok { newData := &pb.DBMline{ Id: primitive.NewObjectID().Hex(), Uid: session.GetUserId(), @@ -62,22 +62,22 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge Award: map[int32]bool{}, Ps: map[int32]int32{}, } + curChapter = newData this.module.modelMline.addNewChapter(session.GetUserId(), newData) break } } } + } + if curChapter == nil { code = pb.ErrorCode_MainlineNotFindChapter return } + if v1, ok := curChapter.Ps[req.StageId]; ok && v1 == 0 { - if v, ok := curChapter.Ps[req.StageId]; ok && v > 0 { - if v != 0 { // 扣1点 - if code = this.module.ConsumeRes(session, stageConf.PsMg, true); code != pb.ErrorCode_Success { // 扣1点 - return - } + if code = this.module.ConsumeRes(session, stageConf.PsMg, true); code != pb.ErrorCode_Success { // 扣1点 + return } - } else { for _, v := range stageConf.PsConsume { if v.A == "attr" && v.T == "ps" { diff --git a/modules/mline/comp_configure.go b/modules/mline/comp_configure.go index b71511bbc..6d71dc235 100644 --- a/modules/mline/comp_configure.go +++ b/modules/mline/comp_configure.go @@ -140,24 +140,3 @@ func (this *configureComp) GetAllStageByChapterID(chapterID int32) (stage []int3 } 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/module.go b/modules/mline/module.go index 124d59dad..256b27d1f 100644 --- a/modules/mline/module.go +++ b/modules/mline/module.go @@ -90,37 +90,44 @@ func (this *Mline) CheckPoint(uid string) bool { } // 参数 难度 + 章节id -func (this *Mline) ModifyMlineDataByNanduID(uid string, nandu, id int32) (code pb.ErrorCode) { +func (this *Mline) ModifyMlineDataByNanduID(session comm.IUserSession, id int32) (code pb.ErrorCode) { var del []string - list, err := this.modelMline.getMainlineList(uid) + list, err := this.modelMline.getMainlineList(session.GetUserId()) if err != nil { code = pb.ErrorCode_DBError return } for _, v := range list { - if v.CType == nandu { - del = append(del, v.Id) - } + 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) + this.modelMline.cleanChapterDataById(session.GetUserId(), del...) + + connf := this.configure.GetMainStageConf(id) + if connf == nil { + return } + _data := this.configure.GetAllChapterID() + for _, v := range _data { + if v <= connf.Chapterid { + newData := &pb.DBMline{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + CType: connf.Episodetype, + ChapterId: v, + StageId: id, + Star: map[int32]int32{}, + Award: map[int32]bool{}, + Ps: map[int32]int32{}, + } + stageConf := this.configure.GetAllStageByChapterID(v) + for _, v := range stageConf { + newData.Star[v] = 3 + } + this.modelMline.addNewChapter(session.GetUserId(), newData) + } + } + return } func (this *Mline) GetUsermLineData(uid string, chapterType int32) (chapterId int32) {