|
|
@@ -780,6 +780,20 @@ function initAfterStart()
|
|
|
end
|
|
|
|
|
|
function onLogin(human)
|
|
|
+ --处理老号已经在小游戏玩法上线前已经推过图没有获得小游戏次数
|
|
|
+ if not human.db.battleGameTimes then
|
|
|
+ local gameTimes = 0
|
|
|
+ local battleID = human.db.battleID
|
|
|
+ local allCfg = BattleExcel.node
|
|
|
+ for i=1, battleID-1 do
|
|
|
+ local cfg = allCfg[i]
|
|
|
+ if cfg and cfg and type(cfg.gameType) == "number" and cfg.gameType == 1 then
|
|
|
+ gameTimes = gameTimes + 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+ human.db.battleGameTimes = gameTimes
|
|
|
+ end
|
|
|
+
|
|
|
if human.db.lv >= BATTLE_LOGIN_LEV_TIPS then
|
|
|
return
|
|
|
end
|
|
|
@@ -1427,6 +1441,8 @@ function query(human)
|
|
|
|
|
|
fontVideoInfo(human, msgRet.videoInfo, monsterConfig)
|
|
|
fontExtraDataSSZH(msgRet.extraDataSSZH, nowNodeConfig.mapID, nNowBattleID, human)
|
|
|
+
|
|
|
+ msgRet.battleGameTimes = human.db.battleGameTimes or 0
|
|
|
-- Msg.trace(msgRet)
|
|
|
Msg.send(msgRet, human.fd)
|
|
|
|
|
|
@@ -2456,6 +2472,14 @@ function onFightEnd(human, result, fightTypeID, param1, combatInfo)
|
|
|
-- end
|
|
|
|
|
|
BattleLogic_SetBattleBattleID(human, nextBattleID)
|
|
|
+
|
|
|
+ --增加小游戏次数
|
|
|
+ if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
|
|
|
+ if config and type(config.gameType) == "number" and config.gameType == 1 then
|
|
|
+ human.db.battleGameTimes = (human.db.battleGameTimes or 0) + 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
-- human.db.battleID = battleID + 1
|
|
|
-- 通过第10关,默认开启二倍速
|
|
|
if nextBattleID == 10 and EliteDefine.COPY_ELITE_NORMAL == nBattleType then
|
|
|
@@ -2619,6 +2643,21 @@ function setBattleByGm(human, val, maxBattleID)
|
|
|
maxBattleID = val
|
|
|
end
|
|
|
|
|
|
+ local nBattleType = BattleLogic_GetBattleType(human)
|
|
|
+ if EliteDefine.COPY_ELITE_NORMAL == nBattleType then
|
|
|
+ local gameTimes = 0
|
|
|
+ local battleID = BattleLogic_GetBattleGuaJiID(human)
|
|
|
+ local allCfg = BattleExcel.node
|
|
|
+ for i=battleID, val-1 do
|
|
|
+ local singleCfg = allCfg[i]
|
|
|
+ if singleCfg and type(singleCfg.gameType) == "number" and singleCfg.gameType == 1 then
|
|
|
+ gameTimes = gameTimes + 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+ human.db.battleGameTimes = (human.db.battleGameTimes or 0) + gameTimes
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
BattleLogic_SetBattleBattleID(human, val)
|
|
|
BattleLogic_SetBattleGuaJiID(human, val)
|
|
|
setBattleID(human, val)
|
|
|
@@ -3442,7 +3481,7 @@ end
|
|
|
|
|
|
-- 获取未领取奖励
|
|
|
local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
|
|
|
- print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
|
|
|
+ --print("1:[BattleLogic_GetNorewardReceived] id = "..human.db._id.." nBattleType = "..nBattleType)
|
|
|
|
|
|
local nBattleID = BattleLogic_GetBattleIDByType(human, nBattleType)
|
|
|
local tBattleConfig = BattleLogic_GetBattleConfigByType(nBattleType)
|
|
|
@@ -3470,7 +3509,7 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
|
|
|
local battleNumber = #tBattleConfig.node
|
|
|
|
|
|
-- local nGuajiID = human.db.guajiID or 0
|
|
|
- print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID.. " nBattleID = "..nBattleID)
|
|
|
+ --print("[BattleLogic_GetNorewardReceived] nGuajiID = "..nGuaJiID.. " nBattleID = "..nBattleID)
|
|
|
|
|
|
-- 判断ID得用战斗ID-1, 因为挂机ID可以设置
|
|
|
local nJudeNum = nGuaJiID
|
|
|
@@ -3482,7 +3521,7 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
|
|
|
nJudeNum = nBattleID - 1
|
|
|
end
|
|
|
|
|
|
- print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
|
|
|
+ --print("[BattleLogic_GetNorewardReceived] nJudeNum = "..nJudeNum)
|
|
|
|
|
|
for k,v in ipairs(tBattleConfig.node) do
|
|
|
if #v.tongguan ~= 0 then
|
|
|
@@ -3515,7 +3554,7 @@ local function BattleLogic_GetNorewardReceived(human, nBattleType, cIndex)
|
|
|
HeroGrid.makeHeroSimpleByID(net.heroReward[1], cf[1][1], nil, other, human)
|
|
|
HeroGrid.makeHeroSimpleByGeneral(net.heroReward[1], cf[1][1])
|
|
|
|
|
|
- local tHeroInfo = Util.printTable(net.heroReward)
|
|
|
+ -- local tHeroInfo = Util.printTable(net.heroReward)
|
|
|
-- print("[BattleLogic_GetNorewardReceived] 英雄数据 k = "..k.." 获取的数据 = "..tHeroInfo)
|
|
|
else
|
|
|
net.reward[0] = 1
|
|
|
@@ -3757,4 +3796,66 @@ function BattleLogic_AddMopup(human, nGoodsID, nGoodsNum)
|
|
|
|
|
|
print("[BattleLogic_AddMopup] 玩家增加扫荡次数 name = "
|
|
|
..human.db.name.." nAddNum ="..nGoodsNum)
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+--获取小游戏奖励
|
|
|
+function GetGameReward(human, indexStr)
|
|
|
+ local battleGameTimes = human.db.battleGameTimes
|
|
|
+
|
|
|
+ if not battleGameTimes or battleGameTimes <= 0 then
|
|
|
+ return Broadcast.sendErr(human, Lang.JINBI_EXCHANGE_ERR_CNT)
|
|
|
+ end
|
|
|
+
|
|
|
+ local indexVec = Util.split(indexStr, "|")
|
|
|
+ if #indexVec <= 0 or #indexVec > 3 then
|
|
|
+ return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
|
|
|
+ end
|
|
|
+
|
|
|
+ local maxTimes = 1
|
|
|
+ local maxTimesIdx
|
|
|
+ local sumIndexTbl = {}
|
|
|
+
|
|
|
+ for _, idx in ipairs(indexVec) do
|
|
|
+ idx = tonumber(idx)
|
|
|
+ if not sumIndexTbl[idx] then
|
|
|
+ sumIndexTbl[idx] = 1
|
|
|
+ else
|
|
|
+ sumIndexTbl[idx] = sumIndexTbl[idx] + 1
|
|
|
+ maxTimes = sumIndexTbl[idx]
|
|
|
+ maxTimesIdx = idx
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ local itemId, itemCnt = 0,0
|
|
|
+ local configs = BattleExcel.gameReward
|
|
|
+
|
|
|
+ if maxTimes <= 1 then
|
|
|
+ local randIndex = math.random(1, #indexVec)
|
|
|
+ maxTimesIdx = tonumber(indexVec[randIndex])
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, v in ipairs(configs) do
|
|
|
+ if v.itemID == maxTimesIdx then
|
|
|
+ itemId = v.itemID
|
|
|
+ if maxTimes <= 1 then
|
|
|
+ itemCnt = v.itemCnt
|
|
|
+ else
|
|
|
+ itemCnt = v["itemCnt"..maxTimes]
|
|
|
+ end
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ if not itemId or not itemCnt then
|
|
|
+ return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
|
|
|
+ end
|
|
|
+
|
|
|
+ battleGameTimes = battleGameTimes - 1
|
|
|
+ human.db.battleGameTimes = battleGameTimes
|
|
|
+ BagLogic.addItemList(human, { {itemId, itemCnt} }, "battle")
|
|
|
+
|
|
|
+ local msgRet = Msg.gc.GC_BATTLE_GETGAMEREWARD
|
|
|
+ msgRet.battleGameTimes = battleGameTimes
|
|
|
+ Msg.send(msgRet, human.fd)
|
|
|
end
|