Commit 95c9089b72c840bd4789490bf3f01eaea35a0ae5
1 parent
9f21cb8e
feat: 新增世界线积分功能。
1. 新增字段worldChangePoints = {"table", {}}, -- 世界变动积分 2. 新增字段 worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1} 3. 新增协议: 1) 抽轮盘协议 2) 一键领取世界积分奖励。
Showing
6 changed files
with
97 additions
and
0 deletions
Show diff stats
src/GlobalVar.lua
@@ -441,4 +441,12 @@ ItemOccupy = { | @@ -441,4 +441,12 @@ ItemOccupy = { | ||
441 | Spark = 5, --火花 | 441 | Spark = 5, --火花 |
442 | Other = 6, | 442 | Other = 6, |
443 | CanUsed = 7, --可使用 | 443 | CanUsed = 7, --可使用 |
444 | +} | ||
445 | + | ||
446 | +-- 世界变动积分 | ||
447 | +ItemWorldLine = { | ||
448 | + RouletteCount = 1, --抽轮盘次数 | ||
449 | + Points = 2, --积分 | ||
450 | + CostDiamond = 3, --消耗钻石 | ||
451 | + CostJade = 4, --消耗红光玉 | ||
444 | } | 452 | } |
445 | \ No newline at end of file | 453 | \ No newline at end of file |
src/ProtocolCode.lua
@@ -60,6 +60,8 @@ actionCodes = { | @@ -60,6 +60,8 @@ actionCodes = { | ||
60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 | 60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 |
61 | Role_setBgRpc = 144, -- 设置看板娘 | 61 | Role_setBgRpc = 144, -- 设置看板娘 |
62 | Role_itemConvertMonthCardRpc = 145, -- 兑换月卡/战令道具 | 62 | Role_itemConvertMonthCardRpc = 145, -- 兑换月卡/战令道具 |
63 | + Role_worldLineRoulette = 146, --世界线抽轮盘 | ||
64 | + Role_worldLineReward = 147, -- 世界线一键领取奖励 | ||
63 | 65 | ||
64 | Adv_startAdvRpc = 151, | 66 | Adv_startAdvRpc = 151, |
65 | Adv_startHangRpc = 152, | 67 | Adv_startHangRpc = 152, |
src/actions/RoleAction.lua
@@ -1744,4 +1744,65 @@ function _M.itemConvertMonthCardRpc(agent, data) | @@ -1744,4 +1744,65 @@ function _M.itemConvertMonthCardRpc(agent, data) | ||
1744 | return status | 1744 | return status |
1745 | end | 1745 | end |
1746 | 1746 | ||
1747 | +function _M.worldLineRoulette(agent, data) | ||
1748 | + local role = agent.role | ||
1749 | + local msg = MsgPack.unpack(data) | ||
1750 | + | ||
1751 | + local worldChangePoints = role:getProperty("worldChangePoints") or {} | ||
1752 | + local rouletteCount = worldChangePoints[ItemWorldLine.RouletteCount] or 0 | ||
1753 | + if rouletteCount == 0 then return 1 end | ||
1754 | + | ||
1755 | + local worldline_gift_base_10, worldline_gift_base_1, worldline_gift_magnification_10, worldline_gift_magnification_1 = {}, {}, {}, {} | ||
1756 | + for k, v in pairs(globalCsv.worldline_gift_base_10) do | ||
1757 | + worldline_gift_base_10[k] = {v} | ||
1758 | + end | ||
1759 | + for k, v in pairs(globalCsv.worldline_gift_base_1) do | ||
1760 | + worldline_gift_base_1[k] = {v} | ||
1761 | + end | ||
1762 | + for k, v in pairs(globalCsv.worldline_gift_magnification_10) do | ||
1763 | + worldline_gift_magnification_10[k] = {v} | ||
1764 | + end | ||
1765 | + for k, v in pairs(globalCsv.worldline_gift_magnification_1) do | ||
1766 | + worldline_gift_magnification_1[k] = {v} | ||
1767 | + end | ||
1768 | + | ||
1769 | + local gift_base_10 = (math.randWeight(worldline_gift_base_10, 1) or 0) * 10 | ||
1770 | + local gift_base_1 = math.randWeight(worldline_gift_base_1, 1) or 0 | ||
1771 | + | ||
1772 | + local gift_magnification_10 = (math.randWeight(worldline_gift_magnification_10, 1) or 0) * 10 | ||
1773 | + local gift_magnification_1 = math.randWeight(worldline_gift_magnification_1, 1) or 0 | ||
1774 | + | ||
1775 | + local points = (gift_base_10 + gift_base_1) * (gift_magnification_10 + gift_magnification_1) | ||
1776 | + worldChangePoints[ItemWorldLine.RouletteCount] = worldChangePoints[ItemWorldLine.RouletteCount] - 1 | ||
1777 | + worldChangePoints[ItemWorldLine.Points] = worldChangePoints[ItemWorldLine.Points] + points | ||
1778 | + role:updateProperty({field = "worldChangePoints", value = worldChangePoints}) | ||
1779 | + | ||
1780 | + SendPacket(actionCodes.Role_worldLineRoulette, MsgPack.pack(worldChangePoints)) | ||
1781 | + return true | ||
1782 | +end | ||
1783 | + | ||
1784 | +function _M.worldLineReward(agent, data) | ||
1785 | + local role = agent.role | ||
1786 | + local worldLineReward = role:getProperty("worldLineReward") or {} | ||
1787 | + local worldChangePoints = role:getProperty("worldChangePoints") or {} | ||
1788 | + local points = worldChangePoints[ItemWorldLine.Points] or 0 | ||
1789 | + | ||
1790 | + local reward, change = {} | ||
1791 | + for key, val in pairs(csvdb["worldline_rewardCsv"]) do | ||
1792 | + if points >= key and not worldLineReward[key] then | ||
1793 | + for k, v in pairs(val.award:toNumMap()) do | ||
1794 | + reward[k] = (reward[k] or 0) + v | ||
1795 | + end | ||
1796 | + worldLineReward[key] = 1 | ||
1797 | + end | ||
1798 | + end | ||
1799 | + | ||
1800 | + role:updateProperty({field = "worldLineReward", value = worldLineReward}) | ||
1801 | + | ||
1802 | + if next(reward) then | ||
1803 | + reward, change = role:award(reward, {log = {desc = "worldLine", int1 = role:getProperty("id")}}) | ||
1804 | + end | ||
1805 | + SendPacket(actionCodes.Role_worldLineReward, MsgPack.pack(role:packReward(reward, change))) | ||
1806 | +end | ||
1807 | + | ||
1747 | return _M | 1808 | return _M |
1748 | \ No newline at end of file | 1809 | \ No newline at end of file |
src/models/Role.lua
@@ -214,6 +214,9 @@ Role.schema = { | @@ -214,6 +214,9 @@ Role.schema = { | ||
214 | heroCnt = {"number", 0}, -- 英雄数量 | 214 | heroCnt = {"number", 0}, -- 英雄数量 |
215 | friendTeam = {"table", {}}, -- 好友切磋队伍信息 {bInfo = {}, team = {}, v = 0} | 215 | friendTeam = {"table", {}}, -- 好友切磋队伍信息 {bInfo = {}, team = {}, v = 0} |
216 | bgId = {"number", 0}, -- 看板娘id | 216 | bgId = {"number", 0}, -- 看板娘id |
217 | + | ||
218 | + worldChangePoints = {"table", {}}, -- 世界变动积分 {[1]= 转盘抽取次数, [2]= 获得的积分, [3]=魔导石消耗, [4]= 虹光玉消耗} | ||
219 | + worldLineReward = {"table", {}}, -- 世界积分 领取记录 {[id] = 1} | ||
217 | } | 220 | } |
218 | 221 | ||
219 | 222 | ||
@@ -457,6 +460,8 @@ function Role:data() | @@ -457,6 +460,8 @@ function Role:data() | ||
457 | unlockChap = self:getProperty("unlockChap"), -- 解锁的章节 | 460 | unlockChap = self:getProperty("unlockChap"), -- 解锁的章节 |
458 | friendTeam = self:getProperty("friendTeam"), | 461 | friendTeam = self:getProperty("friendTeam"), |
459 | bgId = self:getProperty("bgId"), | 462 | bgId = self:getProperty("bgId"), |
463 | + worldChangePoints = self:getProperty("worldChangePoints"), | ||
464 | + worldLineReward = self:getProperty("worldLineReward"), | ||
460 | } | 465 | } |
461 | end | 466 | end |
462 | 467 |
src/models/RoleLog.lua
@@ -163,6 +163,8 @@ local ItemReason = { | @@ -163,6 +163,8 @@ local ItemReason = { | ||
163 | CapsuleReward = 1411, --扭蛋机奖励 | 163 | CapsuleReward = 1411, --扭蛋机奖励 |
164 | CapsuleConvert = 1412, --扭蛋机 消耗票 兑换 | 164 | CapsuleConvert = 1412, --扭蛋机 消耗票 兑换 |
165 | CapsuleCoinCost = 1413, --抽扭蛋机消耗 | 165 | CapsuleCoinCost = 1413, --抽扭蛋机消耗 |
166 | + | ||
167 | + worldLine = 1500, --世界线积分 | ||
166 | } | 168 | } |
167 | 169 | ||
168 | 170 |
src/models/RolePlugin.lua
@@ -574,12 +574,14 @@ function RolePlugin.bind(Role) | @@ -574,12 +574,14 @@ function RolePlugin.bind(Role) | ||
574 | self:notifyUpdateProperty("diamond", self:getAllDiamond()) | 574 | self:notifyUpdateProperty("diamond", self:getAllDiamond()) |
575 | 575 | ||
576 | self:checkTaskEnter("CostDiamond", {count = count}) | 576 | self:checkTaskEnter("CostDiamond", {count = count}) |
577 | + self:checkWorldChangePoints({[ItemWorldLine.CostDiamond]=count}) | ||
577 | return true | 578 | return true |
578 | end | 579 | end |
579 | 580 | ||
580 | function Role:costJade(param) | 581 | function Role:costJade(param) |
581 | self:addItem(param) | 582 | self:addItem(param) |
582 | self:checkTaskEnter("CostJade", {count = - param.count}) | 583 | self:checkTaskEnter("CostJade", {count = - param.count}) |
584 | + self:checkWorldChangePoints({[ItemWorldLine.CostJade]=param.count}) | ||
583 | end | 585 | end |
584 | 586 | ||
585 | function Role:increBy(field, val) | 587 | function Role:increBy(field, val) |
@@ -3264,6 +3266,23 @@ function RolePlugin.bind(Role) | @@ -3264,6 +3266,23 @@ function RolePlugin.bind(Role) | ||
3264 | 3266 | ||
3265 | return capsule:getSpecialNotify(roleId) | 3267 | return capsule:getSpecialNotify(roleId) |
3266 | end | 3268 | end |
3269 | + | ||
3270 | + function Role:checkWorldChangePoints(param) | ||
3271 | + local worldChangePoints = self:getProperty("worldChangePoints") or {} | ||
3272 | + if param[ItemWorldLine.CostJade] then | ||
3273 | + worldChangePoints[ItemWorldLine.CostJade] = (worldChangePoints[ItemWorldLine.CostJade] or 0) + param[ItemWorldLine.CostDiamond] | ||
3274 | + local cost = math.floor(param[ItemWorldLine.CostJade] / globalCsv.worldline_count_currency) | ||
3275 | + worldChangePoints[ItemWorldLine.CostJade] = worldChangePoints[ItemWorldLine.CostJade] - cost | ||
3276 | + worldChangePoints[ItemWorldLine.RouletteCount] = worldChangePoints[ItemWorldLine.RouletteCount] + cost | ||
3277 | + end | ||
3278 | + | ||
3279 | + if param[ItemWorldLine.CostDiamond] then | ||
3280 | + worldChangePoints[ItemWorldLine.CostDiamond] = (worldChangePoints[ItemWorldLine.CostDiamond] or 0) + param[ItemWorldLine.CostDiamond] | ||
3281 | + local cost = math.floor(param[ItemWorldLine.CostDiamond] / globalCsv.worldline_count_currency) | ||
3282 | + worldChangePoints[ItemWorldLine.CostDiamond] = worldChangePoints[ItemWorldLine.CostDiamond] - cost | ||
3283 | + worldChangePoints[ItemWorldLine.Points] = worldChangePoints[ItemWorldLine.Points] + cost | ||
3284 | + end | ||
3285 | + end | ||
3267 | end | 3286 | end |
3268 | 3287 | ||
3269 | return RolePlugin | 3288 | return RolePlugin |
3270 | \ No newline at end of file | 3289 | \ No newline at end of file |