抽卡权重

This commit is contained in:
meixiongfeng 2023-02-09 14:49:52 +08:00
parent 9410119d94
commit cb94f203a6
2 changed files with 14 additions and 14 deletions

View File

@ -90,7 +90,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
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
starIndex = star - 3
heroRecord.Inevitable = heroRecord.Drawcount
update["inevitable"] = heroRecord.Drawcount
szStar = append(szStar, star)
@ -106,7 +106,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
// 保底情况
if heroRecord.Drawcount == iEnd && heroRecord.Inevitable == 0 {
starIndex = star
starIndex = star - 3
heroRecord.Inevitable = heroRecord.Drawcount
update["inevitable"] = heroRecord.Drawcount
szStar = append(szStar, star)
@ -130,7 +130,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
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
starIndex = star - 3
heroRecord.Inevitable = heroRecord.Drawcount
update["inevitable1"] = heroRecord.Drawcount
szStar = append(szStar, star)
@ -151,7 +151,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
// 保底情况
if heroRecord.Drawcount == iEnd && heroRecord.Inevitable == 0 {
starIndex = star
starIndex = star - 3
heroRecord.Inevitable1 = heroRecord.Drawcount
update["inevitable1"] = heroRecord.Drawcount
szStar = append(szStar, star)
@ -173,28 +173,28 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
heroRecord.Star4++ // 4星保底数量+1
heroRecord.Star5++ // 5星保底数量+1
if starIndex == 4 {
if starIndex == 1 {
heroRecord.Star4 = 0
star4Max++
} else if starIndex == 5 {
} else if starIndex == 2 {
star5Max++
heroRecord.Star5 = 0
}
if star4Max >= cfgDraw.Draw10Star4Max || star5Max >= cfgDraw.Draw10Star5Max { // 达到10连抽最大(4,5星)数量 直接给三星
starIndex = 3
starIndex = 0
} else {
// 普通卡池保底
if cfgDraw.DrawFloorStar4 <= heroRecord.Star4 {
heroRecord.Star4 = 0
starIndex = 4
starIndex = 1
}
if cfgDraw.DrawFloorStar5 <= heroRecord.Star5 {
heroRecord.Star5 = 0
starIndex = 5
starIndex = 2
}
}
szStar = append(szStar, starIndex)
szStar = append(szStar, starIndex+3)
if len(szStar) >= int(req.DrawCount) {
break
}
@ -252,13 +252,13 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
starWeight := []int32{cfgDraw.CampPoolStar3, cfgDraw.CampPoolStar4, cfgDraw.CampPoolStar5}
starIndex := this.module.modelHero.GetRandW(starWeight)
if starIndex == 4 {
if starIndex == 1 {
star4Max++
} else if starIndex == 5 {
} else if starIndex == 2 {
star5Max++
}
if star4Max >= cfgDraw.Draw10Star4Max || star5Max >= cfgDraw.Draw10Star5Max {
starIndex = 3
starIndex = 0
}
szStar = append(szStar, starIndex)
if len(szStar) >= int(req.DrawCount) {

View File

@ -624,7 +624,7 @@ func (this *ModelHero) GetRandW(sz []int32) int32 {
for i, v := range sz {
_tmpW += int64(v)
if n.Int64() < _tmpW {
return int32(i) + 3
return int32(i)
}
}
}