Эх сурвалжийг харах

增加境界系统, 调整线下活动相关协议ID

gitxsm 1 жил өмнө
parent
commit
b83cd4d531

+ 1 - 0
script/common/LogDefine.lua

@@ -258,6 +258,7 @@ DEFINE = {
 	diamondcost_get         = 707,           -- 古玉消费限时活动获得
 	activitycollection_get  = 708,           -- 活动合集限时活动获得
 	upgradeGem			 	= 750, 			 --宝石升级
+	realmUpgrade			= 751,			 --境界提升
 }
 
 

+ 7 - 4
script/common/ProtoID.lua

@@ -1294,7 +1294,10 @@ _ENV[1310]="CG_HERO_GEM_LEVELUP_QUERY"
 _ENV[1311]="GC_HERO_GEM_LEVELUP_QUERY"
 _ENV[1312]="CG_HERO_GEM_UPGRADEGEM"
 _ENV[1313]="GC_HERO_GEM_UPGRADEGEM"
-_ENV[1320]="CG_ESTEEMGIFT_QUERY"
-_ENV[1321]="GC_ESTEEMGIFT_QUERY"
-_ENV[1322]="CG_HUGERECHARGE_QUERY"
-_ENV[1323]="GC_HUGERECHARGE_QUERY"
+_ENV[1315]="CG_ESTEEMGIFT_QUERY"
+_ENV[1316]="GC_ESTEEMGIFT_QUERY"
+_ENV[1317]="CG_HUGERECHARGE_QUERY"
+_ENV[1318]="GC_HUGERECHARGE_QUERY"
+_ENV[1320]="CG_ROLE_REALM_QUERY"
+_ENV[1321]="GC_ROLE_REALM_QUERY"
+_ENV[1322]="CG_ROLE_REALM_UPGRADE"

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

