Selaa lähdekoodia

新增获取皮肤协议

249435196@qq.com 1 vuosi sitten
vanhempi
sitoutus
f9b85cfe79
1 muutettua tiedostoa jossa 211 lisäystä ja 0 poistoa
  1. 211 0
      script/module/role/NewLogic.lua

+ 211 - 0
script/module/role/NewLogic.lua

@@ -36,12 +36,223 @@ QUERY_QUICK_HATCH_ZUANSHI    = 17 --查询加速孵化需要的钻石
 
 AD_HATCH_RESET_FREECNT       = 4  --看广告加速孵化次数
 
+
+--[[
+    BuyItem = {
+        buyID : number   -- buy配置表id
+        region : string  -- 区域 默认cn
+        cost : number    -- 价格
+        icon : number    -- 图标
+        name : string    -- 名称
+        desc : string    -- 描述
+        zhekou : number  -- 折扣价
+        yuanjia : number -- 原价
+        ttl : number   -- 有效期
+    }
+    Item = {
+        id : number
+        count : number
+    }
+
+    Gift = {
+        id : number  -- 礼包ID
+        startTimeStamp : number  -- 开启时间戳(秒)
+        restTime : number  -- 剩余时间(秒)
+        buyItem : Buyitem  -- 礼包信息
+        content : {item}  -- 礼包内容
+    }
+
+    attr = {
+        key = number,   --属性类型
+        value = number, -- 属性值
+    }
+
+    SkinData = {
+        id = number  -- 皮肤id
+        attrs = [attr]array
+    }
+
+    IconFrame = {
+        id = number  -- 头像框id
+        desc = string
+        keepTime = number
+        name = string
+        camp = number
+        attrs = [attr]array
+    }
+
+    Skin = {
+        id : number  -- 皮肤配置ID
+        buyItem : Buyitem -- 皮肤信息
+        skinData :SkinData  -- 皮肤内容
+        Iconframe : IconFrame  -- 头像框内容
+    }
+]]
+
+------------------------------- CG请求 -------------------------------
+--[[
+    CG_WARORDER_INFO = {
+        orderType = number   -- 战令类型 1 勇士之证 2 恶魔之证 3 工会之证明 4 竞技之证
+    }
+]]
+local CG_WARORDER_INFO = 101  -- 战令信息请求
+--[[
+    orderType = number   -- 战令类型
+]]
+local CG_WARORDER_REWARD = 102 -- 战令获取奖励
+
+--[[
+    panelId = number    -- panelID
+]]
+local CG_SKIN_QUREY = 103    -- 皮肤活动详情查询
+
+------------------------------- GC推送 -------------------------------
+--[[
+    GC_GIFT_GENERATE = {
+        gift = Gift
+    }
+]]
+local GC_GIFT_GENERATE = 10  -- 新增礼包推送
+--[[
+    GC_QUERY_GIFT = {
+        list = {Gift}
+    }
+]]
+local GC_QUERY_GIFT = 11    -- 登录推送礼包数据
+
+
+--[[
+    BuyItem = {
+        BuyItem = {
+        {"buyID",		1,		"int"},			-- 支付ID
+        {"region",		1,		"string"},		-- 货币类型 CN/HK等
+        {"cost",		1,		"double"},		-- 价格 当前价格
+        {"icon",		1,		"int"},			-- 图标
+        {"name",		1,		"string"}, 		-- 名称
+        {"desc",		1,		"string"},	 	-- 描述
+        {"isFirst",		1,		"byte"},		-- 是否首次购买
+        {"doubleCnt",	1,		"byte"},		-- 双倍次数
+        {"actDoubleCnt",1,		"byte"},		-- 活动双倍次数
+        {"useDoubleCnt",1,		"int"},		    -- 当前消耗双倍次数
+        {"buyCnt",		1,		"int"},		    -- 当前购买次数
+        {"vipExp",		1,		"int"},			-- 附赠vip经验
+        {"zhekou",      1,      "int"},         -- 折扣
+        {"yuanjia",     1,      "int"},         -- 原价
+    }
+    }
+    normal = {
+        idx number                      等级
+        process number                  等级对应所需进度
+        content [ItemGrid]array         普通战令等级奖励
+        upgradeContent [ItemGrid]array  升级战令等级奖励
+    }
+    GC_WARORDER_INFO = {
+        orderType = orderType,         -- 战令类型
+        normal = [normal]array,        -- 普通配置
+        language = string
+        buyItem = BuyItem,             -- 战令商品信息
+        -- 自身的进度
+        exp = orderData.exp,           -- 当前经验
+        unlock = orderData.unlock,     -- 是否解锁升级版 0 表示未解锁 1 表示解锁
+        finish = [number]array,        -- 已经完成的普通版等级
+        upgradeFinish = [number]array, -- 已经完成的升级版等级
+    }
+]]
+local GC_WARORDER_INFO = 12  -- 战令信息推送
+--[[
+    GC_WARORDER_CHANGE = {
+        orderType = number            -- 战令类型
+        exp =   number                -- 战令经验
+        unlock = number               -- 是否解锁升级版 0 表示未解锁 1 表示解锁
+        finish = [number]array        -- idx数组
+        upgradeFinish = [number]array -- idx数组
+        isRed = number                -- 是否红点
+    }
+]]
+local GC_WARORDER_CHANGE = 13  -- 战令数据推送
+
+--[[
+    GC_SKIN_QUERY = {
+        list = [skin]array     -- 皮肤活动详情列表
+    }
+]]
+local GC_SKIN_QUERY = 14 -- 皮肤活动详情推送
+
+-----------------------------------------------------------------------
+
+
+
+local push = {
+    [GC_GIFT_GENERATE] = true,
+    [GC_QUERY_GIFT] = true,
+    [GC_WARORDER_INFO] = true,
+    [GC_WARORDER_CHANGE] = true,
+    [GC_SKIN_QUERY] = true
+}
+
+local handler = {
+    [CG_WARORDER_INFO] = function(human,param)
+        local orderType = assert(tonumber(param),"invalid param")
+        local data = WarOrder.warOrderInfo(human,orderType)
+        if not data then 
+            -- 参数错误,报错
+            return
+        end
+        PushClient(human,GC_WARORDER_INFO,data)
+    end,
+    [CG_WARORDER_REWARD] = function(human,param)
+        local orderType = assert(tonumber(param),"invalid param")
+        local data = WarOrder.warOrderReward(human,orderType)
+        if not data then 
+            -- 参数错误,报错
+            return
+        end
+        PushClient(human,GC_WARORDER_CHANGE,data)
+    end,
+    [CG_SKIN_QUREY] = function(human,param)
+        local panelId = assert(tonumber(param),"invalid param")
+        local heroSkinLogic = require"present.HeroSkinLogic"
+        local data = heroSkinLogic.query(human,panelId)
+        if not data then 
+            return
+        end
+        PushClient(human,GC_SKIN_QUERY,data)
+    end,
+}
+
+--[[function NewProto(human, type, paramJson)
+    -- print("newProto:",type,param)
+    -- local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
+    -- msgRet.ret = type
+    -- msgRet.tip = "test data"
+    -- Msg.send(msgRet,human.fd)
+    local f = assert(handler[type],"invalid proto type")
+    --local param  = Json.Decode(paramJson)
+    return f(human,paramJson)
+end]]
+
+-- 主动推送给客户端
+function PushClient(human,type,data) 
+    if not push[type] then 
+        Broadcast.sendErr(human, Lang.DRILL_CHOOSE_MY_ERR_INDEX .. " type is " .. type)
+        return
+    end
+    local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
+    msgRet.ret = type
+    msgRet.tip = Json.Encode(data)
+    Msg.send(msgRet,human.fd)
+end
+-----------------------------------------------------------
 function NewProto(human, type, param)
     -- print("newProto:",type,param)
     -- local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO
     -- msgRet.ret = type
     -- msgRet.tip = "test data"
     -- Msg.send(msgRet,human.fd)
+    local f = handler[type]
+    if f then 
+        return f(human,param)
+    end
 
     local msgRet = Msg.gc.GC_ROLE_CHANGE_BASEINFO