package data import ( "f1-game/internal/extend/rand" ) var ( monsterPoolWeightMap map[int32]*rand.Weight[*MonsterPoolRow] ) func (p *monsterPoolConfig) OnAfterLoad(_ bool) { loadMap := map[int32]*rand.Weight[*MonsterPoolRow]{} for poolID, rows := range p.poolIDGroupIDUniMaps { weight := rand.NewMapWeight(rows, func(v *MonsterPoolRow) int32 { return v.Weight }) loadMap[poolID] = weight } monsterPoolWeightMap = loadMap } func (p *monsterPoolConfig) RandIDList(poolID int32, num int) []int32 { weighter, ok := monsterPoolWeightMap[poolID] if !ok { return nil } rows := weighter.Select(num) if len(rows) == 0 { return nil } ids := make([]int32, len(rows)) for i, row := range rows { ids[i] = row.GroupID } return ids }