| | |
| | |
|
| | | ## 从列表中产生物品,[[权重, object], ....]
|
| | | # @param weightList 待选列表
|
| | | def GetResultByWeightList(weightList):
|
| | | def GetResultByWeightList(weightList, defValue=None):
|
| | | randList = []
|
| | | weight = 0
|
| | | for info in weightList:
|
| | | weight += info[0]
|
| | | randList.append([weight, info[1] if len(info) == 2 else info[1:]])
|
| | | if not randList:
|
| | | return
|
| | | return defValue
|
| | | rate = random.randint(1, randList[-1][0])
|
| | | return GetResultByRiseList(randList, rate)
|
| | | return GetResultByRiseList(randList, rate, defValue)
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
|