From 795b3e79f5d52aacb731e228e17b0fa9bb81ba27 Mon Sep 17 00:00:00 2001 From: UnKownOwO <80520429@qq.com> Date: Sun, 19 Feb 2023 16:44:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A3=E9=81=97=E7=89=A9=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E8=AF=8D=E6=9D=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gdconf/reliquary_affix_data.go | 13 +++++++++- gs/game/player_reliquary.go | 47 ++++++++++------------------------ 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/gdconf/reliquary_affix_data.go b/gdconf/reliquary_affix_data.go index dbbc09f0..d139825e 100644 --- a/gdconf/reliquary_affix_data.go +++ b/gdconf/reliquary_affix_data.go @@ -46,13 +46,24 @@ func GetReliquaryAffixDataByDepotIdAndPropId(appendPropDepotId int32, appendProp return value[appendPropId] } -func GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32) *ReliquaryAffixData { +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...) diff --git a/gs/game/player_reliquary.go b/gs/game/player_reliquary.go index bd74435a..47db032b 100644 --- a/gs/game/player_reliquary.go +++ b/gs/game/player_reliquary.go @@ -74,44 +74,25 @@ func (g *GameManager) AppendReliquaryProp(reliquary *model.Reliquary, count int3 } // 圣遗物追加属性的次数 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 { logger.Error("append affix config error, appendPropDepotId: %v", reliquaryConfig.AppendPropDepotId) 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)) }