From 47904e5138439c99c5daa5a3df65d69792365de4 Mon Sep 17 00:00:00 2001 From: chenyueqi Date: Tue, 6 Apr 2021 16:24:52 +0800 Subject: [PATCH] 创角后的时间礼包 --- src/ProtocolCode.lua | 1 + src/actions/RoleAction.lua | 22 ++++++++++++++++++++++ src/models/Role.lua | 2 ++ src/models/RoleLog.lua | 1 + 4 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index fa12c7a..69266b6 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -54,6 +54,7 @@ actionCodes = { Role_loadSparks = 138, Role_updateSpark = 139, -- 更新火花 Role_diamondConvertRpc = 140, -- 钻石兑换成别的物品 + Role_getTimeGiftRpc = 141, Adv_startAdvRpc = 151, Adv_startHangRpc = 152, diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 13c2896..1f5cb59 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -1526,4 +1526,26 @@ function _M.accuseRpc(agent, data) return true end +function _M.getTimeGiftRpc(agent, data) + local role = agent.role + + local GiftCsv = csvdb["time_giftCsv"] + local timeGift = role:getProperty("timeGift") + if timeGift >= #GiftCsv then return 0 end + + local nextL = timeGift + 1 + local gift = GiftCsv[nextL] + if not gift then return 1 end + + local createtime = role:getProperty("ctime") + if skynet.timex() - createtime < gift.time then return 2 end + + role:updateProperty({field = "timeGift", value = nextL}) + local reward, change = role:award(gift.gift, {log = {desc = "giftTime", int1 = nextL}}) + role:mylog("role_action", {desc = "giftTime", int1 = nextL}) + + SendPacket(actionCodes.Role_getTimeGiftRpc, MsgPack.pack(reward, change)) + return true +end + return _M \ No newline at end of file diff --git a/src/models/Role.lua b/src/models/Role.lua index 4c392d1..5265c62 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -78,6 +78,7 @@ Role.schema = { -- loveStatus = {"string", ""}, --统计角色的最高 好感度等级 类型相关 -- type=loveL type=loveL crown = {"number", 0}, -- 看伴娘 silent = {"number", 0}, --禁言解禁时间 + timeGift = {"number", 0}, -- 创建角色时间礼包 bagLimit = {"table", globalCsv.store_limit_max}, @@ -348,6 +349,7 @@ function Role:data() diamond = self:getAllDiamond(), bagLimit = self:getProperty("bagLimit"), silent = self:getProperty("silent"), + timeGift = self:getProperty("timeGift"), advPass = self:getProperty("advPass"), advInfo = self:getProperty("advInfo"), diff --git a/src/models/RoleLog.lua b/src/models/RoleLog.lua index 2303769..52ab912 100644 --- a/src/models/RoleLog.lua +++ b/src/models/RoleLog.lua @@ -59,6 +59,7 @@ local ItemReason = { advLevelStage = 143, -- 拾荒活动阶段奖励 towerBnous = 144, -- 爬塔到一定层数对某些功能的奖励 convert = 145, -- 钻石兑换其他物品 + giftTime = 146, -- 创角后的时间礼包 advHang = 301, -- 拾荒挂机 hangBattle = 302, -- 挂机战斗 -- libgit2 0.21.2