gitxsm 2 недель назад
Родитель
Сommit
6d0d71f4ea

+ 1 - 0
script/common/LogDefine.lua

@@ -329,6 +329,7 @@ DEFINE = {
 	AnniversaryVoucherWheel = 787,			-- 周年庆活动-代金券转盘
 	AnniversaryActiveWheel  = 788,			-- 周年庆活动-活跃度转盘
 	BaiZhanChengShen		= 789,			-- 百战成神
+	skinGift				= 790,			-- 华丽皮肤礼包
 
 	errHandle				= 99999,		-- 异常处理
 }

+ 3 - 0
script/common/ProtoID.lua

@@ -1877,3 +1877,6 @@ _ENV[1928]="CG_ROLE_DAILY_GIFT_QUERY"
 _ENV[1929]="GC_ROLE_DAILY_GIFT_QUERY"
 _ENV[1930]="CG_ROLE_DAILY_GIFT_GET"
 
+_ENV[1931]="CG_SKIN_GIFT_QUERY"
+_ENV[1932]="GC_SKIN_GIFT_QUERY"
+

+ 1 - 1
script/module/absAct/Proto.lua

@@ -1527,7 +1527,7 @@ CG_NEW_BUSTHREEACT_GRANDGIFT_QUERY = {}
 
 -- 回复天选豪礼
 GC_NEW_BUSTHREEACT_GRANDGIFT_QUERY = {
-    {"tList",       20,     BUSONEACTYUANZHENG}
+    {"tList",       25,     BUSONEACTYUANZHENG}
 }
 
 -- 请求领取天选豪礼

+ 14 - 24
script/module/roleSystem/RoleDailyGift.lua

@@ -1,16 +1,14 @@
 -- 每日好礼(小7渠道专属)
--- db.roleDailyGiftData = { getTime = 领取时间戳 }
+-- db.roleDailyGiftGot = true 表示今日已领取,跨天由 updateDaily 重置
 
-local Util = require("common.Util")
 local Lang = require("common.Lang")
 local Msg = require("core.Msg")
 local Broadcast = require("broadcast.Broadcast")
 local Grid = require("bag.Grid")
 local BagLogic = require("bag.BagLogic")
-local ObjHuman = require("core.ObjHuman")
 local CommonDefine = require("common.CommonDefine")
--- local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
--- local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
+local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
+local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
 
 local LOGTYPE = "roleDailyGift"
 local REWARD_ITEM_ID = 31
@@ -31,11 +29,7 @@ function ModuleisOpen(human)
 end
 
 local function isClaimedToday(human)
-    local data = human.db.roleDailyGiftData
-    if not data or not data.getTime then
-        return false
-    end
-    return Util.isSameDay(data.getTime)
+    return human.db.roleDailyGiftGot == true
 end
 
 local function getPrizeState(human)
@@ -45,18 +39,19 @@ local function getPrizeState(human)
     return CommonDefine.COMMON_PRIZE_STATE_CANGET
 end
 
--- function isDot(human)
---     if not ModuleisOpen(human) then
---         return false
---     end
---     return getPrizeState(human) == CommonDefine.COMMON_PRIZE_STATE_CANGET
--- end
+function isDot(human)
+    if not ModuleisOpen(human) then
+        return false
+    end
+    return getPrizeState(human) == CommonDefine.COMMON_PRIZE_STATE_CANGET
+end
 
 function updateDaily(human)
     if not ModuleisOpen(human) then
         return
     end
-    -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
+    human.db.roleDailyGiftGot = nil
+    RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
     if human.fd then
         Query(human)
     end
@@ -67,8 +62,6 @@ function Query(human)
         return
     end
 
-    ObjHuman.updateDaily(human)
-
     local msgRet = Msg.gc.GC_ROLE_DAILY_GIFT_QUERY
     msgRet.status = getPrizeState(human)
     Grid.makeItem(msgRet.item, REWARD_ITEM_ID, REWARD_ITEM_CNT)
@@ -80,8 +73,6 @@ function Get(human)
         return Broadcast.sendErr(human, Lang.COMMON_SYSTEM_READY)
     end
 
-    ObjHuman.updateDaily(human)
-
     if isClaimedToday(human) then
         return Broadcast.sendErr(human, "今日已领取")
     end
@@ -89,9 +80,8 @@ function Get(human)
     local itemArr = {{REWARD_ITEM_ID, REWARD_ITEM_CNT}}
     BagLogic.addItemList(human, itemArr, LOGTYPE)
 
-    human.db.roleDailyGiftData = human.db.roleDailyGiftData or {}
-    human.db.roleDailyGiftData.getTime = os.time()
+    human.db.roleDailyGiftGot = true
 
