Commit 4ea2bdc4d3c08d79f55cd5ed4b11046ed0dd22db
Merge branch 'cn/develop' into cn/publish/preview
Showing
8 changed files
with
63 additions
and
24 deletions
Show diff stats
src/GlobalVar.lua
src/ProtocolCode.lua
src/actions/RoleAction.lua
... | ... | @@ -1710,4 +1710,36 @@ function _M.setBgRpc(agent, data) |
1710 | 1710 | return true |
1711 | 1711 | end |
1712 | 1712 | |
1713 | +function _M.itemExchangeRpc(agent, data) | |
1714 | + local role = agent.role | |
1715 | + local msg = MsgPack.unpack(data) | |
1716 | + local itemId = msg.item_id | |
1717 | + local typ = msg.typ | |
1718 | + local count = msg.count | |
1719 | + local exchangeId = msg.change_id | |
1720 | + | |
1721 | + if not ItemId[itemId] then return 1 end | |
1722 | + | |
1723 | + if not role:checkItemEnough({[itemId] = count}) then return 2 end | |
1724 | + role:costItems({[itemId] = count}, {log = {desc = "itemConvertmonthCard", int1 = count, int2 = count}}) | |
1725 | + | |
1726 | + local rechargeData = csvdb["shop_rechargeCsv"][exchangeId] | |
1727 | + if not rechargeData then | |
1728 | + skynet.error("[recharge] recharge id not exist", exchangeId) | |
1729 | + return 3 | |
1730 | + end | |
1731 | + local reward = {} | |
1732 | + for i = 1, count do | |
1733 | + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.id , rechargeData.activity_id) | |
1734 | + if tmpreward then | |
1735 | + table.rewardMerge(reward, tmpreward) | |
1736 | + else | |
1737 | + return | |
1738 | + end | |
1739 | + end | |
1740 | + | |
1741 | + SendPacket(actionCodes.Role_itemExchangeRpc, MsgPack.pack(role:packReward(reward))) | |
1742 | + return status | |
1743 | +end | |
1744 | + | |
1713 | 1745 | return _M |
1714 | 1746 | \ No newline at end of file | ... | ... |
src/actions/StoreAction.lua
... | ... | @@ -291,15 +291,17 @@ function _M.shopBuyRpc(agent , data) |
291 | 291 | return 1 |
292 | 292 | end |
293 | 293 | |
294 | - local cost = {[dataSet.icon] = dataSet.cost * count} | |
294 | + local cost | |
295 | + if dataSet.disount == 0 then | |
296 | + cost = {[dataSet.icon] = math.ceil(dataSet.cost * count)} | |
297 | + else | |
298 | + cost = {[dataSet.icon] = math.ceil(dataSet.cost * count * ((dataSet.disount or 10) / 10))} | |
299 | + end | |
300 | + | |
295 | 301 | |
296 | 302 | local desc = "unknowShop" |
297 | 303 | if dataSet.shop == 1 then -- 普通商店 |
298 | 304 | desc = "dailyShop" |
299 | - local dailySDD = role.dailyData:getProperty("dailySDD") | |
300 | - if dailySDD[id] then -- 折扣 | |
301 | - cost = math.ceil(dataSet.cost * (1 - dataSet.disount / 100)) | |
302 | - end | |
303 | 305 | elseif dataSet.shop == 2 then -- 美食商店 |
304 | 306 | desc = "dinerShop" |
305 | 307 | elseif dataSet.shop == 3 then -- 竞技场商店 |
... | ... | @@ -314,7 +316,7 @@ function _M.shopBuyRpc(agent , data) |
314 | 316 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) |
315 | 317 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) |
316 | 318 | end |
317 | - role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, short1 = dataSet.shop}}) | |
319 | + role:costItems(cost, {log = {desc = desc, int1 = id, int2 = count, cint1= dataSet.shop}}) | |
318 | 320 | |
319 | 321 | local gift = {} |
320 | 322 | for _id, _count in pairs(dataSet.gift:toNumMap()) do | ... | ... |
src/models/RoleLog.lua
... | ... | @@ -66,6 +66,8 @@ local ItemReason = { |
66 | 66 | shopBuy = 150, -- 商店购买 |
67 | 67 | monthCardReward = 151, --月卡奖励 |
68 | 68 | smonthCardReward = 152, --特刊奖励 |
69 | + itemConvertmonthCard = 153, --兑换月卡 | |
70 | + itemConvertsmonthCard = 154, --兑换特刊 | |
69 | 71 | |
70 | 72 | advHang = 301, -- 拾荒挂机 |
71 | 73 | hangBattle = 302, -- 挂机战斗 | ... | ... |
src/models/RolePlugin.lua
... | ... | @@ -2393,15 +2393,10 @@ function RolePlugin.bind(Role) |
2393 | 2393 | end |
2394 | 2394 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) |
2395 | 2395 | elseif rechargeData.shop == 2 then --通行证商店 |
2396 | - --订阅奖励 | |
2397 | - reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | |
2398 | - | |
2399 | - --签收奖励 | |
2396 | + --签收 + 订阅奖励 | |
2400 | 2397 | local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) |
2401 | 2398 | if tmpreward then |
2402 | - for k, v in pairs(tmpreward) do | |
2403 | - reward[k] = (reward[k] or 0) + v | |
2404 | - end | |
2399 | + table.rewardMerge(reward, tmpreward) | |
2405 | 2400 | end |
2406 | 2401 | elseif rechargeData.shop == 3 then -- 礼包商店 |
2407 | 2402 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | ... | ... |
src/models/Store.lua
... | ... | @@ -343,6 +343,8 @@ end |
343 | 343 | |
344 | 344 | --获取月卡每日奖励 |
345 | 345 | function Store:getMonthCardDailyReward(id) |
346 | + if not id then return nil end | |
347 | + | |
346 | 348 | if self:isMonthCardExpire() or self:getProperty("monthCardReceive") == 1 then return nil, nil end |
347 | 349 | |
348 | 350 | local before_ex = self:getProperty("monthCardEx") |
... | ... | @@ -369,6 +371,8 @@ end |
369 | 371 | |
370 | 372 | --获取特刊每日奖励 |
371 | 373 | function Store:getSMonthCardDailyReward(id) |
374 | + if not id then return nil end | |
375 | + | |
372 | 376 | local before_ex = SuperMonthCard["periods"](self, id) |
373 | 377 | local reward, change, cur_ex= SuperMonthCard["itemDaily"](self, id) |
374 | 378 | |
... | ... | @@ -404,21 +408,15 @@ function Store:onBuyCard(type, duration, id, actid) |
404 | 408 | end |
405 | 409 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30}) |
406 | 410 | |
411 | + local reward = {} | |
407 | 412 | --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅" |
408 | - local reward = {} | |
409 | 413 | local tmpreward, _ = self:firstBuyMonthCard(id) |
410 | - if tmpreward then | |
411 | - for k, v in pairs(tmpreward) do | |
412 | - reward[k] = (reward[k] or 0) + v | |
413 | - end | |
414 | - end | |
414 | + if tmpreward then table.rewardMerge(reward, tmpreward) end | |
415 | 415 | |
416 | + --订阅奖励 | |
416 | 417 | tmpreward = SuperMonthCard["itemFirst"](self, id) |
417 | - if next(tmpreward) then | |
418 | - for k, v in pairs(tmpreward) do | |
419 | - reward[k] = (reward[k] or 0) + v | |
420 | - end | |
421 | - end | |
418 | + if next(tmpreward) then table.rewardMerge(reward, tmpreward) end | |
419 | + | |
422 | 420 | return reward |
423 | 421 | elseif type == CardType.SuperMonthCard then |
424 | 422 | if SuperMonthCard["buy"](self, id) then |
... | ... | @@ -832,6 +830,8 @@ function Store:data() |
832 | 830 | bpInfo = self:getProperty("bpInfo"), |
833 | 831 | totalRR = self:getProperty("totalRR"), |
834 | 832 | monthCardId = self:getProperty("monthCardId"), |
833 | + firstMonthCard = self:getProperty("firstMonthCard"), | |
834 | + monthCardReceive = self:getProperty("monthCardReceive"), | |
835 | 835 | smonthCards = self:getProperty("smonthCards"), |
836 | 836 | smonthCardReceive = self:getProperty("smonthCardReceive"), |
837 | 837 | dailyShop = self:getProperty("dailyShop"), | ... | ... |
src/shared/functions.lua