SCFC пре 1 година
родитељ
комит
0ca4d78983

+ 30 - 3
script/module/bag/Grid.lua

@@ -13,7 +13,7 @@ local RoleAttr = require("role.RoleAttr")
 local EquipLogic = require("equip.EquipLogic")
 
 -- 填充装备,道具信息 
-function makeItem(net, itemID, itemCnt, shuijingAttrID, itemGrid, itemIndex, opFlag, equipQuality)
+function makeItem(net, itemID, itemCnt, shuijingAttrID, itemGrid, itemIndex, opFlag, equipQuality, gemBonus)
 	local itemConfig = ItemDefine.getConfig(itemID)
 	net.id = itemConfig and itemID or 0 
 	net.cnt = itemConfig and itemCnt or 0
@@ -49,7 +49,7 @@ function makeItem(net, itemID, itemCnt, shuijingAttrID, itemGrid, itemIndex, opF
 
     makeItemSuipian(net, itemConfig)
     makeItemFuwen(net, itemID, itemConfig, itemGrid, itemIndex)
-    makeItemEquip(net, itemConfig, itemGrid, itemIndex, shuijingAttrID, equipQuality)
+    makeItemEquip(net, itemConfig, itemGrid, itemIndex, shuijingAttrID, equipQuality, gemBonus)
 end
 
 function makeFuwenSkill(net, skillID)
@@ -113,7 +113,7 @@ function makeItemFuwen(net, itemID, itemConfig, fuwenGrid, fuwenIndex)
 	end
 end
 
-function makeItemEquip(net, itemConfig, equipGrid, equipIndex, shuijingAttrID, equipQuality)
+function makeItemEquip(net, itemConfig, equipGrid, equipIndex, shuijingAttrID, equipQuality, gemBonus)
 	if itemConfig.mainType ~= ItemDefine.MAINTYPE_EQUIP then
 		return
 	end
@@ -156,11 +156,24 @@ function makeItemEquip(net, itemConfig, equipGrid, equipIndex, shuijingAttrID, e
         -- 基础属性
 		net.equip[1].baseAttr = {}
 		net.equip[1].baseAttr[0] = #itemConfig.base
+		--宝石
+		net.equip[1].gemBaseAttr[0] = 0
+		if gemBonus then
+			net.equip[1].gemBaseAttr[0] = #itemConfig.base
+		end
+		
 		for i=1, net.equip[1].baseAttr[0] do
 			net.equip[1].baseAttr[i] = net.equip[1].baseAttr[i] or {}
 			net.equip[1].baseAttr[i].key = itemConfig.base[i][1]
 			net.equip[1].baseAttr[i].value = math.floor(itemConfig.base[i][2] * baseRate)
+			
+			if gemBonus then
+				net.equip[1].gemBaseAttr[i].key = itemConfig.base[i][1]
+				net.equip[1].gemBaseAttr[i].value = math.floor(itemConfig.base[i][2] * baseRate * gemBonus.base)
+			end
 		end
+
+
         -- 随机属性
         local attrLen = 0
 		net.equip[1].tzAttr = net.equip[1].tzAttr or {}
@@ -202,10 +215,24 @@ function makeItemEquip(net, itemConfig, equipGrid, equipIndex, shuijingAttrID, e
 		net.equip[1].suit[1] = net.equip[1].suit[1] or {}
 		net.equip[1].suit[1].attr = net.equip[1].suit[1].attr or {}
     	net.equip[1].suit[1].attr[0] = #itemConfig.suitIm
+		
+		net.equip[1].suit[1].gemAttr[0] = 0
+		if gemBonus then
+			net.equip[1].suit[1].gemAttr[0] = #itemConfig.suitIm
+		end
+		
     	for i=1,net.equip[1].suit[1].attr[0] do
 			net.equip[1].suit[1].attr[i] = net.equip[1].suit[1].attr[i] or {}
 			net.equip[1].suit[1].attr[i].key = itemConfig.suitIm[i][1]
 			net.equip[1].suit[1].attr[i].value = itemConfig.suitIm[i][2]
+
+			--宝石
+			if gemBonus and gemBonus[i+1] then
+				net.equip[1].suit[1].gemAttr[i] = net.equip[1].suit[1].gemAttr[i] or {}
+				net.equip[1].suit[1].gemAttr[i].key = itemConfig.suitIm[i][1]
+				--这里i+1的原因是,装备套装属性配置suitIm中, idx为1的value是2件套加成, idx为2的是3件套加成,以此类推
+				net.equip[1].suit[1].gemAttr[i].value = gemBonus[i+1] * 100	--转成百分比发给客户端
+			end
 		end
 		net.equip[1].suit[1].id = itemConfig.suit
     	net.equip[1].suit[1].name = itemConfig.suitName

+ 2 - 0
script/module/bag/Proto.lua

@@ -15,6 +15,7 @@ SuitNet = {
 	{"name",     1,       "string"},        -- 套装名
 	{"num",      1,       "short"},         -- 第几件套
 	{"attr",     4,        Attr},           -- 套装性能
+	{"gemAttr",     4,     Attr},           -- 宝石套装加成
 }
 
 Equip = {
@@ -32,6 +33,7 @@ Equip = {
 	{"camp",       1,       "byte"},     -- 阵营专属
 	{"campAttr",   2,       Attr},       -- 阵营专属属性
 	{"args",	   2,		"int"},		 -- 额外参数 如果是水晶的话,第一个位表示是否满级
+	{"gemBaseAttr",4,		Attr},		 -- 宝石基础加成
 }
 
 FuwenSkillInfo = {

+ 33 - 0
script/module/hecheng/FenjieLogic.lua

@@ -90,6 +90,28 @@ local function solveOutItem(itemID, rate, value, isFloor)
 	end
 end
 
+
+--返还宝石
+local function returnGem(gemData)
+    if not gemData then
+        return
+    end
+
+	local calCnt = function(level)
+		local cnt = 0
+		for i=level, 1, -1 do
+			cnt = cnt + math.ceil(i/3)
+		end
+		return cnt
+	end
+
+    local num = 0
+    for _, v in pairs(gemData) do
+        num = num + calCnt(v.lv)
+    end
+    return  num
+end
+
 ----------------------------------------------------------------------------------------
 
 -- 判断能否分解
@@ -254,6 +276,15 @@ local function calcHeroOut(heroGrid, mainType)
 			end
 		end		
 	end
+
+	
+	--返还宝石
+	local gemCnt = returnGem(heroGrid.gem)
+	if gemCnt and gemCnt > 0 then
+		local gemId = HeroDefine.HEROJOBTOGEM[heroConfig.job]
+		addOutItem(gemId, gemCnt)
+	end
+	
 end
 
 -- 计算打折
@@ -273,6 +304,8 @@ local function calcHeroSelfOut(heroGrid)
 	addOutItem(ItemDefine.ITEM_GREEN_EXP_ID, baseValueConfig.soul)
 	addOutItem(ItemDefine.ITEM_HERO_UPGRADE_ID, baseValueConfig.jinjieshi)
 	addOutItem(ItemDefine.ITEM_SOUL_SUIPIAN_ID, baseValueConfig.suipian)
+
+	--英雄身上的宝石返还
 end
 
 local function calcHeroOuts(human, mainType, heroIDList, heroIndexList)

+ 10 - 0
script/module/hero/Handler.lua

@@ -4,6 +4,7 @@ local HeroEquip = require("hero.HeroEquip")
 local HeroTenZhiHuan = require("hero.HeroTenZhiHuan")
 local BagLogic = require("bag.BagLogic")
 local HeroStrategyLogic = require("hero.HeroStrategyLogic")
+local HeroGem = require("hero.HeroGem")
 
 -- 请求英雄详细信息:静态
 function CG_HERO_BAG_STATIC(human,msg)
@@ -207,3 +208,12 @@ function CG_HERO_BOOK_SINGLE_QUERY(human,msg)
 end
 
 
+----------------------------------------------宝石——--------------------------------------
+function CG_HERO_GEM_LEVELUP_QUERY(human,msg)
+    HeroGem.getGemData(human, msg.heroID, msg.heroIndex, msg.pos)
+end
+
+
+function CG_HERO_GEM_UPGRADEGEM(human,msg)
+    HeroGem.upgradeGem(human, msg.heroID, msg.heroIndex, msg.pos)
+end

+ 12 - 0
script/module/hero/HeroDefine.lua

@@ -16,6 +16,18 @@ HERO_SKIN_CNT = 999
 
 SHUIJING_UP_LV_LOCK = 2 -- 升级为原有水晶
 
+--英雄职业-能穿的宝石的映射表
+HEROJOBTOGEM = {
+    [1] = 1001,         --坦克
+    [2] = 1002,         --战士
+    [3] = 1003,         --法师
+    [4] = 1004,         --辅助
+}
+
+--英雄镶嵌宝石的最大孔位
+HEROGEMMAX = 4
+
+
 WEIGHTLV2HEROS = {}
 HEROELITE = {} --精英英雄列表
 WEIGHTLV2CAMPHEROS = {}   --英雄道具碎片抽奖[权重][阵营]

+ 28 - 4
script/module/hero/HeroEquip.lua

@@ -15,6 +15,7 @@ local Util = require("common.Util")
 local ItemExcel = require("excel.item").item
 local FuwenLogic = require("fuwen.FuwenLogic")
 local EquipLogic = require("equip.EquipLogic")
+local HeroGem = require("hero.HeroGem")
 
 function query(human, heroID, heroIndex)
 	local heroGrid = HeroLogic.getHeroGrid(human, heroID, heroIndex)
@@ -26,6 +27,9 @@ function query(human, heroID, heroIndex)
 	msgRet.id = heroID
 	msgRet.index = heroIndex
 
+	--宝石套装加成
+	local suitBonusTbl = HeroGem.suitAttrBonus(heroGrid)
+	
 	local cnt = 0
 	for i = 1, ItemDefine.EQUIP_MAX_CNT do
         local equipGrid = heroGrid.equip and heroGrid.equip[i]
@@ -34,7 +38,7 @@ function query(human, heroID, heroIndex)
 			if i == ItemDefine.EQUIP_SUBTYPE_SHUIJIN then -- 水晶比较特殊
 				Grid.makeItem(msgRet.equips[cnt], equipGrid.id, 1, heroGrid.shuijingAttrID)
 			else
-				Grid.makeItem(msgRet.equips[cnt], equipGrid.id, 1, nil, equipGrid, -1, Grid.getOpflagAtBag(heroGrid.equip[i].id))
+				Grid.makeItem(msgRet.equips[cnt], equipGrid.id, 1, nil, equipGrid, -1, Grid.getOpflagAtBag(heroGrid.equip[i].id),nil,suitBonusTbl)
 			end
 		end
 
@@ -96,7 +100,11 @@ function putOn(human, heroID, heroIndex, bagIndex, noCalc)
     local msgRet = Msg.gc.GC_HERO_EQUIP_PUTON
     msgRet.heroID = heroID
     msgRet.heroIndex = heroIndex
-    Grid.makeItem(msgRet.equip, equipID, 1, nil, equipGrid, bagIndex, Grid.getOpflagAtBag(equipID))
+
+	--获取宝石加成
+	local suitBonusTbl = HeroGem.suitAttrBonus(heroGrid)
+
+    Grid.makeItem(msgRet.equip, equipID, 1, nil, equipGrid, bagIndex, Grid.getOpflagAtBag(equipID), nil, suitBonusTbl)
 
     if heroGrid.equip == nil or
         heroGrid.equip[pos] == nil then
@@ -198,7 +206,13 @@ function putOnHero(human, heroID, heroIndex, putHeroID, putHeroIndex, putHeroPos
     local msgRet = Msg.gc.GC_HERO_EQUIP_PUTON
     msgRet.heroID = heroID
     msgRet.heroIndex = heroIndex
-    Grid.makeItem(msgRet.equip, equipID, 1, nil, equipGrid, 0, Grid.getOpflagAtBag(equipID))
+	
+	--获取宝石加成
+	local suitBonusTbl = HeroGem.suitAttrBonus(heroGrid)
+
+    Grid.makeItem(msgRet.equip, equipID, 1, nil, equipGrid, bagIndex, Grid.getOpflagAtBag(equipID), nil, suitBonusTbl)
+	
+    --Grid.makeItem(msgRet.equip, equipID, 1, nil, equipGrid, 0, Grid.getOpflagAtBag(equipID))
     Msg.send(msgRet, human.fd)
 end
 
@@ -281,6 +295,9 @@ function doCalcHero(obj,attrs)
 	local equip = obj.equip
 	if not equip then return end
 	
+
+	local suitBonusTbl = HeroGem.suitAttrBonus(obj)
+
     local mathFloor = math.floor
 	local equipSuitCntTable = nil
 	for i = 1,ItemDefine.EQUIP_MAX_CNT do
@@ -289,14 +306,16 @@ function doCalcHero(obj,attrs)
             local equipID = equipGrid.id	
 			local equipConfig = EquipExcel.equip[equipID]
             local baseRate = EquipLogic.getEquipBaseRate(equipGrid.quality)
+
             -- 水晶
 			if equipConfig.subType == ItemDefine.EQUIP_SUBTYPE_SHUIJIN then
 				for _,v in ipairs(EquipExcel.shuijingAttr[obj.shuijingAttrID].attr) do
 					RoleAttr.updateValue(v[1],v[2],attrs)
 				end
 			else
+				--装备基础属性
 				for _,v in ipairs(equipConfig.base) do
-					RoleAttr.updateValue(v[1],mathFloor(v[2] * baseRate),attrs)
+					RoleAttr.updateValue(v[1],mathFloor(v[2] * baseRate * (1 + (suitBonusTbl and suitBonusTbl.base or 0))),attrs)
 				end
 
                 -- 随机属性
@@ -340,6 +359,11 @@ function doCalcHero(obj,attrs)
 					local keyTemp = equipConfigTemp.suitIm[i][1]
 					local valTemp = equipConfigTemp.suitIm[i][2]
 					if v.cnt > i then
+						if suitBonusTbl and suitBonusTbl[i+1] then
+							--suitIm={{203,2500},{201,2500},{219,1500}}
+							--这里i+1的原因是,装备套装属性配置suitIm中, idx为1的value是2件套加成, idx为2的是3件套加成,以此类推
+							valTemp = valTemp * (1 + suitBonusTbl[i+1]) --宝石对套装的加成
+						end
 						RoleAttr.updateValue(keyTemp,valTemp,attrs)
 					end
 				end

+ 215 - 0
script/module/hero/HeroGem.lua

@@ -0,0 +1,215 @@
+-- 宝石相关逻辑
+local Lang = require("common.Lang")
+local Msg = require("core.Msg")
+local BagLogic = require("bag.BagLogic")
+local LogDefine = require("common.LogDefine")
+local HeroLogic = require("hero.HeroLogic")
+local ObjHuman = require("core.ObjHuman")
+local HeroExcel = require("excel.hero")
+local Grid = require("bag.Grid")
+local Util = require("common.Util")
+local HeroDefine = require("hero.HeroDefine")
+
+--宝石最大等级
+local MAXGEMLEVEL = 10
+
+
+--一级宝石对装备基础属性的加成
+local BASEBONUS = 0.05
+
+--一级宝石对装备套装效果的加成,key为套装,value为加成比例
+local GEMTOEQUIPATTR = {
+    [2] = 0.0025,
+    [3] = 0.0025,
+    [4] = 0.0025
+}
+
+--local inlayLog = "inlayGem"
+local upgradeLog = "upgradeGem"
+
+--组装下发给客户端的宝石数据
+function assembleData(sourceTb, targetTb, job, pos)
+    --只生成单个数据
+    local jobToGem = HeroDefine.HEROJOBTOGEM
+    if pos then
+        if sourceTb[pos] then
+            targetTb.id = job and jobToGem[job] or 0
+            targetTb.pos = pos
+            targetTb.lv = sourceTb[pos].lv
+            targetTb.maxLv = MAXGEMLEVEL
+            if targetTb.lv < MAXGEMLEVEL then
+                targetTb.upcost = math.ceil((targetTb.lv + 1) / 3 )
+            else
+                targetTb.upcost = 0 --宝石达到最高级时,消耗数量为0
+            end
+        else
+            targetTb.id = job and jobToGem[job] or 0
+            targetTb.pos = pos
+            targetTb.lv = 0
+            targetTb.maxLv = MAXGEMLEVEL
+            targetTb.upcost = math.ceil(1 / 3 )
+        end
+        return
+    end
+
+    --所有数据
+    for i = 1, HeroDefine.HEROGEMMAX do
+        if sourceTb and sourceTb[i] then
+            local lv = sourceTb[i].lv
+            targetTb[i] = {
+                id = job and jobToGem[job] or 0,
+                pos = sourceTb[i].pos,
+                lv = lv,
+                maxLv = MAXGEMLEVEL,
+            }
+            if lv < MAXGEMLEVEL then
+                targetTb[i].upcost = math.ceil((lv + 1) / 3 )
+            else
+                targetTb[i].upcost = 0 --宝石达到最高级时,消耗数量为0
+            end
+
+        else
+            targetTb[i] = {
+                id = job and jobToGem[job] or 0,
+                pos = i,
+                lv = 0,
+                maxLv = MAXGEMLEVEL,
+            }
+            targetTb[i].upcost = math.ceil( 1/ 3 )
+        end
+    end
+end
+
+
+--宝石对装备加成
+--规则:只要有镶嵌宝石,那么就能对1-4孔位上装备的基础属性,装备套装效果有加成。
+function suitAttrBonus(heroGrid)
+    local gemData = heroGrid.gem
+    if not gemData then
+        return
+    end
+
+    local sumLevel = 0
+    for _, v in pairs(gemData) do
+        sumLevel = sumLevel + v.lv
+    end
+    
+    if sumLevel > 0 then
+        local t = {}
+        for k, v in pairs(GEMTOEQUIPATTR)  do
+            t[k] = v * sumLevel
+        end
+        --基础属性
+        t.base = BASEBONUS * sumLevel
+        return t
+    end
+end
+
+
+--获取宝石数据,以ItemData格式下发
+function getGemData(human, heroID, heroIndex, pos)
+    --位置是否超出装备位置
+    if not pos or pos > HeroDefine.HEROGEMMAX then
+        return 
+    end
+
+    local heroGrid = HeroLogic.getHeroGrid(human, heroID, heroIndex)
+    if not heroGrid  then
+        return
+    end
+    
+    local heroCfg = HeroExcel.hero[heroID]
+    if not heroCfg or not heroCfg.job then
+        return
+    end
+
+    local itemId = HeroDefine.HEROJOBTOGEM[heroCfg.job]
+    local itemCnt = 1
+    
+    --下发客户端
+    local msgRet = Msg.gc.GC_HERO_GEM_LEVELUP_QUERY
+    Grid.makeItem(msgRet.list, itemId, itemCnt)
+    Msg.send(msgRet, human.fd)
+end
+
+
+--升级宝石
+function upgradeGem(human, heroID, heroIndex, pos)
+    --位置是否超出装备位置
+    if not pos or pos > HeroDefine.HEROGEMMAX then
+        return 
+    end
+
+    local heroGrid = HeroLogic.getHeroGrid(human, heroID, heroIndex)
+	if not heroGrid  then
+		return
+	end
+
+    --有没有穿装备
+    if not heroGrid.equip or not heroGrid.equip[pos] then
+        return
+    end
+
+
+    local heroCfg = HeroExcel.hero[heroID]
+    if not heroCfg or not heroCfg.job then
+        return
+    end
+    
+    local itemId = HeroDefine.HEROJOBTOGEM[heroCfg.job]
+    if not itemId then
+        return
+    end
+
+    --英雄数据中没有宝石那就是镶嵌操作
+    local isGen = true
+    local lv = 0
+    local gemData = heroGrid.gem or {}
+    if gemData[pos] then
+        lv = gemData[pos].lv
+        isGen = false
+    end
+
+
+    --已经最高级
+    if lv == MAXGEMLEVEL then
+        return
+    end
+    
+
+    lv = lv + 1
+    local itemCnt = math.ceil(lv / 3)
+
+    --宝石数量是否足够
+    if not BagLogic.checkItemCnt(human, itemId, itemCnt) then
+        return
+    end
+
+    --扣除道具
+    BagLogic.delItem(human, itemId, itemCnt, upgradeLog)
+
+    --更新数据
+    if isGen then
+        gemData[pos] = {
+            pos = pos,
+            lv = lv,
+        }
+        heroGrid.gem = gemData
+    else
+        gemData[pos].lv = lv
+    end
+    
+    ObjHuman.doCalcHero(human, heroIndex)
+    HeroLogic.sendHeroBagDynamic(human, heroID, heroIndex)
+    HeroLogic.refreshDot(human, heroGrid.uuid)
+
+    --通知客户端
+    local msgRet = Msg.gc.GC_HERO_GEM_UPGRADEGEM
+    msgRet.gemData[0] = HeroDefine.HEROGEMMAX
+    assembleData(gemData, msgRet.gemData, heroCfg.job, pos)
+    Msg.send(msgRet, human.fd)
+
+    --更新宝石加成
+    local queryFunc = require("hero.HeroEquip").query
+    queryFunc(human, heroID, heroIndex)
+end

+ 9 - 0
script/module/hero/HeroGrid.lua

@@ -41,6 +41,7 @@ local XingYaoGongMing = require("xingYaoMen.XingYaoGongMing")
 local FuwenExcel = require("excel.fuwen").fuwen
 local Log = require("common.Log")
 local Json = require("common.Json")
+local HeroGem = require("hero.HeroGem")
 
 HERO_GRID_CACHE = HERO_GRID_CACHE or {} -- 为静态英雄数据使用
 HERO_GRID_CACHE_TUJIAN = HERO_GRID_CACHE_TUJIAN or {}
@@ -261,6 +262,14 @@ function makeHeroSimple(net, grid, index, human, others, tuJian)
             net.general[1].desc = tj.desc or ""
         end
     end
+
+	--宝石
+	--根据客户端要求,如果没有宝石数据,就拼接一份默认数据下发
+	net.gemData[0] = 0
+	if net.id and net.id ~= 0 then
+		net.gemData[0] = HeroDefine.HEROGEMMAX
+		HeroGem.assembleData(grid and grid.gem, net.gemData, net.job)
+	end
 end
 
 -- 封装英雄信息装备符文

+ 58 - 2
script/module/hero/HeroLogic.lua

@@ -68,6 +68,7 @@ local YunYingLogic = require("yunying.YunYingLogic")
 local BingshuLogic = require("fuwen.BingshuLogic")
 local GiftLogic = require("topup.GiftLogic")
 
+
 HERO_MAX_STAR    =        15    -- 目前英雄最大星级
 
 local HERO_RESET_FREECNT = 3 	-- 每日重置次数	
@@ -216,7 +217,7 @@ function sendHeroBagList(human)
 	for index = 1, human.db.heroBag[0] do
         local heroGrid = human.db.heroBag[index]
         if heroGrid then
-		    cnt = cnt + 1		
+		    cnt = cnt + 1
 		    HeroGrid.makeHeroSimple(msgRet.list[cnt], heroGrid, index, human)
 		    if cnt >= HeroDefine.PAGE_HERO_COUNT then
 		    	msgRet.list[0] = cnt
@@ -342,8 +343,8 @@ function sendHeroBagUpdate(human, index)
 
 	local msgRet = Msg.gc.GC_HERO_BAG_ADD				
 	HeroGrid.makeHeroSimple(msgRet.data, heroGrid, index, human)
-	Msg.send(msgRet, human.fd)
 
+	Msg.send(msgRet, human.fd)
 end
 
 -- 发送英雄删除
@@ -1067,6 +1068,27 @@ function heroJueXingDo(human, heroID, heroIndex, inputIDList, inputIndexList)
     YunYingLogic.onCallBack(human, "onHeroStarChange", yunYingActParam)
 end
 
+--返还宝石
+function returnGem(gemData)
+    if not gemData then
+        return
+    end
+
+	local calCnt = function(level)
+		local cnt = 0
+		for i=level, 1, -1 do
+			cnt = cnt + math.ceil(i/3)
+		end
+		return cnt
+	end
+
+    local num = 0
+    for _, v in pairs(gemData) do
+        num = num + calCnt(v.lv)
+    end
+    return  num
+end
+
 
 -- 英雄重生预览 
 function heroChongShengQuery(human, heroID, heroIndex)
@@ -1106,7 +1128,23 @@ function heroChongShengQuery(human, heroID, heroIndex)
 	msgRet.needItemCnt = chongShengConfig.needItemCnt
 	Grid.makeItem(msgRet.bentiSuipian, suipianID, chongShengConfig.bentiCnt)
 	Grid.makeItem(msgRet.otherSuipian, otherSuipianID, chongShengConfig.suipianCnt)
+	
 	--Msg.trace(msgRet)
+
+	--宝石返回
+	
+	local gemCnt = returnGem(heroGrid.gem)
+	-- if gemCnt and gemCnt > 0 then
+	-- 	Grid.makeItem(msgRet.gemVec, gemId, gemCnt)
+	-- end
+
+	local gemId = HeroDefine.HEROJOBTOGEM[heroConfig.job] or 0
+
+
+	gemCnt = gemCnt or 0
+	Grid.makeItem(msgRet.gemVec, gemId, gemCnt)
+
+
 	Msg.send(msgRet, human.fd)
 end
 
@@ -1195,6 +1233,15 @@ function heroChongShengDo(human, heroID, heroIndex)
 		end
 	end
 
+
+	--宝石返还
+	local gemCnt = returnGem(heroGrid.gem)
+	if gemCnt and gemCnt > 0 then
+		local gemId = HeroDefine.HEROJOBTOGEM[heroConfig.job] or 0 
+		BagLogic.addItem(human, gemId, gemCnt, "hero_chongsheng")
+	end
+
+
 	-- 再给东西
 	BagLogic.addItem(human, suipianID, chongShengConfig.bentiCnt, "hero_chongsheng")
 	BagLogic.addItem(human, otherSuipianID, chongShengConfig.suipianCnt, "hero_chongsheng")
@@ -1207,6 +1254,15 @@ function heroChongShengDo(human, heroID, heroIndex)
 	msgRet.list[0] = 2
 	Grid.makeItem(msgRet.list[1], suipianID, chongShengConfig.bentiCnt)
 	Grid.makeItem(msgRet.list[2], otherSuipianID, chongShengConfig.suipianCnt)
+
+	--宝石
+	if gemCnt and gemCnt > 0 then
+		local gemId = HeroDefine.HEROJOBTOGEM[heroConfig.job] or 0 
+		msgRet.list[0] = msgRet.list[0] + 1
+		Grid.makeItem(msgRet.list[3], gemId, gemCnt)
+	end
+
+
 	for itemID, itemCnt in pairs(upList) do
 		msgRet.list[0] = msgRet.list[0] + 1
 		Grid.makeItem(msgRet.list[msgRet.list[0]], itemID, itemCnt)

+ 34 - 2
script/module/hero/Proto.lua

@@ -53,6 +53,15 @@ HeroUpgadeData = {
 	{"needItemCnt",	  1,      "int"},      --升到下阶所需英雄进阶石
 }
 
+GemData = {
+    {"id",				1,	"int"},     	-- 宝石ID
+    {"pos",				1,	"byte"},  		-- 装备部位
+    {"lv",				1,	"short"},   	-- 当前等级, 如果是0,表示宝石没升级
+	{"maxLv",			1,	"short"},   	-- 最大等级
+	{"upcost",			1,	"short"},		-- 升到下一级所需的宝石数量
+}
+
+
 -- 英雄简略信息
 HeroSimple = {
 	{"id",			1,		"int"},	 	 --id
@@ -81,7 +90,8 @@ HeroSimple = {
     {"order",       1,       "byte"},   -- 排序用
     {"isGongMing",  1,       "byte"},   -- 是否共鸣 
     {"general",     2,      HeroGeneral},   -- 通用信息 
-    {"xLv",        1,      "int"},   	 --xLv 初始值0
+    {"xLv",        	1,      "int"},   	 --xLv 初始值0
+	{"gemData",     5,     GemData},   -- 宝石
 }
 
 
@@ -599,6 +609,7 @@ GC_HERO_CHONGSHENG_QUERY = {
     {"needItemCnt",		1,		"int"},		-- 消耗道具数量
 	{"bentiSuipian",	1,      ItemData},	-- 返回本体碎片
 	{"otherSuipian",	1,		ItemData},	-- 随机英雄碎片
+	{"gemVec",			1,		ItemData},	-- 返回宝石数量
 }
 
 -- 请求重生
@@ -608,7 +619,7 @@ CG_HERO_CHONGSHENG_DO = {
 }
 -- 重生成功
 GC_HERO_CHONGSHENG_DO = {
-	{"list",            20, 	ItemData},  -- 
+	{"list",            21, 	ItemData},  -- 在原来基础上增加了宝石返还,长度由 20 ——> 21
 }
 
 
@@ -730,7 +741,28 @@ GC_HERO_TEN_ZHIHUAN = {
 }
 
 
+--------------------------------------------------宝石---------------------------
+
+CG_HERO_GEM_LEVELUP_QUERY = {
+	{"heroID",			1,		"int"},   -- 英雄id
+	{"heroIndex",		1,		"short"}, -- 英雄index
+	{"pos",				1,		"byte"},  -- 部位
+}
+
+GC_HERO_GEM_LEVELUP_QUERY = {
+	{"list",			1,		ItemData}, 
+}
+
+--宝石升级
+CG_HERO_GEM_UPGRADEGEM = {
+	{"heroID",			1,		"int"},   -- 英雄id
+	{"heroIndex",		1,		"short"}, -- 英雄index
+	{"pos",				1,		"byte"},  -- 部位
+}
 
+GC_HERO_GEM_UPGRADEGEM = {
+	{"gemData",			1,		GemData}, 
 
+}