随机方法修改

This commit is contained in:
meixiongfeng 2023-12-30 11:18:14 +08:00
parent 4dd7f0f4ee
commit 78758b33c9

View File

@ -1,6 +1,7 @@
package equipment package equipment
import ( import (
"crypto/rand"
"fmt" "fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
@ -10,8 +11,7 @@ import (
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"math" "math"
"math/rand" "math/big"
"time"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
) )
@ -622,8 +622,10 @@ func (this *Equipment) GetForgeEquip(session comm.IUserSession, suiteId int32, p
} }
return return
} }
r := rand.New(rand.NewSource(time.Now().Unix())) // 随机方法修改
index := r.Perm(len(lvs))[0] n, _ := rand.Int(rand.Reader, big.NewInt(int64(len(lvs))))
index := n.Int64() //rand.New(rand.NewSource(time.Now().Unix()))
//index := r.Perm(len(lvs))[0]
if eruip, err = this.modelEquipment.newEquipment(session.GetUserId(), lvs[index], dyweight, isepic); err == nil { if eruip, err = this.modelEquipment.newEquipment(session.GetUserId(), lvs[index], dyweight, isepic); err == nil {
errdata = this.AddEquipment(session, eruip) errdata = this.AddEquipment(session, eruip)
// this.equipmentsChangePush(session, []*pb.DB_Equipment{eruip}) // this.equipmentsChangePush(session, []*pb.DB_Equipment{eruip})