From 0077b2fdd5875cfbeff623d6dc70a5e42ec67ab1 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sat, 31 Dec 2022 19:19:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8A=BD=E5=8D=A1?= =?UTF-8?q?=E8=A7=84=E5=88=99=20+=20=E6=8A=BD=E5=8D=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/api_drawCard.go | 87 ++++++++++++++++-------------------- modules/hero/module.go | 54 ++++++++++++++++++++++ 2 files changed, 92 insertions(+), 49 deletions(-) diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index 53ef01cc6..77f1e51a7 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -1,9 +1,11 @@ package hero import ( + "crypto/rand" "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" + "math/big" "google.golang.org/protobuf/proto" ) @@ -30,7 +32,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq pool string _mapAddHero map[string]int32 strPool []string // 10连跨多个卡池情况 + update map[string]interface{} + normalDraw bool // 是否是普通抽 ) + update = make(map[string]interface{}) _mapAddHero = make(map[string]int32, 0) cfgDraw = this.module.configure.GetGlobalConf() // 读取抽卡配置文件 if cfgDraw == nil { @@ -41,12 +46,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq return } szCards = make([]string, 0) - rsp := &pb.HeroDrawCardResp{} heroRecord, _ = this.module.modelRecord.GetHeroRecord(session.GetUserId()) drawCount = heroRecord.Drawcount if req.DrawType == 0 { // 普通卡池抽卡 + normalDraw = true // 获取普通抽卡池 if req.DrawCount == 1 { costAtn = cfgDraw.BasePoolCost @@ -79,6 +84,28 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq sz = append(sz, cfgDraw.BasePoolStar5) } starIndex := this.module.modelHero.GetRandW(sz) + // 特殊规则 DrawCard_5StarsInRange 第2-30次抽奖必出一个5星英雄(普通卡池) + inRangeConf := this.module.configure.GetGlobalConf().DrawCard5StarsInRange + if len(inRangeConf) == 3 { + iStart := inRangeConf[0] // 抽卡开始 + iEnd := inRangeConf[1] // 抽卡结束 + star := inRangeConf[2] + if heroRecord.Inevitable == 0 && heroRecord.Drawcount > iStart && heroRecord.Drawcount < iEnd && iEnd >= iStart { + n, _ := rand.Int(rand.Reader, big.NewInt(int64(iEnd-iStart))) + if n.Int64() < 1 { // 抽中 + starIndex = star - 3 + heroRecord.Inevitable = heroRecord.Drawcount + update["inevitable"] = heroRecord.Drawcount + } + } + // 保底情况 + if heroRecord.Drawcount == iEnd && heroRecord.Inevitable == 0 { + starIndex = star - 3 + heroRecord.Inevitable = heroRecord.Drawcount + update["inevitable"] = heroRecord.Drawcount + } + } + heroRecord.Star4++ // 4星保底数量+1 heroRecord.Star5++ // 5星保底数量+1 if starIndex == 1 { @@ -212,18 +239,19 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq } } - if req.DrawType == 0 { - update := map[string]interface{}{} - update["star4"] = heroRecord.Star4 - update["star5"] = heroRecord.Star5 - update["drawcount"] = drawCount - this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update) - } // 消耗道具 code = this.module.ConsumeRes(session, costRes, true) if code != pb.ErrorCode_Success { return } + heroRecord.Totalcount += req.DrawCount + heroRecord.Daycount += req.DrawCount + update["star4"] = heroRecord.Star4 + update["star5"] = heroRecord.Star5 + update["drawcount"] = drawCount + update["totalcount"] = heroRecord.Totalcount + update["daycount"] = heroRecord.Daycount + this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update) for _, heroId := range szCards { _mapAddHero[heroId]++ @@ -231,48 +259,9 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq _, code = this.module.CreateRepeatHeros(session, _mapAddHero, true) ///英雄招募 【玩家名称】在招募中获得了【英雄名称】! - for hid := range _mapAddHero { - if user := this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { - this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, hid) - } else { - this.module.Errorf("no found userdata uid:%s", session.GetUserId()) - } - } - rsp.Heroes = szCards - session.SendMsg(string(this.module.GetType()), DrawCard, rsp) + this.module.SendChatMsg(session, _mapAddHero, szCards) // 任务统计 - if req.DrawType == 0 { //普通招募 - if drawCount == 10 { - sz := make(map[int32]int32, 0) - for _, star := range szStar { - sz[star]++ - } - for k := range sz { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype17, 1, k) - } - } - //this.module.ModuleRtask.SendToRtask(session, comm.Rtype14, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype18, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype141, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype143, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype145, req.DrawCount) - } else { // 阵营招募 - //this.module.ModuleRtask.SendToRtask(session, comm.Rtype15, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype19, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype142, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype144, req.DrawCount) - this.module.ModuleRtask.SendToRtask(session, comm.Rtype146, req.DrawCount) - if drawCount == 10 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype91, 1) // 阵营10连 - } - } - for _, star := range szStar { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype16, star, 1) - } - if drawCount == 10 { - this.module.ModuleRtask.SendToRtask(session, comm.Rtype90, 1) - } - this.module.ModuleRtask.SendToRtask(session, comm.Rtype89, req.DrawCount) + this.module.SendTaskMsg(session, szStar, req.DrawCount, normalDraw) return } diff --git a/modules/hero/module.go b/modules/hero/module.go index 8fd5dc640..3ddca05b5 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -30,6 +30,7 @@ type Hero struct { moduleFetter comm.IHeroFetter service core.IService moduleHoroscope comm.IHoroscope + chat comm.IChat } //模块名 @@ -65,6 +66,10 @@ func (this *Hero) Start() (err error) { } this.moduleHoroscope = module.(comm.IHoroscope) + if module, err = this.service.GetModule(comm.ModuleChat); err != nil { + return + } + this.chat = module.(comm.IChat) err = this.ModuleBase.Start() event.RegisterGO(comm.EventUserOffline, this.EventUserOffline) return @@ -738,3 +743,52 @@ func (this *Hero) GetAllMaxHero(session comm.IUserSession) (code pb.ErrorCode) { } return } + +func (this *Hero) SendChatMsg(session comm.IUserSession, _mapAddHero map[string]int32, cards []string) { + rsp := &pb.HeroDrawCardResp{} + ///英雄招募 【玩家名称】在招募中获得了【英雄名称】! + for hid := range _mapAddHero { + if user := this.ModuleUser.GetUser(session.GetUserId()); user != nil { + + this.chat.SendSysChatToWorld(comm.ChatSystem13, nil, 0, 0, user.Name, hid) + } else { + this.Errorf("no found userdata uid:%s", session.GetUserId()) + } + } + rsp.Heroes = cards + session.SendMsg(string(this.GetType()), DrawCard, rsp) +} + +func (this *Hero) SendTaskMsg(session comm.IUserSession, szStar []int32, drawCount int32, itype bool) { + // 任务统计 + if itype { //普通招募 + if drawCount == 10 { + sz := make(map[int32]int32, 0) + for _, star := range szStar { + sz[star]++ + } + for k := range sz { + this.ModuleRtask.SendToRtask(session, comm.Rtype17, 1, k) + } + } + this.ModuleRtask.SendToRtask(session, comm.Rtype18, drawCount) + this.ModuleRtask.SendToRtask(session, comm.Rtype141, drawCount) + this.ModuleRtask.SendToRtask(session, comm.Rtype143, drawCount) + this.ModuleRtask.SendToRtask(session, comm.Rtype145, drawCount) + } else { // 阵营招募 + this.ModuleRtask.SendToRtask(session, comm.Rtype19, drawCount) + this.ModuleRtask.SendToRtask(session, comm.Rtype142, drawCount) + this.ModuleRtask.SendToRtask(session, comm.Rtype144, drawCount) + this.ModuleRtask.SendToRtask(session, comm.Rtype146, drawCount) + if drawCount == 10 { + this.ModuleRtask.SendToRtask(session, comm.Rtype91, 1) // 阵营10连 + } + } + for _, star := range szStar { + this.ModuleRtask.SendToRtask(session, comm.Rtype16, star, 1) + } + if drawCount == 10 { + this.ModuleRtask.SendToRtask(session, comm.Rtype90, 1) + } + this.ModuleRtask.SendToRtask(session, comm.Rtype89, drawCount) +} From 7f2db5b932f7efee80faa242ba2ec03f497194f9 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 3 Jan 2023 14:05:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=AF=E7=BA=BF=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_worldtask.json | 28 ++++++++++++++-------------- modules/user/module.go | 6 ++++-- modules/worldtask/api_finish.go | 10 +++++----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index b9f7bc50c..5ebd83749 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -2,7 +2,7 @@ { "key": 10100, "lock": 1, - "ontxe": 0, + "ontxe": 999999, "id_after": 10101, "group": 1, "des": 2, @@ -17,7 +17,7 @@ 1001 ], "completetask": 0, - "auto_accept": 1, + "auto_accept": 0, "overtips": 1, "reword": [ { @@ -1730,9 +1730,9 @@ }, { "key": 30001, - "lock": 999, + "lock": 1, "ontxe": 0, - "id_after": 0, + "id_after": 30002, "group": 101, "des": 3, "icon": "", @@ -1775,7 +1775,7 @@ { "key": 30003, "lock": 1, - "ontxe": 30001, + "ontxe": 0, "id_after": 0, "group": 101, "des": 3, @@ -1796,7 +1796,7 @@ }, { "key": 30004, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1818,7 +1818,7 @@ }, { "key": 30005, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1840,7 +1840,7 @@ }, { "key": 30006, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1856,13 +1856,13 @@ 300011 ], "completetask": 0, - "auto_accept": 1, + "auto_accept": 0, "overtips": 1, "reword": [] }, { "key": 30007, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1884,7 +1884,7 @@ }, { "key": 30008, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1906,7 +1906,7 @@ }, { "key": 30009, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1928,7 +1928,7 @@ }, { "key": 30010, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, @@ -1950,7 +1950,7 @@ }, { "key": 30011, - "lock": 999, + "lock": 1, "ontxe": 0, "id_after": 0, "group": 101, diff --git a/modules/user/module.go b/modules/user/module.go index 902c201ca..760ea61e1 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -165,8 +165,10 @@ func (this *User) CleanSession(session comm.IUserSession) { // 在线玩家列表 func (this *User) UserOnlineList() ([]*pb.CacheUser, error) { var cache []*pb.CacheUser - if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil { - return nil, err + if !this.IsCross() { + if err := this.modelSession.GetList(comm.RDS_EMPTY, &cache); err != nil { + return nil, err + } } return cache, nil } diff --git a/modules/worldtask/api_finish.go b/modules/worldtask/api_finish.go index c1d8a0978..f19e45a1b 100644 --- a/modules/worldtask/api_finish.go +++ b/modules/worldtask/api_finish.go @@ -50,7 +50,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe } // 判断玩家等级要求 - if user.Lv < curTaskConf.Lock { + if curTaskConf.Des == 2 && user.Lv < curTaskConf.Lock { code = pb.ErrorCode_WorldtaskLvNotEnough return } @@ -80,15 +80,14 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe hero = make([]string, 0) newhero = make([]string, 0) var nextTaskId int32 - nextTaskId = curTaskConf.IdAfter + finishRsp := func() { if err := session.SendMsg(string(this.module.GetType()), WorldtaskSubtypeFinish, rsp); err != nil { code = pb.ErrorCode_SystemError return } - - // 世界任务类型 - if curTaskConf.Des == 2 { + if curTaskConf.IdAfter != 0 { + nextTaskId = curTaskConf.IdAfter // 任务完成推送 if err := session.SendMsg(string(this.module.GetType()), WorldtaskNexttaskPush, &pb.WorldtaskNexttaskPush{ NextTaskId: nextTaskId, @@ -97,6 +96,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WorldtaskFinishRe return } } + } finishCall := func() {