Commit 4ea2bdc4d3c08d79f55cd5ed4b11046ed0dd22db

Authored by jiyue
2 parents 2f0830e3 34c8cf27

Merge branch 'cn/develop' into cn/publish/preview

src/GlobalVar.lua
... ... @@ -154,6 +154,7 @@ ItemId = {
154 154 AdvKey = 80, -- 冒险钥匙
155 155 AdvPower = 4701, -- 拾荒体力
156 156 CrisisScore = 8010, -- 积分
  157 + MonthCard = 31000, --兑换月卡的物品
157 158 }
158 159  
159 160 TimeReset = {
... ...
src/ProtocolCode.lua
... ... @@ -59,6 +59,7 @@ actionCodes = {
59 59 Role_runeBuyRpc = 142, -- 铭文购买
60 60 Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍
61 61 Role_setBgRpc = 144, -- 设置看板娘
  62 + Role_itemExchangeRpc = 145, -- 道具兑换
62 63  
63 64 Adv_startAdvRpc = 151,
64 65 Adv_startHangRpc = 152,
... ...
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
... ... @@ -865,3 +865,9 @@ function table.array2Table(arr)
865 865 return ret
866 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 874 \ No newline at end of file
... ...