|
|
@@ -103,6 +103,8 @@ JJC_RESULT_DEF_WIN = 3
|
|
|
|
|
|
local QUICK_COND_TIMES = 10 -- 跳过战斗需要战斗次数
|
|
|
|
|
|
+local WORSHIP_NUM = 10 -- 一键膜拜数量
|
|
|
+
|
|
|
|
|
|
-- 检查是否加入竞技场
|
|
|
function checkNeedJoin(human)
|
|
|
@@ -741,8 +743,9 @@ function championWorship(human,uuid)
|
|
|
RoleDBLogic.saveRole(db)
|
|
|
worshipCnt = db.jjcBeWorship
|
|
|
end
|
|
|
+
|
|
|
-- 给奖励
|
|
|
- BagLogic.addItem(human, ItemDefine.ITEM_JINBI_ID, JJC_WORSHIP_JINBI_CNT, "jjc_worship")
|
|
|
+ BagLogic.addItem(human, ItemDefine.ITEM_JINBI_ID, itemCnt, "jjc_worship")
|
|
|
Broadcast.sendErr(human, Util.format(Lang.JJC_WORSHIP_GOOD, JJC_WORSHIP_JINBI_CNT))
|
|
|
|
|
|
local msgRet = Msg.gc.GC_JJC_CHAMPION_WORSHIP
|
|
|
@@ -754,6 +757,96 @@ function championWorship(human,uuid)
|
|
|
Msg.send(msgRet,human.fd)
|
|
|
end
|
|
|
|
|
|
+
|
|
|
+local function getRankdByRand(human, excludeIdxList)
|
|
|
+ human.db.jjcWorship = human.db.jjcWorship or {}
|
|
|
+ local jjcWorship = human.db.jjcWorship
|
|
|
+ local rankCnt = 50 --#JjcDB.RANK_2_JJCDATA --只在前50名随机点赞
|
|
|
+
|
|
|
+ local bl = false
|
|
|
+ local randArr = {}
|
|
|
+
|
|
|
+ for i=1, rankCnt do
|
|
|
+ local dataTemp = JjcDB.RANK_2_JJCDATA[i]
|
|
|
+ if not excludeIdxList[i] and not jjcWorship[dataTemp._id] then
|
|
|
+ table.insert(randArr, i)
|
|
|
+ bl = true
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ if not bl then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local randIdx = randArr[math.random(1, #randArr)]
|
|
|
+ return randIdx
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+-- 一键膜拜
|
|
|
+function WorshipByOneTouch(human)
|
|
|
+ -- 初始化膜拜数据
|
|
|
+ human.db.jjcWorship = human.db.jjcWorship or {}
|
|
|
+ human.db.jjcWorship.count = human.db.jjcWorship.count or 0
|
|
|
+
|
|
|
+ -- 每日膜拜已达上限
|
|
|
+ if human.db.jjcWorship.count >= JJC_WORSHIP_CNT then
|
|
|
+ return Broadcast.sendErr(human, Lang.GODWAR_MOBAI_ERR)
|
|
|
+ end
|
|
|
+
|
|
|
+ local subCnt = JJC_WORSHIP_CNT - human.db.jjcWorship.count
|
|
|
+ local rankCnt = #JjcDB.RANK_2_JJCDATA
|
|
|
+ subCnt = math.min(subCnt, rankCnt)
|
|
|
+
|
|
|
+ if subCnt <= 0 then
|
|
|
+ return Broadcast.sendErr(human, Lang.GODWAR_MOBAI_ERR)
|
|
|
+ end
|
|
|
+
|
|
|
+ local excludeIdxList = {}
|
|
|
+ local rank = JjcDB.UUID_2_RANK[human.db._id]
|
|
|
+ if rank then
|
|
|
+ excludeIdxList[rank] = true
|
|
|
+ end
|
|
|
+
|
|
|
+ local cnt = 0
|
|
|
+ for i=1, subCnt do
|
|
|
+ local rankIdx = getRankdByRand(human, excludeIdxList)
|
|
|
+ if not rankIdx then
|
|
|
+ break
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 写被膜拜玩家数据库
|
|
|
+ local dataTemp = JjcDB.RANK_2_JJCDATA[rankIdx]
|
|
|
+ local db = RoleDBLogic.getDb(dataTemp._id)
|
|
|
+ if db == nil then
|
|
|
+ JjcDB.updateWorshipCnt(dataTemp._id)
|
|
|
+ else
|
|
|
+ db.jjcBeWorship = db.jjcBeWorship or 0
|
|
|
+ db.jjcBeWorship = db.jjcBeWorship + 1
|
|
|
+ RoleDBLogic.saveRole(db)
|
|
|
+ end
|
|
|
+
|
|
|
+ cnt = cnt + 1
|
|
|
+ excludeIdxList[rankIdx] = true
|
|
|
+
|
|
|
+ -- 写数据库
|
|
|
+ human.db.jjcWorship[dataTemp._id] = 1
|
|
|
+ human.db.jjcWorship.count = human.db.jjcWorship.count + 1
|
|
|
+ end
|
|
|
+
|
|
|
+ if cnt > 0 then
|
|
|
+ -- 给奖励
|
|
|
+ local itemCnt = JJC_WORSHIP_JINBI_CNT * cnt
|
|
|
+ BagLogic.addItem(human, ItemDefine.ITEM_JINBI_ID, itemCnt, "jjc_worship")
|
|
|
+ Broadcast.sendErr(human, Util.format(Lang.JJC_WORSHIP_GOOD, itemCnt))
|
|
|
+
|
|
|
+ -- 推送数据
|
|
|
+ championBillboardQuery(human)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
function championBillboardQuery(human)
|
|
|
local flag = RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1301)
|
|
|
if flag ~= true then
|
|
|
@@ -772,7 +865,7 @@ function championBillboardQuery(human)
|
|
|
msgRet.leftSec = leftSec
|
|
|
msgRet.topList[0] = 0
|
|
|
for i = 1, #JjcDB.RANK_2_JJCDATA do
|
|
|
- if i > 100 then
|
|
|
+ if i > 50 then
|
|
|
break
|
|
|
end
|
|
|
|
|
|
@@ -1124,9 +1217,11 @@ function onFightEnd(human, result, combatType, defUuid, combatInfo)
|
|
|
itemCnt = itemCnt * 2
|
|
|
isDouble = true
|
|
|
end
|
|
|
+
|
|
|
BagLogic.addItem(human, itemID, itemCnt, "jjc_fight")
|
|
|
|
|
|
Grid.makeItem(msgRet.items[1], itemID, itemCnt)
|
|
|
+ -- Grid.makeItem(msgRet.items[1], itemID, itemCnt, nil ,nil, nil, nil, nil, nil, sourceId)
|
|
|
|
|
|
msgRet.double = isDouble and 1 or 0
|
|
|
msgRet.result = result
|