-    -- RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
+    RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_113)
     Query(human)
 end

+ 5 - 0
script/module/skin/Handler.lua

@@ -1,4 +1,5 @@
 local SkinLogic = require("skin.SkinLogic")
+local SkinGiftLogic = require("skin.SkinGiftLogic")
 function CG_SKIN_BAG(human, msg)
 	SkinLogic.skinQuery(human)
 end
@@ -6,6 +7,10 @@ end
 function CG_SKIN_ON(human, msg)
 	SkinLogic.skinOp(human,msg.heroInd,msg.skinIn)
 end
+
+function CG_SKIN_GIFT_QUERY(human)
+	SkinGiftLogic.Query(human)
+end
 --[[
 function CG_SKIN_FENJIE(human, msg)
 	SkinLogic.fenjie(human,msg.ind)

+ 10 - 0
script/module/skin/Proto.lua

@@ -1,4 +1,6 @@
 local Attr = require("role.Proto").Attr
+local BuyItem = require("topup.Proto").BuyItem
+local ItemData = require("bag.Proto").ItemData
 ----------------------------------------------------------------------------------
 
 -- 皮肤数据查询
@@ -56,3 +58,11 @@ GC_SKIN_ON = {
 	{"heroId",		1,		"int"},
 	{"skinInd",		1,		"int"}, 
 }
+
+-- 华丽皮肤礼包
+CG_SKIN_GIFT_QUERY = {}
+
+GC_SKIN_GIFT_QUERY = {
+	{"buyItem",		1,		BuyItem},		-- 直购信息
+	{"giftItem",	2,		ItemData},		-- 礼包奖励
+}

+ 90 - 0
script/module/skin/SkinGiftLogic.lua

@@ -0,0 +1,90 @@
+-- 华丽皮肤礼包:仅直购,配置读取 excel.skin.skinGift
+
+local Msg = require("core.Msg")
+local Grid = require("bag.Grid")
+local BagLogic = require("bag.BagLogic")
+local BuyLogic = require("topup.BuyLogic")
+local Lang = require("common.Lang")
+local Broadcast = require("broadcast.Broadcast")
+
+local SkinGiftExcel = require("excel.skin").skinGift
+
+local LOGTAG = "skinGift"
+local GIFT_CFG_ID = 1
+
+local function getCfg()
+    return SkinGiftExcel[GIFT_CFG_ID]
+end
+
+local function getCfgByBuyId(buyId)
+    local cfg = getCfg()
+    if cfg and cfg.buyID == buyId then
+        return cfg
+    end
+end
+
+local function getBuyCnt(human, buyId)
+    local skinGiftData = human.db.skinGiftData
+    return skinGiftData and skinGiftData[buyId] or 0
+end
+
+function Query(human)
+    local cfg = getCfg()
+    if not cfg then
+        return
+    end
+
+    local msgRet = Msg.gc.GC_SKIN_GIFT_QUERY
+    BuyLogic.fontBuyItem(human, msgRet.buyItem, cfg.buyID)
+
+    msgRet.giftItem[0] = #cfg.rewards
+    for i, item in ipairs(cfg.rewards) do
+        Grid.makeItem(msgRet.giftItem[i], item[1], item[2])
+    end
+
+    Msg.send(msgRet, human.fd)
+end
+
+function onCharge(human, buyId, buyNum)
+    local cfg = getCfgByBuyId(buyId)
+    if not cfg then
+        return
+    end
+
+    buyNum = buyNum or 1
+    local nowBuyCnt = getBuyCnt(human, buyId)
+    if cfg.amount > 0 and buyNum + nowBuyCnt > cfg.amount then
+        return Broadcast.sendErr(human, Lang.ABS_GIFT_BUY_LIMIT)
+    end
+
+    local itemArr = {}
+    for i, item in ipairs(cfg.rewards) do
+        itemArr[i] = {item[1], item[2] * buyNum}
+    end
+
+    BagLogic.addItemList(human, itemArr, LOGTAG)
+
+    local skinGiftData = human.db.skinGiftData or {}
+    skinGiftData[buyId] = nowBuyCnt + buyNum
+    human.db.skinGiftData = skinGiftData
+
+    Query(human)
+end
+
+function GetRemainNum(human, buyId)
+    local cfg = getCfgByBuyId(buyId)
+    if not cfg then
+        return 0
+    end
+
+    if cfg.amount == 0 then
+        return 0
+    end
+
+    local nowBuyCnt = getBuyCnt(human, buyId)
+    if cfg.amount > nowBuyCnt then
+        return cfg.amount - nowBuyCnt
+    end
+
+    return 0
+end