Commit e28973d531f1f6a6ee42d979a3ece6da0587bd4a
1 parent
aca85b6f
fix: 额外宝藏 删除藏宝图字段treasureMapCount,用道具itemId=861作为藏宝图
Showing
5 changed files
with
18 additions
and
19 deletions
Show diff stats
src/GlobalVar.lua
src/actions/GmAction.lua
... | ... | @@ -1191,22 +1191,21 @@ end |
1191 | 1191 | table.insert(helpDes, {"抓取额外宝藏", "treasure_extra"}) |
1192 | 1192 | function _M.treasure_extra(role, pms) |
1193 | 1193 | local extraCount = role.dailyData:getProperty("treasureExtraCount") --每日发现额外宝藏使用次数(累计),隔天清零 |
1194 | - local mapCount = role.dailyData:getProperty("treasureMapCount") | |
1195 | 1194 | local baseExtra = role.dailyData:getProperty("treasureBaseExtra") |
1196 | 1195 | |
1197 | 1196 | if extraCount >= globalCsv.idle_treasure_extra_limie then return 1 end |
1198 | - if mapCount <= 0 then return 2 end | |
1199 | 1197 | |
1200 | - baseExtra = baseExtra + globalCsv.idle_treasure_base_extra | |
1198 | + local cost ={[ItemId.TreasureMap] = 1} | |
1199 | + if not role:checkItemEnough(cost) then return 2 end | |
1201 | 1200 | |
1201 | + baseExtra = baseExtra + globalCsv.idle_treasure_base_extra | |
1202 | 1202 | local tmpTreasure, treasureListExtra = role.dailyData:getTreasureExtra(baseExtra) |
1203 | - | |
1204 | - dump(tmpTreasure) | |
1205 | - dump(treasureListExtra) | |
1206 | 1203 | if not tmpTreasure then return 3 end |
1207 | 1204 | |
1205 | + if not role:costItems(cost, {log = {desc = "TreasureMap", int1 = ItemId.TreasureMap, int2 = 1}}) then return 4 end | |
1206 | + | |
1207 | + dump(treasureListExtra) | |
1208 | 1208 | role.dailyData:updateProperty({field = "treasureExtraCount", delta = 1}) |
1209 | - role.dailyData:updateProperty({field = "treasureMapCount", value = mapCount - 1}) | |
1210 | 1209 | role.dailyData:updateProperty({field = "treasureBaseExtra", value = baseExtra}) |
1211 | 1210 | |
1212 | 1211 | return "成功" |
... | ... | @@ -1218,10 +1217,9 @@ function _M.treasure_map(role, pms) |
1218 | 1217 | local cost ={[ItemId.Jade] = globalCsv.idle_treasure_buy * count} |
1219 | 1218 | if not role:checkItemEnough(cost) then return -1 end |
1220 | 1219 | if not role:costItems(cost, {log = {desc = "treasureMap", int1 = count}}) then return -2 end |
1221 | - role.dailyData:updateProperty({field = "treasureMapCount", delta = 1*count}) | |
1222 | 1220 | |
1223 | - local treasureMapCount = role.dailyData:getProperty("treasureMapCount") | |
1224 | - return treasureMapCount | |
1221 | + local reward, change = role:award({[ItemId.TreasureMap] = count}, {log = {desc = "TreasureMap", int1 = ItemId.TreasureMap, int2 = count}}) | |
1222 | + return "兑换成功" | |
1225 | 1223 | end |
1226 | 1224 | |
1227 | 1225 | table.insert(helpDes, {"清空", "treasure_clear"}) | ... | ... |
src/actions/HangAction.lua
... | ... | @@ -1200,19 +1200,20 @@ end |
1200 | 1200 | function _M.takeTreasureRpc(agent, data) |
1201 | 1201 | local role = agent.role |
1202 | 1202 | local extraCount = role.dailyData:getProperty("treasureExtraCount") --每日发现额外宝藏使用次数(累计),隔天清零 |
1203 | - local mapCount = role.dailyData:getProperty("treasureMapCount") | |
1204 | 1203 | local baseExtra = role.dailyData:getProperty("treasureBaseExtra") |
1205 | 1204 | |
1206 | 1205 | if extraCount >= globalCsv.idle_treasure_extra_limie then return 1 end |
1207 | - if mapCount <= 0 then return 2 end | |
1208 | 1206 | |
1209 | - baseExtra = baseExtra + globalCsv.idle_treasure_base_extra | |
1207 | + local cost ={[ItemId.TreasureMap] = 1} | |
1208 | + if not role:checkItemEnough(cost) then return 2 end | |
1210 | 1209 | |
1210 | + baseExtra = baseExtra + globalCsv.idle_treasure_base_extra | |
1211 | 1211 | local tmpTreasure, treasureListExtra = role.dailyData:getTreasureExtra(baseExtra) |
1212 | 1212 | if not tmpTreasure then return 3 end |
1213 | 1213 | |
1214 | + if not role:costItems(cost, {log = {desc = "TreasureMap", int1 = ItemId.TreasureMap, int2 = 1}}) then return 4 end | |
1215 | + | |
1214 | 1216 | role.dailyData:updateProperty({field = "treasureExtraCount", delta = 1}) |
1215 | - role.dailyData:updateProperty({field = "treasureMapCount", value = mapCount - 1}) | |
1216 | 1217 | role.dailyData:updateProperty({field = "treasureBaseExtra", value = baseExtra}) |
1217 | 1218 | |
1218 | 1219 | SendPacket(actionCodes.Hang_takeTreasureRpc, MsgPack.pack({treasureListExtra = treasureListExtra, treasure = tmpTreasure})) |
... | ... | @@ -1226,10 +1227,9 @@ function _M.treasureMapRpc(agent,data) |
1226 | 1227 | local cost ={[ItemId.Jade] = globalCsv.idle_treasure_buy * count} |
1227 | 1228 | if not role:checkItemEnough(cost) then return 1 end |
1228 | 1229 | if not role:costItems(cost, {log = {desc = "treasureMap", int1 = count}}) then return 2 end |
1229 | - role.dailyData:updateProperty({field = "treasureMapCount", delta = count}) | |
1230 | 1230 | |
1231 | - local treasureMapCount = role.dailyData:getProperty("treasureMapCount") | |
1232 | - SendPacket(actionCodes.Hang_treasureMapRpc, MsgPack.pack({mapCount = treasureMapCount})) | |
1231 | + local reward, change = role:award({[ItemId.TreasureMap] = count}, {log = {desc = "TreasureMap", int1 = ItemId.TreasureMap, int2 = count}}) | |
1232 | + SendPacket(actionCodes.Hang_treasureMapRpc, MsgPack.pack(role:packReward(reward, change))) | |
1233 | 1233 | return true |
1234 | 1234 | end |
1235 | 1235 | ... | ... |
src/models/Daily.lua
... | ... | @@ -38,7 +38,6 @@ Daily.schema = { |
38 | 38 | treasureList = {"table", {}}, --挂机图鉴 |
39 | 39 | |
40 | 40 | treasureListExtra = {"table", {}}, --额外宝藏,挂机图鉴扩展功能 |
41 | - treasureMapCount = {"number", 0}, --宝藏图,消耗一张宝藏图可以发现一次额外宝藏 | |
42 | 41 | treasureExtraCount = {"number", 0}, --每日发现额外宝藏使用次数(累计),隔天清零 |
43 | 42 | treasureBaseExtra = {"number", 0}, --额外宝藏资源值 |
44 | 43 | |
... | ... | @@ -131,7 +130,6 @@ function Daily:data() |
131 | 130 | treasureBase = self:getProperty("treasureBase"), |
132 | 131 | treasureList = self:getProperty("treasureList"), |
133 | 132 | treasureListExtra = self:getProperty("treasureListExtra"), |
134 | - treasureMapCount = self:getProperty("treasureMapCount"), | |
135 | 133 | treasureExtraCount = self:getProperty("treasureExtraCount"), |
136 | 134 | treasureBaseExtra = self:getProperty("treasureBaseExtra"), |
137 | 135 | chatTimes = self:getProperty("chatTimes"), | ... | ... |