Commit b58b5b49bc6561f7678c2087fd1b26181e24ad70
1 parent
b8eb016b
零件bug
Showing
2 changed files
with
13 additions
and
18 deletions
Show diff stats
src/models/HeroPlugin.lua
@@ -154,7 +154,7 @@ function HeroPlugin.bind(Hero) | @@ -154,7 +154,7 @@ function HeroPlugin.bind(Hero) | ||
154 | local rune = self.owner.runeBag[uid] | 154 | local rune = self.owner.runeBag[uid] |
155 | local buildData = csvdb["rune_buildCsv"][rune:getProperty("level")] | 155 | local buildData = csvdb["rune_buildCsv"][rune:getProperty("level")] |
156 | for k,v in pairs(rune:getProperty("attrs"):toNumMap()) do | 156 | for k,v in pairs(rune:getProperty("attrs"):toNumMap()) do |
157 | - attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + (v * (1 + buildData.effect/100)) | 157 | + attrs.value[AttsEnumEx[k]] = attrs.value[AttsEnumEx[k]] + (v / 10 * (1 + buildData.effect/100)) -- 零件的加成属性有特殊需求 填的是 10倍的值 |
158 | 158 | ||
159 | end | 159 | end |
160 | local csvData = csvdb["runeCsv"][rune:getProperty("type")][rune:getProperty("id")] | 160 | local csvData = csvdb["runeCsv"][rune:getProperty("type")][rune:getProperty("id")] |
src/models/Rune.lua
@@ -53,34 +53,29 @@ end | @@ -53,34 +53,29 @@ end | ||
53 | local function getRandomValue(types,values) | 53 | local function getRandomValue(types,values) |
54 | local typeMap = types:toNumMap() | 54 | local typeMap = types:toNumMap() |
55 | local valueArry = values:toArray() | 55 | local valueArry = values:toArray() |
56 | + | ||
56 | if table.nums(typeMap) ~= #valueArry then return nil end | 57 | if table.nums(typeMap) ~= #valueArry then return nil end |
57 | - local typ,value | ||
58 | - local typTab,weightSum = {},0 | 58 | + local typ, value |
59 | + local typTab = {} | ||
59 | for t,w in pairs(typeMap) do | 60 | for t,w in pairs(typeMap) do |
60 | - weightSum = weightSum + w | ||
61 | - table.insert(typTab,{t=t,w=weightSum}) | 61 | + table.insert(typTab,{t=t,w=w}) |
62 | end | 62 | end |
63 | 63 | ||
64 | - local tk | ||
65 | - local tmp = math.random(1,weightSum) | ||
66 | - for k,v in ipairs(typTab) do | ||
67 | - if v.w >= tmp then | ||
68 | - typ = v.t | ||
69 | - tk = k | ||
70 | - break | ||
71 | - end | ||
72 | - end | 64 | + local tk = math.randWeight(typTab, "w") |
65 | + typ = typTab[tk]["t"] | ||
73 | 66 | ||
74 | local range = valueArry[tk]:toArray(true,"=") | 67 | local range = valueArry[tk]:toArray(true,"=") |
75 | - value = math.random(range[1],range[2]) | ||
76 | - return typ,value | 68 | + value = math.randomInt(range[1],range[2]) |
69 | + return typ, value | ||
77 | end | 70 | end |
78 | 71 | ||
79 | function Rune:generateAttrs() | 72 | function Rune:generateAttrs() |
80 | local runeData = csvdb["runeCsv"][self:getProperty("type")][self:getProperty("id")] | 73 | local runeData = csvdb["runeCsv"][self:getProperty("type")][self:getProperty("id")] |
81 | local attrs = "" | 74 | local attrs = "" |
82 | - attrs = attrs:setv(getRandomValue(runeData.attr1,runeData.range1)) | ||
83 | - attrs = attrs:setv(getRandomValue(runeData.attr2,runeData.range2)) | 75 | + local typ, value = getRandomValue(runeData.attr1,runeData.range1) |
76 | + attrs = attrs:setv(typ, value) | ||
77 | + local typ, value = getRandomValue(runeData.attr1,runeData.range1) | ||
78 | + attrs = attrs:setv(typ, value) | ||
84 | self:setProperty("attrs",attrs) | 79 | self:setProperty("attrs",attrs) |
85 | end | 80 | end |
86 | 81 |