|
|
@@ -351,7 +351,7 @@ local function getBattleAttrByType(human, battleType)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-
|
|
|
+--统计当前已获得属性的类型
|
|
|
local function getAttrTypeList(ids)
|
|
|
if not ids then
|
|
|
return
|
|
|
@@ -366,30 +366,32 @@ local function getAttrTypeList(ids)
|
|
|
end
|
|
|
|
|
|
|
|
|
---生成随机数据
|
|
|
-local function generateCfgWeightInfo(excludeIDList, excludeTypeList)
|
|
|
- local totalWeight = 0
|
|
|
- local type2List = {}
|
|
|
-
|
|
|
- --刷新单条属性时, 如果所有类型都获得了, 就不能继续刷新了
|
|
|
- if excludeTypeList then
|
|
|
- local bl = false
|
|
|
+--获取某个ID所属类型中品质最高的ID
|
|
|
+local function getMaxQualityId(id)
|
|
|
+ local targetType = battleRougeCfg[id].type
|
|
|
|
|
|
- for _, v in ipairs(battleRougeCfg) do
|
|
|
- if not excludeTypeList[v.type] then
|
|
|
- bl = true
|
|
|
- break
|
|
|
- end
|
|
|
- end
|
|
|
+ local q = 0
|
|
|
+ local targetId = 0
|
|
|
|
|
|
- if not bl then
|
|
|
- return totalWeight,type2List
|
|
|
+ for k, cfg in ipairs(battleRougeCfg) do
|
|
|
+ if cfg.type == targetType and cfg.quality > q then
|
|
|
+ targetId = k
|
|
|
+ q = cfg.quality
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ return targetId
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+--生成随机数据
|
|
|
+local function generateCfgWeightInfo(excludeTypeList)
|
|
|
+ local totalWeight = 0
|
|
|
+ local type2List = {}
|
|
|
+
|
|
|
for k,v in ipairs(battleRougeCfg) do
|
|
|
- if not excludeIDList or not excludeIDList[k] then
|
|
|
- local tp = v.type
|
|
|
+ local tp = v.type
|
|
|
+ if not excludeTypeList or not excludeTypeList[tp] then
|
|
|
local weight = v.weight
|
|
|
type2List[tp] = type2List[tp] or {weight = 0, typeList = {}}
|
|
|
type2List[tp].weight = type2List[tp].weight + weight
|
|
|
@@ -432,22 +434,47 @@ local function getIndexByRand(totalWeight, randList)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+--单条属性刷新时的随机处理
|
|
|
+local function getIndexByRand2(totalWeight, randList, times)
|
|
|
+ local tpList
|
|
|
+ local weight = 0
|
|
|
+ local randWeight = math.random(0, totalWeight)
|
|
|
+ for _,v in ipairs(randList) do
|
|
|
+ weight = weight + v.weight
|
|
|
+ if randWeight <= weight then
|
|
|
+ tpList = v
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ local id2NumList = {}
|
|
|
+ for i=1, times do
|
|
|
+ weight = 0
|
|
|
+ randWeight = math.random(0, tpList.weight)
|
|
|
+ for _,v in ipairs(tpList.typeList) do
|
|
|
+ weight = weight + v.weight
|
|
|
+ if randWeight <= weight then
|
|
|
+ id2NumList[v.id] = (id2NumList[v.id] or 0) + 1
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
|
|
|
---获得与当前ID同类型的最低级ID
|
|
|
--- local function getLowestIDByType(attrId)
|
|
|
--- local cfg = battleRougeCfg[attrId]
|
|
|
--- if cfg.lv == 1 then
|
|
|
--- return attrId
|
|
|
--- end
|
|
|
+ local finalId = 0
|
|
|
+ local tbl = {lv = 0, cfgNum = 0}
|
|
|
+ for id, num in pairs(id2NumList) do
|
|
|
+ finalId = id
|
|
|
+ local cfg = battleRougeCfg[id]
|
|
|
+ tbl.lv = tbl.lv + num * cfg.lv
|
|
|
+ tbl.cfgNum = tbl.cfgNum + num
|
|
|
+ end
|
|
|
|
|
|
--- local tp = cfg.type
|
|
|
--- for k,v in ipairs(battleRougeCfg) do
|
|
|
--- if v.type == tp and v.lv == 1 then
|
|
|
--- return k
|
|
|
--- end
|
|
|
--- end
|
|
|
--- end
|
|
|
+ if tbl.lv >= 4 then
|
|
|
+ finalId = getMaxQualityId(finalId)
|
|
|
+ end
|
|
|
|
|
|
+ return finalId, tbl
|
|
|
+end
|
|
|
|
|
|
|
|
|
--生成老号不同闯关模式的属性加成
|
|
|
@@ -475,7 +502,6 @@ local function generateDiffBattleAttr(human, battleType)
|
|
|
|
|
|
if times > 0 then
|
|
|
local totalWeight, randList = generateCfgWeightInfo()
|
|
|
-
|
|
|
if totalWeight <= 0 then
|
|
|
return
|
|
|
end
|
|
|
@@ -484,19 +510,40 @@ local function generateDiffBattleAttr(human, battleType)
|
|
|
local attrList = {}
|
|
|
|
|
|
for i=1, times do
|
|
|
- local id = getIndexByRand(totalWeight, randList)
|
|
|
- local cfg = battleRougeCfg[id]
|
|
|
-
|
|
|
+ local randId = getIndexByRand(totalWeight, randList)
|
|
|
+ local cfg = battleRougeCfg[randId]
|
|
|
local targetId = type2Id[cfg.type]
|
|
|
|
|
|
if targetId then
|
|
|
- attrList[targetId] = attrList[targetId] + cfg.lv
|
|
|
+ attrList[targetId].lv = attrList[targetId].lv + cfg.lv
|
|
|
+ attrList[targetId].cfgNum = attrList[targetId].cfgNum + 1
|
|
|
else
|
|
|
- attrList[id] = cfg.lv
|
|
|
- type2Id[cfg.type] = id
|
|
|
+ attrList[randId] = {
|
|
|
+ lv = cfg.lv,
|
|
|
+ cfgNum = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ type2Id[cfg.type] = randId
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ local tbl = {}
|
|
|
+ for id, info in pairs(attrList) do
|
|
|
+ if info.lv >= 4 then
|
|
|
+ local newId = getMaxQualityId(id)
|
|
|
+ tbl[id] = newId
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ for oldId, newId in pairs(tbl) do
|
|
|
+ attrList[newId] = {
|
|
|
+ lv = attrList[oldId].lv,
|
|
|
+ cfgNum = attrList[oldId].cfgNum
|
|
|
+ }
|
|
|
+ attrList[oldId] = nil
|
|
|
+ end
|
|
|
+
|
|
|
return attrList
|
|
|
end
|
|
|
end
|
|
|
@@ -520,13 +567,13 @@ end
|
|
|
--计算出战斗时使用的属性
|
|
|
local function calcAttr(attrData)
|
|
|
local attrList = {}
|
|
|
- for id, lv in pairs(attrData) do
|
|
|
+ for id, info in pairs(attrData) do
|
|
|
local attrCfg = battleRougeCfg[id]
|
|
|
|
|
|
if attrCfg then
|
|
|
local attrID = attrCfg.attrs[1]
|
|
|
local minAttrVal = getMinAttrValeByID(id)
|
|
|
- attrList[attrID] = (attrList[attrID] or 0) + (minAttrVal * lv)
|
|
|
+ attrList[attrID] = (attrList[attrID] or 0) + (minAttrVal * info.lv)
|
|
|
end
|
|
|
end
|
|
|
return attrList
|
|
|
@@ -2763,16 +2810,18 @@ function onFightEnd(human, result, fightTypeID, param1, combatInfo)
|
|
|
if totalWeight > 0 then
|
|
|
for i=1, 3 do
|
|
|
local id = getIndexByRand(totalWeight, randList)
|
|
|
- local cfg = battleRougeCfg[id]
|
|
|
+ -- local cfg = battleRougeCfg[id]
|
|
|
attrAddData.unSelectedAttrList = attrAddData.unSelectedAttrList or {}
|
|
|
- attrAddData.unSelectedAttrList[id] = cfg.lv
|
|
|
-
|
|
|
+ -- attrAddData.unSelectedAttrList[id] = cfg.lv
|
|
|
+ attrAddData.unSelectedAttrList[i] = id
|
|
|
end
|
|
|
QueryDiffBattleUnSelectAttr(human)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- TriggerLogic.PublishEvent(TriggerDefine.BATTLE_NORMAL_MODE_PASS, human.db._id, 1)
|
|
|
+ if nBattleType == EliteDefine.COPY_ELITE_NORMAL then
|
|
|
+ TriggerLogic.PublishEvent(TriggerDefine.BATTLE_NORMAL_MODE_PASS, human.db._id, 1)
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
function setBattleID(human, guajiID)
|
|
|
@@ -4130,11 +4179,11 @@ function GetNowBattleModeUnSelectAttr(human)
|
|
|
|
|
|
local msgRet = Msg.gc.GC_GETCHOOSEATTR_INFO
|
|
|
msgRet.attrInfo[0] = 0
|
|
|
- for id, lv in pairs(attrAddData.unSelectedAttrList) do
|
|
|
+ for _, id in ipairs(attrAddData.unSelectedAttrList) do
|
|
|
len = len + 1
|
|
|
local cfg = battleRougeCfg[id]
|
|
|
msgRet.attrInfo[len].id = id
|
|
|
- msgRet.attrInfo[len].level = lv
|
|
|
+ msgRet.attrInfo[len].level = cfg.lv
|
|
|
msgRet.attrInfo[len].icon = cfg.icon
|
|
|
msgRet.attrInfo[len].name = cfg.name
|
|
|
msgRet.attrInfo[len].quality = cfg.quality
|
|
|
@@ -4150,6 +4199,7 @@ end
|
|
|
local function sendNowBattleModeAllAttr(human, chosenAttrList)
|
|
|
local len = 0
|
|
|
local max_len = 20
|
|
|
+
|
|
|
local msgRet = Msg.gc.GC_GETALLATTR_INFO
|
|
|
msgRet.attrInfo[0] = 0
|
|
|
msgRet.isEnd = 0
|
|
|
@@ -4161,17 +4211,17 @@ local function sendNowBattleModeAllAttr(human, chosenAttrList)
|
|
|
end
|
|
|
|
|
|
|
|
|
- for id, nowLv in pairs(chosenAttrList) do
|
|
|
+ for id, attrInfo in pairs(chosenAttrList) do
|
|
|
len = len + 1
|
|
|
local cfg = battleRougeCfg[id]
|
|
|
msgRet.attrInfo[len].id = id
|
|
|
- msgRet.attrInfo[len].level = nowLv
|
|
|
+ msgRet.attrInfo[len].level = attrInfo.lv
|
|
|
msgRet.attrInfo[len].name = cfg.name
|
|
|
msgRet.attrInfo[len].icon = cfg.icon
|
|
|
msgRet.attrInfo[len].quality = cfg.quality
|
|
|
msgRet.attrInfo[len].attr.key = cfg.attrs[1]
|
|
|
local minAttrVal = getMinAttrValeByID(id)
|
|
|
- msgRet.attrInfo[len].attr.value = minAttrVal * nowLv
|
|
|
+ msgRet.attrInfo[len].attr.value = minAttrVal * attrInfo.lv
|
|
|
|
|
|
if len >= max_len then
|
|
|
msgRet.attrInfo[0] = len
|
|
|
@@ -4180,6 +4230,7 @@ local function sendNowBattleModeAllAttr(human, chosenAttrList)
|
|
|
num = num - max_len
|
|
|
if num <= 0 then
|
|
|
msgRet.isEnd = 1
|
|
|
+ return Msg.send(msgRet, human.fd)
|
|
|
end
|
|
|
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
@@ -4205,22 +4256,24 @@ function GetNowBattleModeAllAttr(human)
|
|
|
sendNowBattleModeAllAttr(human, attrAddData.chosenAttrList)
|
|
|
end
|
|
|
|
|
|
+
|
|
|
--选择属性
|
|
|
-function ChooseAttr(human, id)
|
|
|
+function ChooseAttr(human, idx)
|
|
|
local nBattleType = BattleLogic_GetBattleType(human)
|
|
|
local attrAddData = getBattleAttrByType(human, nBattleType)
|
|
|
|
|
|
- if not attrAddData or not attrAddData.unSelectedAttrList or not attrAddData.unSelectedAttrList[id] then
|
|
|
+ if not attrAddData or not attrAddData.unSelectedAttrList or not attrAddData.unSelectedAttrList[idx] then
|
|
|
return Broadcast.sendErr(human, Lang.BATTLE_NO_ATTR)
|
|
|
end
|
|
|
|
|
|
- attrAddData.chosenAttrList = attrAddData.chosenAttrList or {}
|
|
|
- local chosenAttrList = attrAddData.chosenAttrList
|
|
|
-
|
|
|
+ local id = attrAddData.unSelectedAttrList[idx]
|
|
|
+ local lv = battleRougeCfg[id].lv
|
|
|
|
|
|
local targetId = 0
|
|
|
local targetType = battleRougeCfg[id].type
|
|
|
- local lv = attrAddData.unSelectedAttrList[id]
|
|
|
+
|
|
|
+ attrAddData.chosenAttrList = attrAddData.chosenAttrList or {}
|
|
|
+ local chosenAttrList = attrAddData.chosenAttrList
|
|
|
|
|
|
for attrId in pairs(chosenAttrList) do
|
|
|
local cfg = battleRougeCfg[attrId]
|
|
|
@@ -4231,9 +4284,25 @@ function ChooseAttr(human, id)
|
|
|
end
|
|
|
|
|
|
if targetId ~= 0 then
|
|
|
- chosenAttrList[targetId] = chosenAttrList[targetId] + lv
|
|
|
+ chosenAttrList[targetId].lv = chosenAttrList[targetId].lv + lv
|
|
|
+ chosenAttrList[targetId].cfgNum = chosenAttrList[targetId].cfgNum + 1
|
|
|
+
|
|
|
+ --等级大于等于4级时, 使用最高品质的ID
|
|
|
+ if chosenAttrList[targetId].lv >= 4 then
|
|
|
+ local newId = getMaxQualityId(targetId)
|
|
|
+
|
|
|
+ chosenAttrList[newId] = {
|
|
|
+ lv = chosenAttrList[targetId].lv,
|
|
|
+ cfgNum = chosenAttrList[targetId].cfgNum
|
|
|
+ }
|
|
|
+
|
|
|
+ chosenAttrList[targetId] = nil
|
|
|
+ end
|
|
|
else
|
|
|
- chosenAttrList[id] = lv
|
|
|
+ chosenAttrList[id] = {
|
|
|
+ lv = lv,
|
|
|
+ cfgNum = 1
|
|
|
+ }
|
|
|
end
|
|
|
|
|
|
attrAddData.unSelectedAttrList = nil
|
|
|
@@ -4274,11 +4343,11 @@ function RefreshAttr(human, type_m, targetId)
|
|
|
|
|
|
for i=1, 3 do
|
|
|
local id = getIndexByRand(totalWeight, randList)
|
|
|
- local cfg = battleRougeCfg[id]
|
|
|
- unSelectedAttrList[id] = cfg.lv
|
|
|
+ unSelectedAttrList[i] = id
|
|
|
end
|
|
|
|
|
|
GetNowBattleModeUnSelectAttr(human)
|
|
|
+
|
|
|
elseif type_m == 2 then --刷新已选择的某个属性
|
|
|
if not attrAddData.chosenAttrList or not attrAddData.chosenAttrList[targetId] then
|
|
|
return Broadcast.sendErr(human, Lang.BATTLE_NO_ATTR)
|
|
|
@@ -4286,7 +4355,11 @@ function RefreshAttr(human, type_m, targetId)
|
|
|
|
|
|
local chosenAttrList = attrAddData.chosenAttrList
|
|
|
local excludeTypeList = getAttrTypeList(chosenAttrList)
|
|
|
- local totalWeight, randList = generateCfgWeightInfo(chosenAttrList, excludeTypeList)
|
|
|
+ local nowType = battleRougeCfg[targetId].type
|
|
|
+ excludeTypeList[nowType] = nil
|
|
|
+
|
|
|
+
|
|
|
+ local totalWeight, randList = generateCfgWeightInfo(excludeTypeList)
|
|
|
if totalWeight == 0 then
|
|
|
return Broadcast.sendErr(human, Lang.BATTLE_GET_ALL_ATTR)
|
|
|
end
|
|
|
@@ -4297,25 +4370,25 @@ function RefreshAttr(human, type_m, targetId)
|
|
|
end
|
|
|
BagLogic.delItem(human, ItemDefine.ITEM_ZUANSHI_ID, itemCnt, "battle")
|
|
|
|
|
|
- local newId = getIndexByRand(totalWeight, randList)
|
|
|
- local oldLv = chosenAttrList[targetId]
|
|
|
- chosenAttrList[targetId] = nil
|
|
|
- chosenAttrList[newId] = oldLv
|
|
|
+ --随机
|
|
|
+ local oldAttrData = chosenAttrList[targetId]
|
|
|
|
|
|
+ local newId, newAttrInfo = getIndexByRand2(totalWeight, randList, oldAttrData.cfgNum)
|
|
|
+ chosenAttrList[targetId] = nil
|
|
|
+ chosenAttrList[newId] = newAttrInfo
|
|
|
|
|
|
local cfg = battleRougeCfg[newId]
|
|
|
local msgRet = Msg.gc.GC_REFRESH_ATTR
|
|
|
msgRet.oldId = targetId
|
|
|
-
|
|
|
msgRet.newAttrData.name = cfg.name
|
|
|
msgRet.newAttrData.icon = cfg.icon
|
|
|
msgRet.newAttrData.id = newId
|
|
|
msgRet.newAttrData.quality = cfg.quality
|
|
|
- msgRet.newAttrData.level = oldLv
|
|
|
+ msgRet.newAttrData.level = newAttrInfo.lv
|
|
|
|
|
|
msgRet.newAttrData.attr.key = cfg.attrs[1]
|
|
|
local minAttrVal = getMinAttrValeByID(newId)
|
|
|
- msgRet.newAttrData.attr.value = minAttrVal * oldLv
|
|
|
+ msgRet.newAttrData.attr.value = minAttrVal * newAttrInfo.lv
|
|
|
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
|