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"
|
||||
)
|
||||
|
||||
// ReliquaryAffixData 圣遗物追加属性配置表
|
||||
@@ -46,35 +45,6 @@ func GetReliquaryAffixDataByDepotIdAndPropId(appendPropDepotId int32, appendProp
|
||||
return value[appendPropId]
|
||||
}
|
||||
|
||||
func GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32, excludeTypeList ...uint32) *ReliquaryAffixData {
|
||||
appendPropMap, exist := CONF.ReliquaryAffixDataMap[appendPropDepotId]
|
||||
if !exist {
|
||||
return nil
|
||||
}
|
||||
choices := make([]weightedrand.Choice, 0, len(appendPropMap))
|
||||
for _, data := range appendPropMap {
|
||||
isBoth := false
|
||||
// 排除列表中的属性类型是否相同
|
||||
for _, propType := range excludeTypeList {
|
||||
if propType == uint32(data.PropType) {
|
||||
isBoth = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if isBoth {
|
||||
continue
|
||||
}
|
||||
choices = append(choices, weightedrand.NewChoice(data, uint(data.RandomWeight)))
|
||||
}
|
||||
chooser, err := weightedrand.NewChooser(choices...)
|
||||
if err != nil {
|
||||
logger.Error("reliquary append random error: %v", err)
|
||||
return nil
|
||||
}
|
||||
result := chooser.Pick()
|
||||
return result.(*ReliquaryAffixData)
|
||||
}
|
||||
|
||||
func GetReliquaryAffixDataMap() map[int32]map[int32]*ReliquaryAffixData {
|
||||
return CONF.ReliquaryAffixDataMap
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user