mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-03-01 00:35:36 +08:00
优化代码
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"hk4e/pkg/logger"
|
||||
|
||||
"github.com/jszwec/csvutil"
|
||||
"github.com/mroth/weightedrand"
|
||||
)
|
||||
|
||||
// ReliquaryMainData 圣遗物主属性配置表
|
||||
@@ -46,24 +45,6 @@ func GetReliquaryMainDataByDepotIdAndPropId(mainPropDepotId int32, mainPropId in
|
||||
return value[mainPropId]
|
||||
}
|
||||
|
||||
func GetReliquaryMainDataRandomByDepotId(mainPropDepotId int32) *ReliquaryMainData {
|
||||
mainPropMap, exist := CONF.ReliquaryMainDataMap[mainPropDepotId]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
choices := make([]weightedrand.Choice, 0, len(mainPropMap))
|
||||
for _, data := range mainPropMap {
|
||||
choices = append(choices, weightedrand.NewChoice(data, uint(data.RandomWeight)))
|
||||
}
|
||||
chooser, err := weightedrand.NewChooser(choices...)
|
||||
if err != nil {
|
||||
logger.Error("reliquary main random error: %v", err)
|
||||
return nil
|
||||
}
|
||||
result := chooser.Pick()
|
||||
return result.(*ReliquaryMainData)
|
||||
}
|
||||
|
||||
func GetReliquaryMainDataMap() map[int32]map[int32]*ReliquaryMainData {
|
||||
return CONF.ReliquaryMainDataMap
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user