Commit 43a6d57ea720a3a2c2577aa64b4fa30fd39cf77c

Authored by liuzujun
1 parent 2e1c7d7f

拾荒活动

src/adv/Adv.lua
... ... @@ -178,7 +178,7 @@ end
178 178 function Adv:clear()
179 179 self.chapterId = nil
180 180 self.level = nil
181   - self.actid = 0
  181 + self.actid = nil
182 182 self.score = {}
183 183 self.round = 0
184 184 self.lastEnemyId = 1
... ... @@ -769,6 +769,10 @@ function Adv:isEndless()
769 769 return AdvCommon.isEndless(self.chapterId)
770 770 end
771 771  
  772 +function Adv:isActivity()
  773 + return self.actid ~= nil
  774 +end
  775 +
772 776 function Adv:getCurFloorData()
773 777 local chapter = self.chapterId % 100
774 778 return (csvdb["adv_chapter_floorCsv"][self.chapterId] or {})[self.level]
... ...
src/models/Activity.lua
... ... @@ -1030,6 +1030,55 @@ activityFunc[Activity.ActivityType.NewSign] = {
1030 1030 end,
1031 1031 }
1032 1032  
  1033 +local function closeActAdvHang(role, chapterId)
  1034 + local advHang = role:getProperty("advHang")
  1035 + local info = advHang[chapterId]
  1036 + if not info then return end
  1037 +
  1038 + local index = info.index or 1
  1039 + local chapterData = csvdb["adv_chapter_campsiteCsv"][chapterId]
  1040 + if not chapterData then return end
  1041 + local campSiteData = chapterData[info.campId or 2]
  1042 + if not campSiteData then return 1 end
  1043 + if campSiteData.idleReward_1 == "" and campSiteData.idleReward_2 == "" then return 2 end --没有奖励 没有挂机
  1044 +
  1045 + local adv_idle_time = globalCsv.adv_idle_time[index]
  1046 + local adv_idle_energy = globalCsv.adv_idle_energy[index]
  1047 + local adv_idle_reward_coef = globalCsv.adv_idle_reward[index]
  1048 + if not adv_idle_time or not adv_idle_energy or not adv_idle_reward_coef then
  1049 + return 2
  1050 + end
  1051 + adv_idle_time = adv_idle_time * 60
  1052 +
  1053 + local reward, isFull, change, heroFaithMap
  1054 + local heroCnt = 0
  1055 + if skynet.timex() >= info.time then
  1056 + -- 增加英雄信赖
  1057 + local exp = info.duration / 60
  1058 + heroFaithMap = {}
  1059 + for _, heroId in pairs(info.format.heros) do
  1060 + local curFaith = role:addHeroFaith(heroId, exp)
  1061 + heroFaithMap[heroId] = curFaith
  1062 + heroCnt = heroCnt + 1
  1063 + end
  1064 +
  1065 + local totalReward = campSiteData.idleReward_1 .. " " .. campSiteData.idleReward_2
  1066 +
  1067 + local idleReward = totalReward:toNumMap()
  1068 + for itemId, count in pairs(idleReward) do
  1069 + idleReward[itemId] = count * adv_idle_reward_coef
  1070 + end
  1071 + reward, change = role:award(idleReward, {log = {desc = "advHang", int1 = chapterId}})
  1072 + end
  1073 +
  1074 + role:changeUpdates({{type = "advHang", field = chapterId, value = nil}})
  1075 +
  1076 + role:mylog("adv_action", {desc = "endHang", int1 = chapterId, short1 = 2})
  1077 +
  1078 + role:checkTaskEnter("AdvHang", {})
  1079 + role:checkTaskEnter("AdvHangHeroCnt", {count = heroCnt})
  1080 +end
  1081 +
1033 1082 activityFunc[Activity.ActivityType.AdvLevel] = {
1034 1083 -- ["check"] = function(self, actType, notify) -- 检查
1035 1084 -- end,
... ... @@ -1042,7 +1091,16 @@ activityFunc[Activity.ActivityType.AdvLevel] = {
1042 1091 local advPass = self.owner:getProperty("advPass")
1043 1092 advPass[chapterId] = nil
1044 1093 self.owner:updateProperty({field="advPass", value=advPass})
  1094 +
  1095 + -- 关闭活动代理拾荒
  1096 + closeActAdvHang(chapterId)
  1097 + end
  1098 + -- 强制关闭活动拾荒关卡
  1099 + local adv = self:getAdvData()
  1100 + if adv:isRunning() and adv:isActivity() then
  1101 + adv:forceOver()
1045 1102 end
  1103 +
1046 1104 end,
1047 1105 }
1048 1106  
... ...
src/models/RolePlugin.lua
... ... @@ -2049,6 +2049,15 @@ function RolePlugin.bind(Role)
2049 2049 return {list = list, rank = rank}
2050 2050 end
2051 2051  
  2052 + function Role:addHeroFaith(heroId, exp)
  2053 + local hero = self.heros[heroId]
  2054 + if not hero then
  2055 + return
  2056 + end
  2057 +
  2058 + hero:addHeroFaith(exp)
  2059 + return hero:getProperty("faith")
  2060 + end
2052 2061  
2053 2062 end
2054 2063  
... ...