diff --git a/src/core/web/headhunt.go b/src/core/web/headhunt.go index efa2e53..24aa2a1 100644 --- a/src/core/web/headhunt.go +++ b/src/core/web/headhunt.go @@ -5,12 +5,14 @@ import ( "arknights_bot/utils" "crypto/rand" "fmt" - "github.com/gin-gonic/gin" - "github.com/spf13/viper" "math/big" "net/http" "strconv" "strings" + "time" + + "github.com/gin-gonic/gin" + "github.com/spf13/viper" ) func Headhunt(r *gin.Engine) { @@ -29,20 +31,7 @@ func Headhunt(r *gin.Engine) { var operators []utils.Operator for i := 0; i < 10; i++ { var operator utils.Operator - name := "" - autoProb(&r6prob, &r5prob, &r4prob, &r3prob, ×) - allPro := r6prob + r5prob + r4prob + r3prob - rankRand := float64(getRandomInt(1, int64(allPro))) - if rankRand <= r6prob { - name = randChar(6) - reProb(&r6prob, &r5prob, &r4prob, &r3prob, ×) - } else if rankRand <= r6prob+r5prob { - name = randChar(5) - } else if rankRand <= r6prob+r5prob+r4prob { - name = randChar(4) - } else if rankRand <= r6prob+r5prob+r4prob+r3prob { - name = randChar(3) - } + name := genOpeName(&r6prob, &r5prob, &r4prob, &r3prob, ×) char := utils.GetOperatorByName(name) operator.Profession = char.Profession operator.Rarity = char.Rarity @@ -56,6 +45,32 @@ func Headhunt(r *gin.Engine) { }) } +// 生成干员 +func genOpeName(r6prob *float64, r5prob *float64, r4prob *float64, r3prob *float64, times *int) string { + name := "" + // 愚人节应设定为全3星 + now := time.Now() + _, month, day := now.Date() + if month == time.April && day == 1 { + name = randChar(3) + return name + } + autoProb(r6prob, r5prob, r4prob, r3prob, times) + allPro := *r6prob + *r5prob + *r4prob + *r3prob + rankRand := float64(getRandomInt(1, int64(allPro))) + if rankRand <= *r6prob { + name = randChar(6) + reProb(r6prob, r5prob, r4prob, r3prob, times) + } else if rankRand <= *r6prob+*r5prob { + name = randChar(5) + } else if rankRand <= *r6prob+*r5prob+*r4prob { + name = randChar(4) + } else { + name = randChar(3) + } + return name +} + // 自动调整6星概率 func autoProb(r6prob, r5prob, r4prob, r3prob *float64, times *int) { if *times > 50 {