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
| @@ -154,6 +154,7 @@ ItemId = { | @@ -154,6 +154,7 @@ ItemId = { | ||
| 154 | AdvKey = 80, -- 冒险钥匙 | 154 | AdvKey = 80, -- 冒险钥匙 |
| 155 | AdvPower = 4701, -- 拾荒体力 | 155 | AdvPower = 4701, -- 拾荒体力 |
| 156 | CrisisScore = 8010, -- 积分 | 156 | CrisisScore = 8010, -- 积分 |
| 157 | + MonthCard = 31000, --兑换月卡的物品 | ||
| 157 | } | 158 | } |
| 158 | 159 | ||
| 159 | TimeReset = { | 160 | TimeReset = { |
src/ProtocolCode.lua
| @@ -59,6 +59,7 @@ actionCodes = { | @@ -59,6 +59,7 @@ actionCodes = { | ||
| 59 | Role_runeBuyRpc = 142, -- 铭文购买 | 59 | Role_runeBuyRpc = 142, -- 铭文购买 |
| 60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 | 60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 |
| 61 | Role_setBgRpc = 144, -- 设置看板娘 | 61 | Role_setBgRpc = 144, -- 设置看板娘 |
| 62 | + Role_itemExchangeRpc = 145, -- 道具兑换 | ||
| 62 | 63 | ||
| 63 | Adv_startAdvRpc = 151, | 64 | Adv_startAdvRpc = 151, |
| 64 | Adv_startHangRpc = 152, | 65 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
| @@ -1710,4 +1710,36 @@ function _M.setBgRpc(agent, data) | @@ -1710,4 +1710,36 @@ function _M.setBgRpc(agent, data) | ||
| 1710 | return true | 1710 | return true |
| 1711 | end | 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 | return _M | 1745 | return _M |
| 1714 | \ No newline at end of file | 1746 | \ No newline at end of file |
src/actions/StoreAction.lua
| @@ -291,15 +291,17 @@ function _M.shopBuyRpc(agent , data) | @@ -291,15 +291,17 @@ function _M.shopBuyRpc(agent , data) | ||
| 291 | return 1 | 291 | return 1 |
| 292 | end | 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 | local desc = "unknowShop" | 302 | local desc = "unknowShop" |
| 297 | if dataSet.shop == 1 then -- 普通商店 | 303 | if dataSet.shop == 1 then -- 普通商店 |
| 298 | desc = "dailyShop" | 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 | elseif dataSet.shop == 2 then -- 美食商店 | 305 | elseif dataSet.shop == 2 then -- 美食商店 |
| 304 | desc = "dinerShop" | 306 | desc = "dinerShop" |
| 305 | elseif dataSet.shop == 3 then -- 竞技场商店 | 307 | elseif dataSet.shop == 3 then -- 竞技场商店 |
| @@ -314,7 +316,7 @@ function _M.shopBuyRpc(agent , data) | @@ -314,7 +316,7 @@ function _M.shopBuyRpc(agent , data) | ||
| 314 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) | 316 | role.storeData:updateProperty({field = "buyR", value = buyRecord}) |
| 315 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) | 317 | limitStr = string.format("%s/%s", buyRecord[id], dataSet.limit) |
| 316 | end | 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 | local gift = {} | 321 | local gift = {} |
| 320 | for _id, _count in pairs(dataSet.gift:toNumMap()) do | 322 | for _id, _count in pairs(dataSet.gift:toNumMap()) do |
src/models/RoleLog.lua
| @@ -66,6 +66,8 @@ local ItemReason = { | @@ -66,6 +66,8 @@ local ItemReason = { | ||
| 66 | shopBuy = 150, -- 商店购买 | 66 | shopBuy = 150, -- 商店购买 |
| 67 | monthCardReward = 151, --月卡奖励 | 67 | monthCardReward = 151, --月卡奖励 |
| 68 | smonthCardReward = 152, --特刊奖励 | 68 | smonthCardReward = 152, --特刊奖励 |
| 69 | + itemConvertmonthCard = 153, --兑换月卡 | ||
| 70 | + itemConvertsmonthCard = 154, --兑换特刊 | ||
| 69 | 71 | ||
| 70 | advHang = 301, -- 拾荒挂机 | 72 | advHang = 301, -- 拾荒挂机 |
| 71 | hangBattle = 302, -- 挂机战斗 | 73 | hangBattle = 302, -- 挂机战斗 |
src/models/RolePlugin.lua
| @@ -2393,15 +2393,10 @@ function RolePlugin.bind(Role) | @@ -2393,15 +2393,10 @@ function RolePlugin.bind(Role) | ||
| 2393 | end | 2393 | end |
| 2394 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) | 2394 | self:gainDiamond({count = diamondCount, isRecharge = true, sid = params.sid, log = {desc = "recharge", int1 = id}}) |
| 2395 | elseif rechargeData.shop == 2 then --通行证商店 | 2395 | elseif rechargeData.shop == 2 then --通行证商店 |
| 2396 | - --订阅奖励 | ||
| 2397 | - reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | ||
| 2398 | - | ||
| 2399 | - --签收奖励 | 2396 | + --签收 + 订阅奖励 |
| 2400 | local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) | 2397 | local tmpreward, _ = self.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) |
| 2401 | if tmpreward then | 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 | end | 2400 | end |
| 2406 | elseif rechargeData.shop == 3 then -- 礼包商店 | 2401 | elseif rechargeData.shop == 3 then -- 礼包商店 |
| 2407 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) | 2402 | reward, _ = self:award(rechargeData.itemFirst, {isRecharge = true, log = {desc = "recharge", int1 = id}}) |
src/models/Store.lua
| @@ -343,6 +343,8 @@ end | @@ -343,6 +343,8 @@ end | ||
| 343 | 343 | ||
| 344 | --获取月卡每日奖励 | 344 | --获取月卡每日奖励 |
| 345 | function Store:getMonthCardDailyReward(id) | 345 | function Store:getMonthCardDailyReward(id) |
| 346 | + if not id then return nil end | ||
| 347 | + | ||
| 346 | if self:isMonthCardExpire() or self:getProperty("monthCardReceive") == 1 then return nil, nil end | 348 | if self:isMonthCardExpire() or self:getProperty("monthCardReceive") == 1 then return nil, nil end |
| 347 | 349 | ||
| 348 | local before_ex = self:getProperty("monthCardEx") | 350 | local before_ex = self:getProperty("monthCardEx") |
| @@ -369,6 +371,8 @@ end | @@ -369,6 +371,8 @@ end | ||
| 369 | 371 | ||
| 370 | --获取特刊每日奖励 | 372 | --获取特刊每日奖励 |
| 371 | function Store:getSMonthCardDailyReward(id) | 373 | function Store:getSMonthCardDailyReward(id) |
| 374 | + if not id then return nil end | ||
| 375 | + | ||
| 372 | local before_ex = SuperMonthCard["periods"](self, id) | 376 | local before_ex = SuperMonthCard["periods"](self, id) |
| 373 | local reward, change, cur_ex= SuperMonthCard["itemDaily"](self, id) | 377 | local reward, change, cur_ex= SuperMonthCard["itemDaily"](self, id) |
| 374 | 378 | ||
| @@ -404,21 +408,15 @@ function Store:onBuyCard(type, duration, id, actid) | @@ -404,21 +408,15 @@ function Store:onBuyCard(type, duration, id, actid) | ||
| 404 | end | 408 | end |
| 405 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30}) | 409 | self:updateProperty({field = "monthCardEx", value = self:getProperty("monthCardEx") + 30}) |
| 406 | 410 | ||
| 411 | + local reward = {} | ||
| 407 | --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅" | 412 | --初回特典 仅首次购买月卡时赠送SSR级角色"拉塔托娅" |
| 408 | - local reward = {} | ||
| 409 | local tmpreward, _ = self:firstBuyMonthCard(id) | 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 | tmpreward = SuperMonthCard["itemFirst"](self, id) | 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 | return reward | 420 | return reward |
| 423 | elseif type == CardType.SuperMonthCard then | 421 | elseif type == CardType.SuperMonthCard then |
| 424 | if SuperMonthCard["buy"](self, id) then | 422 | if SuperMonthCard["buy"](self, id) then |
| @@ -832,6 +830,8 @@ function Store:data() | @@ -832,6 +830,8 @@ function Store:data() | ||
| 832 | bpInfo = self:getProperty("bpInfo"), | 830 | bpInfo = self:getProperty("bpInfo"), |
| 833 | totalRR = self:getProperty("totalRR"), | 831 | totalRR = self:getProperty("totalRR"), |
| 834 | monthCardId = self:getProperty("monthCardId"), | 832 | monthCardId = self:getProperty("monthCardId"), |
| 833 | + firstMonthCard = self:getProperty("firstMonthCard"), | ||
| 834 | + monthCardReceive = self:getProperty("monthCardReceive"), | ||
| 835 | smonthCards = self:getProperty("smonthCards"), | 835 | smonthCards = self:getProperty("smonthCards"), |
| 836 | smonthCardReceive = self:getProperty("smonthCardReceive"), | 836 | smonthCardReceive = self:getProperty("smonthCardReceive"), |
| 837 | dailyShop = self:getProperty("dailyShop"), | 837 | dailyShop = self:getProperty("dailyShop"), |
src/shared/functions.lua
| @@ -865,3 +865,9 @@ function table.array2Table(arr) | @@ -865,3 +865,9 @@ function table.array2Table(arr) | ||
| 865 | return ret | 865 | return ret |
| 866 | end | 866 | end |
| 867 | 867 | ||
| 868 | + | ||
| 869 | +function table.rewardMerge(dest, src) | ||
| 870 | + for k, v in pairs(src) do | ||
| 871 | + dest[k] = (dest[k] or 0) + v | ||
| 872 | + end | ||
| 873 | +end | ||
| 868 | \ No newline at end of file | 874 | \ No newline at end of file |