|
|
@@ -493,4 +493,81 @@ end
|
|
|
|
|
|
function isDot(human)
|
|
|
return human.db.warDot
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+local function getWarReportIdxByRand(warReportArr, excludeIdxList)
|
|
|
+ local warReportCnt = #warReportArr
|
|
|
+
|
|
|
+ local len = 0
|
|
|
+ local randArr = {}
|
|
|
+ for i = 1, warReportCnt do
|
|
|
+ if not excludeIdxList or not excludeIdxList[i] then
|
|
|
+ len = len + 1
|
|
|
+ randArr[len] = i
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ if len == 0 then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local idx = randArr[math.random(1, len)]
|
|
|
+ return idx
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+-- 冠军联赛录像一键点赞
|
|
|
+function AdmireByOneTouch(human)
|
|
|
+ if human.db.warAdmire == nil then
|
|
|
+ return Broadcast.sendErr(human, Lang.WAR_REPORT_ADMIRE_NOT_ENOUGH)
|
|
|
+ end
|
|
|
+
|
|
|
+ local warAdmireSubCnt = human.db.warAdmire
|
|
|
+
|
|
|
+ local len = 0
|
|
|
+ local queryCond = {war_index = { ["$exists"] = 1}, type = WAR_REPORT_1}
|
|
|
+ LuaMongo.find(DB.db_war_report, queryCond)
|
|
|
+
|
|
|
+
|
|
|
+ local war_data_list = {}
|
|
|
+ while true do
|
|
|
+ local war_data = {}
|
|
|
+ if not LuaMongo.next(war_data) then
|
|
|
+ break
|
|
|
+ end
|
|
|
+
|
|
|
+ if len >= WAR_COUNT_MAX then
|
|
|
+ break
|
|
|
+ end
|
|
|
+
|
|
|
+ if not war_data.admireList or not war_data.admireList[human.db._id] then
|
|
|
+ len = len + 1
|
|
|
+ war_data_list[len] = war_data
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ warAdmireSubCnt = math.min(warAdmireSubCnt, len)
|
|
|
+ if warAdmireSubCnt <= 0 then
|
|
|
+ print("=========================没有符合的录像数据=========================")
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
+ local excludeIdxList
|
|
|
+ for i = 1, warAdmireSubCnt do
|
|
|
+ local idx = getWarReportIdxByRand(war_data_list, excludeIdxList)
|
|
|
+ if not idx then
|
|
|
+ break
|
|
|
+ end
|
|
|
+
|
|
|
+ local warReportUuid = war_data_list[idx]._id
|
|
|
+ excludeIdxList = excludeIdxList or {}
|
|
|
+ excludeIdxList[idx] = true
|
|
|
+
|
|
|
+ -- 通过原有接口进行点赞
|
|
|
+ admire(human, WAR_REPORT_1, warReportUuid)
|
|
|
+ end
|
|
|
+
|
|
|
+ query(human, WAR_REPORT_1, 1)
|
|
|
end
|