فهرست منبع

增加所有战令奖励全部领取完后关闭战令入口相关代码

gitxsm 1 سال پیش
والد
کامیت
184babdef6
2فایلهای تغییر یافته به همراه78 افزوده شده و 1 حذف شده
  1. 16 0
      script/module/roleSystem/RoleSystemLogic.lua
  2. 62 1
      script/module/shop/WarOrder.lua

+ 16 - 0
script/module/roleSystem/RoleSystemLogic.lua

@@ -72,6 +72,15 @@ function isOpen(human, id, sendErr)
             return false
         end
     end
+
+	--战令, 临时处理下, 如果多了再优化成通用方法
+	if id == RoleSystemDefine.ROLE_SYS_ID_2005 then
+		local WarOrder = require("shop.WarOrder")
+		local res = WarOrder.isOpen(human)
+		if not res then
+			return false, config
+		end
+	end
 	
 	return true, config
 end
@@ -275,6 +284,13 @@ function onDot(human,id, noSend)
     end
 end
 
+--是否关闭
+function isClose(human,id)
+	if not isOpen(human, id) then
+		sendSystemSingle(human, id)
+	end
+end
+
 -- 是否有双倍
 function isDouble(human, id)
 	if human.db.lv < DOUBLE_NEED_LV then return false end

+ 62 - 1
script/module/shop/WarOrder.lua

@@ -142,6 +142,48 @@ local function genBuyItem()
     }
 end
 
+--某个战令奖励是否已经领完, 返回false表示没有,true表示已经领完
+local function isGetAllAward(human,orderType)
+    local warOrder = human.db.warOrder
+    if not warOrder then
+        return false
+    end
+
+    local orderName = orderNameMap[orderType]
+    local cfg = OrderExcel[orderName]
+    local orderData = warOrder[orderName]
+    if not cfg or not orderData then
+        return false
+    end
+
+    local allNum = #cfg
+    local isGetAll = true
+
+    --普通奖励
+    local commonNum = 0
+    local commonRecord = orderData.finish
+    for k in pairs(commonRecord or {}) do
+        commonNum = commonNum + 1
+    end
+
+    if commonNum < allNum then
+        isGetAll = false
+        return isGetAll
+    end
+
+    --进阶奖励
+    local upgradeNum = 0
+    local upgradeRecord = orderData.upgradeFinish
+    for k in pairs(upgradeRecord or {}) do
+        upgradeNum = upgradeNum + 1
+    end
+    if upgradeNum < allNum then
+        isGetAll = false
+    end
+
+    return isGetAll
+end
+
 ------------------------------------------------------
 -- 对外暴露接口
 ------------------------------------------------------
@@ -157,6 +199,17 @@ function isDot(human)
     return isDot
 end
 
+--判断是否显示入口, 返回true表示显示, false表示不显示, 领完四个类型战令的奖励就关闭
+function isOpen(human)
+    for orderType in pairs(orderNameMap) do
+        if not isGetAllAward(human,orderType) then
+            return true
+        end
+    end
+    return false
+end
+
+
 function warOrderInfo(human,orderType)
     local orderName = orderNameMap[orderType]
     local cfg = OrderExcel[orderName]
@@ -255,7 +308,9 @@ function warOrderReward(human,orderType)
     local itemMap = {}
     --local finish_copy = table.copy(orderData.finish)
     --local upgrade_finish_copy = table.copy(orderData.upgradeFinish)
-    for _,v in pairs(cfg) do 
+    local allAwardCnt = 0
+    for _,v in pairs(cfg) do
+        allAwardCnt = allAwardCnt + 1
         if  process >= v.process then
             local isOk,isUpgradeOk = checkRewardByIdx(human,orderType,v.idx)
             if isOk then 
@@ -301,6 +356,12 @@ function warOrderReward(human,orderType)
     isRed[orderType] = nil
     -- 通知外层红点取消
     RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_2005)
+
+    --判断是否领完奖励要关闭入口显示了
+    if #finish >= allAwardCnt and #upgradeFinish >= allAwardCnt then
+        RoleSystemLogic.isClose(human, RoleSystemDefine.ROLE_SYS_ID_2005)
+    end
+    
     return {
         orderType = orderType,
         exp = orderData.exp,