From 0fe15f3ba1c47ec6a22aedda4805107abe76f2b9 Mon Sep 17 00:00:00 2001 From: chenxi Date: Fri, 5 May 2023 15:39:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=91=E7=8C=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/god_pig/god_pig_data.lua | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/lua/app/userdata/activity/god_pig/god_pig_data.lua b/lua/app/userdata/activity/god_pig/god_pig_data.lua index b2ebc6c8..c527573a 100644 --- a/lua/app/userdata/activity/god_pig/god_pig_data.lua +++ b/lua/app/userdata/activity/god_pig/god_pig_data.lua @@ -4,7 +4,7 @@ function GodPigData:init(data) data = data or GConst.EMPTY_TABLE self.data.id = data.id or 0 if self.data.id == 0 then - self.data.id = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value + self.data.id = self:getFirstLevelId() end self.data.count = data.count or 0 self.data.cd = data.cd or 0 @@ -34,6 +34,27 @@ function GodPigData:addGoldPigCount() end end +function GodPigData:getFirstLevelId() + if self.firstLevelId == nil then + self.firstLevelId = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value + end + return self.firstLevelId +end + +function GodPigData:getTimeOverCD() + if self.timeOverCD == nil then + self.timeOverCD = ConfigManager:getConfig("const")["act_gold_pig_cd"].value * 3600 + end + return self.timeOverCD +end + +function GodPigData:getBoughtCD() + if self.boughtCD == nil then + self.boughtCD = ConfigManager:getConfig("const")["act_gold_pig_buy_cd"].value * 3600 + end + return self.boughtCD +end + function GodPigData:getCfg() if self.cfg == nil then self.cfg = ConfigManager:getConfig("act_god_pig") @@ -67,4 +88,34 @@ function GodPigData:tryActiveGoldPig() self.data.endTime = Time:getServerTime() + self:getDuration() end +-- 时间到了,消失并降档 +function GodPigData:onTimeOver() + if not self.data.isOpen then + return + end + self.data.isOpen = false + local cfg = self:getCfg() + local info = cfg[self.data.id] + if info == nil then + self.data.id = self:getFirstLevelId() + else + self.data.id = info.before_id or self:getFirstLevelId() + end + self.data.cd = self:getTimeOverCD() +end + +-- 购买后,消失并升档位 +function GodPigData:onBought(id) + if not self.data.isOpen then + return + end + self.data.isOpen = false + local cfg = self:getCfg() + local info = cfg[id] + if info then + self.data.id = info.next_id or id + end + self.data.cd = self:getBoughtCD() +end + return GodPigData \ No newline at end of file