Kaynağa Gözat

烟花道具

niexx 1 yıl önce
ebeveyn
işleme
450f37e8d0

+ 24 - 0
script/common/CommonDB.lua

@@ -37,6 +37,7 @@ KEY_CDK_BATCH = "cdkBatchIdx"                           -- CDK批次序号
 KEY_WEEKLOOP_CARD_BATCH = "weekLoopCardBatch"			-- 周活动-抽卡批次
 KEY_VOUCHER_INFLATE = "tVoucherInflateInfo"				-- 代金券膨胀信息
 kEY_RECOMMENDLINEUP = "recommendlineup"					-- 推荐阵容
+KEY_FIREWORKBONUS_TIME="fireWorksBonusTime"             -- 烟花加成时间
 
 db = db or {
 	serverStartTime = nil,								-- 开服时间
@@ -61,6 +62,7 @@ db = db or {
 	weekLoopCardBatch = nil,							-- 周活动-抽卡批次
 	tVoucherInflateInfo = {},							-- 代金券膨胀信息
 	recommendlineup = {},								-- 推荐阵容
+	fireWorksBonusTime = nil,                           -- 烟花加成时间
 }
 
 function init()
@@ -400,4 +402,26 @@ function SetRecommendLineUp(tData)
 	db.recommendlineup = tData
 
 	updateValue(kEY_RECOMMENDLINEUP, db.recommendlineup)
+end
+
+-- 获取烟花加成时间
+function getFireWorksBonusTime()
+	return db.fireWorksBonusTime or 0
+end
+
+-- 设置烟花加成时间
+function setFireWorkBonusTime(nValue)
+	updateValue(KEY_FIREWORKBONUS_TIME,nValue)
+end
+
+function GetInFireWork()
+    -- 获取当前时间
+    local nNowTime = os.time()
+    local currentDuration = getFireWorksBonusTime()
+    -- 检查是否在加成内
+    if nNowTime <= currentDuration then
+        return true
+    end
+    
+    return false
 end

+ 19 - 1
script/module/bag/BagLogic.lua

@@ -34,8 +34,10 @@ local EquipLogic = require("equip.EquipLogic")
 -- local PanelDefine = require("broadcast.PanelDefine")
 local HeroGrowUp = require("absAct.HeroGrowUp")
 local CommonDefine = require("common.CommonDefine")
-
+local CommonDB = require("common.CommonDB")
 local ITEM_MOMENT_ADD_LIST = {}
+local jinbi_id=101
+local jinyan_id=111
 ADDITEM_TYPE_1 = 1   --顺序 不整合添加道具 非1 表示整合所有相同的道具数量
 ADDITEM_TYPE_2 = 2
 
@@ -86,6 +88,7 @@ function addItem(human, id, cnt, logType, noSend, otherData)
 	if not LogDefine.DEFINE[logType] or not LogDefine.TYPE["item"] then
 		assert()
 	end
+	cnt=calculateBonusItemCount(human,id,cnt)
 
 	MiddleOption.addItem(human, id, cnt, logType)
 	if handlerSpObj(human, id, cnt, logType) then
@@ -693,4 +696,19 @@ function BagLogic_GetAllSendInfo(human, tMsgItemList, list, nType)
 	else
 		return false
 	end
+end
+
+-- 计算加成后的物品数量
+function calculateBonusItemCount(human, id, cnt)
+    -- 检查是否是金币(101)或经验(111)道具
+    if id == jinbi_id or id == jinyan_id then
+        -- 检查是否处于加成时间
+        local isInBonusTime = CommonDB.GetInFireWork(human)
+        if isInBonusTime==true then
+            -- 应用10%加成,向下取整
+            return math.floor(cnt * 1.1)
+        end
+    end
+    -- 默认返回原数量
+    return cnt
 end

+ 8 - 0
script/module/bag/ItemLogic.lua

@@ -392,6 +392,14 @@ function cmd.treasurechestadd(data, human)
 
     TreasureChestLogic.TreasureChestLogic_AddItem(human, data.id, data.cnt)
 end
+
+function cmd.UseYanHua(data,human)
+    if 0>=data.cnt then
+        return
+    end
+    TopupLogic.addTime(human,data.cnt)
+    data.left = 0
+end
 -----------------------------------------------------------------------------
 
 -- 仅使用道具,不扣道具

+ 6 - 1
script/module/topup/Handler.lua

@@ -7,4 +7,9 @@ end
 
 function CG_BUY_CHECK(human, msg)
 	BuyLogic.checkCanBuy(human, msg.buyID)
-end
+end
+
+function CG_FIREWORKS_QUERY(human,msg)
+    TopupLogic.DurationofBonus(human)
+end
+

+ 2 - 1
script/module/topup/Proto.lua

@@ -54,5 +54,6 @@ GC_FIREWORKS_QUERY = {
 }
 
 GC_FIREWORKS_SHOW={
-
+	{"buffDuration", 1, "int"}, -- buff时效(单位:秒)
+	{"playerName",   1, "string"}  -- 新增:玩家名字
 }

+ 69 - 2
script/module/topup/TopupLogic.lua

@@ -14,14 +14,19 @@ local DailyLeichong = require("present.DailyLeichong")
 local LoginSignLogic = require("loginSign.LoginSignLogic")
 local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
 local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
-
+local MailExcel = require("excel.mail")
+local MailManager = require("mail.MailManager")
+local CommonDB = require("common.CommonDB")
+local Msg = require("core.Msg")
 -- 专属客服充值额度
 EXCLUSIVE_SERVER_9937 = 1000
 
 TOPUP_LIBAO_ID1 = 1   --盲盒礼包
 TOPUP_LIBAO_ID2 = 2   --铂金周卡
 TOPUP_LIBAO_ID3 = 3   --365王卡
-
+local MAX_FIREWORKS_DURATION = 43200
+local YanhuaEmail = 7012
+local ItemId=1022
 --封装直购基本信息
 local function wrapTopupItem(net, config, human)
 	net.id = config.id	
@@ -59,6 +64,29 @@ function clacTopupAcount(human, price, buyID)
 	LeichongHaoli.onAddMoney(human, price)
 	LeijiChongzhi.onAddMoney(human, price)
 	LoginSignLogic.chargeAfter(human)
+
+	sendFireworksMail(human,price)
+end
+
+-- 发送烟花邮件
+function sendFireworksMail(human, price)
+	if price < 100 then return end  -- 如果充值金额小于100,不发送邮件
+
+    -- 计算烟花数量
+    local nFireWorksCount = math.floor(price / 100)
+	if 0 >= nFireWorksCount then
+		return
+	end
+	local mailCfg = MailExcel.mail[YanhuaEmail]
+	local title = mailCfg.title
+	local content = mailCfg.content
+	local senderName = mailCfg.senderName
+    local items = {
+        {itemID = ItemId, count = nFireWorksCount}  -- 1022是烟花的道具ID
+    }
+
+    -- 调用邮件管理器发送邮件
+    MailManager.add(MailManager.SYSTEM, human.db._id, title, content, items, senderName)
 end
 
 function checkKf(human)
@@ -66,4 +94,43 @@ function checkKf(human)
     if human.db.topupAcount ~= nil and human.db.topupAcount >= EXCLUSIVE_SERVER_9937 then
         Msg.send(Msg.gc.GC_EXCLUSIVE_SERVER,human.fd)
     end
+end
+
+--给客户端下发结束时间//定义的协议时间 //当客户端有点击请求的时候
+function DurationofBonus(human)
+	local tMsgData = Msg.gc.GC_FIREWORKS_QUERY
+	tMsgData.buffDuration = CommonDB.getFireWorksBonusTime()
+	Msg.send(tMsgData, human.fd)
+end
+
+function Addtime(human, fireworksCount)
+	local nNowTime = os.time()
+	if not human or fireworksCount <= 0 then
+        return
+    end
+    local currentEndTime = CommonDB.getFireWorksBonusTime()
+	local baseTime=nNowTime
+	if currentEndTime>nNowTime then
+		baseTime=currentEndTime
+	end
+    local addedTime = math.max(fireworksCount * 60,60)
+	local newEndTime=math.min(
+		baseTime + addedTime,
+        nNowTime + MAX_FIREWORKS_DURATION
+	)
+	local totalDuration=newEndTime-nNowTime
+	if totalDuration <=0 or totalDuration> MAX_FIREWORKS_DURATION then
+		return
+	end
+    CommonDB.setFireWorkBonusTime(newEndTime)
+	local tMsgData = Msg.gc.GC_FIREWORKS_SHOW
+	tMsgData.buffDuration = CommonDB.getFireWorksBonusTime()
+	tMsgData.playerName=human.db.Name
+	
+    -- 下发时间给客户端时间和玩家名称
+	for _, human in pairs(ObjHuman.onlineUuid) do
+		if human and human.fd then
+		    Msg.send(tMsgData, human.fd)
+		end
+	end    
 end

+ 4 - 2
script/module/voucher/VoucherShopLogic.lua

@@ -22,7 +22,7 @@ local BagLogic = require("bag.BagLogic")
 local Log = require("common.Log")
 local BuyLogic = require("topup.BuyLogic")
 local YunYingLogic = require("yunying.YunYingLogic")
-
+local TopupLogic =require("topup.TopupLogic")
 
 -- 商店配置
 local tVoucherShopCof = nil
@@ -366,7 +366,9 @@ function VoucherShop_BuyItem(human, nBuyID)
         price = tTrueBuyConfig.CN
     }
     BuyLogic.buy(human, tBuyInfo)
-
+    if nDelVoucherNum >= 100 then
+        TopupLogic.sendFireworksMail(human, nDelVoucherNum)
+    end
     YunYingLogic.sendIconUpdate(VOUCHERSHOP_ACTID, human)
     
     -- 写日志