源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2752 lines
97 KiB

  1. OperateActivityModel = OperateActivityModel or BaseClass(BaseVo, true)
  2. local OperateActivityModel = OperateActivityModel
  3. OperateActivityModel.REQUEST_INFO = "OperateActivityModel.REQUEST_INFO"
  4. OperateActivityModel.OPEN_ACTIVITY_BASE_VIEW = "OperateActivityModel.OPEN_ACTIVITY_BASE_VIEW"--打开主界面
  5. OperateActivityModel.UPDATE_ACTIVITY_BASE_VIEW = "OperateActivityModel.UPDATE_ACTIVITY_BASE_VIEW"--更新主界面
  6. OperateActivityModel.OPEN_RANK_SHOW_VIEW = "OperateActivityModel.OPEN_RANK_SHOW_VIEW"--打开往期排行
  7. OperateActivityModel.REQUEST_INFO = "OperateActivityModel.REQUEST_INFO"--请求协议
  8. OperateActivityModel.ANS_UPDATE_VIEW = "OperateActivityModel.ANS_UPDATE_VIEW"--更新界面
  9. OperateActivityModel.START_LUCKY_TURN_ACTION = "OperateActivityModel.START_LUCKY_TURN_ACTION"--转盘抽奖动画
  10. OperateActivityModel.QUIK_USE = "OperateActivityModel.QUIK_USE"--触发快捷使用
  11. OperateActivityModel.SHOW_REWARD_TIP = "OperateActivityModel.SHOW_REWARD_TIP"--显示物品列表(奖池等)
  12. OperateActivityModel.SHOW_REWARD_TIP_NEW = "OperateActivityModel.SHOW_REWARD_TIP_NEW"--显示物品列表(有小标题)
  13. OperateActivityModel.SCRAPING_CARD_BASE_DRAW_UPDATE = "OperateActivityModel.SCRAPING_CARD_UPDATEINFO"--刮刮卡抽卡更新
  14. OperateActivityModel.SCRAPING_CARD_SCROE_DRAW_UPDATE = "OperateActivityModel.SCRAPING_CARD_SCROE_DRAW_UPDATE"--刮刮卡积分抽卡更新
  15. OperateActivityModel.SCRAPING_CARD_REFRESH_UPDATE = "OperateActivityModel.SCRAPING_CARD_REFRESH_UPDATE"--刮刮卡重置
  16. OperateActivityModel.TAROT_BASE_UPDATE = "OperateActivityModel.TAROT_BASE_UPDATE"--塔罗牌基本信息刷新
  17. OperateActivityModel.TAROT_RECORD_UPDATE = "OperateActivityModel.TAROT_RECORD_UPDATE"--塔罗牌记录刷新
  18. OperateActivityModel.TAROT_DRAW_UPDATE = "OperateActivityModel.TAROT_DRAW_UPDATE"--塔罗牌抽卡刷新
  19. OperateActivityModel.STAGE_EXCHANGE_BASE_UPDATE = "OperateActivityModel.STAGE_EXCHANGE_BASE_UPDATE"--阶段兑换基本信息刷新
  20. OperateActivityModel.STAGE_EXCHANGE_REWARD_UPDATE = "OperateActivityModel.STAGE_EXCHANGE_REWARD_UPDATE"--阶段兑换阶段奖励列表
  21. OperateActivityModel.ADVENTURE_BASE_UPDATE = "OperateActivityModel.ADVENTURE_BASE_UPDATE"--冒险征途基本信息刷新
  22. OperateActivityModel.UPDATE_GIDSAW_EVENT_DATA = "OperateActivityModel.UPDATE_GIDSAW_EVENT_DATA" -- 更新活跃拼图协议信息
  23. OperateActivityModel.REVERSI_BASE_UPDATE = "OperateActivityModel.REVERSI_BASE_UPDATE"--黑白棋总信息刷新
  24. OperateActivityModel.REVERSI_CUR_STATUS_UPDATE = "OperateActivityModel.REVERSI_CUR_STATUS_UPDATE"--黑白棋当前棋盘状态刷新
  25. OperateActivityModel.REVERSI_CUR_REWARD_UPDATE = "OperateActivityModel.REVERSI_CUR_REWARD_UPDATE"--黑白棋当前棋盘奖励刷新
  26. OperateActivityModel.OPEN_REFRESH_TIP = "OperateActivityModel.OPEN_REFRESH_TIP"--黑白棋刷新提示
  27. OperateActivityModel.DO_REFRESH_ANIM = "OperateActivityModel.DO_REFRESH_ANIM"--执行黑白棋刷新动画
  28. OperateActivityModel.OPEN_FESTIVAL_BOSS_REWARD_VIEW = "OperateActivityModel.OPEN_FESTIVAL_BOSS_REWARD_VIEW"--节日幻魔奖励列表
  29. OperateActivityModel.REFRESH_FESTIVAL_BOSS = "OperateActivityModel.REFRESH_FESTIVAL_BOSS"--节日幻魔数据更新
  30. OperateActivityModel.AMASING_JIPSAW_UPDATE_BASEINFO = "OperateActivityModel.AMASING_JIPSAW_UPDATE_BASEINFO"--眼疾手快基本数据
  31. OperateActivityModel.AMASING_JIPSAW_UPDATE_GAMEINFO = "OperateActivityModel.AMASING_JIPSAW_UPDATE_GAMEINFO"--眼疾手快游戏数据
  32. OperateActivityModel.AMASING_JIPSAW_UPDATE_GAME_START = "OperateActivityModel.AMASING_JIPSAW_UPDATE_GAME_START"--眼疾手快游戏开始
  33. OperateActivityModel.AMASING_JIPSAW_UPDATE_GAME_EXCHANGE = "OperateActivityModel.AMASING_JIPSAW_UPDATE_GAME_EXCHANGE"--眼疾手快卡片交换
  34. OperateActivityModel.AMASING_JIPSAW_UPDATE_REWARD = "OperateActivityModel.AMASING_JIPSAW_UPDATE_REWARD"--眼疾手快奖励
  35. OperateActivityModel.PRAY_TREE_BASE_INFO = "OperateActivityModel.PRAY_TREE_BASE_INFO"--人参果树基本信息
  36. OperateActivityModel.PRAY_TREE_DRAW = "OperateActivityModel.PRAY_TREE_DRAW"--人参果树抽卡
  37. OperateActivityModel.PRAY_TREE_GET_REWARD = "OperateActivityModel.PRAY_TREE_GET_REWARD"--人参果树获取奖励
  38. OperateActivityModel.UPDATE_COMPOSE_ROBOT_ANNOUNCE_INFO = "OperateActivityModel.UPDATE_COMPOSE_ROBOT_ANNOUNCE_INFO"--发明家信息更新
  39. OperateActivityModel.UPDATE_COMPOSE_ROBOT_FORMULA_INFO = "OperateActivityModel.UPDATE_COMPOSE_ROBOT_FORMULA_INFO"--配方状态信息更新
  40. OperateActivityModel.UPDATE_COMPOSE_ROBOT_COLLECT_INFO = "OperateActivityModel.UPDATE_COMPOSE_ROBOT_COLLECT_INFO"--配方收藏信息更新
  41. OperateActivityModel.UPDATE_COMPOSE_ROBOT_MATERIAL_GOODS_NUM = "OperateActivityModel.UPDATE_COMPOSE_ROBOT_MATERIAL_GOODS_NUM"--材料数量更新
  42. OperateActivityModel.ADD_COMPOSE_ROBOT_MATERIAL = "OperateActivityModel.ADD_COMPOSE_ROBOT_MATERIAL"--添加材料
  43. OperateActivityModel.MINUS_COMPOSE_ROBOT_MATERIAL = "OperateActivityModel.MINUS_COMPOSE_ROBOT_MATERIAL"--减去材料
  44. OperateActivityModel.UPDATE_COMPOSE_ROBOT_ASK_CD = "OperateActivityModel.UPDATE_COMPOSE_ROBOT_ASK_CD"--询问cd刷新
  45. --自选扭蛋
  46. OperateActivityModel.UPDATE_SELECT_EGG_VIEW = "OperateActivityModel.UPDATE_SELECT_EGG_VIEW"--刷新自选扭蛋界面
  47. OperateActivityModel.UPDATE_SELECT_EGG_SELECT_REWARDS = "OperateActivityModel.UPDATE_SELECT_EGG_SELECT_REWARDS"--自选奖励后刷新选中状态
  48. OperateActivityModel.UPDATE_SELECT_EGG_VIEW_AFTER_DRAW = "OperateActivityModel.UPDATE_SELECT_EGG_VIEW_AFTER_DRAW"--抽奖后刷新界面
  49. OperateActivityModel.OPEN_SELECT_EGG_PREVIEW = "OperateActivityModel.OPEN_SELECT_EGG_PREVIEW"--预览奖励
  50. OperateActivityModel.SELECT_EGG_START_DRAW = "OperateActivityModel.SELECT_EGG_START_DRAW"--准备发出抽奖协议
  51. OperateActivityModel.AFTER_SELECT_EGG_DRAW = "OperateActivityModel.AFTER_SELECT_EGG_DRAW"--抽奖后放动画
  52. OperateActivityModel.DO_SELECT_SELECT_EGG_REWARD = "OperateActivityModel.DO_SELECT_SELECT_EGG_REWARD"--要选择奖励的事件,通知主界面判断是否要切换栏目
  53. OperateActivityModel.CANCLE_CHANGE_RARE_LINE = "OperateActivityModel.CANCLE_CHANGE_RARE_LINE"--取消切换栏目
  54. OperateActivityModel.OPEN_SUPER_AWARD_SHOW_VIEW = "OperateActivityModel.OPEN_SUPER_AWARD_SHOW_VIEW"--打开超能大奖奖励展示界面
  55. OperateActivityModel.OPEN_MATERIALSUBMIT_REQ_VIEW = "OperateActivityModel.OPEN_MATERIALSUBMIT_REQ_VIEW"--打开材料提交彩钻提交界面
  56. OperateActivityModel.OPEN_MATERIAL_SUBMIT_BUFF_VIEW = "OperateActivityModel.OPEN_MATERIAL_SUBMIT_BUFF_VIEW"--打开材料提交buff界面
  57. function OperateActivityModel:__init()
  58. OperateActivityModel.Instance = self
  59. self.login_red = nil--登陆红点
  60. self:Reset()
  61. end
  62. OperateActivityModel.ScrapingCardFLAGTYPE =
  63. {
  64. RANDOM_DRAW = 1,
  65. CUSTOM_DRAW = 2
  66. }
  67. OperateActivityModel.MaterialSubmitBuffKind = {
  68. PEACH_EXP = 1,--触发加成后,参加舞池派对和公会篝火期间检验额外加成100%
  69. BOSS_HUT_ADD = 2,--触发加成后,每次挑战赏金幻魔首次钻石鼓舞免费
  70. BOSS_ATTACK_ADD = 3,--触发加成后,参加赏金幻魔和专属幻魔时,伤害结算计算BUFF加成,对BOSS伤害提高10%,BOSS对人物伤害降低10%,针对原属性采用加算
  71. ADVENTURE_EXP_UP = 4,--触发加成后,玩家每分钟放置冒险经验收益提升100%(增对初始数值计算)
  72. BOSS_DROP_DOUBLE = 5,--触发加成后,玩家赏金幻魔/专属幻魔掉落概率+100%
  73. EGG_LUCKY_NUM = 6,--触发加成后,<color@1>龙神宝库</color>幸运值持续维持999,抽中不清空
  74. BOSS_ADD_TIME = 11,--触发加成后,刷新所有赏金幻魔复活状态,且玩家挑战剩余次数+1
  75. DUN_DOUBLE = 12,--触发加成后,通关材料副本可获得双倍奖励
  76. DUN_ADD_TIMES = 13,--触发加成后,所有材料副本、守卫幼宠剩余次数+1
  77. LUCKY_OFFER = 14,--触发加成后,龙神宝库首次10连抽、50连抽分别享受八折优惠
  78. ADVENTURE_EXP = 15,--触发加成后,玩家放置冒险获得1次免费2倍速(不计入消耗次数)
  79. GUILD_SPORT = 16,--拼单献礼触发加成后,<color@1>社团协助</color>玩法每人收益提升10%
  80. ACT_LUCKY_OFFER = 21,--触发加成后,玩家参加定制活动108刮刮卡/111塔罗牌/115黑白棋时,前10次非免费抽奖享受8折
  81. ACT_LUCKY_FREE = 22,--触发加成后,玩家参加定制活动108刮刮卡/111塔罗牌/115黑白棋时,首次抽奖免费
  82. }
  83. function OperateActivityModel:Reset()
  84. self.view_info = {}--界面信息
  85. self.act_red_dot_info = {}
  86. self.red_dot_info = {}
  87. self.is_close_main_icon = false
  88. self.lucky_turn_table_base_info = {}--幸运转盘基础信息
  89. self.lucky_turn_table_record_info = {}--幸运转盘记录信息
  90. self.lucky_turn_table_open = false--是否打开了幸运转盘
  91. self.lucky_turn_subtype = nil--幸运转盘多开子活动
  92. self.lucky_turn_table_type = nil --幸运转盘的种类
  93. self.is_skip_lucky_turn_table_action = false--跳过动画
  94. ---刮刮卡
  95. self.sc_all_reward_list = false
  96. self.sc_base_info = {}
  97. self.sc_cfg = false
  98. ---塔罗牌卡
  99. self.tarot_all_reward_list = false
  100. self.tarot_base_info = {}
  101. self.tarot_draw_cnt_list = {}
  102. self.tarot_cfg = false
  103. --阶段兑换
  104. self.stage_exchange_info = {}
  105. --冒险征途
  106. self.adventure_num_info = {}--进度值信息
  107. self.adventure_task_info = {}--任务信息
  108. self.adventure_random_pool = {}--奖池列表
  109. --黑白棋
  110. self.reversi_info = {}
  111. self.reversi_cur_info = {}
  112. self.reversi_cur_pool_info = {}
  113. -- 活跃拼图
  114. self.jigsaw_event_list = {} -- 活跃拼图协议数据
  115. self.jigsaw_red_cache = {} -- 拼图红点
  116. --三日作战信息
  117. self.three_fight_view_info = {}
  118. self.three_fight_toggle = {}--三日作战补给购买复选
  119. --人参果树
  120. self.pray_tree_info = false --人参果树基本数据
  121. self.pray_tree_reward_list = {} --人参果树奖励配置
  122. -- 眼疾手快
  123. self.amasing_jipsaw_info = {} -- 眼疾手快基本数据
  124. --合成机
  125. self.compose_robot_material_cfg = {} --原材料配置
  126. self.compose_robot_formula_cfg = {} --配方配置
  127. self.compose_robot_pool_cfg = {}--奖池配置
  128. self.compose_robot_normal_pool_cfg = {}--普通奖池
  129. self.compose_robot_collect_list = {} --收藏的合成配方列表
  130. self.compose_robot_formula_data = {} --配方状态信息
  131. self.compose_robot_announce_data = {} --广播滚动的发明家信息
  132. self.compose_robot_now_use_material_list = {} --当前选中的材料列表
  133. self.compose_robot_act_first_red = {} --活动开启的一次性红点
  134. self.compose_robot_have_open_view = {} --是否打开过界面的标记
  135. self.is_in_compose_view = {}
  136. self.compose_robot_red_info = {}
  137. self.compose_robot_ask_time = {}
  138. --自选扭蛋
  139. self.select_egg_ser_data = {}--自选扭蛋奖励等后端数据
  140. self.select_egg_red_info = {}--自选扭蛋红点信息
  141. self.select_egg_is_in_drawing = false
  142. self.material_submit_info = {}--材料上交信息
  143. self:InitCfg()
  144. end
  145. function OperateActivityModel:getInstance()
  146. if OperateActivityModel.Instance == nil then
  147. OperateActivityModel.Instance = OperateActivityModel.New()
  148. end
  149. return OperateActivityModel.Instance
  150. end
  151. --初始化配置
  152. function OperateActivityModel:InitCfg( )
  153. self.drop_time_limit = {}--BOSS掉落基本配置
  154. local drop_time_limit = DeepCopy(Config.Droptimelimit)
  155. local link = nil
  156. for k,v in pairs(drop_time_limit) do
  157. local data = v
  158. link = stringtotable(v.link)--跳转数据
  159. data.link = link and link[1]
  160. data.award = stringtotable(v.award)--掉落奖励
  161. data.desc = Trim(v.desc)--名字
  162. data.tips = Trim(v.tips)--大奖名字
  163. if not self.drop_time_limit[v.drop_type] then
  164. self.drop_time_limit[v.drop_type] = {}
  165. end
  166. self.drop_time_limit[v.drop_type][v.drop_way] = data
  167. end
  168. self:InitThreeFightTaskCFG()--初始化三日作战任务表配置
  169. self:InitThreeFightTaskActCFG()--初始化三日作战任务活动配置
  170. self:InitComposeRobotMaterialCfg()--初始化合成机材料配置
  171. self:InitComposeRobotFormulaCfg()--初始化合成机配方配置
  172. self:InitComposeRobotPoolCfg()--初始化合成机奖池配置
  173. end
  174. --检查主界面红点(合并活动全部放在KFmodel里面了)
  175. function OperateActivityModel:CheckMainIconRedDot()
  176. end
  177. --检测开服活动活动图标是否需要开启[兼顾设置开服活动活动内部的活动列表](合并活动全部放在KFmodel里面了)
  178. function OperateActivityModel:CheckIconBoolOpen()
  179. end
  180. --这样写红点 每次调全局的只要调两次
  181. function OperateActivityModel:IsNeedRedAll( )
  182. end
  183. --(合并活动全部放在KFmodel里面了)
  184. function OperateActivityModel:IsNeedRed( id,is_all,sub_type )
  185. -- local bool = false
  186. -- self:Fire(OperateActivityModel.ANS_UPDATE_VIEW,id,bool)
  187. -- if not is_all then
  188. -- self:CheckMainIconRedDot()
  189. -- end
  190. -- print("huangcong:OperateActivityModel [222]: ",bool,id)
  191. -- PrintTable(self.red_dot_info)
  192. end
  193. --获得活动信息页签列表(合并活动全部放在KFmodel里面了)
  194. function OperateActivityModel:UpdateTab( )
  195. end
  196. --获得活动信息页签列表(合并活动全部放在KFmodel里面了)
  197. function OperateActivityModel:CheckActivityIdOpen( id )
  198. end
  199. --获得界面类
  200. function OperateActivityModel:GetViewClass(id)
  201. end
  202. --获得boss掉落奖励获取途径配置
  203. function OperateActivityModel:GetBossDropTimeLimitCfg( drop_type )
  204. return self.drop_time_limit[drop_type]
  205. end
  206. --得到副本是否是多倍掉落的数据信息
  207. function OperateActivityModel:GetDunIsMulDropVo( dun_id,dun_type )
  208. local sub_type_list = DeepCopy(CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.DUN_MUL_DROP))
  209. local temp_list = {}
  210. for i,v in pairs(sub_type_list) do
  211. for ii,vv in ipairs(v.condition_list) do
  212. if vv[1] and vv[2] then
  213. if vv[1] == "type" then
  214. if dun_id then--目前只有进阶副本只传副本ID
  215. if tonumber(vv[3]) == dun_id then
  216. temp_list[#temp_list + 1] = v
  217. end
  218. elseif dun_type then--副本类型
  219. if tonumber(vv[2]) == dun_type then
  220. temp_list[#temp_list + 1] = v
  221. end
  222. end
  223. end
  224. end
  225. end
  226. end
  227. if #temp_list == 1 then
  228. return temp_list[1]
  229. else
  230. local sort_list = {}
  231. local curTime = TimeUtil:getServerTime()
  232. for kk,vv in ipairs(temp_list) do
  233. if vv.stime <= curTime and curTime <= vv.etime then
  234. return vv
  235. else
  236. sort_list[#sort_list + 1] = vv
  237. end
  238. end
  239. if #sort_list > 0 then--如果没有找到时间内开放的活动 找与当前时间差值小的活动展示
  240. local sort_func = function ( a, b )--开始时间从小到大
  241. return a.stime < b.stime
  242. end
  243. if #sort_list > 1 then
  244. table.sort(sort_list, sort_func)
  245. end
  246. for k,v in pairs(sort_list) do--找到开始时间里当前时间最近的
  247. if curTime < v.stime then
  248. return v
  249. end
  250. end
  251. return sort_list[#sort_list]--没找到返回最后一个
  252. end
  253. end
  254. end
  255. --得到副本是否是多倍掉落
  256. function OperateActivityModel:GetDunIsMulDrop( dun_id,dun_type )
  257. local sub_type_list = DeepCopy(CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.DUN_MUL_DROP))
  258. local mul_info = self:GetDunIsMulDropVo(dun_id,dun_type)
  259. local mul_num = 0
  260. local open_lv = 1
  261. local dun_type = dun_type or 1
  262. local temp_list = {}
  263. if mul_info then
  264. for ii,vv in ipairs(mul_info.condition_list) do
  265. if vv[1] and vv[2] then
  266. if vv[1] == "open_lv" then
  267. open_lv = tonumber(vv[2])
  268. break
  269. end
  270. end
  271. end
  272. local act_sec = mul_info.etime - TimeUtil:getServerTime()--活动剩余时间
  273. local act_have_start = mul_info.stime - TimeUtil:getServerTime()--活动剩余时间
  274. if act_have_start <= 0 and act_sec > 0 then
  275. for i,v in ipairs(mul_info.condition_list) do
  276. if v[1] and v[2] then
  277. if v[1] == "multiple" then
  278. mul_num = tonumber(v[2])
  279. end
  280. end
  281. end
  282. if open_lv > RoleManager.Instance.mainRoleInfo.level then
  283. return false,mul_num
  284. elseif dun_type == BaseDungeonModel.DUN_TYPE.VIP and RoleManager.Instance.mainRoleInfo.vip_flag < 1 then
  285. return false,mul_num
  286. else
  287. return true,mul_num
  288. end
  289. end
  290. else
  291. return false,mul_num
  292. end
  293. end
  294. --幸运转盘界面信息
  295. function OperateActivityModel:SetLuckyTurnTableBaseInfo( subtype, turn_type, vo )
  296. if subtype and turn_type then
  297. if not self.lucky_turn_table_base_info[subtype] then
  298. self.lucky_turn_table_base_info[subtype] = {}
  299. end
  300. self.lucky_turn_table_base_info[subtype][turn_type] = vo
  301. end
  302. self:ChangeVar("lucky_turn_table_base_info", self.lucky_turn_table_base_info, false, true)
  303. end
  304. function OperateActivityModel:GetLuckyTurnTableBaseInfo( subtype, turn_type )
  305. if self.lucky_turn_table_base_info[subtype] then
  306. return self.lucky_turn_table_base_info[subtype][turn_type] or {}
  307. else
  308. return {}
  309. end
  310. end
  311. --幸运转盘记录信息
  312. function OperateActivityModel:SetLuckyTurenTableRecordInfo( subtype, turn_type, vo )
  313. if subtype and turn_type then
  314. if not self.lucky_turn_table_record_info[subtype] then
  315. self.lucky_turn_table_record_info[subtype] = {}
  316. end
  317. self.lucky_turn_table_record_info[subtype][turn_type] = vo
  318. end
  319. self:ChangeVar("lucky_turn_table_record_info", self.lucky_turn_table_record_info, false, true)
  320. end
  321. function OperateActivityModel:GetLuckyTurnTableRecordInfo( subtype, turn_type )
  322. if self.lucky_turn_table_record_info[subtype] then
  323. return self.lucky_turn_table_record_info[subtype][turn_type] or {}
  324. end
  325. return {}
  326. end
  327. function OperateActivityModel:IsLuckyTurnTableOpen( )
  328. return self.lucky_turn_table_open
  329. end
  330. function OperateActivityModel:RefreshLuckyTurnTableSCMD( )
  331. if self.lucky_turn_table_open and self.lucky_turn_subtype and self.lucky_turn_table_type then
  332. self:Fire(OperateActivityModel.REQUEST_INFO, 33202, self.lucky_turn_subtype, self.lucky_turn_table_type)
  333. end
  334. end
  335. ---------------------------------------刮刮卡开始 ---------------------------------------
  336. function OperateActivityModel:SetScrapingCardBaseInfo(vo)
  337. self.sc_base_info = self.sc_base_info or {}
  338. self.sc_base_info.sub_type = vo.sub_type
  339. self.sc_base_info.all_reward_list = vo.reward_list
  340. self.sc_base_info.card_list = {}
  341. for i,v in ipairs(vo.card_list) do
  342. self.sc_base_info.card_list[v.pos] = v.goods_list[1]
  343. end
  344. self:Fire(OperateActivityModel.SCRAPING_CARD_BASE_DRAW_UPDATE)
  345. end
  346. function OperateActivityModel:SetScrapingCardScoreInfo(vo)
  347. self.sc_base_info = self.sc_base_info or {}
  348. self.sc_base_info.sub_type = vo.sub_type
  349. self.sc_base_info.score = vo.score
  350. self.sc_base_info.next_score = vo.next_score
  351. self.sc_base_info.draw_times = vo.draw_times
  352. local draw_list_pos = {}
  353. for i,v in ipairs(vo.draw_list) do
  354. draw_list_pos[v.draw_pos] = true
  355. end
  356. local score_reward_list = {}
  357. for i,v in ipairs(vo.reward_list) do
  358. score_reward_list[v.pos] =
  359. {
  360. goods = v.goods_list[1],
  361. is_get = draw_list_pos[v.pos] or false,
  362. }
  363. end
  364. self.sc_base_info.score_reward_list = score_reward_list
  365. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ScrapingCard, nil, vo.sub_type)
  366. self:Fire(OperateActivityModel.SCRAPING_CARD_SCROE_DRAW_UPDATE)
  367. end
  368. function OperateActivityModel:SaveScrapingCardBaseDrawResult(vo)
  369. local pos = false
  370. self.sc_base_info.card_list = self.sc_base_info.card_list or {}
  371. for i,v in ipairs(vo.reward_list) do
  372. self.sc_base_info.card_list[v.pos] = v.goods_list[1]
  373. if not pos then
  374. pos = v.pos
  375. end
  376. end
  377. local get_scroce = vo.score - self.sc_base_info.score
  378. self.sc_base_info.score = vo.score
  379. if vo.option == 1 and pos then
  380. local t = vo.reward_list[1].goods_list[1]
  381. local d =
  382. {
  383. sub_type = vo.sub_type,
  384. goods_type_id = t.goods_type_id,
  385. num = t.num,
  386. }
  387. KfActivityModel:getInstance():Fire(KfActivityModel.OPEN_SCRAOING_CARD_TIPS_VIEW_VIEW, d)
  388. self.sc_base_info.ignore_pos = pos
  389. end
  390. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ScrapingCard, nil, vo.sub_type)
  391. self:Fire(OperateActivityModel.SCRAPING_CARD_BASE_DRAW_UPDATE)
  392. Message.show(string.format("获得 %s 刮刮卡积分", HtmlColorTxt(get_scroce, ColorUtil.SHALLOW_GREEN)))
  393. end
  394. function OperateActivityModel:SaveScrapingCardScoreDrawResult(vo)
  395. self.sc_base_info.score = vo.score
  396. self.sc_base_info.next_score = vo.next_score
  397. local draw_list_pos = {}
  398. for i,v in ipairs(vo.draw_list) do
  399. draw_list_pos[v.draw_pos] = true
  400. end
  401. local score_reward_list = {}
  402. for i,v in ipairs(vo.reward_list) do
  403. score_reward_list[v.pos] =
  404. {
  405. goods = v.goods_list[1],
  406. is_get = draw_list_pos[v.pos] or false,
  407. }
  408. end
  409. self.sc_base_info.score_reward_list = score_reward_list
  410. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ScrapingCard, nil, vo.sub_type)
  411. self:Fire(OperateActivityModel.SCRAPING_CARD_SCROE_DRAW_UPDATE)
  412. end
  413. function OperateActivityModel:RefreshScrapingCardBaseDraw()
  414. self.sc_base_info = self.sc_base_info or {}
  415. self.sc_base_info.card_list = {}
  416. self:Fire(OperateActivityModel.SCRAPING_CARD_BASE_DRAW_UPDATE)
  417. end
  418. function OperateActivityModel:ScrapingCardInitCfg(vo)
  419. self.sc_cfg = vo
  420. end
  421. function OperateActivityModel:ScrapingCardShowRewardTips(vo)
  422. if vo.pos then
  423. self.sc_base_info.ignore_pos = false
  424. if self.sc_base_info and self.sc_base_info.card_list and self.sc_base_info.card_list[vo.pos] then
  425. local goods_type_id = self.sc_base_info.card_list[vo.pos].goods_type_id
  426. local num = self.sc_base_info.card_list[vo.pos].num
  427. local goods_fly_data = {[1] = goods_type_id}
  428. if TableSize(goods_fly_data) > 0 then
  429. MainUIModel:getInstance():PlayGoodsFlyList(goods_fly_data)
  430. end
  431. --飘字
  432. local goods_fly_data = {
  433. [1] = {
  434. goods_type_id = goods_type_id,
  435. num = num,
  436. }
  437. }
  438. if TableSize(goods_fly_data) > 0 then
  439. MainUIModel:getInstance():AddFloatInfo(goods_fly_data, true)
  440. end
  441. end
  442. self:Fire(OperateActivityModel.SCRAPING_CARD_BASE_DRAW_UPDATE)
  443. end
  444. end
  445. function OperateActivityModel:ScrapingCardCheckDo(can_do, price, str, ok_func, tips_flag_type)
  446. function ok_function( )
  447. if ok_func then
  448. ok_func()
  449. end
  450. end
  451. function toggle_function( flag )
  452. if OperateActivityModel.ScrapingCardFLAGTYPE.RANDOM_DRAW == tips_flag_type then
  453. self.sc_base_info.random_draw_toggle = flag
  454. elseif OperateActivityModel.ScrapingCardFLAGTYPE.CUSTOM_DRAW == tips_flag_type then
  455. self.sc_base_info.custom_draw_toggle = flag
  456. end
  457. end
  458. local show_tips_flag = false
  459. self.sc_base_info = self.sc_base_info
  460. if OperateActivityModel.ScrapingCardFLAGTYPE.RANDOM_DRAW == tips_flag_type then
  461. show_tips_flag = self.sc_base_info.random_draw_toggle or false
  462. elseif OperateActivityModel.ScrapingCardFLAGTYPE.CUSTOM_DRAW == tips_flag_type then
  463. show_tips_flag = self.sc_base_info.custom_draw_toggle or false
  464. end
  465. if not show_tips_flag then
  466. if can_do then
  467. local data =
  468. {
  469. show_content = str,
  470. type = Alert.Type.Four,
  471. ok_callback = ok_function,
  472. toggle_function = toggle_function,
  473. }
  474. Alert.showbytable(data)
  475. else
  476. price = price or 0
  477. local asset, source = WordManager:GetCommonMoneyIcon(1)
  478. local data = {
  479. gold_ab_res = asset,
  480. gold_res = source,
  481. price = price,
  482. insufficientText = "",
  483. priceText = str,
  484. titleText = "提示",
  485. ok_callback = ok_function,
  486. toggle_function = toggle_function,
  487. }
  488. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
  489. end
  490. else
  491. ok_func()
  492. end
  493. end
  494. function OperateActivityModel:ScrapingGetDrawCfg()
  495. local need_item_id = 102350
  496. local one_draw_cnt = 10
  497. local item_money = 1
  498. local cfg = self.sc_cfg
  499. if cfg and cfg.condition_list then
  500. for k,v in pairs(cfg.condition_list ) do
  501. if v[1] == "scratch_card_cost" then
  502. if v[2][1] and v[2][1][2] then
  503. need_item_id = tonumber(v[2][1][2])
  504. one_draw_cnt = tonumber(v[2][1][3])
  505. break
  506. end
  507. end
  508. end
  509. end
  510. local item_cfg = Config.Goodsprice[self.need_item_id]
  511. if item_cfg then
  512. item_money = item_cfg.price
  513. end
  514. return need_item_id, one_draw_cnt, item_money
  515. end
  516. function OperateActivityModel:ScrapingCradGetRedDot(sub_type)
  517. local b = false
  518. if self.sc_base_info and self.sc_base_info.score and self.sc_base_info.next_score then
  519. b = self.sc_base_info.score >= self.sc_base_info.next_score
  520. end
  521. if not b then
  522. local base_type = CustomActivityModel.CustomActBaseType.TAROT
  523. local free_buff_kind = OperateActivityModel.MaterialSubmitBuffKind.ACT_LUCKY_FREE --是否存在活动加成buff 首次抽奖免费
  524. local free_buff_cfg,free_buff_info = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(free_buff_kind)
  525. local buff_free_times = 0
  526. if free_buff_cfg and free_buff_info then
  527. local sec = free_buff_info.etime - TimeUtil:getServerTime( )
  528. if sec > 0 then
  529. self:ActScrapingCardBuffTimeLate(sec,sub_type)
  530. buff_free_times = free_buff_cfg.data
  531. for k,v in pairs(free_buff_info.used) do
  532. if v.kdata == base_type then--十连还有次数
  533. buff_free_times = buff_free_times - v.vdata
  534. break
  535. end
  536. end
  537. if buff_free_times > 0 then
  538. b = true
  539. end
  540. end
  541. end
  542. end
  543. return b
  544. end
  545. --刮刮卡活动BUFF时间倒计时
  546. function OperateActivityModel:ActScrapingCardBuffTimeLate( sec,sub_type )
  547. if self.act_scraping_card_buff_timer_id then
  548. GlobalTimerQuest:CancelQuest(self.act_scraping_card_buff_timer_id)
  549. self.act_scraping_card_buff_timer_id = nil
  550. end
  551. if self.scraping_card_act_sec and self.scraping_card_act_sec >= sec then
  552. return
  553. else
  554. self.scraping_card_act_sec = sec
  555. end
  556. local sec = sec or 0
  557. if sec > 0 then
  558. local function onTimer()
  559. sec = sec - 1
  560. if sec > 0 then
  561. else
  562. if self.act_scraping_card_buff_timer_id then
  563. GlobalTimerQuest:CancelQuest(self.act_scraping_card_buff_timer_id)
  564. self.act_scraping_card_buff_timer_id = nil
  565. end
  566. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ScrapingCard,nil,sub_type)
  567. end
  568. end
  569. if not self.act_scraping_card_buff_timer_id then
  570. self.act_scraping_card_buff_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
  571. end
  572. onTimer()
  573. else
  574. if self.act_scraping_card_buff_timer_id then
  575. GlobalTimerQuest:CancelQuest(self.act_scraping_card_buff_timer_id)
  576. self.act_scraping_card_buff_timer_id = nil
  577. end
  578. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ScrapingCard,nil,sub_type)
  579. end
  580. end
  581. function OperateActivityModel:ScrapingCradIsOpen(sub_type)
  582. local b = false
  583. if self.sc_cfg and self.sc_cfg.sub_type == sub_type then
  584. local time = TimeUtil:getServerTime()
  585. if time >= self.sc_cfg.stime and time <= self.sc_cfg.etime then
  586. b = true
  587. end
  588. end
  589. if not b then
  590. Message.show("活动未开启")
  591. end
  592. return b
  593. end
  594. ---------------------------------------刮刮卡结束 ---------------------------------------
  595. ---------------------------------------塔罗牌开始 ---------------------------------------
  596. function OperateActivityModel:SetTarotBaseInfo(vo)
  597. self.tarot_base_info = self.tarot_base_info or {}
  598. self.tarot_base_info.sub_type = vo.sub_type
  599. local reward_pool = vo.reward_pool
  600. table.sort(reward_pool, function (a, b)
  601. return a.index < b.index
  602. end)
  603. self.tarot_base_info.reward_pool = reward_pool
  604. local get_reward_list = {}
  605. local cnt = 0
  606. for i,v in ipairs( vo.reward_pool) do
  607. if v.status ~= 0 then
  608. get_reward_list[v.status] = v
  609. cnt = cnt + 1
  610. end
  611. end
  612. local card_list = vo.card_list
  613. table.sort(card_list, function (a, b)
  614. return a.pos < b.pos
  615. end)
  616. self.tarot_base_info.card_list = card_list
  617. self.tarot_base_info.get_reward_list = get_reward_list
  618. self.tarot_draw_cnt_list = self.tarot_draw_cnt_list or {}
  619. self.tarot_draw_cnt_list[vo.sub_type] = cnt
  620. self:Fire(OperateActivityModel.TAROT_BASE_UPDATE)
  621. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Tarot, nil, vo.sub_type)
  622. end
  623. function OperateActivityModel:UpdateTarorDrag(vo)
  624. if self.tarot_base_info then
  625. if self.tarot_base_info.reward_pool then
  626. for i,v in ipairs(self.tarot_base_info.reward_pool) do
  627. if v.index == vo.index then
  628. v.status = vo.pos
  629. self.tarot_base_info.get_reward_list = self.tarot_base_info.get_reward_list or {}
  630. self.tarot_base_info.get_reward_list[vo.pos] = v
  631. break
  632. end
  633. end
  634. end
  635. if self.tarot_base_info.card_list then
  636. for i,v in ipairs(self.tarot_base_info.card_list) do
  637. if v.pos == vo.pos then
  638. v.status = 1
  639. break
  640. end
  641. end
  642. end
  643. end
  644. self.tarot_draw_cnt_list = self.tarot_draw_cnt_list or {}
  645. self.tarot_draw_cnt_list[vo.sub_type] = self.tarot_draw_cnt_list[vo.sub_type] or 0
  646. self.tarot_draw_cnt_list[vo.sub_type] = self.tarot_draw_cnt_list[vo.sub_type] + 1
  647. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Tarot, nil, vo.sub_type)
  648. self:Fire(OperateActivityModel.TAROT_DRAW_UPDATE, vo.pos)
  649. end
  650. function OperateActivityModel:GetTargetRewardInfoByPos(pos)
  651. local info
  652. if self.tarot_base_info and self.tarot_base_info.get_reward_list then
  653. info = self.tarot_base_info.get_reward_list[pos]
  654. end
  655. return info
  656. end
  657. function OperateActivityModel:GetTargetResList(list, size, sub_type)
  658. local res_list = {}
  659. if list and #list > 0 and size and size >= #list then
  660. self.tarot_base_info.res_list = self.tarot_base_info.res_list or {}
  661. self.tarot_base_info.res_list[sub_type] = self.tarot_base_info.res_list[sub_type] or {}
  662. local function init_res_list(need_size, max_size)
  663. local t = {}
  664. local res_table = {}
  665. for i=1,max_size do
  666. t[i] = i
  667. end
  668. for i=1,need_size do
  669. local idx = math.random(1, #t)
  670. local tt = table.remove(t, idx)
  671. res_table[i] = tt
  672. end
  673. return res_table
  674. end
  675. if #self.tarot_base_info.res_list[sub_type] == 0 then
  676. self.tarot_base_info.res_list[sub_type] = init_res_list(#list, size)
  677. else
  678. local is_open = false
  679. for i,v in ipairs(list) do
  680. if v.status ~= 0 then
  681. is_open = true
  682. break
  683. end
  684. end
  685. if not is_open then
  686. self.tarot_base_info.res_list[sub_type] = init_res_list(#list, size)
  687. end
  688. end
  689. res_list = self.tarot_base_info.res_list[sub_type]
  690. end
  691. return res_list
  692. end
  693. function OperateActivityModel:UpdateTarorRefresh(vo)
  694. self:Fire(OperateActivityModel.TAROT_BASE_UPDATE)
  695. end
  696. function OperateActivityModel:SetTarotResetFlag(flag)
  697. self.tarot_base_info = self.tarot_base_info or {}
  698. self.tarot_base_info.reset_flag = flag
  699. end
  700. function OperateActivityModel:GetTarotResetFlag()
  701. return self.tarot_base_info.reset_flag
  702. end
  703. function OperateActivityModel:SetTarotRecordInfo(vo)
  704. self.tarot_base_info = self.tarot_base_info or {}
  705. self.tarot_base_info.sub_type = vo.sub_type
  706. local goods_log = {}
  707. for i,v in ipairs(vo.goods_log) do
  708. table.insert(goods_log, v)
  709. end
  710. self.tarot_base_info.goods_log = goods_log
  711. self:Fire(OperateActivityModel.TAROT_RECORD_UPDATE)
  712. end
  713. function OperateActivityModel:SetTarotRecordInfoAdd(vo)
  714. self.tarot_base_info = self.tarot_base_info or {}
  715. self.tarot_base_info.goods_log = self.tarot_base_info.goods_log or {}
  716. table.insert(self.tarot_base_info.goods_log, 1, vo)
  717. if #self.tarot_base_info.goods_log > 30 then
  718. table.remove(self.tarot_base_info.goods_log, #self.tarot_base_info.goods_log)
  719. end
  720. self:Fire(OperateActivityModel.TAROT_RECORD_UPDATE)
  721. end
  722. function OperateActivityModel:GetTargetRandomPos()
  723. local pos = 0
  724. local t = {}
  725. if self.tarot_base_info and self.tarot_base_info.card_list then
  726. for i,v in ipairs(self.tarot_base_info.card_list) do
  727. if v.status == 0 then
  728. table.insert(t, i)
  729. end
  730. end
  731. if #t > 1 then
  732. local idx = math.random(1, #t)
  733. pos = t[idx]
  734. elseif #t == 1 then
  735. pos = t[1]
  736. end
  737. end
  738. return pos
  739. end
  740. function OperateActivityModel:SetTarotCfg(vo)
  741. self.tarot_cfg = self.tarot_cfg or {}
  742. self.tarot_cfg[vo.sub_type]= vo
  743. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Tarot, nil, vo.sub_type)
  744. end
  745. function OperateActivityModel:IsTarotOver()
  746. local b = false
  747. if self.tarot_cfg then
  748. local cur_time = TimeUtil:getServerTime()
  749. if self.tarot_cfg.etime > cur_time then
  750. b = true
  751. end
  752. end
  753. return b
  754. end
  755. function OperateActivityModel:GetTarotAllRewardList(base_type, sub_type)
  756. if not self.tarot_all_reward_list or not self.tarot_all_reward_list[base_type] or not self.tarot_all_reward_list[base_type][sub_type] then
  757. self.tarot_all_reward_list = self.tarot_all_reward_list or {}
  758. local act_info = CustomActivityModel:getInstance():getOneActRewardList(base_type, sub_type)
  759. if act_info then
  760. local list = {}
  761. for i=#act_info.reward_list,1,-1 do
  762. local t = stringtotable(act_info.reward_list[i].reward)
  763. table.insert(list, t[1])
  764. end
  765. self.tarot_all_reward_list = self.tarot_all_reward_list or {}
  766. self.tarot_all_reward_list[base_type] = self.tarot_all_reward_list[base_type] or {}
  767. if list and #list > 1 then
  768. table.sort(list, function ( a,b )
  769. a.basic = a.basic or GoodsModel:getInstance():GetGoodsBasicByTypeId(tonumber(a[2]))
  770. b.basic = b.basic or GoodsModel:getInstance():GetGoodsBasicByTypeId(tonumber(b[2]))
  771. return a.basic.color > b.basic.color
  772. end)
  773. end
  774. self.tarot_all_reward_list[base_type][sub_type] = list
  775. end
  776. end
  777. return self.tarot_all_reward_list and self.tarot_all_reward_list[base_type] and self.tarot_all_reward_list[base_type][sub_type] or {}
  778. end
  779. function OperateActivityModel:GetTarotDrawCnt()
  780. local cnt = 0
  781. if self.tarot_base_info and self.tarot_base_info.card_list then
  782. for i,v in ipairs(self.tarot_base_info.card_list) do
  783. if v.status ~= 0 then
  784. cnt = cnt + 1
  785. end
  786. end
  787. end
  788. return cnt
  789. end
  790. function OperateActivityModel:GetDragCostInfo(sub_type, cnt)
  791. local info =
  792. {
  793. goods_id = 102350,
  794. cost_num = 9,
  795. price = 1,
  796. price_type = 1,
  797. }
  798. if self.tarot_cfg and self.tarot_cfg[sub_type] and self.tarot_cfg[sub_type].condition_list then
  799. local cfg = self.tarot_cfg[sub_type]
  800. if cfg.condition_list[1] and cfg.condition_list[1][2] then
  801. info.goods_id = tonumber(cfg.condition_list[1][2])
  802. end
  803. local draw_cnt = cnt or self:GetTarotDrawCnt() + 1
  804. if cfg.condition_list[2] and cfg.condition_list[2][2] then
  805. info.cost_num = tonumber(cfg.condition_list[2][2][draw_cnt])
  806. end
  807. end
  808. local cfg = Config.Goodsprice
  809. if cfg[info.goods_id] then
  810. info.price = cfg[info.goods_id].price
  811. info.price_type = cfg[info.goods_id].price_type
  812. end
  813. return info
  814. end
  815. function OperateActivityModel:GetRefreshCostInfo(sub_type)
  816. local info =
  817. {
  818. goods_id = 102314,
  819. cost_num = 1,
  820. price = 1,
  821. price_type = 1,
  822. }
  823. if self.tarot_cfg and self.tarot_cfg[sub_type] and self.tarot_cfg[sub_type].condition_list then
  824. local cfg = self.tarot_cfg[sub_type]
  825. if cfg.condition_list[3] and cfg.condition_list[3][2] and cfg.condition_list[3][2][1] then
  826. local d = cfg.condition_list[3][2][1]
  827. info.goods_id = tonumber(d[2])
  828. info.cost_num = tonumber(d[3])
  829. end
  830. end
  831. local cfg = Config.Goodsprice
  832. if cfg[info.goods_id] then
  833. info.price = cfg[info.goods_id].price
  834. info.price_type = cfg[info.goods_id].price_type
  835. end
  836. return info
  837. end
  838. function OperateActivityModel:GetDragGoodsId()
  839. local goods_id = 102350
  840. for k,v in pairs(self.tarot_cfg) do
  841. local cfg = v
  842. if cfg.condition_list[1] and cfg.condition_list[1][2] then
  843. goods_id = tonumber(cfg.condition_list[1][2])
  844. end
  845. break
  846. end
  847. return goods_id
  848. end
  849. function OperateActivityModel:GetRefreshGoodsId()
  850. local goods_id = 102314
  851. for k,v in pairs(self.tarot_cfg) do
  852. local cfg = v
  853. if cfg.condition_list[3] and cfg.condition_list[3][2] and cfg.condition_list[3][2][1] and cfg.condition_list[3][2][1][2] then
  854. goods_id = tonumber(cfg.condition_list[3][2][1][2])
  855. end
  856. break
  857. end
  858. return goods_id
  859. end
  860. function OperateActivityModel:TarotIsOpen(sub_type)
  861. local b = false
  862. if self.tarot_cfg and self.tarot_cfg[sub_type] then
  863. local cfg = self.tarot_cfg[sub_type]
  864. local time = TimeUtil:getServerTime()
  865. if time >= cfg.stime and time <= cfg.etime then
  866. b = true
  867. end
  868. end
  869. if not b then
  870. Message.show("活动未开启")
  871. end
  872. return b
  873. end
  874. function OperateActivityModel:TarotCheckDo(can_do, price, str, ok_func)
  875. function ok_function( )
  876. if ok_func then
  877. ok_func()
  878. end
  879. end
  880. function toggle_function( flag )
  881. self.tarot_base_info.custom_draw_toggle = flag
  882. end
  883. local show_tips_flag = self.tarot_base_info.custom_draw_toggle or false
  884. if not can_do and not show_tips_flag then
  885. price = price or 0
  886. local asset, source = WordManager:GetCommonMoneyIcon(1)
  887. local data = {
  888. gold_ab_res = asset,
  889. gold_res = source,
  890. price = price,
  891. insufficientText = "",
  892. priceText = str,
  893. titleText = "提示",
  894. ok_callback = ok_function,
  895. toggle_function = toggle_function,
  896. }
  897. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
  898. else
  899. ok_func()
  900. end
  901. end
  902. function OperateActivityModel:TarotCheckRefresh(can_do, price, str, ok_func)
  903. function ok_function( )
  904. if ok_func then
  905. ok_func()
  906. end
  907. end
  908. function toggle_function( flag )
  909. self.tarot_base_info.custom_refresh_toggle = flag
  910. end
  911. local show_tips_flag = self.tarot_base_info.custom_refresh_toggle or false
  912. if not can_do and not show_tips_flag then
  913. price = price or 0
  914. local asset, source = WordManager:GetCommonMoneyIcon(1)
  915. local data = {
  916. gold_ab_res = asset,
  917. gold_res = source,
  918. price = price,
  919. insufficientText = "",
  920. priceText = str,
  921. titleText = "提示",
  922. ok_callback = ok_function,
  923. toggle_function = toggle_function,
  924. }
  925. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
  926. else
  927. ok_func()
  928. end
  929. end
  930. function OperateActivityModel:TarotGetRedDot(sub_type)
  931. local b = false
  932. if self.tarot_cfg and self.tarot_cfg[sub_type] and self.tarot_draw_cnt_list and self.tarot_draw_cnt_list[sub_type] then
  933. local draw_cost_info = self:GetDragCostInfo(self.tarot_draw_cnt_list[sub_type] + 1)
  934. b = draw_cost_info.cost_num == 0
  935. end
  936. if not b then
  937. local base_type = CustomActivityModel.CustomActBaseType.TAROT
  938. local free_buff_kind = OperateActivityModel.MaterialSubmitBuffKind.ACT_LUCKY_FREE --是否存在活动加成buff 首次抽奖免费
  939. local free_buff_cfg,free_buff_info = OperateActivityModel:getInstance():GetMaterialBuffInfoByKind(free_buff_kind)
  940. local buff_free_times = 0
  941. if free_buff_cfg and free_buff_info then
  942. local sec = free_buff_info.etime - TimeUtil:getServerTime( )
  943. if sec > 0 then
  944. self:ActTarotBuffTimeLate(sec)
  945. buff_free_times = free_buff_cfg.data
  946. for k,v in pairs(free_buff_info.used) do
  947. if v.kdata == base_type then--十连还有次数
  948. buff_free_times = buff_free_times - v.vdata
  949. break
  950. end
  951. end
  952. if buff_free_times > 0 then
  953. b = true
  954. end
  955. end
  956. end
  957. end
  958. return b
  959. end
  960. --塔罗牌活动BUFF时间倒计时
  961. function OperateActivityModel:ActTarotBuffTimeLate( sec )
  962. if self.act_tarot_buff_timer_id then
  963. GlobalTimerQuest:CancelQuest(self.act_tarot_buff_timer_id)
  964. self.act_tarot_buff_timer_id = nil
  965. end
  966. if self.tarot_act_sec and self.tarot_act_sec >= sec then
  967. return
  968. else
  969. self.tarot_act_sec = sec
  970. end
  971. local sec = sec or 0
  972. if sec > 0 then
  973. local function onTimer()
  974. sec = sec - 1
  975. if sec > 0 then
  976. else
  977. if self.act_tarot_buff_timer_id then
  978. GlobalTimerQuest:CancelQuest(self.act_tarot_buff_timer_id)
  979. self.act_tarot_buff_timer_id = nil
  980. end
  981. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Tarot)
  982. end
  983. end
  984. if not self.act_tarot_buff_timer_id then
  985. self.act_tarot_buff_timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
  986. end
  987. onTimer()
  988. else
  989. if self.act_tarot_buff_timer_id then
  990. GlobalTimerQuest:CancelQuest(self.act_tarot_buff_timer_id)
  991. self.act_tarot_buff_timer_id = nil
  992. end
  993. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Tarot)
  994. end
  995. end
  996. ---------------------------------------塔罗牌结束 ---------------------------------------
  997. ---------------------------------------阶段兑换商城信息 ---------------------------------------
  998. function OperateActivityModel:GetStageExchangeInfo( sub_type )
  999. return self.stage_exchange_info[sub_type]
  1000. end
  1001. function OperateActivityModel:SetStageExchangeInfo( value,one_data )
  1002. if (not value) and one_data then
  1003. --修改单条信息
  1004. local base_info = self:GetStageExchangeInfo(one_data.sub_type)
  1005. if base_info then
  1006. for k,v in pairs(base_info) do
  1007. if v.phase == one_data.phase then
  1008. for kk,vv in pairs(v.goods_list) do
  1009. if vv.grade_id == one_data.grade_id then
  1010. vv.exchange_num = one_data.exchange_num
  1011. -------------------------
  1012. if one_data.phase == 4 and vv.limit_num == 999 then
  1013. --无限制的那些要特殊处理
  1014. vv.exchange_num = 0
  1015. end
  1016. -------------------------
  1017. return
  1018. end
  1019. end
  1020. end
  1021. end
  1022. end
  1023. return
  1024. end
  1025. -------------------------
  1026. for k,v in pairs(self.stage_exchange_info) do
  1027. if v.phase == 4 then
  1028. for kk,vv in pairs(v.goods_list) do
  1029. if vv.limit_num == 999 then
  1030. --无限制的那些要特殊处理
  1031. vv.exchange_num = 0
  1032. end
  1033. end
  1034. end
  1035. end
  1036. -------------------------
  1037. local function sort_call( a,b )
  1038. return a.phase < b.phase
  1039. end
  1040. table.sort( value.goods_phase, sort_call )
  1041. self.stage_exchange_info[value.sub_type] = value.goods_phase
  1042. end
  1043. --获取阶段商城当前解锁期
  1044. function OperateActivityModel:GetStageExchangeUnlockPhase( sub_type )
  1045. local base_info = self:GetStageExchangeInfo(sub_type)
  1046. if not base_info then return 0 end
  1047. local unlock_phase = 0
  1048. for i,v in ipairs(base_info) do
  1049. unlock_phase = v.phase
  1050. for a,b in pairs(v.goods_list) do
  1051. if b.exchange_num < b.limit_num then
  1052. return unlock_phase
  1053. end
  1054. end
  1055. end
  1056. return unlock_phase
  1057. end
  1058. function OperateActivityModel:GetStageExchangeCostId( sub_type )
  1059. self.cost_id_stage_exchange = self.cost_id_stage_exchange or {}
  1060. if not self.cost_id_stage_exchange[sub_type] then
  1061. local act_info = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.STAGE_EXCHANGE, sub_type)
  1062. local list_condition = stringtotable(act_info.condition)
  1063. for k,v in pairs(list_condition) do
  1064. if v[1] == "cost_type" then
  1065. self.cost_id_stage_exchange[sub_type] = tonumber(v[2])
  1066. break
  1067. end
  1068. end
  1069. end
  1070. return self.cost_id_stage_exchange[sub_type]
  1071. end
  1072. ---------------------------------------阶段兑换商城信息 ---------------------------------------
  1073. ---------------------------------------冒险征途 start---------------------------------------
  1074. --进度值信息
  1075. function OperateActivityModel:GetAdventureNumInfo( sub_type )
  1076. return self.adventure_num_info[sub_type]
  1077. end
  1078. function OperateActivityModel:SetAdventureNumInfo( value )
  1079. self.adventure_num_info[value.sub_type] = value
  1080. self:AdventureTaskFix(value.sub_type)
  1081. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Adventure,nil,value.sub_type)
  1082. end
  1083. --任务信息
  1084. function OperateActivityModel:GetAdventureTaskInfo( sub_type )
  1085. return self.adventure_task_info[sub_type]
  1086. end
  1087. function OperateActivityModel:SetAdventureTaskInfo( value )
  1088. self.adventure_task_info[value.sub_type] = value.mod_list
  1089. self:AdventureTaskFix(value.sub_type)
  1090. self:SetAdventureRandomPool(value.sub_type,value.reward_list or {})
  1091. end
  1092. --随机奖池
  1093. function OperateActivityModel:GetAdventureRandomPool( sub_type )
  1094. return self.adventure_random_pool[sub_type]
  1095. end
  1096. function OperateActivityModel:SetAdventureRandomPool( sub_type,value )
  1097. self.adventure_random_pool[sub_type] = value
  1098. end
  1099. --给任务信息添加进度信息
  1100. function OperateActivityModel:AdventureTaskFix( sub_type )
  1101. local data_1 = self:GetAdventureNumInfo(sub_type)
  1102. local data_2 = self:GetAdventureTaskInfo(sub_type)
  1103. if data_1 and data_2 then
  1104. for k,v in pairs(data_2) do
  1105. for kk,vv in pairs(data_1.task_list) do
  1106. if (v.mod_id == vv.mod_id) and (v.sub_id == vv.sub_id) then
  1107. v.times = vv.times
  1108. break
  1109. end
  1110. end
  1111. v.times = v.times or 0
  1112. end
  1113. end
  1114. end
  1115. function OperateActivityModel:GetAdventureCostIcon( sub_type )
  1116. local act_info = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.ADVENTURE, sub_type)
  1117. if act_info and act_info.condition then
  1118. local confition_list = stringtotable(act_info.condition)
  1119. for k,v in pairs(confition_list) do
  1120. if v[1] == "act_icon_pic" then
  1121. return v[2]
  1122. end
  1123. end
  1124. end
  1125. return 1
  1126. end
  1127. ---------------------------------------冒险征途 end---------------------------------------
  1128. ---------------------------------------活跃拼图 start---------------------------------------
  1129. -- 缓存活跃拼图协议信息 33153
  1130. function OperateActivityModel:SetJigsawEventData(vo)
  1131. if not vo then return end
  1132. self.jigsaw_event_list[vo.sub_type] = self.jigsaw_event_list[vo.sub_type] or {}
  1133. self.jigsaw_event_list[vo.sub_type].grades = {}
  1134. -- 按键值存储已领取阶段
  1135. for k, v in ipairs(vo.grades) do
  1136. self.jigsaw_event_list[vo.sub_type].grades[v.grade] = true
  1137. end
  1138. self.jigsaw_event_list[vo.sub_type].tasks = {}
  1139. local key = ""
  1140. for k, v in ipairs(vo.tasks) do
  1141. key = v.task_row .. "@" .. v.task_colu
  1142. self.jigsaw_event_list[vo.sub_type].tasks[key] = v
  1143. end
  1144. end
  1145. function OperateActivityModel:GetJigsawEventData(sub_type)
  1146. return self.jigsaw_event_list[sub_type] or nil
  1147. end
  1148. -- 获取活跃拼图奖励领取情况 已领取会返回true
  1149. function OperateActivityModel:GetJigsawGradeFlag(sub_type, grade)
  1150. if sub_type and grade and self.jigsaw_event_list[sub_type] then
  1151. return self.jigsaw_event_list[sub_type].grades[grade]
  1152. end
  1153. return false
  1154. end
  1155. -- 获取活跃拼图任务协议数据
  1156. function OperateActivityModel:GetJigsawTaskEventData(sub_type, task_row, task_colu)
  1157. if sub_type then
  1158. if task_row and task_colu then
  1159. return self.jigsaw_event_list[sub_type]
  1160. and self.jigsaw_event_list[sub_type].tasks
  1161. and self.jigsaw_event_list[sub_type].tasks[task_row .. "@" .. task_colu] or nil
  1162. else
  1163. return self.jigsaw_event_list[sub_type] and self.jigsaw_event_list[sub_type].tasks or nil
  1164. end
  1165. end
  1166. return nil
  1167. end
  1168. -- 返回表1:根据活跃拼图的奖励配置,筛选出带有奖励的任务列表 格式为 [任务行@任务列] = true
  1169. -- 返回表2:根据活动的condition_list,拼接形成键值后用gade作为值成表方便查询grade
  1170. function OperateActivityModel:GetJigsawAwardTaskListAndGradeList(reward_cfg)
  1171. local tb1, tb2 = {}, {}
  1172. local key = ""
  1173. if reward_cfg then
  1174. for k, v in ipairs(reward_cfg.reward_list) do
  1175. for k2, v2 in ipairs(v.condition_list) do
  1176. for k3, v3 in ipairs(v2) do
  1177. if k3 == 1 then
  1178. key = v3
  1179. else
  1180. key = key .. "@" .. v3
  1181. end
  1182. end
  1183. -- 根据条件列表组合成键值保存奖励档次
  1184. tb2[key] = v.grade
  1185. -- 如果是任务节点的奖励,则重新创建键值并添加到表1
  1186. if v2[1] == "order" then
  1187. key = v2[2] .. "@" .. v2[3]
  1188. tb1[key] = true
  1189. end
  1190. end
  1191. end
  1192. end
  1193. return tb1, tb2
  1194. end
  1195. -- 获取活跃拼图任务进度 task_state:0待完成 1可领取 2已领取(有部分任务有奖励,要做是否存在奖励分类处理,对于没有奖励的任务,前端新增状态3)
  1196. function OperateActivityModel:GetJigsawTaskState(sub_type, award_task_list, task_row, task_colu)
  1197. local state = 0
  1198. if sub_type and award_task_list and task_row and task_colu then
  1199. -- 是否是有奖励的任务
  1200. local has_reward = award_task_list[task_row.."@"..task_colu] or false
  1201. -- 获取任务状态
  1202. local event_data = self:GetJigsawTaskEventData(sub_type, task_row, task_colu)
  1203. state = event_data and event_data.task_state or 0
  1204. -- 完成没有奖励的任务,特殊处理为3
  1205. if not has_reward and state == 1 then
  1206. state = 3
  1207. end
  1208. end
  1209. return state
  1210. end
  1211. -- 拼图活动领取更新缓存 33154
  1212. function OperateActivityModel:UpdateJigsawGradeData(vo)
  1213. if vo and self.jigsaw_event_list[vo.sub_type] and self.jigsaw_event_list[vo.sub_type].grades then
  1214. self.jigsaw_event_list[vo.sub_type].grades[vo.grade] = true
  1215. end
  1216. end
  1217. -- 获取活跃拼图任务配置
  1218. function OperateActivityModel:GetJigsawTaskCfgData(condition_list)
  1219. if not condition_list then return end
  1220. local tb = {}
  1221. local suit_id, bg_res = nil, "bg_1" -- 背景图有默认资源
  1222. -- 获取任务套的id
  1223. for k, v in ipairs(condition_list) do
  1224. if v[1] == "suit" then
  1225. suit_id = tonumber(v[2])
  1226. end
  1227. if string.find(v[1], "bg_") then
  1228. bg_res = v[1]
  1229. end
  1230. end
  1231. -- 根据任务套id获取任务内容
  1232. if suit_id then
  1233. for k, v in pairs(Config.Actslicetask) do
  1234. if v.suit == suit_id then
  1235. tb[#tb+1] = v
  1236. end
  1237. end
  1238. -- 排序任务
  1239. local sort_func = function ( a, b )
  1240. if a.row == b.row then
  1241. return a.colu < b.colu
  1242. else
  1243. return a.row < b.row
  1244. end
  1245. end
  1246. table.sort(tb, sort_func)
  1247. end
  1248. return tb, suit_id, bg_res
  1249. end
  1250. -- 活跃拼图红点
  1251. function OperateActivityModel:GetJigsawRed(sub_type, reward_cfg)
  1252. local bool = false
  1253. if sub_type and reward_cfg then
  1254. self.jigsaw_red_cache[sub_type] = {}
  1255. -- 行,列的完成任务数
  1256. local row_task_state_tb, col_task_state_tb = {}, {}
  1257. -- 先检测任务可完成的红点
  1258. local award_task_list, grade_list = self:GetJigsawAwardTaskListAndGradeList(reward_cfg)
  1259. local key, state = "", 0
  1260. local tasks = self:GetJigsawTaskEventData(sub_type) -- 任务协议状态
  1261. local total_task_num = TableSize(tasks)
  1262. local task_finished_num = 0
  1263. if tasks then
  1264. for k, v in pairs(tasks) do
  1265. state = self:GetJigsawTaskState(sub_type, award_task_list, v.task_row, v.task_colu)
  1266. key = v.task_row .. "@" .. v.task_colu
  1267. -- 根据行列记录任务完成数
  1268. row_task_state_tb[v.task_row] = row_task_state_tb[v.task_row] or 0
  1269. row_task_state_tb[v.task_row] = state >= 2 and row_task_state_tb[v.task_row] + 1 or row_task_state_tb[v.task_row]
  1270. col_task_state_tb[v.task_colu] = col_task_state_tb[v.task_colu] or 0
  1271. col_task_state_tb[v.task_colu] = state >= 2 and col_task_state_tb[v.task_colu] + 1 or col_task_state_tb[v.task_colu]
  1272. -- 累加完成个数
  1273. task_finished_num = state >= 2 and task_finished_num + 1 or task_finished_num
  1274. bool = state == 1 or bool
  1275. end
  1276. end
  1277. -- 再检测横行竖列的红点
  1278. local key_list = {}
  1279. for k, v in pairs(grade_list) do
  1280. if not self:GetJigsawGradeFlag(sub_type, v) then -- 没有已领取记录
  1281. key_list = Split(k, "@")
  1282. if key_list[1] == "row" and row_task_state_tb[tonumber(key_list[2])] then -- 检测横行的红点
  1283. bool = row_task_state_tb[tonumber(key_list[2])] >= 3 or bool
  1284. elseif key_list[1] == "column" and col_task_state_tb[tonumber(key_list[2])] then -- 检测竖列的红点
  1285. bool = col_task_state_tb[tonumber(key_list[2])] >= 3 or bool
  1286. elseif key_list[1] == "count" then -- 检测任务是否全部完成
  1287. -- 缓存红点
  1288. self.jigsaw_red_cache[sub_type][key_list[1]] = task_finished_num >= total_task_num and total_task_num > 0
  1289. bool = self.jigsaw_red_cache[sub_type][key_list[1]] or bool
  1290. end
  1291. end
  1292. end
  1293. end
  1294. return bool
  1295. end
  1296. function OperateActivityModel:GetJigsawRedCache(sub_type, red_type)
  1297. if sub_type then
  1298. if red_type then
  1299. return self.jigsaw_red_cache[sub_type] and self.jigsaw_red_cache[sub_type][red_type] or false
  1300. else
  1301. return self.jigsaw_red_cache[sub_type]
  1302. end
  1303. else
  1304. return false
  1305. end
  1306. end
  1307. ---------------------------------------活跃拼图 end---------------------------------------
  1308. ---------------------------------------黑白棋 start---------------------------------------
  1309. --总奖励列表
  1310. function OperateActivityModel:GetReversiInfo( sub_type )
  1311. return self.reversi_info[sub_type]
  1312. end
  1313. function OperateActivityModel:SetReversiInfo( value )
  1314. self.reversi_info[value.sub_type] = value
  1315. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Reversi, nil, value.sub_type)
  1316. end
  1317. --当前奖池状态
  1318. function OperateActivityModel:GetReversiCurInfo( sub_type )
  1319. return self.reversi_cur_info[sub_type]
  1320. end
  1321. function OperateActivityModel:SetReversiCurInfo( value )
  1322. self.reversi_cur_info[value.sub_type] = value.reward_list
  1323. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.Reversi, nil, value.sub_type)
  1324. end
  1325. --当前奖池奖励列表
  1326. function OperateActivityModel:GetReversiCurPoolInfo( sub_type )
  1327. return self.reversi_cur_pool_info[sub_type]
  1328. end
  1329. function OperateActivityModel:SetReversiCurPoolInfo( value )
  1330. value.cost_tb = stringtotable(value.cost)[1]
  1331. value.other_cost_tb = stringtotable(value.other_cost)[1]
  1332. self.reversi_cur_pool_info[value.sub_type] = value
  1333. end
  1334. ---------------------------------------黑白棋 end---------------------------------------
  1335. ---------------------------------------三日作战 start---------------------------------------
  1336. function OperateActivityModel:InitThreeFightTaskCFG( )--初始化三日作战任务表配置
  1337. self.three_fight_task_cfg = {}
  1338. local data = DeepCopy(Config.Daysplantask)
  1339. for k,v in pairs(data) do
  1340. if not self.three_fight_task_cfg[v.task_type] then
  1341. self.three_fight_task_cfg[v.task_type] = {}
  1342. end
  1343. v.reward = stringtotable(v.reward)
  1344. v.link = stringtotable(v.link)
  1345. v.desc = Trim(v.desc)
  1346. self.three_fight_task_cfg[v.task_type][v.task_id] = v
  1347. end
  1348. end
  1349. function OperateActivityModel:GetThreeFightTaskCfg( task_type,task_id )--获得三日作战任务表配置
  1350. if self.three_fight_task_cfg[task_type] then
  1351. return self.three_fight_task_cfg[task_type][task_id]
  1352. end
  1353. end
  1354. function OperateActivityModel:InitThreeFightTaskActCFG( )--初始化三日作战任务活动配置
  1355. self.three_fight_act_task_cfg = {}
  1356. local data = DeepCopy(Config.Daysplantasksuit)
  1357. for k,v in pairs(data) do
  1358. if not self.three_fight_act_task_cfg[v.suit] then
  1359. self.three_fight_act_task_cfg[v.suit] = {}
  1360. end
  1361. if not self.three_fight_act_task_cfg[v.suit][v.open_day] then
  1362. self.three_fight_act_task_cfg[v.suit][v.open_day] = {}
  1363. end
  1364. self.three_fight_act_task_cfg[v.suit][v.open_day][#self.three_fight_act_task_cfg[v.suit][v.open_day] + 1] = v
  1365. end
  1366. end
  1367. function OperateActivityModel:SetThreeFightViewInfoOne( v )--设置三日作战服务端数据
  1368. local new_data = {}
  1369. local cur_times = 0
  1370. local max_times = 0
  1371. for kk,vv in pairs(v.list) do
  1372. new_data[vv.day] = vv
  1373. end
  1374. v.list = new_data
  1375. self.three_fight_view_info[v.sub_type] = v
  1376. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ThreeFight,nil,v.sub_type)
  1377. end
  1378. function OperateActivityModel:CheckThreeFightRedDot( sub_type )--检查三日作战红点
  1379. local show = false
  1380. self.three_fight_red_info = self.three_fight_red_info or {}
  1381. self.three_fight_red_info[sub_type] = {}
  1382. local base_type = CustomActivityModel.CustomActBaseType.THREE_FIGHT
  1383. local sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(base_type)
  1384. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  1385. local act_type = CustomActivityModel.CustomIconActType.KfAct
  1386. if act_list then
  1387. act_type = act_list.act_type
  1388. local start_day = math.ceil((TimeUtil:getServerTime() - act_list.stime)/60/60/24)--当前活动开始的第几天
  1389. for k,v in pairs(self.three_fight_view_info) do
  1390. if v.sub_type == sub_type then
  1391. for kk,vv in pairs(v.list) do
  1392. for kkk,vvv in pairs(vv.task_list) do
  1393. if vvv.state == 1 and start_day >= vv.day then
  1394. show = true
  1395. self.three_fight_red_info[sub_type][vv.day] = true
  1396. end
  1397. end
  1398. end
  1399. end
  1400. end
  1401. end
  1402. return show,act_type
  1403. end
  1404. ---------------------------------------三日作战 end---------------------------------------
  1405. ---------------------------------------眼疾手快 start---------------------------------------
  1406. --更新眼疾手快基本信息
  1407. function OperateActivityModel:SetAmasingJipSawBaseInfo(vo)
  1408. self.amasing_jipsaw_info = self.amasing_jipsaw_info or {}
  1409. self.amasing_jipsaw_info.base_info = {}
  1410. self.amasing_jipsaw_info.base_info.sub_type = vo.sub_type
  1411. self.amasing_jipsaw_info.base_info.stage = vo.stage
  1412. self.amasing_jipsaw_info.base_info.puzzle_times = vo.puzzle_times
  1413. self:Fire(OperateActivityModel.AMASING_JIPSAW_UPDATE_BASEINFO)
  1414. end
  1415. --更新眼疾手快游戏拼图数据
  1416. function OperateActivityModel:SetAmasingJipSawGameInfo(vo)
  1417. self.amasing_jipsaw_info = self.amasing_jipsaw_info or {}
  1418. self.amasing_jipsaw_info.pic_info = {}
  1419. self.amasing_jipsaw_info.pic_info.sub_type = vo.sub_type
  1420. self.amasing_jipsaw_info.pic_info.option_type = vo.option_type
  1421. self.amasing_jipsaw_info.pic_info.picture_id = vo.picture_id
  1422. self.amasing_jipsaw_info.pic_info.start_time = vo.start_time
  1423. self.amasing_jipsaw_info.pic_info.end_time = vo.end_time
  1424. self.amasing_jipsaw_info.pic_info.row = 0
  1425. self.amasing_jipsaw_info.pic_info.col = 0
  1426. local card_list = vo.card_list
  1427. if #card_list > 0 then
  1428. table.sort( card_list, function (a, b)
  1429. if a.x ~= b.x then
  1430. return a.x < b.x
  1431. else
  1432. return a.y < b.y
  1433. end
  1434. end )
  1435. self.amasing_jipsaw_info.pic_info.row = card_list[#card_list].x
  1436. self.amasing_jipsaw_info.pic_info.col = card_list[#card_list].y
  1437. local t = {}
  1438. for i,v in ipairs(card_list) do
  1439. table.insert(t, v.num)
  1440. end
  1441. card_list = t
  1442. end
  1443. self.amasing_jipsaw_info.pic_info.card_list = card_list
  1444. self:Fire(OperateActivityModel.AMASING_JIPSAW_UPDATE_GAMEINFO, vo.option_type)
  1445. --如果是开始游戏,同步一下进度
  1446. if vo.option_type == 2 then
  1447. self:Fire(OperateActivityModel.REQUEST_INFO, 33271, vo.sub_type)
  1448. end
  1449. end
  1450. --拼图交换
  1451. function OperateActivityModel:SetAmasingJipSawGameExchange(old_idx, new_idx)
  1452. if self.amasing_jipsaw_info.pic_info and self.amasing_jipsaw_info.pic_info.card_list then
  1453. if self.amasing_jipsaw_info.pic_info.card_list[old_idx] and self.amasing_jipsaw_info.pic_info.card_list[new_idx] then
  1454. self.amasing_jipsaw_info.pic_info.card_list[old_idx], self.amasing_jipsaw_info.pic_info.card_list[new_idx] = self.amasing_jipsaw_info.pic_info.card_list[new_idx], self.amasing_jipsaw_info.pic_info.card_list[old_idx]
  1455. end
  1456. end
  1457. end
  1458. --眼疾手快奖励
  1459. function OperateActivityModel:SetAmasingJipSawReward(vo)
  1460. self.amasing_jipsaw_info = self.amasing_jipsaw_info or {}
  1461. self.amasing_jipsaw_info.base_info = {}
  1462. self.amasing_jipsaw_info.base_info.sub_type = vo.sub_type
  1463. self.amasing_jipsaw_info.base_info.stage = vo.stage
  1464. self.amasing_jipsaw_info.base_info.puzzle_times = vo.puzzle_times
  1465. self.amasing_jipsaw_info.reward_list = vo.reward_list
  1466. end
  1467. --更新眼疾手快奖励预览信息
  1468. function OperateActivityModel:SetAmasingJipSawShowReward(vo)
  1469. self.amasing_jipsaw_info = self.amasing_jipsaw_info or {}
  1470. self.amasing_jipsaw_info.show_info = {}
  1471. self.amasing_jipsaw_info.show_info.sub_type = vo.sub_type
  1472. local reward_list = {}
  1473. if #vo.reward_list > 0 then
  1474. for i=1,6 do
  1475. local idx = #vo.reward_list - i + 1
  1476. if vo.reward_list[idx] then
  1477. table.insert(reward_list, vo.reward_list[idx])
  1478. end
  1479. end
  1480. end
  1481. self.amasing_jipsaw_info.show_info.reward_list = reward_list
  1482. self:Fire(OperateActivityModel.AMASING_JIPSAW_UPDATE_BASEINFO)
  1483. end
  1484. --眼疾手快获取基本数据
  1485. function OperateActivityModel:GetAmasingJipSawBaseInfo()
  1486. return (self.amasing_jipsaw_info and self.amasing_jipsaw_info.base_info) and self.amasing_jipsaw_info.base_info or nil
  1487. end
  1488. --眼疾手快获取奖励预览数据
  1489. function OperateActivityModel:GetAmasingJipSawShowReward()
  1490. return (self.amasing_jipsaw_info and self.amasing_jipsaw_info.show_info and self.amasing_jipsaw_info.show_info.reward_list) and self.amasing_jipsaw_info.show_info.reward_list or nil
  1491. end
  1492. --眼疾手快获取拼图数据
  1493. function OperateActivityModel:GetAmasingJipSawGameInfo()
  1494. return (self.amasing_jipsaw_info and self.amasing_jipsaw_info.pic_info) and self.amasing_jipsaw_info.pic_info or nil
  1495. end
  1496. --眼疾手快游戏开始
  1497. function OperateActivityModel:AmasingJipSawGameStart(vo)
  1498. self:Fire(OperateActivityModel.AMASING_JIPSAW_UPDATE_GAME_START, vo.sub_type, vo.stage)
  1499. end
  1500. ---------------------------------------眼疾手快 end---------------------------------------
  1501. ---------------------------------------人参果树 start---------------------------------------
  1502. --人参果树基本信息
  1503. function OperateActivityModel:SetPrayTreeBaseInfo(vo)
  1504. self.pray_tree_info = self.pray_tree_info or {}
  1505. self.pray_tree_info.sub_type = vo.sub_type
  1506. self.pray_tree_info.next_hit = vo.next_hit
  1507. self.pray_tree_info.score = vo.score
  1508. self.pray_tree_info.free_count = vo.free_count
  1509. self:Fire(OperateActivityModel.PRAY_TREE_BASE_INFO)
  1510. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.PrayTree, nil, vo.sub_type)
  1511. end
  1512. --人参果树抽卡
  1513. function OperateActivityModel:SetPrayTreeDrawnfo(vo)
  1514. self:Fire(OperateActivityModel.PRAY_TREE_DRAW, vo)
  1515. end
  1516. --人参果树领奖
  1517. function OperateActivityModel:SetPrayTreeRewardInfo(vo)
  1518. self:Fire(OperateActivityModel.PRAY_TREE_GET_REWARD)
  1519. end
  1520. --人参果树领奖
  1521. function OperateActivityModel:GetPrayTreeBaseInfo()
  1522. return self.pray_tree_info
  1523. end
  1524. --人参果树最大祝福值
  1525. function OperateActivityModel:GetPrayTreeMaxValue()
  1526. local cfg = Config.Customactkv
  1527. return (cfg and cfg["120@blessing_value_max"]) and cfg["120@blessing_value_max"].value_content or 100
  1528. end
  1529. --人参果树祝福奖励
  1530. function OperateActivityModel:GetPrayTreeLessReward()
  1531. local cfg = Config.Customactkv
  1532. return (cfg and cfg["120@blessing_reward"]) and stringtotable(cfg["120@blessing_reward"].value_content)[1] or false
  1533. end
  1534. --人参果树最大祝福值
  1535. function OperateActivityModel:GetPrayTreeDrawCost(draw_type)
  1536. local cfg = Config.Customactkv
  1537. --单抽
  1538. if draw_type == 1 then
  1539. if (cfg and cfg["120@cost_one"]) then
  1540. local info = stringtotable(cfg["120@cost_one"].value_content)
  1541. local cost_item_id = info[1][2]
  1542. local cost_info =
  1543. {
  1544. kind = info[1][1],
  1545. goods_id = info[1][2],
  1546. cost_num = info[1][3],
  1547. }
  1548. local price_cfg = Config.Goodsprice
  1549. if price_cfg and price_cfg[cost_item_id] then
  1550. local d = price_cfg[cost_item_id]
  1551. cost_info.price = d.price
  1552. cost_info.price_type = d.price_type
  1553. end
  1554. return cost_info
  1555. end
  1556. else
  1557. --连抽
  1558. if (cfg and cfg["120@cost_ten"]) then
  1559. local info = stringtotable(cfg["120@cost_ten"].value_content)
  1560. local cost_item_id = info[1][2]
  1561. local cost_info =
  1562. {
  1563. kind = info[1][1],
  1564. goods_id = info[1][2],
  1565. cost_num = info[1][3],
  1566. }
  1567. local price_cfg = Config.Goodsprice
  1568. if price_cfg and price_cfg[cost_item_id] then
  1569. local d = price_cfg[cost_item_id]
  1570. cost_info.price = d.price
  1571. cost_info.price_type = d.price_type
  1572. end
  1573. return cost_info
  1574. end
  1575. end
  1576. end
  1577. --人参果树抽取id
  1578. function OperateActivityModel:GetPrayTreeDrawId()
  1579. local cost_info = self:GetPrayTreeDrawCost(1)
  1580. return cost_info and cost_info.goods_id or 0
  1581. end
  1582. --人参果树最大祝福值
  1583. function OperateActivityModel:GetPrayTreeRewardList(base_type, sub_type, show_type)
  1584. if not base_type or not sub_type or not show_type then
  1585. return {}
  1586. end
  1587. local key = base_type .. "@" .. sub_type .. "@" .. show_type
  1588. if not self.pray_tree_reward_list[key] then
  1589. local rewards = CustomActivityModel.getInstance():getOneActRewardList(base_type, sub_type)
  1590. local t = self.pray_tree_reward_list
  1591. if rewards and rewards.reward_list then
  1592. local l_key
  1593. for i,v in ipairs(rewards.reward_list) do
  1594. l_key = base_type .. "@" .. sub_type .. "@" .. v.condition_list[1][2]
  1595. t[l_key] = t[l_key] or {}
  1596. local item = {[1] = v.reward_info[1].goods_kind,[2] = v.reward_info[1].goods_id, [3] = v.reward_info[1].goods_count}
  1597. table.insert(t[l_key], item)
  1598. end
  1599. end
  1600. end
  1601. return self.pray_tree_reward_list[key] or {}
  1602. end
  1603. function OperateActivityModel:PrayTreeCheckDo(can_do, price, str, ok_func)
  1604. function ok_function( )
  1605. if ok_func then
  1606. ok_func()
  1607. end
  1608. end
  1609. function toggle_function( flag )
  1610. self.pray_tree_info.custom_draw_toggle = flag
  1611. end
  1612. local show_tips_flag = self.pray_tree_info.custom_draw_toggle or false
  1613. if not can_do and not show_tips_flag then
  1614. price = price or 0
  1615. local asset, source = WordManager:GetCommonMoneyIcon(1)
  1616. local data = {
  1617. gold_ab_res = asset,
  1618. gold_res = source,
  1619. price = price,
  1620. insufficientText = "",
  1621. priceText = str,
  1622. titleText = "提示",
  1623. ok_callback = ok_function,
  1624. toggle_function = toggle_function,
  1625. }
  1626. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
  1627. else
  1628. ok_func()
  1629. end
  1630. end
  1631. --人参果树红点
  1632. function OperateActivityModel:PrayTreeGetRedDot()
  1633. local b = false
  1634. if self.pray_tree_info and self.pray_tree_info.free_count then
  1635. local max_value = self:GetPrayTreeMaxValue()
  1636. b = self.pray_tree_info.free_count > 0 or self.pray_tree_info.score >= max_value
  1637. end
  1638. return b
  1639. end
  1640. ---------------------------------------人参果树 end---------------------------------------
  1641. ---------------------------------------合成机 start---------------------------------------
  1642. --保存收藏列表 33294
  1643. function OperateActivityModel:SetComposeRobotCollectList(vo)
  1644. self.compose_robot_collect_list[vo.sub_type] = vo.print_list
  1645. local function onSortFunction(v1, v2)
  1646. return v1.id < v2.id
  1647. end
  1648. table.sort(self.compose_robot_collect_list[vo.sub_type], onSortFunction)
  1649. end
  1650. --获取收藏列表
  1651. function OperateActivityModel:GetComposeRobotCollectList(sub_type)
  1652. if not self.compose_robot_collect_list[sub_type] then return {} end
  1653. return self.compose_robot_collect_list[sub_type]
  1654. end
  1655. --判断收藏列表中有没有该id的配方
  1656. function OperateActivityModel:IsInComposeRobotCollectList(sub_type, id)
  1657. if not self.compose_robot_collect_list[sub_type] then return false end
  1658. for k,v in pairs(self.compose_robot_collect_list[sub_type]) do
  1659. if v.id == id then
  1660. return true
  1661. end
  1662. end
  1663. return false
  1664. end
  1665. --更新收藏列表 33293
  1666. function OperateActivityModel:UpdateComposeRobotCollectList(vo)
  1667. local is_in_collect_list = self:IsInComposeRobotCollectList(vo.sub_type, vo.id)
  1668. if vo.type == 0 then--取消收藏
  1669. if is_in_collect_list then
  1670. local temp = nil
  1671. for k,v in pairs(self.compose_robot_collect_list[vo.sub_type]) do
  1672. if v.id == vo.id then
  1673. temp = v
  1674. break
  1675. end
  1676. end
  1677. if temp then
  1678. TableRemove(self.compose_robot_collect_list[vo.sub_type],temp)
  1679. end
  1680. end
  1681. elseif vo.type == 1 then--收藏
  1682. if not is_in_collect_list then
  1683. self.compose_robot_collect_list[vo.sub_type] = self.compose_robot_collect_list[vo.sub_type] or {}
  1684. local temp = {
  1685. id = vo.id,
  1686. }
  1687. table.insert(self.compose_robot_collect_list[vo.sub_type], temp)
  1688. local function onSortFunction(v1, v2)
  1689. return v1.id < v2.id
  1690. end
  1691. table.sort(self.compose_robot_collect_list[vo.sub_type], onSortFunction)
  1692. end
  1693. end
  1694. end
  1695. --保存配方状态信息 33296
  1696. function OperateActivityModel:SetComposeRobotFormulaData(vo)
  1697. self.compose_robot_formula_data[vo.sub_type] = {}
  1698. for i,v in ipairs(vo.print_list) do
  1699. self.compose_robot_formula_data[vo.sub_type][v.id] = v
  1700. end
  1701. end
  1702. --增量更新配方状态信息列表 33296
  1703. function OperateActivityModel:UpdateComposeRobotFormulaData(vo)
  1704. self.compose_robot_formula_data[vo.sub_type] = self.compose_robot_formula_data[vo.sub_type] or {}
  1705. for i,v in ipairs(vo.print_list) do
  1706. for kk,vv in pairs(self.compose_robot_formula_data[vo.sub_type]) do
  1707. if vv.id == v.id then
  1708. vv.state = v.state
  1709. end
  1710. end
  1711. end
  1712. end
  1713. --获取配方状态信息列表
  1714. function OperateActivityModel:GetComposeRobotFormulaData(sub_type)
  1715. if not self.compose_robot_formula_data[sub_type] then return {} end
  1716. return self.compose_robot_formula_data[sub_type]
  1717. end
  1718. --获取某id配方的状态信息
  1719. function OperateActivityModel:GetComposeRobotFormulaStateById(sub_type, id)
  1720. if not self.compose_robot_formula_data[sub_type] or not self.compose_robot_formula_data[sub_type][id] then
  1721. return 0
  1722. end
  1723. return self.compose_robot_formula_data[sub_type][id].state
  1724. end
  1725. --保存发明家消息列表 33297
  1726. function OperateActivityModel:SetComposeRobotAnnounceData(vo)
  1727. self.compose_robot_announce_data[vo.sub_type] = vo.rold_list
  1728. local function onSortFunction(v1, v2)
  1729. return v1.id < v2.id
  1730. end
  1731. table.sort(self.compose_robot_announce_data[vo.sub_type], onSortFunction)
  1732. end
  1733. --更新发明家消息列表 33298
  1734. function OperateActivityModel:UpdateComposeRobotAnnounceData(vo)
  1735. self.compose_robot_announce_data[vo.sub_type] = self.compose_robot_announce_data[vo.sub_type] or {}
  1736. local temp_data = {
  1737. role_name = vo.role_name,
  1738. id = vo.id,
  1739. }
  1740. table.insert(self.compose_robot_announce_data[vo.sub_type],temp_data)
  1741. local function onSortFunction(v1, v2)
  1742. return v1.id < v2.id
  1743. end
  1744. table.sort(self.compose_robot_announce_data[vo.sub_type], onSortFunction)
  1745. end
  1746. --拿到发明家消息列表
  1747. function OperateActivityModel:GetComposeRobotAnnounceData(sub_type)
  1748. if not self.compose_robot_announce_data[sub_type] then return {} end
  1749. return self.compose_robot_announce_data[sub_type]
  1750. end
  1751. --拿到当前子类型合成机活动的原料套数item_suit
  1752. function OperateActivityModel:GetComposeRobotItemSuit(sub_type)
  1753. local act_data = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.COMPOSE_ROBOT,sub_type)
  1754. local item_suit_id = 0
  1755. if act_data and act_data.condition_list then
  1756. for k,v in pairs(act_data.condition_list) do
  1757. if v[1] == "item_suit" then
  1758. item_suit_id = tonumber(v[2])
  1759. end
  1760. end
  1761. end
  1762. return item_suit_id
  1763. end
  1764. --初始化合成机原材料配置
  1765. function OperateActivityModel:InitComposeRobotMaterialCfg( )
  1766. for k,v in pairs(Config.Printerdraw) do
  1767. self.compose_robot_material_cfg[v.item_suit] = self.compose_robot_material_cfg[v.item_suit] or {}
  1768. table.insert(self.compose_robot_material_cfg[v.item_suit], v)
  1769. end
  1770. for k,v in pairs(self.compose_robot_material_cfg) do
  1771. for kk,vv in pairs(v) do
  1772. local function onSortFunction(v1, v2)
  1773. return v1.exchange_item < v2.exchange_item
  1774. end
  1775. table.sort(v, onSortFunction)
  1776. end
  1777. end
  1778. end
  1779. --获取当前子类型合成机活动的原材料配置
  1780. function OperateActivityModel:GetComposeRobotMaterialCfg(sub_type)
  1781. local item_suit = self:GetComposeRobotItemSuit(sub_type)
  1782. if not self.compose_robot_material_cfg[item_suit] then return {} end
  1783. return self.compose_robot_material_cfg[item_suit]
  1784. end
  1785. --初始化合成机配方配置
  1786. function OperateActivityModel:InitComposeRobotFormulaCfg( )
  1787. for k,v in pairs(Config.Printerdrawlist) do
  1788. self.compose_robot_formula_cfg[v.item_suit] = self.compose_robot_formula_cfg[v.item_suit] or {}
  1789. -- self.compose_robot_formula_cfg[v.item_suit][v.id] = v
  1790. table.insert(self.compose_robot_formula_cfg[v.item_suit],v)
  1791. end
  1792. end
  1793. --根据配方id获取配置
  1794. function OperateActivityModel:GetComposeRobotFormulaCfgById(sub_type,id)
  1795. local item_suit = self:GetComposeRobotItemSuit(sub_type)
  1796. if not self.compose_robot_formula_cfg[item_suit] then return nil end
  1797. for k,v in pairs(self.compose_robot_formula_cfg[item_suit]) do
  1798. if v.id == id then
  1799. return v
  1800. end
  1801. end
  1802. return nil
  1803. end
  1804. --获取当前的配方配置列表
  1805. function OperateActivityModel:GetComposeRobotFormulaListCfg(sub_type)
  1806. local item_suit = self:GetComposeRobotItemSuit(sub_type)
  1807. if not self.compose_robot_formula_cfg[item_suit] then return {} end
  1808. return self.compose_robot_formula_cfg[item_suit]
  1809. end
  1810. --传入原材料id列表,判断是否合法配方并返回配置
  1811. function OperateActivityModel:JudgeCanMaterialCompose(sub_type, material_id_list)
  1812. if #material_id_list ~= 3 then return nil end
  1813. local id_list = DeepCopy(material_id_list)
  1814. local item_suit = self:GetComposeRobotItemSuit(sub_type)
  1815. if not self.compose_robot_formula_cfg[item_suit] then return nil end
  1816. --先把id_list排序一下
  1817. local function onSortFunction(v1, v2)
  1818. return v1 < v2
  1819. end
  1820. table.sort(id_list, onSortFunction)
  1821. for k,v in pairs(self.compose_robot_formula_cfg[item_suit]) do
  1822. local need_material_list = DeepCopy(stringtotable(v.exchange))
  1823. local function onSortFunction(v1, v2)
  1824. return v1 < v2
  1825. end
  1826. table.sort(need_material_list, onSortFunction)
  1827. if need_material_list[1] == id_list[1] and need_material_list[2] == id_list[2] and need_material_list[3] == id_list[3] then
  1828. return v
  1829. end
  1830. end
  1831. return nil
  1832. end
  1833. --拿到配方所需的材料列表
  1834. function OperateActivityModel:GetComposeRobotMaterialList(sub_type, formula_id)
  1835. local formula_cfg = self:GetComposeRobotFormulaCfgById(sub_type, formula_id)
  1836. if not formula_cfg then return {} end
  1837. return stringtotable(formula_cfg.exchange)
  1838. end
  1839. --初始化奖池配置
  1840. function OperateActivityModel:InitComposeRobotPoolCfg( )
  1841. for k,v in pairs(Config.Printerdrawpool) do
  1842. self.compose_robot_pool_cfg[v.pool] = self.compose_robot_pool_cfg[v.pool] or {}
  1843. table.insert(self.compose_robot_pool_cfg[v.pool], stringtotable(v.goods)[1])
  1844. self.compose_robot_normal_pool_cfg[v.pool_type] = self.compose_robot_normal_pool_cfg[v.pool_type] or {}
  1845. if v.is_show == 1 then
  1846. table.insert(self.compose_robot_normal_pool_cfg[v.pool_type], stringtotable(v.goods)[1])
  1847. end
  1848. end
  1849. end
  1850. --获取普通奖励
  1851. function OperateActivityModel:GetComposeRobotNormalReward(sub_type)
  1852. local item_suit = self:GetComposeRobotItemSuit(sub_type)
  1853. if not self.compose_robot_normal_pool_cfg[item_suit] then return {} end
  1854. return self.compose_robot_normal_pool_cfg[item_suit]
  1855. end
  1856. --根据奖池id获取奖池列表
  1857. function OperateActivityModel:GetComposeRobotRewardList(pool_id)
  1858. if not self.compose_robot_pool_cfg[pool_id] then return {} end
  1859. return self.compose_robot_pool_cfg[pool_id]
  1860. end
  1861. --材料数量更新
  1862. function OperateActivityModel:OnMaterialGoodsNumUpdate( )
  1863. self:Fire(OperateActivityModel.UPDATE_COMPOSE_ROBOT_MATERIAL_GOODS_NUM)
  1864. local sub_type_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.COMPOSE_ROBOT)
  1865. for k,v in pairs(sub_type_list) do
  1866. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.ComposeRobot,nil,v.sub_type)
  1867. end
  1868. end
  1869. --获取当前的选中材料列表
  1870. function OperateActivityModel:GetNowUseComposeMaterial(sub_type)
  1871. if not self.compose_robot_now_use_material_list[sub_type] then
  1872. self.compose_robot_now_use_material_list[sub_type] = {
  1873. [1] = 0,
  1874. [2] = 0,
  1875. [3] = 0,
  1876. }
  1877. end
  1878. return self.compose_robot_now_use_material_list[sub_type]
  1879. end
  1880. --加入材料到选中列表
  1881. function OperateActivityModel:AddComposeMaterial(sub_type, goods_id)
  1882. if not self.compose_robot_now_use_material_list[sub_type] then
  1883. self.compose_robot_now_use_material_list[sub_type] = {
  1884. [1] = 0,
  1885. [2] = 0,
  1886. [3] = 0,
  1887. }
  1888. end
  1889. local add_index = 0
  1890. for i,v in ipairs(self.compose_robot_now_use_material_list[sub_type]) do
  1891. if v == 0 then
  1892. self.compose_robot_now_use_material_list[sub_type][i] = goods_id
  1893. add_index = i
  1894. break
  1895. end
  1896. end
  1897. return add_index
  1898. end
  1899. --取消选中材料
  1900. function OperateActivityModel:MinusComposeMaterial(sub_type, pos_index)
  1901. if self.compose_robot_now_use_material_list[sub_type] then
  1902. self.compose_robot_now_use_material_list[sub_type][pos_index] = 0
  1903. end
  1904. end
  1905. --重置选中列表
  1906. function OperateActivityModel:ResetUseComposeMaterialList(sub_type)
  1907. self.compose_robot_now_use_material_list[sub_type] = {
  1908. [1] = 0,
  1909. [2] = 0,
  1910. [3] = 0,
  1911. }
  1912. end
  1913. --保存活动开启的红点
  1914. function OperateActivityModel:SetComposeRobotActFirstRed(sub_type)
  1915. self.compose_robot_act_first_red[sub_type] = true
  1916. end
  1917. --记录是否打开过界面的标识
  1918. function OperateActivityModel:SetComposeRobotViewOpenState(sub_type)
  1919. self.compose_robot_have_open_view[sub_type] = true
  1920. end
  1921. function OperateActivityModel:CheckComposeRobotActFirstRedDot(sub_type)
  1922. if not self.compose_robot_have_open_view[sub_type] and self.compose_robot_act_first_red[sub_type] and not self.is_in_compose_view[sub_type]then
  1923. return true
  1924. end
  1925. return false
  1926. end
  1927. function OperateActivityModel:CheckComposeRobotCanComposeRed(sub_type)
  1928. self.compose_robot_red_info[sub_type] = false
  1929. if self.is_in_compose_view[sub_type] then
  1930. return false
  1931. end
  1932. local formula_list = DeepCopy(self:GetComposeRobotFormulaListCfg(sub_type))
  1933. for i,v in ipairs(formula_list) do
  1934. v.formula_state =self:GetComposeRobotFormulaStateById(sub_type,v.id)
  1935. local material_list = self:GetComposeRobotMaterialList(sub_type,v.id)
  1936. local main_need_material_list = {}
  1937. for ii,vv in ipairs(material_list) do
  1938. local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(vv)
  1939. if not main_need_material_list[vv] then
  1940. main_need_material_list[vv] = {
  1941. id = vv,
  1942. need_num = 1,
  1943. bag_goods_num = goods_num
  1944. }
  1945. else
  1946. main_need_material_list[vv].need_num = main_need_material_list[vv].need_num + 1
  1947. end
  1948. end
  1949. local max_can_get_num = 99999999
  1950. for m,n in pairs(main_need_material_list) do
  1951. local multi = math.floor(n.bag_goods_num/n.need_num)
  1952. if multi < max_can_get_num then
  1953. max_can_get_num = multi
  1954. end
  1955. end
  1956. if max_can_get_num > 0 then
  1957. self.compose_robot_red_info[sub_type] = true
  1958. return true
  1959. end
  1960. end
  1961. return false
  1962. end
  1963. --得到合成级红点
  1964. function OperateActivityModel:GetComposeRobotMainRed(sub_type)
  1965. local can_compose_red = self:CheckComposeRobotCanComposeRed(sub_type)
  1966. local first_red = self:CheckComposeRobotActFirstRedDot(sub_type)
  1967. if first_red or can_compose_red then
  1968. return true
  1969. else
  1970. return false
  1971. end
  1972. end
  1973. --询问cd状态
  1974. function OperateActivityModel:SetComposeRobotAskCd(vo)
  1975. self.compose_robot_ask_time[vo.sub_type] = vo.time
  1976. end
  1977. function OperateActivityModel:GetComposeRobotAskCd(sub_type)
  1978. if not self.compose_robot_ask_time[sub_type] then return 0 end
  1979. return self.compose_robot_ask_time[sub_type]
  1980. end
  1981. ---------------------------------------合成机 end---------------------------------------
  1982. ---------------------------------------自选扭蛋 start---------------------------------------
  1983. --33600 保存自选扭蛋相关数据
  1984. function OperateActivityModel:SetSelectEggServerData(vo)
  1985. self.select_egg_ser_data[vo.sub_type] = {}
  1986. self.select_egg_ser_data[vo.sub_type].sub_type = vo.sub_type
  1987. self.select_egg_ser_data[vo.sub_type].reward_list = {}
  1988. for k,v in pairs(vo.reward_list) do--已抽中的奖励列表
  1989. local rewards_data = stringtotable(v.rewards)
  1990. self.select_egg_ser_data[vo.sub_type].reward_list[v.rare] = rewards_data
  1991. end
  1992. self.select_egg_ser_data[vo.sub_type].select_reward_list = {}
  1993. for k,v in pairs(vo.select_reward_list) do--已选择的奖励列表
  1994. local rewards_data = stringtotable(v.rewards)
  1995. self.select_egg_ser_data[vo.sub_type].select_reward_list[v.rare] = rewards_data
  1996. end
  1997. self.select_egg_ser_data[vo.sub_type].cfg_reward_list = {}
  1998. for k,v in pairs(vo.cfg_reward_list) do--本期活动的奖池
  1999. local rewards_data = stringtotable(v.cfg_rewards)
  2000. self.select_egg_ser_data[vo.sub_type].cfg_reward_list[v.cfg_rare] = rewards_data
  2001. end
  2002. self.select_egg_ser_data[vo.sub_type].cost_goods_type_id = vo.cost_goods_type_id--下一抽消耗物品类型Id
  2003. self.select_egg_ser_data[vo.sub_type].cost_num = vo.cost_num--下一抽消耗物品数量
  2004. self.select_egg_ser_data[vo.sub_type].left_reset_times = vo.left_reset_times--剩余重置次数
  2005. self.select_egg_ser_data[vo.sub_type].is_ensure = vo.is_ensure--是否确认奖励
  2006. end
  2007. --33601 选择奖励后更新选中的奖励列表
  2008. function OperateActivityModel:UpdateSelectEggSelectRewardList(vo)
  2009. if not self.select_egg_ser_data[vo.sub_type] then return end
  2010. self.select_egg_ser_data[vo.sub_type].select_reward_list = {}
  2011. for k,v in pairs(vo.select_reward_list) do
  2012. local rewards_data = stringtotable(v.rewards)
  2013. self.select_egg_ser_data[vo.sub_type].select_reward_list[v.rare] = rewards_data
  2014. end
  2015. end
  2016. --33603 抽奖后更新相关数据
  2017. function OperateActivityModel:UpdateSelectEggDataAfterDraw(vo)
  2018. if not self.select_egg_ser_data[vo.sub_type] then return end
  2019. self.select_egg_ser_data[vo.sub_type].reward_list = self.select_egg_ser_data[vo.sub_type].reward_list or {}
  2020. self.select_egg_ser_data[vo.sub_type].reward_list[vo.rare] = self.select_egg_ser_data[vo.sub_type].reward_list[vo.rare] or {}
  2021. local rewards_data = stringtotable(vo.rewards)
  2022. table.insert(self.select_egg_ser_data[vo.sub_type].reward_list[vo.rare],rewards_data[1])
  2023. self.select_egg_ser_data[vo.sub_type].cost_goods_type_id = vo.cost_goods_type_id--下一抽消耗物品类型Id
  2024. self.select_egg_ser_data[vo.sub_type].cost_num = vo.cost_num--下一抽消耗物品数量
  2025. self.select_egg_ser_data[vo.sub_type].is_ensure = vo.is_ensure--是否确认奖励
  2026. end
  2027. --33604 快速选奖更新相关数据
  2028. function OperateActivityModel:UpdateSelectEggDataAfterQuiclSelect(vo)
  2029. if not self.select_egg_ser_data[vo.sub_type] then return end
  2030. self.select_egg_ser_data[vo.sub_type].select_reward_list = {}
  2031. for k,v in pairs(vo.select_reward_list) do--已选择的奖励列表
  2032. local rewards_data = stringtotable(v.rewards)
  2033. self.select_egg_ser_data[vo.sub_type].select_reward_list[v.rare] = rewards_data
  2034. end
  2035. end
  2036. --33605 刷新确认状态
  2037. function OperateActivityModel:UpdateSelectEggEnsureState(vo)
  2038. if not self.select_egg_ser_data[vo.sub_type] then return end
  2039. self.select_egg_ser_data[vo.sub_type].is_ensure = vo.is_ensure--是否确认奖励
  2040. end
  2041. --是否已经确认奖池
  2042. function OperateActivityModel:IsSelectEggPoolEnsure(sub_type)
  2043. if not self.select_egg_ser_data[sub_type] then return false end
  2044. return self.select_egg_ser_data[sub_type].is_ensure or false
  2045. end
  2046. --获取选中的奖励列表
  2047. function OperateActivityModel:GetSelectEggSelectRewardListByRare(sub_type,rare)
  2048. if not self.select_egg_ser_data[sub_type] then return {} end
  2049. if not self.select_egg_ser_data[sub_type].select_reward_list then return {} end
  2050. return self.select_egg_ser_data[sub_type].select_reward_list[rare] or {}
  2051. end
  2052. --判断物品是否已经在选中列表中
  2053. function OperateActivityModel:IsInSelectEggSelectRewardList(sub_type,reward_id)
  2054. if not self.select_egg_ser_data[sub_type] then return false end
  2055. if not self.select_egg_ser_data[sub_type].select_reward_list then return false end
  2056. for k,v in pairs(self.select_egg_ser_data[sub_type].select_reward_list) do
  2057. for m,n in pairs(v) do
  2058. if n[1] == reward_id then
  2059. return true
  2060. end
  2061. end
  2062. end
  2063. return false
  2064. end
  2065. --判断物品是否在已抽中列表中
  2066. function OperateActivityModel:IsInSelectEggGetRewardList(sub_type,reward_id)
  2067. if not self.select_egg_ser_data[sub_type] then return false end
  2068. if not self.select_egg_ser_data[sub_type].reward_list then return false end
  2069. local bool = false
  2070. for k,v in pairs(self.select_egg_ser_data[sub_type].reward_list) do
  2071. for m,n in pairs(v) do
  2072. if n[1] == reward_id then
  2073. bool = true
  2074. break
  2075. end
  2076. end
  2077. end
  2078. return bool
  2079. end
  2080. --快速选择奖励,返回奖励id列表
  2081. function OperateActivityModel:GetQuickSelectRewardList(sub_type,rare)
  2082. if not self.select_egg_ser_data[sub_type] then return {} end
  2083. if not self.select_egg_ser_data[sub_type].cfg_reward_list then return {} end
  2084. if not self.select_egg_ser_data[sub_type].cfg_reward_list[rare] then return {} end
  2085. local not_select_list = {}
  2086. for k,v in pairs(self.select_egg_ser_data[sub_type].cfg_reward_list[rare]) do
  2087. if not self:IsInSelectEggSelectRewardList(sub_type,v[1]) then
  2088. table.insert(not_select_list,v[1])
  2089. end
  2090. end
  2091. local select_reward_list = self:GetSelectEggSelectRewardListByRare(sub_type,rare)
  2092. local left_can_select_num = 0
  2093. if rare == 1 then
  2094. left_can_select_num = 1-#select_reward_list
  2095. elseif rare == 2 then
  2096. left_can_select_num = 3-#select_reward_list
  2097. elseif rare == 3 then
  2098. left_can_select_num = 4-#select_reward_list
  2099. end
  2100. if left_can_select_num == 0 then return {} end
  2101. local final_list = {}
  2102. for i=1,left_can_select_num do
  2103. local random_index = math.random(1, #not_select_list)
  2104. table.insert(final_list,not_select_list[random_index])
  2105. table.remove(not_select_list,random_index)
  2106. end
  2107. return final_list
  2108. end
  2109. --获取现在的中奖列表
  2110. function OperateActivityModel:GetSelectEggAllRewardList(sub_type)
  2111. if not self.select_egg_ser_data[sub_type] then return {} end
  2112. if not self.select_egg_ser_data[sub_type].reward_list then return {} end
  2113. local all_list = {}
  2114. for k,v in pairs(self.select_egg_ser_data[sub_type].reward_list) do
  2115. for m,n in pairs(v) do
  2116. table.insert(all_list,n)
  2117. end
  2118. end
  2119. return all_list
  2120. end
  2121. --根据稀有度获取奖池列表
  2122. function OperateActivityModel:GetSelectEggPoolRewardListByRare(sub_type,rare)
  2123. if not self.select_egg_ser_data[sub_type] then return {} end
  2124. if not self.select_egg_ser_data[sub_type].cfg_reward_list then return {} end
  2125. return self.select_egg_ser_data[sub_type].cfg_reward_list[rare] or {}
  2126. end
  2127. --根据稀有度获取抽中的奖励列表
  2128. function OperateActivityModel:GetSelectEggGottenRewardListByRare(sub_type,rare)
  2129. if not self.select_egg_ser_data[sub_type] then return {} end
  2130. if not self.select_egg_ser_data[sub_type].reward_list then return {} end
  2131. return self.select_egg_ser_data[sub_type].reward_list[rare] or {}
  2132. end
  2133. --获取下次抽奖的消耗信息
  2134. function OperateActivityModel:GetSelectEggNextDrawCostData(sub_type)
  2135. if not self.select_egg_ser_data[sub_type] then return nil,nil end
  2136. return self.select_egg_ser_data[sub_type].cost_goods_type_id,self.select_egg_ser_data[sub_type].cost_num
  2137. end
  2138. --获取剩余重置次数
  2139. function OperateActivityModel:GetSelectEggLeftResetTimes(sub_type)
  2140. if not self.select_egg_ser_data[sub_type] then return 0 end
  2141. return self.select_egg_ser_data[sub_type].left_reset_times
  2142. end
  2143. --判断当前扭蛋阶段(开始抽奖了就表示不可以抽了)(判断依据是服务端发回来的reward_list长度)
  2144. --1|选奖阶段 #reward_list==0 不可抽奖 不可重置 只能选奖
  2145. --2|抽奖阶段 #reward_list>0 or ensure == 1 不可选奖 可重置 可抽奖
  2146. --3|抽完阶段 #reward_list==8 不可选奖 可重置 不可抽奖
  2147. --4|奖励选完待确认 #reward_list == 0 and #select_reward == 8 and ensure == 0可选奖 不可重置 不可抽奖
  2148. --5|奖励选完可以开抽 #reward_list == 0 and #select_reward == 8 and ensure == 1不可选奖 可重置 可抽奖
  2149. function OperateActivityModel:GetSelectEggNowPlayState(sub_type)
  2150. local all_reward_list = self:GetSelectEggAllRewardList(sub_type)
  2151. local ensure = self:IsSelectEggPoolEnsure(sub_type)
  2152. if #all_reward_list == 0 then
  2153. local select_reward_list_1 = self:GetSelectEggSelectRewardListByRare(sub_type,1)
  2154. local select_reward_list_2 = self:GetSelectEggSelectRewardListByRare(sub_type,2)
  2155. local select_reward_list_3 = self:GetSelectEggSelectRewardListByRare(sub_type,3)
  2156. if #select_reward_list_1 + #select_reward_list_2 + #select_reward_list_3 == 8 and ensure == 0 then
  2157. return 4
  2158. elseif #select_reward_list_1 + #select_reward_list_2 + #select_reward_list_3 == 8 and ensure == 1 then
  2159. return 5
  2160. else
  2161. return 1
  2162. end
  2163. elseif #all_reward_list > 0 and #all_reward_list < 8 then
  2164. return 2
  2165. elseif #all_reward_list == 8 then
  2166. return 3
  2167. end
  2168. return 0
  2169. end
  2170. --得到自选扭蛋红点
  2171. -- 红点规则:
  2172. -- 1、玩家有足够抽奖道具时红点提示【扭一次】
  2173. -- 2、玩家所有道具抽取完,且存在重置次数,红点提示【重置奖励】
  2174. function OperateActivityModel:GetSelectEggMainRed(sub_type)
  2175. local can_draw_red = self:CheckSelectEggCanFDrawRed(sub_type,true)
  2176. local can_reset_red = self:CheckSelectEggCanResetRed(sub_type,true)
  2177. local can_ensure_red = self:CheckSelectEggCanEnsureRed(sub_type,true)
  2178. local com_act_red = self:CheckSelectEggComActRed(sub_type,true)
  2179. if can_draw_red or can_reset_red or can_ensure_red or com_act_red then
  2180. return true
  2181. else
  2182. return false
  2183. end
  2184. end
  2185. --自选扭蛋有道具可抽奖红点
  2186. function OperateActivityModel:CheckSelectEggCanFDrawRed(sub_type,check_new)
  2187. if not check_new then
  2188. if self.select_egg_red_info[sub_type] and self.select_egg_red_info[sub_type].can_draw_red then
  2189. return true
  2190. else
  2191. return false
  2192. end
  2193. end
  2194. ------------------
  2195. self.select_egg_red_info[sub_type] = self.select_egg_red_info[sub_type] or {}
  2196. local bool = false
  2197. local state = self:GetSelectEggNowPlayState(sub_type)
  2198. if state~=2 and state~=5 then
  2199. bool = false
  2200. else
  2201. --判断当前抽奖所需消耗的道具数量是否足够
  2202. local cost_goods_type_id,cost_need_num = self:GetSelectEggNextDrawCostData(sub_type)
  2203. if cost_goods_type_id and cost_need_num then
  2204. local have_cost_num = GoodsModel:getInstance():GetTypeGoodsNum(cost_goods_type_id)
  2205. if have_cost_num >= cost_need_num then
  2206. bool = true
  2207. end
  2208. end
  2209. end
  2210. self.select_egg_red_info[sub_type].can_draw_red = bool
  2211. return bool
  2212. end
  2213. --自选扭蛋可重置红点
  2214. function OperateActivityModel:CheckSelectEggCanResetRed(sub_type,check_new)
  2215. if not check_new then
  2216. if self.select_egg_red_info[sub_type] and self.select_egg_red_info[sub_type].can_reset_red then
  2217. return true
  2218. else
  2219. return false
  2220. end
  2221. end
  2222. ------------------
  2223. self.select_egg_red_info[sub_type] = self.select_egg_red_info[sub_type] or {}
  2224. local bool = false
  2225. --这轮抽完且有重置次数才能给红点
  2226. local state = self:GetSelectEggNowPlayState(sub_type)
  2227. local left_reset_times = self:GetSelectEggLeftResetTimes(sub_type)
  2228. if state == 3 and left_reset_times > 0 then
  2229. bool = true
  2230. end
  2231. self.select_egg_red_info[sub_type].can_reset_red = bool
  2232. return bool
  2233. end
  2234. --确认红点
  2235. function OperateActivityModel:CheckSelectEggCanEnsureRed(sub_type,check_new)
  2236. if not check_new then
  2237. if self.select_egg_red_info[sub_type] and self.select_egg_red_info[sub_type].can_ensure_red then
  2238. return true
  2239. else
  2240. return false
  2241. end
  2242. end
  2243. ------------------
  2244. self.select_egg_red_info[sub_type] = self.select_egg_red_info[sub_type] or {}
  2245. local bool = false
  2246. local state = self:GetSelectEggNowPlayState(sub_type)
  2247. bool = state == 4
  2248. self.select_egg_red_info[sub_type].can_ensure_red = bool
  2249. return bool
  2250. end
  2251. --自选扭蛋通用礼包
  2252. function OperateActivityModel:CheckSelectEggComActRed(sub_type,check_new)
  2253. if not check_new then
  2254. if self.select_egg_red_info[sub_type] and self.select_egg_red_info[sub_type].com_act_red then
  2255. return true
  2256. else
  2257. return false
  2258. end
  2259. end
  2260. ------------------
  2261. self.select_egg_red_info[sub_type] = self.select_egg_red_info[sub_type] or {}
  2262. local bool = false
  2263. local com_act_red_info = CustomActivityModel:getInstance():GetActComAwardInfo(CustomActivityModel.CustomActBaseType.SELECT_EGG,sub_type)
  2264. if com_act_red_info then
  2265. bool = com_act_red_info.status == 1
  2266. end
  2267. self.select_egg_red_info[sub_type].com_act_red = bool
  2268. return bool
  2269. end
  2270. --自选扭蛋消耗道具数量更新 通知刷红点
  2271. function OperateActivityModel:OnSelectEggCostGoodsNumChange( )
  2272. local sub_type_list = CustomActivityModel:getInstance():getAllActListByBaseType(CustomActivityModel.CustomActBaseType.SELECT_EGG)
  2273. for k,v in pairs(sub_type_list) do
  2274. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.SelectEgg,nil,v.sub_type)
  2275. end
  2276. end
  2277. ---------------------------------------自选扭蛋 end---------------------------------------
  2278. ---------------------------------------材料上交 start------------------------------------
  2279. function OperateActivityModel:SetMaterialSubmitInfo( vo )
  2280. self.material_submit_info[vo.sub_type] = {}
  2281. local buffs_dot_list = {}--buff点位信息
  2282. local buffs_bid_list = {}--buff id信息
  2283. for i,v in ipairs(vo.buffs) do
  2284. buffs_dot_list[v.dot] = v
  2285. buffs_bid_list[v.bid] = v
  2286. end
  2287. local role_awards_dot_list = {}
  2288. for i,v in ipairs(vo.role_awards) do
  2289. role_awards_dot_list[v.dot] = v
  2290. end
  2291. local server_awards_dot_list = {}
  2292. for i,v in ipairs(vo.server_awards) do
  2293. server_awards_dot_list[v.dot] = v
  2294. end
  2295. self.material_submit_info[vo.sub_type].server_pro = vo.server_pro
  2296. self.material_submit_info[vo.sub_type].role_pro = vo.role_pro
  2297. self.material_submit_info[vo.sub_type].buffs_dot_list = buffs_dot_list
  2298. self.material_submit_info[vo.sub_type].buffs_bid_list = buffs_bid_list
  2299. self.material_submit_info[vo.sub_type].role_awards_dot_list = role_awards_dot_list
  2300. self.material_submit_info[vo.sub_type].server_awards_dot_list = server_awards_dot_list
  2301. end
  2302. function OperateActivityModel:GetMaterialSubmitInfo( subtype )
  2303. return self.material_submit_info[subtype]
  2304. end
  2305. --检查材料上交红点
  2306. function OperateActivityModel:CheckMaterialSubmitRedDot( base_type,sub_type )
  2307. local server_info = self:GetMaterialSubmitInfo(sub_type)
  2308. if not server_info then return false end
  2309. local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
  2310. if not act_list then return false end
  2311. local group_num = 0
  2312. local suit_sub_id = nil
  2313. local cost_id = 0
  2314. for k,v in pairs(act_list.condition_list) do--[{role_lv,80},{sub,1},{cost,30},{group,5}]
  2315. if v[1] == "suit" then--全服进度套件ID
  2316. suit_sub_id = tonumber(v[2])
  2317. elseif v[1] == "group" then--材料提交份数
  2318. group_num = tonumber(v[2])
  2319. elseif v[1] == "cost_type" then--材料提交份数
  2320. cost_id = tonumber(v[2])
  2321. end
  2322. end
  2323. local num = GoodsModel:getInstance():GetTypeGoodsNum(cost_id) or 0
  2324. if num >= group_num then
  2325. return true
  2326. end
  2327. --先计算个人奖励的
  2328. local award_data = CustomActivityModel:getInstance():getOneActRewardList(base_type,sub_type)
  2329. if not award_data or not award_data.reward_list then return false end
  2330. local submit = 0
  2331. for k,v in pairs(award_data.reward_list) do
  2332. submit = 0
  2333. for kk,vv in pairs(v.condition_list) do
  2334. if vv[1] == "submit" then--点数需求
  2335. submit = tonumber(vv[2])
  2336. break
  2337. end
  2338. end
  2339. if server_info.role_pro >= submit and not server_info.role_awards_dot_list[v.grade] then
  2340. return true
  2341. end
  2342. end
  2343. --计算全服奖励的
  2344. local server_award_cfg = self:GetMaterialSubmitServerCfg(suit_sub_id)
  2345. if server_award_cfg then
  2346. for k,v in ipairs(server_award_cfg) do
  2347. if v.type == 3 and server_info.server_pro >= v.need and not server_info.server_awards_dot_list[v.dot] then
  2348. return true
  2349. elseif server_info.server_awards_dot_list and v.type == 2 then
  2350. if server_info.server_pro >= v.need and not server_info.server_awards_dot_list[v.dot] then
  2351. return true
  2352. end
  2353. end
  2354. end
  2355. end
  2356. return false
  2357. end
  2358. --初始化材料上交全服配置
  2359. function OperateActivityModel:InitMaterialSubmitServerCfg( )
  2360. if not self.material_submit_server_cfg then
  2361. self.material_submit_server_cfg = {}
  2362. local cfg = DeepCopy(Config.Unitebuffawards)
  2363. for k,v in pairs(cfg) do
  2364. if v.type == 2 or v.type == 3 then
  2365. v.awards = stringtotable(v.awards)
  2366. end
  2367. if not self.material_submit_server_cfg[v.suit] then
  2368. self.material_submit_server_cfg[v.suit] = {}
  2369. end
  2370. self.material_submit_server_cfg[v.suit][#self.material_submit_server_cfg[v.suit] + 1] = v
  2371. end
  2372. end
  2373. end
  2374. --获取材料上交全服配置
  2375. function OperateActivityModel:GetMaterialSubmitServerCfg( suit,dot )
  2376. if not self.material_submit_server_cfg then
  2377. self:InitMaterialSubmitServerCfg()
  2378. end
  2379. if not dot then
  2380. return self.material_submit_server_cfg[suit]
  2381. elseif self.material_submit_server_cfg[suit] and dot then
  2382. for i,v in ipairs(self.material_submit_server_cfg[suit]) do
  2383. if v.dot == dot then
  2384. return v
  2385. end
  2386. end
  2387. end
  2388. end
  2389. function OperateActivityModel:GetMaterialSubmitCostId( sub_type )
  2390. local cost_id = nil
  2391. local act_list = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.MATERIAL_SUBMIT, sub_type)
  2392. if not act_list then
  2393. return
  2394. end
  2395. for k,v in pairs(act_list.condition_list) do--[{role_lv,80},{sub,1},{cost,30},{group,5}]
  2396. if v[1] == "cost_type" then--提交消耗材料
  2397. cost_id = tonumber(v[2])
  2398. break
  2399. end
  2400. end
  2401. return cost_id
  2402. end
  2403. --通过类型获得相关BUFF加成
  2404. function OperateActivityModel:GetMaterialBuffInfoByKind( kind )
  2405. if self.material_submit_info then
  2406. local curTime = TimeUtil:getServerTime()
  2407. local buff_list = {}
  2408. for k,v in pairs(self.material_submit_info) do
  2409. for kk,vv in pairs(v.buffs_bid_list) do
  2410. if Config.Unitebuff[kk] and Config.Unitebuff[kk].kind == kind and vv.stime < curTime and curTime < vv.etime then--激活
  2411. buff_list[#buff_list + 1] = vv
  2412. end
  2413. end
  2414. end
  2415. local len = #buff_list
  2416. if len > 0 and len == 1 then
  2417. return Config.Unitebuff[buff_list[1].bid],DeepCopy(buff_list[1]),buff_list[1].dot
  2418. elseif len >= 2 then
  2419. local cur_data = nil
  2420. for k,v in ipairs(buff_list) do
  2421. if not cur_data then
  2422. cur_data = v
  2423. else
  2424. local cur_data_cfg = Config.Unitebuff[cur_data.bid]
  2425. local next_cfg = Config.Unitebuff[v.bid]
  2426. cur_data = cur_data_cfg.data > next_cfg.data and cur_data or v
  2427. end
  2428. end
  2429. if cur_data then
  2430. return Config.Unitebuff[cur_data.bid],DeepCopy(cur_data),cur_data.dot
  2431. end
  2432. end
  2433. end
  2434. end
  2435. --设置集字红点提示cookie
  2436. function OperateActivityModel:SetJiZiRedDotTipCookie( sub_type,grade,no_show_red )
  2437. local list = self:GetJiZiRedDotTipCookie() or {}
  2438. list[sub_type] = list[sub_type] or {}
  2439. list[sub_type][grade] = no_show_red
  2440. CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_ALWAYS,CookieKey.OP_JI_ZI_RED_DOT_TIP,list)
  2441. CookieWrapper.Instance:WriteAll()
  2442. KfActivityModel:getInstance():IsNeedRed(KfActivityModel.TabID.CollectZi,nil,sub_type)
  2443. end
  2444. --获得集字红点提示cookie
  2445. function OperateActivityModel:GetJiZiRedDotTipCookie( )
  2446. local list = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.OP_JI_ZI_RED_DOT_TIP) or {}
  2447. return list
  2448. end
  2449. --获得Boss掉落活动展示奖励
  2450. function OperateActivityModel:GetBossActDropAward( sub_type )
  2451. --如果有BOSS掉落活动 这里要添加展示奖励
  2452. local award_list = {}
  2453. local sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(CustomActivityModel.CustomActBaseType.BOSS_DROP)
  2454. local act_list = CustomActivityModel:getInstance():getActList(CustomActivityModel.CustomActBaseType.BOSS_DROP, sub_type)
  2455. if act_list then
  2456. local drop_type = nil
  2457. local drop_goods_id = nil
  2458. for i,v in ipairs(act_list.condition_list) do
  2459. if v[1] and v[2] then
  2460. if v[1] == "drop_type" then
  2461. drop_type = tonumber(v[2])
  2462. elseif v[1] == "drop_goods" then
  2463. drop_goods_id = tonumber(v[2])
  2464. end
  2465. end
  2466. end
  2467. if drop_type and not (drop_type >= 101 and not drop_goods_id) then
  2468. local drop_time_limit_cfg = OperateActivityModel:getInstance():GetBossDropTimeLimitCfg(drop_type)
  2469. if not drop_time_limit_cfg then return end
  2470. local item_list = DeepCopy(drop_time_limit_cfg)
  2471. if not item_list or TableSize(item_list) == 0 then
  2472. return
  2473. end
  2474. local new_list = {}
  2475. for i,v in pairs(item_list) do
  2476. new_list[#new_list + 1] = v
  2477. end
  2478. local sort_func = function ( a, b )
  2479. return a.drop_way < b.drop_way
  2480. end
  2481. table.sort(new_list, sort_func)
  2482. item_list = new_list
  2483. if drop_type < 101 then
  2484. for i,v in ipairs(item_list) do
  2485. for ii,vv in ipairs(v.award) do
  2486. if vv[2] then
  2487. award_list[#award_list + 1] = vv[2]
  2488. end
  2489. end
  2490. break
  2491. end
  2492. else
  2493. award_list = {{0,drop_goods_id,1}}
  2494. end
  2495. end--没有展示奖励立即退出
  2496. end
  2497. return award_list
  2498. end