protected function add_prop_reward_log($func_id = 0) { // Com_Log::log($this->arrPropLogs,"sysnotice.log",1); if (!empty($this->arrPropLogs)) { // Com_Log::log($this->arrParams,"sysnotice.log",1); // //同步到前端 Protocol_Prop::prop_806($this->player_id, $this->arrPropLogs, $func_id); $arr_async = array(); foreach ($this->arrPropLogs as $val) { if (isset($this->arrParams['func_id'])) { $data['player_id'] = $this->player_id; $data['func_id'] = $this->arrParams['func_id']; $data['chapter'] = $this->arrParams['chapter']; $data['map_id'] = $this->arrParams['map_id']; $data['prop_id'] = $val['prop_id']; $data['item_num'] = $val['item_num']; $data['player_prop_id'] = $val['player_prop_id']; $data['need_broad_cast'] = $val['need_broad_cast']; $this->add_notice($data); } if (isset($val['overlay_num'])) { $item_num = $val['overlay_num']; } else { $item_num = $val['item_num']; } if ($val['type'] == 2 && $val['sub_type'] == 1) { $arr_async['potion_hot_cnt'] += $item_num; } if ($val['type'] == 2 && $val['sub_type'] == 6) { $arr_async['potion_dh_cnt'] += $item_num; } if ($val['type'] == 2 && $val['sub_type'] == 11) { $arr_async['mp_potion_cnt'] += $item_num; } $this->_out_reward[$val['prop_id']] += $item_num; if (!isset($val['send_mail'])) { #发邮件的不记录日志 Log_Common::getInstance()->add_prop_log($this->player_id, $this->arrParams['level'], $this->arrParams['vip'], $this->arrParams['privilege_level'], $this->arrParams['cmd_id'], 1, $val['player_prop_id'], $val['prop_id'], $val['type'], $val['name'], $val['quality'], $item_num, $val['level'], $val['item_num'] - $item_num, $val, $val['sub_type']); } Protocol_Reward::add($this->player_id, $val); } if ($arr_async) { Protocol_Player::p2c_part_update($this->player_id, $arr_async); } } }
/** * @Purpose: * 通缉副本结算 * @Param $player_array 玩家数组 * @Param $passed 通关状态 * @Param $fb_id 副本ID * @Param $way 立即完成:ture */ public function fb_reward($player_array, $passed, $fb_id, $way = false) { $passed = intval($passed); if ($player_array[0] < 1 || $passed != 1) { if ($way) { $this->throw_error('10110'); #数据错误 } return array('0' => 0, '1' => array()); } $player_id = intval($player_array[0]); $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'privilege_level', 'level', 'vip', 'ticket', 'gold', 'ad_info', 'career_type')); $union_id = $player_info['union_id']; if ($way) { #获取玩家公会ID,验证公会信息 if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } } #获取玩家通缉榜数据 $data = $this->get_data("UnionWanted")->get_union_wanted_info($player_id); if (!$data) { if ($way) { $this->throw_error('10110'); #数据错误 } return array('0' => 0, '1' => array()); } if ($data['wanted_info'] && !is_array($data['wanted_info'])) { $wanted_info = json_decode($data['wanted_info'], true); } else { $wanted_info = $data['wanted_info']; } $fb_id = intval($fb_id); if (!$wanted_info['union_wanted_info'][$fb_id]) { if ($way) { $this->throw_error('10110'); #数据错误 } return array('0' => 0, '1' => array()); } $arr_consume = array(); if ($way) { $cost = $wanted_info['union_wanted_info'][$fb_id]['finish_expend']; if ($cost) { $deduct_coin = 0; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] < $cost) { $deduct_coin = $player_info['ticket']; } else { $deduct_coin = $cost; } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $deduct_coin); } if ($deduct_coin < $cost) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost - $deduct_coin); } $arr_consume = array('price' => $cost, 'gold' => $cost - $deduct_coin, 'ticket' => $deduct_coin, 'count' => 1); #数据中心推送 } } #获取玩家通缉榜天数据 $uwd_data = $this->get_data("UnionWanted")->get_union_wanted_daily_info($player_id, 'uwd', 'day'); if (!$uwd_data) { $this->throw_error('10110'); #数据错误 } $update_uwd = array(); if ($wanted_info['finish_times_max'] > 0 && $uwd_data['finished_times'] < $wanted_info['finish_times_max']) { $update_uwd['finished_times'] = ++$uwd_data['finished_times']; #$update_uwd['finish_times'] = --$uwd_data['finish_times']; /* #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10060); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } $free_times_vip_table = array(); if ($player_vip > 0) { #获取VIP配置表免费次数配置 $free_times_vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, 10060); } if ($uwd_data['used_free'] >= $free_times_vip_table['max_times'] + $uwd_data['use_free']) { $update_uwd['used_times'] = 1; $times_table = $this->get_cache_table_data('times_table', array('type' => 1, 'times' => $update_uwd['used_times'])); if ($times_table) { #通过刷新消耗配置表获得下次刷新需要消耗的货币数量 list($id, $value) = explode("|", $times_table['cost']); $update_uwd['use_expend'] = json_encode(array('id' => $id, 'num' => $value)); } }*/ } else { $this->throw_error('1719003'); //通缉次数不足 } #获取公会通缉榜等级 $wanted_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'wanted_level'); #创建通缉数据结构 $wanted_data = $this->create_wanted_struct($wanted_level); $data['wanted_info'] = $wanted_info; $data['wanted_info']['union_wanted_info'] = $wanted_data; $update_data['wanted_info'] = json_encode($data['wanted_info']); #获取玩家等级对应的任务基础奖励 $player_level = $player_info['level']; $level_base_reward = $this->get_reward_by_level($player_level); $wanted_fb = $wanted_info['union_wanted_info'][$fb_id]; #计算加成奖励 $wanted_info['union_wanted_info'][$fb_id]['union_award']['exp']['num'] = $this->calculation_reward($level_base_reward['exp'], $wanted_fb['union_award']['exp']['num'], $uwd_data['fortune_award_per']); $wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num'] = $this->calculation_reward($level_base_reward['player_exp'], $wanted_fb['union_award']['player_exp']['num'], $uwd_data['fortune_award_per']); $wanted_info['union_wanted_info'][$fb_id]['union_award']['contribution']['num'] = $this->calculation_reward($level_base_reward['contribution'], $wanted_fb['union_award']['contribution']['num'], $uwd_data['fortune_award_per']); #获取玩家公会ID $union_id = $player_info['union_id']; #获取公会数据 $union_info = $this->get_data("UnionInfo")->get_union_info($union_id); if ($union_info) { #更新公会经验 $union_info['union_exp'] = $wanted_info['union_wanted_info'][$fb_id]['union_award']['exp']['num']; } $today_contribution = 0; $update_player = array(); #获取玩家公会数据 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $front_amount_dedicate = $player_data['total_dedicate']; //贡献 if ($player_data) { $today_contribution = $wanted_info['union_wanted_info'][$fb_id]['union_award']['contribution']['num']; #更新玩家贡献 $player_data['total_dedicate'] += $today_contribution; $update_player = $player_data; } $player_exp_info = array(); //添加玩家副本奖励经验 if ($wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num']) { $player_exp_info[] = array('type' => 'exp', 'item_id' => '1', 'item_num' => $wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num']); } $this->start_trans(); #更新通缉副本 $update_res = $this->get_data("UnionWanted")->update_union_wanted($player_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } if (!empty($update_uwd)) { #更新玩家公会通缉榜天数据 $this->get_data("UnionWanted")->update_union_wanted_daily_data($player_id, 'uwd', $update_uwd); #同步更新玩家使用次数总表 $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'union_wanted_times', $update_uwd['finished_times']); $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if ($base_table) { $times_max = $base_table['daily_complete_times']; #更新公会引导状态 $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $update_uwd['finished_times'], $times_max, 2, 2); } } $success_add_exp = 0; if ($union_info['union_exp']) { $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if (empty($base_table)) { $this->throw_error('10109'); #配置表读取错误 } #完成的悬赏任务大于每日可完成的悬赏任务,则不再增加公会经验 $is_get_exp = true; if ($base_table['num_for_union_exp'] > 0) { $union_times = $this->get_data('PlayerDailyTime')->get_player_used_time($union_id, 'union_wanted_num'); if ($union_times < $base_table['num_for_union_exp']) { $add_res = $this->get_data('PlayerDailyTime')->pre_add_used_time($union_id, 'union_wanted_num'); } else { $is_get_exp = false; } } if ($is_get_exp) { #增加公会经验 $arr_union_reward = array(); $arr_union_reward[] = array("type" => "union_exp", "item_id" => 9, "item_num" => $union_info['union_exp']); $ret = $this->get_game('UnionReward')->send_reward($player_id, $arr_union_reward, array("cmd_id" => 1753)); if ($ret !== false) { $success_add_exp = $ret; } } } if (Com_Array::is_good_arr($player_exp_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $player_exp_info, array('cmd_id' => '1753'), 1); if ($result !== true) { $this->throw_error('10104'); } } if (!empty($update_player)) { $update_res = $this->get_game("UnionPlayer")->add_player_dedicate($player_id, $today_contribution); #更新玩家今日贡献 #$this->get_data("PlayerDailyTime")->add_used_time($player_id, "union_player_contribute", $today_contribution); #更新玩家公会 #$update_res = $this->get_data('UnionPlayer')->update_union_player_info($union_id, $player_id, $update_player); if (!$update_res) { $this->throw_error('10104'); } //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $today_contribution, 'amount' => $front_amount_dedicate, 'after_amount' => $player_data['total_dedicate'], 'cmd_id' => 1753); Log_Common::getInstance()->add_log($log_data); } if ($way && $wanted_info['union_wanted_info'][$fb_id]['finish_expend']) { #扣钻石 $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1753, array(), $arr_consume); #$update_res = $this->get_data('Player')->update_player_gold($player_id, "-" . $wanted_info['union_wanted_info'][$fb_id]['finish_expend'] ); if (!$update_res) { $this->throw_error('10104'); } } $this->commit(); $this->update_temporary_data($data); $this->get_game('Reward')->add_reward_log(); $this->get_game('UnionReward')->add_union_reward_log(); #更新公会成就任务 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 11, 1, 1); #更新公会福利大厅任务 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9030); #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 29, 1); //找回资源埋点 $this->get_game('GetBackCurrency')->add_function_day_times($player_id, 13); #增加公会记录 $code = 1719006; $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $today_contribution, 'rep_color' => "ffb901"); if ($success_add_exp > 0) { $arr_replace[] = array('rep_type' => 7, 'txt' => $success_add_exp, 'rep_color' => "ffb901"); $code = 1719005; } $player_exp = $wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num']; $arr_replace[] = array('rep_type' => 7, 'txt' => $player_exp, 'rep_color' => "ffb901"); $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, $code, $arr_replace); if ($success_add_exp < 1) { unset($wanted_info['union_wanted_info'][$fb_id]['union_award']['exp']); } $union_award = $wanted_info['union_wanted_info'][$fb_id]['union_award']; if ($way) { if ($success_add_exp > 0) { Protocol_Reward::add($player_id, array('prop_id' => $union_award['exp']['id'], 'item_num' => $success_add_exp, 'item_position' => 1, 'grid' => 0)); } Protocol_Reward::add($player_id, array('prop_id' => $union_award['player_exp']['id'], 'item_num' => $union_award['player_exp']['num'], 'item_position' => 1, 'grid' => 0)); Protocol_Reward::add($player_id, array('prop_id' => $union_award['contribution']['id'], 'item_num' => $union_award['contribution']['num'], 'item_position' => 1, 'grid' => 0)); Protocol_Reward::out(); } else { $log_data = array('player_id' => $player_id, 'channel' => 55, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'ad_info' => $player_info['ad_info'], 'career_type' => $player_info['career_type'], 'type' => 2, 'module_id' => $fb_id, 'add_time' => time()); Log_Common::getInstance()->add_log_by_table($log_data, 'log_enter'); } return array('0' => 1, '1' => $union_award); }