From afc2468ef609587013d51b4f7305b1057a581470 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Mon, 15 Aug 2022 17:37:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_com.json | 29 +++++++++- modules/hero/api_drawCard.go | 72 +++++++++++++++++------- modules/items/module.go | 2 +- sys/configure/structs/game.comData.go | 14 +++++ sys/configure/structs/game.globalData.go | 14 +++++ 5 files changed, 110 insertions(+), 21 deletions(-) diff --git a/bin/json/game_com.json b/bin/json/game_com.json index 00f11b087..26ae44012 100644 --- a/bin/json/game_com.json +++ b/bin/json/game_com.json @@ -79,6 +79,31 @@ "t": "10005", "n": 1 }, + "base_pool_10cost": { + "a": "item", + "t": "10001", + "n": 10 + }, + "camp1_pool_10cost": { + "a": "item", + "t": "10002", + "n": 10 + }, + "camp2_pool_10cost": { + "a": "item", + "t": "10003", + "n": 10 + }, + "camp3_pool_10cost": { + "a": "item", + "t": "10004", + "n": 10 + }, + "camp4_pool_10cost": { + "a": "item", + "t": "10005", + "n": 10 + }, "camp1_pool1": "camp1_pool", "camp2_pool1": "camp2_pool", "camp3_pool1": "camp3_pool", @@ -109,6 +134,8 @@ "camp_pool_star3": 9000, "camp_pool_star4": 900, "camp_pool_star5": 100, - "gourmet": 500 + "gourmet": 500, + "smithy_maxplayer": 20, + "smithy_maxtime": 36000 } ] \ No newline at end of file diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index 86873bdfc..f3e330076 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -9,7 +9,7 @@ import ( ) func (this *apiComp) DrawCardCheck(session comm.IUserSession, req *pb.HeroDrawCardReq) (code pb.ErrorCode) { - if req.DrawType < 0 { // 只能是单抽或10抽 + if req.DrawType < 0 && (req.DrawCount == 1 || req.DrawCount == 10) { // 只能是单抽或10抽 code = pb.ErrorCode_ReqParameterError } return @@ -39,19 +39,24 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq szCards = make([]string, 0) rsp := &pb.HeroDrawCardResp{} cfg := cfgDraw - costAtn = cfgDraw.BasePoolCost + heroRecord, _ = this.module.modelRecord.GetHeroRecord(session.GetUserId()) drawCount = heroRecord.Drawcount pool = this.module.modelHero.CheckPool(drawCount, cfg) if req.DrawType == 0 { // 普通卡池抽卡 // 获取普通抽卡池 + if req.DrawCount == 1 { + costAtn = cfgDraw.BasePoolCost + } else { + costAtn = cfgDraw.BasePool10cost + } costRes = append(costRes, costAtn) code = this.module.CheckRes(session, costRes) if code != pb.ErrorCode_Success { // 消耗数量不足直接返回 return } - for { + for i := 0; i < int(req.DrawCount); i++ { sz := make([]int32, 0) if cfgDraw.BasePoolStar3 != 0 { sz = append(sz, cfgDraw.BasePoolStar3) @@ -64,25 +69,56 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq sz = append(sz, cfgDraw.BasePoolStar5) } - + starIndex := this.module.modelHero.GetRandW(sz) + if starIndex == 1 { + star4Max++ + } else if starIndex == 2 { + star5Max++ + } + if star4Max >= cfgDraw.Draw10Star4Max || star5Max >= cfgDraw.Draw10Star5Max { + starIndex = 0 + } + szStar = append(szStar, starIndex+3) + if len(szStar) >= int(req.DrawCount) { + break + } } } else { // 所有阵营抽卡都走这里 + if req.DrawCount == 1 { + switch req.DrawType { + case 1: + pool = cfg.Camp1Pool1 + costAtn = cfgDraw.Camp1PoolCost - switch req.DrawType { - case 1: - pool = cfg.Camp1Pool1 + case 2: + pool = cfg.Camp2Pool1 + costAtn = cfgDraw.Camp2PoolCost + case 3: + pool = cfg.Camp3Pool1 + costAtn = cfgDraw.Camp3PoolCost + case 4: + pool = cfg.Camp4Pool1 + costAtn = cfgDraw.Camp4PoolCost + } + } else { costAtn = cfgDraw.Camp1PoolCost + switch req.DrawType { + case 1: + pool = cfg.Camp1Pool1 + costAtn = cfgDraw.Camp1Pool10cost - case 2: - pool = cfg.Camp2Pool1 - costAtn = cfgDraw.Camp2PoolCost - case 3: - pool = cfg.Camp3Pool1 - costAtn = cfgDraw.Camp3PoolCost - case 4: - pool = cfg.Camp4Pool1 - costAtn = cfgDraw.Camp4PoolCost + case 2: + pool = cfg.Camp2Pool1 + costAtn = cfgDraw.Camp2Pool10cost + case 3: + pool = cfg.Camp3Pool1 + costAtn = cfgDraw.Camp3Pool10cost + case 4: + pool = cfg.Camp4Pool1 + costAtn = cfgDraw.Camp4Pool10cost + } } + costAtn.N *= req.DrawCount costRes = append(costRes, costAtn) @@ -94,11 +130,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq for { sz := make([]int32, 0) if cfgDraw.CampPoolStar3 != 0 { - sz = append(sz, cfgDraw.CampPoolStar3) + sz = append(sz, cfgDraw.CampPoolStar3) // 3 4 5 性权重 } if cfgDraw.CampPoolStar4 != 0 { sz = append(sz, cfgDraw.CampPoolStar4) - } if cfgDraw.CampPoolStar5 != 0 { sz = append(sz, cfgDraw.CampPoolStar5) @@ -118,7 +153,6 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq break } } - } _data := this.module.configure.GetPollByType(pool) if _data == nil { diff --git a/modules/items/module.go b/modules/items/module.go index 8be1a3d08..b62df821c 100644 --- a/modules/items/module.go +++ b/modules/items/module.go @@ -61,7 +61,7 @@ func (this *Items) EventUserOffline(session comm.IUserSession) { //IItems------------------------------------------------------------------------------------------------------------------------------- ///查询用户背包物品数量 func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid string) (amount uint32) { - defer this.Debugf("获取物品 uId:%s itemid:%d addnum:%d ", uId, itemid, amount) + defer this.Debugf("获取物品 uId:%s itemid:%s addnum:%d ", uId, itemid, amount) amount = 0 if result := this.modelItems.QueryUserPackItemsAmount(uId, itemid); result != nil && len(result) > 0 { return result[itemid] diff --git a/sys/configure/structs/game.comData.go b/sys/configure/structs/game.comData.go index 9d340aa9b..746ed7f86 100644 --- a/sys/configure/structs/game.comData.go +++ b/sys/configure/structs/game.comData.go @@ -49,6 +49,11 @@ type GamecomData struct { Camp2PoolCost *Gameatn Camp3PoolCost *Gameatn Camp4PoolCost *Gameatn + BasePool10cost *Gameatn + Camp1Pool10cost *Gameatn + Camp2Pool10cost *Gameatn + Camp3Pool10cost *Gameatn + Camp4Pool10cost *Gameatn Camp1Pool1 string Camp2Pool1 string Camp3Pool1 string @@ -64,6 +69,8 @@ type GamecomData struct { CampPoolStar4 int32 CampPoolStar5 int32 Gourmet int32 + SmithyMaxplayer int32 + SmithyMaxtime int32 } const TypeId_GamecomData = -395344177 @@ -176,6 +183,11 @@ func (_v *GamecomData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp2_pool_cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp2_pool_cost error"); return }; if _v.Camp2PoolCost, err = DeserializeGameatn(_x_); err != nil { return } } { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp3_pool_cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp3_pool_cost error"); return }; if _v.Camp3PoolCost, err = DeserializeGameatn(_x_); err != nil { return } } { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp4_pool_cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp4_pool_cost error"); return }; if _v.Camp4PoolCost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["base_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("base_pool_10cost error"); return }; if _v.BasePool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp1_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp1_pool_10cost error"); return }; if _v.Camp1Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp2_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp2_pool_10cost error"); return }; if _v.Camp2Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp3_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp3_pool_10cost error"); return }; if _v.Camp3Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp4_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp4_pool_10cost error"); return }; if _v.Camp4Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } { var _ok_ bool; if _v.Camp1Pool1, _ok_ = _buf["camp1_pool1"].(string); !_ok_ { err = errors.New("camp1_pool1 error"); return } } { var _ok_ bool; if _v.Camp2Pool1, _ok_ = _buf["camp2_pool1"].(string); !_ok_ { err = errors.New("camp2_pool1 error"); return } } { var _ok_ bool; if _v.Camp3Pool1, _ok_ = _buf["camp3_pool1"].(string); !_ok_ { err = errors.New("camp3_pool1 error"); return } } @@ -191,6 +203,8 @@ func (_v *GamecomData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["camp_pool_star4"].(float64); !_ok_ { err = errors.New("camp_pool_star4 error"); return }; _v.CampPoolStar4 = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["camp_pool_star5"].(float64); !_ok_ { err = errors.New("camp_pool_star5 error"); return }; _v.CampPoolStar5 = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["gourmet"].(float64); !_ok_ { err = errors.New("gourmet error"); return }; _v.Gourmet = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["smithy_maxplayer"].(float64); !_ok_ { err = errors.New("smithy_maxplayer error"); return }; _v.SmithyMaxplayer = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["smithy_maxtime"].(float64); !_ok_ { err = errors.New("smithy_maxtime error"); return }; _v.SmithyMaxtime = int32(_tempNum_) } return } diff --git a/sys/configure/structs/game.globalData.go b/sys/configure/structs/game.globalData.go index 6bb58126e..27d2ddb76 100644 --- a/sys/configure/structs/game.globalData.go +++ b/sys/configure/structs/game.globalData.go @@ -49,6 +49,11 @@ type GameglobalData struct { Camp2PoolCost *Gameatn Camp3PoolCost *Gameatn Camp4PoolCost *Gameatn + BasePool10cost *Gameatn + Camp1Pool10cost *Gameatn + Camp2Pool10cost *Gameatn + Camp3Pool10cost *Gameatn + Camp4Pool10cost *Gameatn Camp1Pool1 string Camp2Pool1 string Camp3Pool1 string @@ -64,6 +69,8 @@ type GameglobalData struct { CampPoolStar4 int32 CampPoolStar5 int32 Gourmet int32 + SmithyMaxplayer int32 + SmithyMaxtime int32 } const TypeId_GameglobalData = -518904471 @@ -176,6 +183,11 @@ func (_v *GameglobalData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp2_pool_cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp2_pool_cost error"); return }; if _v.Camp2PoolCost, err = DeserializeGameatn(_x_); err != nil { return } } { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp3_pool_cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp3_pool_cost error"); return }; if _v.Camp3PoolCost, err = DeserializeGameatn(_x_); err != nil { return } } { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp4_pool_cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp4_pool_cost error"); return }; if _v.Camp4PoolCost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["base_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("base_pool_10cost error"); return }; if _v.BasePool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp1_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp1_pool_10cost error"); return }; if _v.Camp1Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp2_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp2_pool_10cost error"); return }; if _v.Camp2Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp3_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp3_pool_10cost error"); return }; if _v.Camp3Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } + { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["camp4_pool_10cost"].(map[string]interface{}); !_ok_ { err = errors.New("camp4_pool_10cost error"); return }; if _v.Camp4Pool10cost, err = DeserializeGameatn(_x_); err != nil { return } } { var _ok_ bool; if _v.Camp1Pool1, _ok_ = _buf["camp1_pool1"].(string); !_ok_ { err = errors.New("camp1_pool1 error"); return } } { var _ok_ bool; if _v.Camp2Pool1, _ok_ = _buf["camp2_pool1"].(string); !_ok_ { err = errors.New("camp2_pool1 error"); return } } { var _ok_ bool; if _v.Camp3Pool1, _ok_ = _buf["camp3_pool1"].(string); !_ok_ { err = errors.New("camp3_pool1 error"); return } } @@ -191,6 +203,8 @@ func (_v *GameglobalData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["camp_pool_star4"].(float64); !_ok_ { err = errors.New("camp_pool_star4 error"); return }; _v.CampPoolStar4 = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["camp_pool_star5"].(float64); !_ok_ { err = errors.New("camp_pool_star5 error"); return }; _v.CampPoolStar5 = int32(_tempNum_) } { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["gourmet"].(float64); !_ok_ { err = errors.New("gourmet error"); return }; _v.Gourmet = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["smithy_maxplayer"].(float64); !_ok_ { err = errors.New("smithy_maxplayer error"); return }; _v.SmithyMaxplayer = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["smithy_maxtime"].(float64); !_ok_ { err = errors.New("smithy_maxtime error"); return }; _v.SmithyMaxtime = int32(_tempNum_) } return }