Merge branches 'dev' and 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev

This commit is contained in:
meixiongfeng 2022-08-01 17:11:05 +08:00
commit 1d942d918f
3 changed files with 41 additions and 44 deletions

View File

@ -1,157 +1,157 @@
[
{
"key": 1,
"id": "10001",
"id": "13001",
"type_id": 1,
"weight": 1000
},
{
"key": 2,
"id": "10002",
"id": "13002",
"type_id": 1,
"weight": 1000
},
{
"key": 3,
"id": "10003",
"id": "13003",
"type_id": 1,
"weight": 1000
},
{
"key": 4,
"id": "10004",
"id": "13004",
"type_id": 1,
"weight": 1000
},
{
"key": 5,
"id": "10005",
"id": "13005",
"type_id": 1,
"weight": 1000
},
{
"key": 6,
"id": "10006",
"id": "14001",
"type_id": 1,
"weight": 1000
},
{
"key": 7,
"id": "10007",
"id": "14002",
"type_id": 1,
"weight": 1000
},
{
"key": 8,
"id": "10008",
"id": "14003",
"type_id": 1,
"weight": 1000
},
{
"key": 9,
"id": "10009",
"id": "14004",
"type_id": 1,
"weight": 1000
},
{
"key": 10,
"id": "10010",
"id": "14005",
"type_id": 1,
"weight": 1000
},
{
"key": 11,
"id": "10011",
"id": "14006",
"type_id": 1,
"weight": 1000
},
{
"key": 12,
"id": "10012",
"id": "14007",
"type_id": 1,
"weight": 1000
},
{
"key": 13,
"id": "10013",
"id": "15001",
"type_id": 1,
"weight": 1000
},
{
"key": 14,
"id": "10014",
"id": "15002",
"type_id": 1,
"weight": 1000
},
{
"key": 15,
"id": "10015",
"id": "15003",
"type_id": 1,
"weight": 1000
},
{
"key": 16,
"id": "10016",
"id": "15004",
"type_id": 1,
"weight": 1000
},
{
"key": 17,
"id": "10017",
"id": "23001",
"type_id": 1,
"weight": 1000
},
{
"key": 18,
"id": "10018",
"id": "23002",
"type_id": 1,
"weight": 1000
},
{
"key": 19,
"id": "10019",
"id": "23003",
"type_id": 1,
"weight": 1000
},
{
"key": 20,
"id": "10020",
"id": "23004",
"type_id": 1,
"weight": 1000
},
{
"key": 21,
"id": "10001",
"id": "24001",
"type_id": 2,
"weight": 1000
},
{
"key": 22,
"id": "10002",
"id": "24002",
"type_id": 2,
"weight": 1000
},
{
"key": 23,
"id": "10001",
"id": "24003",
"type_id": 11,
"weight": 1000
},
{
"key": 24,
"id": "10002",
"id": "24004",
"type_id": 11,
"weight": 1000
},
{
"key": 25,
"id": "10003",
"id": "24005",
"type_id": 11,
"weight": 1000
},
{
"key": 26,
"id": "10004",
"id": "24006",
"type_id": 11,
"weight": 1000
},

View File

@ -35,6 +35,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
upDraw []*cfg.Game_drawUpdrawData // 活动数据 英雄抽卡权重增加
cardW map[string]int32 // 当前卡牌卡池卡牌对应的权重
)
cardW = make(map[string]int32, 0)
upDraw = make([]*cfg.Game_drawUpdrawData, 0)
szCards = make([]string, 0)
rsp := &pb.HeroDrawCardResp{}
@ -96,6 +97,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
// 权重赋值
for _, v := range _conf {
cardW[v.Id] += v.Weight
totalWeight += int64(cardW[v.Id])
}
_costConf, err := this.module.configure.GetDrawCostConfigByID(req.DrawType) // 抽卡消耗
@ -120,28 +122,26 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
drawTimes = _costConf.Count // 抽卡次数
drawTimes = 1
for i := 0; i < int(drawTimes); i++ {
n, _ := rand.Int(rand.Reader, big.NewInt(totalWeight)) // [0,totalWeight)
curWeigth = 0
for k, v := range cardW {
curWeigth += int64(v)
if curWeigth < n.Int64() { // 命中
// 获取当前星级
_getCardCfg := this.module.configure.GetHero(k) //获取的英雄信息
if _getCardCfg != nil {
continue
}
if _getCardCfg.Star == 4 { // 当抽取到的英雄是4星的时候 清除 该类型的保底次数
curStar4Count = 0
continue
} else if _getCardCfg.Star == 5 { // 当抽取到的英雄是5星的时候 清除 该类型的保底次数
curStar5Count = 0 // 清0
if _getCardCfg == nil {
continue
}
curStar4Count++
curStar5Count++
bGet := false
if _getCardCfg.Star == 4 { // 当抽取到的英雄是4星的时候 清除 该类型的保底次数
curStar4Count = 0
} else if _getCardCfg.Star == 5 { // 当抽取到的英雄是5星的时候 清除 该类型的保底次数
curStar5Count = 0 // 清0
}
// 达标保底次数
if curStar4Count >= config4Count {
//_costConf.Floor4cards
@ -158,7 +158,6 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
_tmpW += int64(v.Weight)
if n.Int64() > _tmpW { // 种族保底卡池命中
szCards = append(szCards, v.Id)
bGet = true
break
}
}
@ -177,15 +176,13 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
_tmpW += int64(v.Weight)
if n.Int64() > _tmpW { // 种族保底卡池命中
szCards = append(szCards, v.Id)
bGet = true
break
}
}
}
}
if !bGet {
szCards = append(szCards, k)
}
szCards = append(szCards, k)
break
}
}
}

View File

@ -165,7 +165,7 @@ func (this *ModuleBase) CheckRes(session comm.IUserSession, res []*cfg.Game_atn)
// code = pb.ErrorCode_ConfigurationException
// return
// }
if amount = int32(this.ModuleItems.QueryItemAmount(source, session.GetSessionId(), v.T)); amount < v.N {
if amount = int32(this.ModuleItems.QueryItemAmount(source, session.GetUserId(), v.T)); amount < v.N {
code = pb.ErrorCode_ResNoEnough
this.Errorf("道具不足:A:%s,T:%s,N:%d", v.A, v.T, v.N)
return
@ -199,7 +199,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Game_at
// code = pb.ErrorCode_ConfigurationException
// return
// }
if amount = int32(this.ModuleItems.QueryItemAmount(source, session.GetSessionId(), v.T)); amount < v.N {
if amount = int32(this.ModuleItems.QueryItemAmount(source, session.GetUserId(), v.T)); amount < v.N {
code = pb.ErrorCode_ResNoEnough
this.Errorf("道具不足:A:%s,T:%s,N:%d", v.A, v.T, v.N)
return