mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
圣遗物追加词条优化
This commit is contained in:
@@ -46,13 +46,24 @@ func GetReliquaryAffixDataByDepotIdAndPropId(appendPropDepotId int32, appendProp
|
|||||||
return value[appendPropId]
|
return value[appendPropId]
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32) *ReliquaryAffixData {
|
func GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32, excludeTypeList ...uint32) *ReliquaryAffixData {
|
||||||
appendPropMap, exist := CONF.ReliquaryAffixDataMap[appendPropDepotId]
|
appendPropMap, exist := CONF.ReliquaryAffixDataMap[appendPropDepotId]
|
||||||
if !exist {
|
if !exist {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
choices := make([]weightedrand.Choice, 0, len(appendPropMap))
|
choices := make([]weightedrand.Choice, 0, len(appendPropMap))
|
||||||
for _, data := range 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)))
|
choices = append(choices, weightedrand.NewChoice(data, uint(data.RandomWeight)))
|
||||||
}
|
}
|
||||||
chooser, err := weightedrand.NewChooser(choices...)
|
chooser, err := weightedrand.NewChooser(choices...)
|
||||||
|
|||||||
@@ -74,44 +74,25 @@ func (g *GameManager) AppendReliquaryProp(reliquary *model.Reliquary, count int3
|
|||||||
}
|
}
|
||||||
// 圣遗物追加属性的次数
|
// 圣遗物追加属性的次数
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
|
// 要排除的属性类型
|
||||||
|
excludeTypeList := make([]uint32, 0, len(reliquary.AppendPropIdList)+1)
|
||||||
|
// 排除主属性
|
||||||
|
excludeTypeList = append(excludeTypeList, uint32(reliquaryMainConfig.PropType))
|
||||||
|
// 排除追加的属性
|
||||||
|
for _, propId := range reliquary.AppendPropIdList {
|
||||||
|
targetAffixConfig := gdconf.GetReliquaryAffixDataByDepotIdAndPropId(reliquaryConfig.AppendPropDepotId, int32(propId))
|
||||||
|
if targetAffixConfig == nil {
|
||||||
|
logger.Error("target affix config error, propId: %v", propId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
excludeTypeList = append(excludeTypeList, uint32(targetAffixConfig.PropType))
|
||||||
|
}
|
||||||
// 将要添加的属性
|
// 将要添加的属性
|
||||||
appendAffixConfig := gdconf.GetReliquaryAffixDataRandomByDepotId(reliquaryConfig.AppendPropDepotId)
|
appendAffixConfig := gdconf.GetReliquaryAffixDataRandomByDepotId(reliquaryConfig.AppendPropDepotId, excludeTypeList...)
|
||||||
if appendAffixConfig == nil {
|
if appendAffixConfig == nil {
|
||||||
logger.Error("append affix config error, appendPropDepotId: %v", reliquaryConfig.AppendPropDepotId)
|
logger.Error("append affix config error, appendPropDepotId: %v", reliquaryConfig.AppendPropDepotId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
isNotBoth := false
|
|
||||||
// 如果圣遗物词条为0就直接加不用校验是否相同
|
|
||||||
for len(reliquary.AppendPropIdList) > 0 {
|
|
||||||
if isNotBoth {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
// 追加的属性类型不能相同
|
|
||||||
for i, propId := range reliquary.AppendPropIdList {
|
|
||||||
targetAffixConfig := gdconf.GetReliquaryAffixDataByDepotIdAndPropId(reliquaryConfig.AppendPropDepotId, int32(propId))
|
|
||||||
if targetAffixConfig == nil {
|
|
||||||
logger.Error("target affix config error, propId: %v", propId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 如果类型相同则重新随机获取一个属性
|
|
||||||
// 追加的属性还不能和主属性相同
|
|
||||||
if appendAffixConfig.PropType == targetAffixConfig.PropType || appendAffixConfig.PropType == reliquaryMainConfig.PropType {
|
|
||||||
reliquaryAffixConfig := gdconf.GetReliquaryAffixDataRandomByDepotId(reliquaryConfig.AppendPropDepotId)
|
|
||||||
if reliquaryAffixConfig == nil {
|
|
||||||
logger.Error("reliquary affix config error, appendPropDepotId: %v", reliquaryConfig.AppendPropDepotId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 将属性赋值并重新查找
|
|
||||||
appendAffixConfig = reliquaryAffixConfig
|
|
||||||
break
|
|
||||||
}
|
|
||||||
// 如果循环到最后一个还不匹配那就是没有相同的了
|
|
||||||
if i == len(reliquary.AppendPropIdList)-1 {
|
|
||||||
isNotBoth = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 圣遗物添加词条
|
// 圣遗物添加词条
|
||||||
reliquary.AppendPropIdList = append(reliquary.AppendPropIdList, uint32(appendAffixConfig.AppendPropId))
|
reliquary.AppendPropIdList = append(reliquary.AppendPropIdList, uint32(appendAffixConfig.AppendPropId))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user