@@ -929,7 +929,7 @@ GC_ABS_NEWHERO = {
     {"id",              1,  "int"},         -- 英雄id
     {"startTime",       1,  "int"},         -- 开启时间
     {"endTime",         1,  "int"},         -- 结束时间
-    {"giftlist",        4,  NewHeroGift},   -- 礼包列表
+    {"giftlist",        14,  NewHeroGift},   -- 礼包列表
 }
 
 CG_ABS_NEWHERO_BUYGIFT = {

+ 1 - 0
script/module/role/Proto.lua

@@ -36,6 +36,7 @@ RoleBase = {
     {"serverName", 1, "string"},	    -- 蓝钻信息
     {"createTime", 1, "int"},
     {"signInCnt", 1, "int"},
+	{"realmName", 1, "string"},	    	-- 境界名称
 }
 
 ChenghaoNet = {

+ 4 - 0
script/module/role/RoleAttr.lua

@@ -36,6 +36,7 @@ local ItemDefine = require("bag.ItemDefine")
 local EquipLogic = require("equip.EquipLogic")
 local CombatPosLogic = require("combat.CombatPosLogic")
 local CombatDefine = require("combat.CombatDefine")
+local RoleRealmLogic = require("roleSystem.RoleRealmLogic")
 
 -- 计算人数属性
 function doCalc(human)
@@ -147,6 +148,9 @@ function calcHeroGrid(heroGrid, index, human)
 	UnionLivenessLogic.doCalcHero(human, HERO_OTHER_ATTRS) --公会活跃等级
 	ChengjiuLogic.doCalcHero(human, HERO_OTHER_ATTRS) --成就属性加成
 	MoshouLogic.doCalcHero(human, heroGrid, HERO_OTHER_ATTRS) -- 魔兽	
+
+	RoleRealmLogic.doCalcHero(human, HERO_OTHER_ATTRS) --境界
+
 	--不同模块在英雄属性计算 end	
 	
 	-- 计算评分

+ 2 - 0
script/module/role/RoleDBLogic.lua

@@ -418,6 +418,8 @@ function createDefaultRole(account)
 		nWeekCardNum = nil,						-- 周活动-抽卡数量
 		tWeekCardPrize = nil,					-- 周活动-抽卡奖励信息
 
+		realmLv = nil,							--境界等级
+
         mergeInfo = {},   --融合信息 {mergeStartTime: 0 , mergeTime: 0, mergeEndTime: 0, heroId: 0}
 		gift = {
 			unlock = {},

+ 4 - 0
script/module/role/RoleLogic.lua

@@ -25,6 +25,8 @@ local RoleHeadLogic = require("role.RoleHeadLogic")
 local UnionExcel = require("excel.union")
 local FilterUtil = require("common.FilterUtil")
 local Broadcast = require("broadcast.Broadcast")
+local RoleRealmLogic = require("roleSystem.RoleRealmLogic")
+
 
 FieldRoleBase = {identity=1, name=1, lv=1, vipLv=1, systemSet=1, head=1, headFrame=1, body=1, chenghao=1, unionUuid=1, zhandouli=1, blue=1, yellow=1,birthday = 1,sex = 1,signature = 1}
 local FAKE_HUMAN = {db = nil}
@@ -104,6 +106,8 @@ function getRoleBase(human, net, combatType, isMinNet)
     net.yellow.year = (db and db.yellow and db.yellow.year) and 1 or 0
     net.yellow.lux = (db and db.yellow and db.yellow.lux) and 1 or 0
 
+    net.realmName = RoleRealmLogic.getRealmName(human)
+
     if isMinNet then
        clear2MinNet(db, net)
     end

+ 12 - 0
script/module/roleSystem/Handler.lua

@@ -1,5 +1,7 @@
 local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
 
+local RoleRealmLogic = require("roleSystem.RoleRealmLogic")
+
 function CG_ROLESYSTEM_QUERY(human, msg)
 	
 end
@@ -11,3 +13,13 @@ end
 function CG_ROLESYSTEM_OPEN(human, msg)
    RoleSystemLogic.open(human, msg.id)
 end
+
+
+
+function CG_ROLE_REALM_QUERY(human, msg)
+   RoleRealmLogic.query(human)
+end
+
+function CG_ROLE_REALM_UPGRADE(human, msg)
+   RoleRealmLogic.realmUpgrade(human)
+end

+ 22 - 0
script/module/roleSystem/Proto.lua

@@ -1,3 +1,6 @@
+local ItemData = require("bag.Proto").ItemData
+local Attr = require("role.Proto").Attr
+
 RoleSystemNet = {
 	{"id",			1,	"short"},
 	{"isOpen",		1,	"byte"},--1:开启 0 未开启
@@ -32,4 +35,23 @@ CG_ROLESYSTEM_OPEN = {
 
 GC_ROLESYSTEM_OPEN = {
      {"id",			50,	"short"},
+}
+
+--境界查询
+CG_ROLE_REALM_QUERY = {
+
+}
+
+
+GC_ROLE_REALM_QUERY = {
+	{"nowRealmName",		 1,  "string"}, --当前境界名称
+	{"nowAttrs",			 9,	  Attr},	--当前境界属性加成
+	{"nextRealmName",		 1,  "string"}, --下一境界名称
+    {"nextAttrs",			 9,	  Attr},	--下一境界属性加成
+    {"itemData", 			 1,  ItemData},	--提升下一境界消耗道具
+}
+
+--提升境界
+CG_ROLE_REALM_UPGRADE = {
+
 }

+ 190 - 0
script/module/roleSystem/RoleRealmLogic.lua

@@ -0,0 +1,190 @@
+--境界系统
+--[=[
+    数据库存储数据: human.db.realmLv
+    只存境界等级,境界的属性加成等则是实时计算
+]=]--
+
+local Msg = require("core.Msg")
+local BagLogic = require("bag.BagLogic")
+local realmConfig = require("excel.realm").Sheet1
+local Grid = require("bag.Grid")
+local RoleAttr = require("role.RoleAttr")
+local RoleDefine = require("role.RoleDefine")
+local ObjHuman = require("core.ObjHuman")
+local Util = require("common.Util")
+local REALM_UPGRADE_LOG = "realmUpgrade"
+
+
+--加万分比的属性
+local sp_attr = {
+    [201] = 1,
+    [202] = 1,
+    [203] = 1,
+    [204] = 1
+}
+
+local function calAttrSum(tbl, lv)
+    for i = 1, lv do
+        local cfg = realmConfig[i]
+        if cfg and cfg.attrs then
+            for k,v in ipairs(cfg.attrs) do
+                local id = v[1]
+                local value = v[2]
+                tbl[k] = tbl[k] or {}
+                tbl[k].key = id
+                if sp_attr[id] then
+                    tbl[k].value = (tbl[k].value or 0) + (value / 100)
+                else
+                    tbl[k].value = (tbl[k].value or 0) + value
+                end
+            end
+        end
+    end
+end
+
+
+
+local function sendToclient(human)
+    local realmLv = human.db and human.db.realmLv or 0
+    local msgRet = Util.copyTable(Msg.gc.GC_ROLE_REALM_QUERY)
+
+    local bl = false
+    if realmLv <= 0 then
+        bl = true
+        msgRet.nowRealmName = ""
+    end
+
+
+    local nowRealmCfg = bl and realmConfig[1] or realmConfig[realmLv]
+    if not nowRealmCfg then
+        return
+    end
+    if not bl then
+        msgRet.nowRealmName = nowRealmCfg.name
+    end
+    
+    local attrsCfg = nowRealmCfg.attrs
+    msgRet.nowAttrs[0] = #attrsCfg
+
+    if bl then
+        for k,v in ipairs(attrsCfg) do
+            msgRet.nowAttrs[k] = msgRet.nowAttrs[k] or {}
+            msgRet.nowAttrs[k].key = v[1] or 0
+            msgRet.nowAttrs[k].value = 0
+        end
+    else
+        calAttrSum(msgRet.nowAttrs, realmLv)
+    end
+
+    local itemId, itemCnt, nextRealmCfg
+    if realmLv < #realmConfig then
+        nextRealmCfg = realmConfig[realmLv + 1]
+        if not nextRealmCfg then
+            return
+        end
+        itemCnt = nextRealmCfg.itemCnt
+        calAttrSum(msgRet.nextAttrs, realmLv+1)
+    else
+        nextRealmCfg = realmConfig[realmLv]
+        itemCnt = 0
+        calAttrSum(msgRet.nextAttrs, realmLv)
+    end
+    itemId = nextRealmCfg.itemId
+    Grid.makeItem(msgRet.itemData, itemId, itemCnt)
+
+    msgRet.nextRealmName = nextRealmCfg.name
+
+    msgRet.nextAttrs[0] = #nextRealmCfg.attrs
+
+    Msg.send(msgRet, human.fd)
+end
+
+
+--境界对属性加成
+function doCalcHero(human, attrs)
+    if not human then
+        return
+    end
+    local realmLv =  human.db and human.db.realmLv or 0
+    if realmLv <= 0 then
+        return
+    end
+    for i=1, realmLv do
+        local singleCfg = realmConfig[i]
+        if singleCfg and singleCfg.attrs then
+            for _, v in ipairs(singleCfg.attrs) do
+                if v[2] > 0 then
+                    RoleAttr.updateValue(v[1], v[2], attrs)
+                end
+            end
+        end
+    end
+end
+
+--获取境界名字
+function getRealmName(human)
+    local name = ""
+    if  human.db and human.db.realmLv then
+        local singleCfg = realmConfig[human.db.realmLv]
+        if singleCfg and singleCfg.name then
+            name = singleCfg.name
+        end
+    end
+    return name
+end
+
+--红点判断
+function isDot(human)
+    local realmLv = human.db.realmLv or 0
+    if realmLv >= #realmConfig then
+        return false
+    end
+
+    local singleCfg = realmConfig[1]
+    if realmLv > 0 then
+        singleCfg = realmConfig[realmLv + 1]
+    end
+    if not singleCfg then
+        return false
+    end
+    local itemId = singleCfg.itemId
+    local itemCnt = singleCfg.itemCnt
+    if BagLogic.getItemCnt(human, itemId) < itemCnt then
+        return false
+    end
+    return true
+end
+
+
+--查询
+function query(human)
+    sendToclient(human)
+end
+
+--提升境界
+function realmUpgrade(human)
+    local realmLv = human.db.realmLv or 0
+
+    if realmLv >= #realmConfig then
+        return
+    end
+
+    realmLv = realmLv + 1
+    local singleCfg = realmConfig[realmLv]
+    if not singleCfg then
+        return
+    end
+
+    local itemId = singleCfg.itemId
+    local itemCnt = singleCfg.itemCnt
+    if not BagLogic.checkItemCnt(human, itemId, itemCnt) then
+        return
+    end
+
+    BagLogic.delItem(human, itemId, itemCnt, REALM_UPGRADE_LOG)
+    human.db.realmLv = realmLv
+    sendToclient(human)
+    RoleAttr.cleanHeroAttrCache(human)
+    RoleAttr.doCalc(human)
+    ObjHuman.sendAttr(human, RoleDefine.ZHANDOULI)
+end