Explorar o código

冠军联赛录像和排行榜一键点赞功能

gitxsm hai 9 meses
pai
achega
28b729b44b

+ 2 - 2
script/common/ProtoID.lua

@@ -1502,5 +1502,5 @@ _ENV[1550]="GC_ONEKILLGIFT_CLOSE"
 _ENV[1553]="CG_EQUIP_ATTR_LOCK"
 _ENV[1554]="CG_EQUIP_RETUN_RANDOM_ATTR"
 
--- _ENV[1555]="CG_WAR_REPROT_ADMIRE_BY_ONETOUCH"
--- _ENV[1556]="CG_JJC_WORSHIP_ONETOUCH"
+_ENV[1555]="CG_WAR_REPROT_ADMIRE_BY_ONETOUCH"
+_ENV[1556]="CG_JJC_WORSHIP_ONETOUCH"

+ 5 - 0
script/module/jjc/Handler.lua

@@ -35,4 +35,9 @@ end
 
 function CG_JJC_CHAMPION_BILLBOARD_QUERY(human)
 	JjcLogic.championBillboardQuery(human)
+end
+
+
+function CG_JJC_WORSHIP_ONETOUCH(human)
+	JjcLogic.WorshipByOneTouch(human)
 end

+ 3 - 0
script/module/jjc/Proto.lua

@@ -157,3 +157,6 @@ GC_JJC_CHAMPION_BE_CHALLENGE = {}
 -- 赛季结束 收到这个协议时 客户端如果打开了竞技场面板 需要关闭竞技场面板
 GC_JJC_SEASON_END = {}
 
+
+-- 冠军联赛排行榜一键膜拜
+CG_JJC_WORSHIP_ONETOUCH = {}

+ 5 - 0
script/module/warReport/Handler.lua

@@ -33,4 +33,9 @@ end
 function CG_WAR_REPROT_HARM(human, msg)
 
    WarReportLogic.harm(human, msg.type, msg.id)
+end
+
+
+function CG_WAR_REPROT_ADMIRE_BY_ONETOUCH(human, msg)
+   WarReportLogic.AdmireByOneTouch(human)
 end

+ 5 - 0
script/module/warReport/Proto.lua

@@ -78,3 +78,8 @@ GC_WAR_REPROT_HARM = {
    {"data",		1,		CombatFinishData},
 }
 
+-- 冠军联赛录像一键点赞
+CG_WAR_REPROT_ADMIRE_BY_ONETOUCH= {
+
+}
+

+ 77 - 0
script/module/warReport/WarReportLogic.lua

@@ -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