Exemple #1
0
 public function router($cmd0, $cmd1, $cmd2, $player_id, $arr_param)
 {
     global $arrParam, $arrAuthUser, $logHandler;
     $arrAuthUser['player_id'] = $player_id;
     $arrParam = $arr_param;
     $class = 'S2P_' . $cmd1;
     $include_file = ACTION_PATH . "/S2P/S2P_{$cmd1}.php";
     if (is_file($include_file)) {
         require $include_file;
         try {
             //调用对应指令函数
             $obj = new $class();
             $exec_cmd2 = 'CMD2_' . $cmd2;
             if (ECONOMY_LOG_SWITCH === TRUE) {
                 $logHandler['logger'] = new Com_Logger($cmd0, $cmd1, $cmd2, $player_id);
             }
             call_user_func_array(array($obj, $exec_cmd2), array());
             $protocols = Protocol::get_protocol();
             Protocol::out();
             Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 1, 'exec fun success', $protocols);
             if (ECONOMY_LOG_SWITCH === TRUE) {
                 $logHandler['logger']->flush_log();
             }
             exit;
         } catch (Exception $e) {
             //有异常
             $msg = json_decode($e->getMessage(), true);
             $error = "Exception: " . $e->getFile() . " line:" . $e->getLine() . " error code " . $msg['error']['code'];
             Statistic::report($cmd0, $cmd1, $cmd2, $arrAuthUser, $arrParam, 0, $error);
             Protocol::input($player_id, 8, 7, 742, array(0 => array($msg['error'])));
             Protocol::out();
             exit;
         }
     }
 }
 /**
  * decissions shows the decissions of this or all protocols
  * 
  * @param int $pid entry-id for protocol
  * @return string html of the decissions page
  */
 private function decisions($pid)
 {
     // pagecaption
     $this->tpl->assign('pagecaption', parent::lang('class.ProtocolView#page#caption#decisions'));
     // check rights
     if (Rights::check_rights($pid, 'protocol', true) || $pid == false) {
         // prepare template
         $sD = new JudoIntranetSmarty();
         // check pid all or single
         if ($pid === false) {
             // get protocol ids
             $pids = Protocol::return_protocols();
             // create protocol objects to sort
             $protocols = array();
             foreach ($pids as $pid) {
                 $protocols[] = new Protocol($pid);
             }
             // sort array by protocols date
             usort($protocols, array($this, 'callback_compare_protocols'));
             // walk through ids
             $counter = 0;
             foreach ($protocols as $protocol) {
                 // assign data
                 $data[$counter] = array('date' => $protocol->get_date('d.m.Y'), 'type' => $protocol->get_type(), 'location' => $protocol->get_location(), 'decisions' => $this->parseHtml($protocol->get_protocol(), '<p class="tmceDecision">|</p>'));
                 // check if protocol has decisions
                 if (count($data[$counter]['decisions']) == 0) {
                     unset($data[$counter]);
                 }
                 $data = array_merge($data);
                 // add to template
                 $sD->assign('data', $data);
                 // increment counter
                 $counter++;
             }
         } else {
             // get protocol object
             $protocol = new Protocol($pid);
             // assign data
             $data[] = array('date' => $protocol->get_date('d.m.Y'), 'type' => $protocol->get_type(), 'location' => $protocol->get_location(), 'decisions' => $this->parseHtml($protocol->get_protocol(), '<p class="tmceDecision">|</p>'));
             // add to template
             $sD->assign('data', $data);
         }
         // return
         return $sD->fetch('smarty.protocol.showdecisions.tpl');
     } else {
         // error
         $errno = $GLOBALS['Error']->error_raised('NotAuthorized', 'entry:' . $this->get('id'), $this->get('id'));
         $GLOBALS['Error']->handle_error($errno);
         return $GLOBALS['Error']->to_html($errno);
     }
 }
Exemple #3
0
 /**
  * 429: 天梯战斗结算奖励
  * @note	注意,C++请求该方法时传入的player_id=0[玩家下线离开仍然要有战斗结果,即结果与挑战发起方无关],不能用plaeyr_id做二次验证,只能用战斗序号验证
  * @note	考虑到天梯挑战的战斗结果与当事人发起挑战后的其它游戏行为无关,即当发起挑战后,无论当事人有任何游戏行为,
  * @note	该场战斗仍然客观进行中,结果都必须结算,而ladder_id已经可以唯一确认一场天梯挑战
  * @note	当$winner_player_id == 0 && $loser_player_id == 0时,表示玩家异常操作,刷新或下线,PHP后端自行结算战斗奖励及结果
  * @param 	$player_id
  * @param 	$battle_seq
  * @param 	$winner_player_id
  * @param 	$loser_player_id
  * @return 	bool
  */
 public function finish_challenge_battle($player_id, $battle_seq, $winner_player_id, $loser_player_id)
 {
     # 记录行为
     Com_Log::write('xgame.challenge', "{$player_id}\t" . "finish_challenge_battle\tstart\t" . "{$battle_seq}\t" . "{$winner_player_id}\t" . "{$loser_player_id}\t");
     $this->current_time = time();
     #  后台进程调用的方法需要重置当前时间
     # 获取挑战日志
     $battle_log = $this->get_data('Challenge')->get_challenge_battle_log($battle_seq);
     if (empty($battle_log) || $battle_log['battle_status'] == 1) {
         $this->throw_error('120102');
         # 天梯战斗结果验证异常,或战斗序号错误
     }
     # 挑战双方player_id
     $player_id = $battle_log['player_id'];
     $tgt_player_id = $battle_log['tgt_player_id'];
     $mon_offset = $battle_log['mon_offset'];
     $reward_buff_type = $battle_log['reward_buff_type'];
     $reward_buff_offset = $battle_log['reward_buff_offset'];
     $fight_with_monster = $mon_offset ? 1 : 0;
     # 是否挑战怪物标识
     $exception_flag = 0;
     # 异常标识
     $player_info = $this->get_data('Player')->get_player_info($player_id);
     # 挑战方一定是玩家,可先获取其玩家信息
     # --------------------------------------------------------------------
     # 初始化奖励信息:1.怪物额外奖励;2.挑战奖励;3.reward buff额外奖励
     # --------------------------------------------------------------------
     $currency_index = Cache_Currency::getInstance()->get_index();
     $reward_detail_monster = array();
     $reward_detail_buff = array();
     # ----------------------------------------------------------------
     # 获取排名信息
     $player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info($player_id);
     $player_rank_before = $player_rank_info['rank'];
     # 发起方战前排名,本人在虚拟天梯榜时,值为0
     $player_cstatus_before = $player_rank_info['challenge_status'];
     # 发起方战前天梯状态
     $player_frank_before = $player_rank_info['fake_rank'];
     # 发起方战前虚假排名
     $player_frank_after = $player_rank_info['fake_rank'];
     # 发起方战后虚假排名[挑战怪物,则玩家cstatus<=2,虚假排名不会变;挑战玩家,虚假排名可能变化]
     $fight_with_dummy = 0;
     # 是否与虚拟榜虚假玩家战斗
     if ($mon_offset) {
         $tgt_player_rank_info = array();
         # 对手为怪物时,值为false
         $tgt_player_rank_before = 0;
         # 被挑战方战前排名[挑战怪物,则为0,怪物没有天梯排名]
     } else {
         $tgt_player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info($tgt_player_id);
         # 对手为虚拟玩家时,值为false
         $tgt_player_rank_before = empty($tgt_player_rank_info) ? 0 : $tgt_player_rank_info['rank'];
         # 被挑战方战前排名[挑战虚拟玩家,则为0,虚拟玩家没有天梯排名;挑战真实玩家,则为真实玩家排名]
     }
     # ----------------------------------------------------------------
     $this->start_trans();
     # 玩家挑战怪物,正常情况:只传回玩家ID,怪物ID不传,异常情况[掉线或刷新]: 玩家ID与怪物ID都传0
     if (!empty($mon_offset)) {
         if ($winner_player_id == 0 && $loser_player_id == 0) {
             # 异常战斗行为处理:包括玩家下线及刷新等
             $battle_result = 1;
             $exception_flag = 1;
         } else {
             if ($player_id != $winner_player_id && $player_id != $loser_player_id) {
                 $this->throw_error('120102');
                 # 天梯战斗结果验证异常
             }
             $battle_result = $player_id == $winner_player_id ? 1 : 0;
             # 挑战结果
         }
         # TODO: 此处有高并发问题隐患,当过了此处验证时,另一玩家已经挑战完该怪物并清空该怪物,下面的排位移动将出问题
         $monster_info = $this->get_data('Challenge')->get_challenge_monster_info($mon_offset);
         if (empty($mon_offset) || empty($monster_info)) {
             $this->throw_error('120102');
             # 天梯战斗结果验证异常
         }
         # 发放怪物额外奖励[输了怪物奖励折半]
         $ladder_element_info = Cache_Ladder::getInstance()->get_element_info_by_double_type(2, $tgt_player_id);
         if (empty($ladder_element_info)) {
             $this->throw_error('120108');
         }
         $coeff_monster = $battle_result == 1 ? 1 : 0.5;
         $reward_detail_monster = $this->get_game('Reward')->get_reward_detail($ladder_element_info['reward'], $coeff_monster);
         # 若胜利,清除该偏移量位置上的怪物,玩家取代怪物位置,怪物后直到玩家之前的所有玩家向后推移1位
         if ($battle_result) {
             # 清除怪物
             $re = $this->get_data('Challenge')->delete_challenge_monster_info($mon_offset);
             $this->write_check($re, 3010666);
             if (empty($player_rank_before)) {
                 # 本人在虚假天梯榜,显示排名3001,假设mon_offset=2997,则打完后,本人排名为2997,实际2997-2999变为2998-3000,实际3000移出真实榜
                 $player_rank_info['rank'] = $mon_offset;
                 $player_rank_info['is_in_battle'] = 0;
                 # 战斗状态变更
                 $player_rank_info['challenge_status'] = 1;
                 # 移入真实天梯榜
                 $player_rank_info['mod_date'] = $this->current_time;
                 $need_update_player_rank_info = array(0 => $player_rank_info);
                 # 怪物后第一位一直到边界值排位的前一位正常处理
                 $need_modify_rank = array();
                 for ($i = $mon_offset; $i < $this->challenge_partition_boundary; $i++) {
                     # 这部分玩家排位后移1位,
                     $need_modify_rank[] = $i;
                 }
                 list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($need_modify_rank);
                 foreach ($player_info_list as $rank => $rank_info) {
                     $rank_info['rank'] += 1;
                     $rank_info['mod_date'] = $this->current_time;
                     $need_update_player_rank_info[] = $rank_info;
                 }
                 # 边界值排位的玩家额外处理【即真实天梯榜最后一名额外处理,需移出真实天梯榜】
                 list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($this->challenge_partition_boundary);
                 foreach ($player_info_list as $rank => $rank_info) {
                     $rank_info['rank'] = 0;
                     $rank_info['challenge_status'] = 2;
                     $rank_info['mod_date'] = $this->current_time;
                     $need_update_player_rank_info[] = $rank_info;
                 }
                 # 更新
                 foreach ($need_update_player_rank_info as $rank_info) {
                     $re = $this->get_data('Challenge')->update_challenge_rank_info($rank_info);
                     $this->write_check($re, 3010701);
                 }
             } elseif ($player_rank_before > $mon_offset) {
                 # 本人在正常天梯榜,只有往前打怪才移动排名,往后打排名不变,只清除怪物
                 $player_rank_info['rank'] = $mon_offset;
                 $player_rank_info['is_in_battle'] = 0;
                 # 战斗状态变更
                 $player_rank_info['mod_date'] = $this->current_time;
                 $need_update_player_rank_info = array(0 => $player_rank_info);
                 $need_modify_rank = array();
                 for ($i = $mon_offset; $i <= $player_rank_before - 1; $i++) {
                     # 这部分玩家排位后移1位
                     $need_modify_rank[] = $i;
                 }
                 list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($need_modify_rank);
                 foreach ($player_info_list as $rank => $rank_info) {
                     $rank_info['rank'] += 1;
                     $rank_info['mod_date'] = $this->current_time;
                     $need_update_player_rank_info[] = $rank_info;
                 }
                 # 更新
                 foreach ($need_update_player_rank_info as $rank_info) {
                     $re = $this->get_data('Challenge')->update_challenge_rank_info($rank_info);
                     $this->write_check($re, 3010726);
                 }
                 #$this->handle_challenge_rank_refer_achieve($player_id, $player_rank_info['rank']);
             }
             # 公会任务触发
             $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1050);
         } else {
             # 若失败,排名不变
             # 更新怪物战斗状态
             $monster_info['is_in_battle'] = 0;
             $re = $this->get_data('Challenge')->update_challenge_monster_info($monster_info);
             $this->write_check($re, 3010737);
         }
     } else {
         # 玩家挑战玩家
         if ($winner_player_id == 0 && $loser_player_id == 0) {
             # 异常战斗行为处理:包括玩家下线及刷新等
             # 连败时的战力加成处理
             if ($player_info['challenge_cont_lose'] > 0) {
                 $ability_add_info = Cache_Ladder::getInstance()->get_ability_add_info($player_info['challenge_cont_lose']);
                 if (empty($ability_add_info)) {
                     $this->throw_error('120106');
                     # 没有连胜或连败的加成配置信息
                 }
                 $player_info['sum_fpower'] = $player_info['sum_fpower'] * (1 + intval($ability_add_info['ability_add'] / 100));
             }
             $tgt_player_info = $this->get_data('Player')->get_player_info($tgt_player_id);
             $battle_result = $player_info['sum_fpower'] >= $tgt_player_info['sum_fpower'] ? 1 : 0;
             # 挑战结果
             $exception_flag = 1;
         } else {
             if ($player_id != $winner_player_id && $player_id != $loser_player_id || $tgt_player_id != $winner_player_id && $tgt_player_id != $loser_player_id) {
                 $this->throw_error('120102');
                 # 天梯战斗结果验证异常
             }
             $battle_result = $player_id == $winner_player_id ? 1 : 0;
             # 挑战结果
         }
         if (!empty($tgt_player_rank_before)) {
             # 真实天梯对手才需要更新
             # 若胜利,取二者较前排名【不交换排名是因为向后挑战时排名不变更】
             if ($battle_result) {
                 if (empty($player_rank_before)) {
                     # 本人在虚假天梯榜时,将对方移出真实天梯榜,取而代之,也可用$player_rank_info['challenge_status'] == 2||3判断
                     $player_rank_info['rank'] = $tgt_player_rank_before;
                     $player_rank_info['challenge_status'] = 1;
                     # 移入真实天梯榜
                     $tgt_player_rank_info['rank'] = 0;
                     $tgt_player_rank_info['challenge_status'] = 2;
                     # 移出真实天梯榜
                 } else {
                     $player_rank_info['rank'] = min($player_rank_before, $tgt_player_rank_before);
                     $tgt_player_rank_info['rank'] = max($player_rank_before, $tgt_player_rank_before);
                 }
                 $player_rank_info['mod_date'] = $tgt_player_rank_info['mod_date'] = $this->current_time;
                 #$this->handle_challenge_rank_refer_achieve($player_id, $player_rank_info['rank']);
                 # 公会任务触发
                 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1050);
             } else {
                 # 若失败,排名不变
                 # do nothing
             }
             # 更新玩家战斗状态
             $player_rank_info['is_in_battle'] = $tgt_player_rank_info['is_in_battle'] = 0;
             $re = $this->get_data('Challenge')->update_challenge_rank_info($player_rank_info);
             $this->write_check($re, 3010799);
             $re = $this->get_data('Challenge')->update_challenge_rank_info($tgt_player_rank_info);
             $this->write_check($re, 3010801);
         } else {
             # 虚拟天梯对手,由于虚拟玩家未实际进入天梯,故此时不更新虚拟玩家天梯信息[包含两类:1初始进入时即进入虚假天梯榜,2初始进入真实天梯榜,但被其它玩家打出真实天梯榜]
             if ($battle_result) {
                 $fake_rank = $player_rank_info['fake_rank'];
                 foreach ($player_rank_info['fake_rank_list'] as $rank => $rank_info) {
                     if ($rank_info['player_id'] == $tgt_player_id) {
                         $tgt_player_rank = $rank_info['rank'];
                         break;
                     }
                 }
                 if ($fake_rank > $tgt_player_rank) {
                     # 向排名较前的人挑战则交换,否则不交换
                     $player_rank_info['fake_rank'] = $tgt_player_rank;
                     $player_rank_info['fake_rank_list'][$fake_rank]['player_id'] = $tgt_player_id;
                     $player_rank_info['fake_rank_list'][$tgt_player_rank]['player_id'] = $player_id;
                     $player_rank_info['mod_date'] = $this->current_time;
                 }
                 # 公会任务触发
                 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1050);
             }
             $player_rank_info['fake_battle_num'] += 1;
             # 战斗次数加1
             if ($player_rank_info['fake_battle_num'] >= $this->challenge_req_fake_battle_num) {
                 $player_rank_info['challenge_status'] = 2;
                 # 天梯状态置为2
             }
             $player_rank_info['is_in_battle'] = 0;
             $re = $this->get_data('Challenge')->update_challenge_rank_info($player_rank_info);
             $this->write_check($re, 3010828);
             $player_frank_after = $player_rank_info['fake_rank'];
             # 发起方战前后假排名
             $fight_with_dummy = 1;
             # 是否与虚拟榜虚假玩家战斗
         }
     }
     $this->handle_challenge_battle_refer_achieve($player_id, $battle_result);
     $this->handle_challenge_battle_refer_union_achieve($player_id, $battle_result);
     # --------------------------------------------------------------------
     # 玩家挑战怪物 | 玩家挑战玩家 | 玩家下线等异常操作,以下是共同逻辑
     # --------------------------------------------------------------------
     # --------------------------------------------------------------------
     # 连胜连败处理
     # --------------------------------------------------------------------
     if ($battle_result) {
         $player_info['challenge_cont_win'] += 1;
         $player_info['challenge_cont_lose'] = 0;
     } else {
         $player_info['challenge_cont_win'] = 0;
         $player_info['challenge_cont_lose'] += 1;
     }
     # --------------------------------------------------------------------
     # 挑战奖励
     # --------------------------------------------------------------------
     $coeff = 1;
     # 连胜连败加成系数
     if ($battle_result == 0) {
         # 若失败,奖励减半
         $coeff = 0.5;
     } else {
         # 若成功,考虑连胜加成
         if ($player_info['challenge_cont_win'] > 0) {
             $award_add_info = Cache_Ladder::getInstance()->get_award_add_info($player_info['challenge_cont_win']);
             if (empty($award_add_info)) {
                 $this->throw_error('120106');
                 # 没有连胜或连败的加成配置信息
             }
             $coeff = 1 + $award_add_info['award_add'] / 100;
         }
     }
     $award_battle_info = Cache_Ladder::getInstance()->get_ladder_award_battle_info($player_info['level']);
     if (empty($award_battle_info) || empty($award_battle_info['reward_base'])) {
         $this->throw_error('120121');
         # 没有经验奖励配置信息
     }
     # 挑战奖励要求加成绝对值,不使用加成比率
     #$reward_detail_battle = $this->get_game('Reward')->get_reward_detail_other_way($award_battle_info['reward_base'], $award_battle_info['reward_add']);
     $reward_detail_battle = $this->get_game('Reward')->get_reward_detail($award_battle_info['reward_base']);
     if (!empty($award_battle_info['reward_add'])) {
         $add_info_array = explode("|", $award_battle_info['reward_add']);
         foreach ($add_info_array as $add_info) {
             list($item_id, $item_value) = explode(":", $add_info);
             if (isset($reward_detail_battle[$item_id])) {
                 $reward_detail_battle[$item_id] += $item_value * ($player_info['level'] - $award_battle_info['level']);
             }
         }
     }
     $reward_string_battle = $this->get_game('Reward')->get_reward_string_by_reward_detail($reward_detail_battle);
     $reward_detail_battle_correct = $this->get_game('Reward')->get_reward_detail($reward_string_battle, $coeff);
     # 处理连胜连败加成
     # --------------------------------------------------------------------
     # 发放额外奖励buff的奖励并清空该偏移量位置上的reward_buff[无论输赢都清空buff,但输的时候buff奖励折半]
     # --------------------------------------------------------------------
     $reward_buff_info = $this->get_data('Challenge')->get_challenge_reward_buff($player_id);
     if (!empty($reward_buff_type) && !empty($reward_buff_offset) && !empty($reward_buff_info)) {
         $ladder_element_info = Cache_Ladder::getInstance()->get_element_info_by_double_type(1, $reward_buff_type);
         if (empty($ladder_element_info)) {
             $this->throw_error('120108');
         }
         $coeff_buff = $battle_result == 1 ? 1 : 0.5;
         $reward_detail_buff = $this->get_game('Reward')->get_reward_detail($ladder_element_info['reward'], $coeff_buff);
         if (isset($reward_detail_buff[$this->need_correct_item])) {
             # 部分奖励资源需要根据玩家等级修正
             $element_correct_info = Cache_Ladder::getInstance()->get_element_correct_info($player_info['level'], $this->need_correct_item_id);
             if (empty($element_correct_info)) {
                 $this->throw_error('120125');
                 # 天梯奖励元素修正表配置为空
             }
             $correct_detail = explode("|", $element_correct_info['reward_correct']);
             foreach ($correct_detail as $correct_info) {
                 list($item_idx, $item_num) = explode(":", $correct_info);
                 if ($item_idx == $this->need_correct_item_id) {
                     $reward_detail_buff[$this->need_correct_item_id] = $item_num;
                     break;
                 }
             }
         }
         for ($i = 1; $i <= $this->challenge_reward_buff_stint; $i++) {
             if ($reward_buff_info['buff' . $i . '_offset'] == $reward_buff_offset) {
                 $reward_buff_info['buff' . $i . '_offset'] = 0;
                 $reward_buff_info['buff' . $i . '_type'] = 0;
                 break;
             }
         }
         $re = $this->get_data('Challenge')->update_challenge_reward_buff($reward_buff_info);
         $this->write_check($re, 3010923);
     }
     # 更新连胜连败信息
     $update_fields = array('challenge_cont_win' => $player_info['challenge_cont_win'], 'challenge_cont_lose' => $player_info['challenge_cont_lose']);
     $re = $this->get_data('Player')->update_player_info($player_id, $update_fields);
     $this->write_check($re, 3010932);
     $item_keys = Cache_Currency::getInstance()->get_key();
     # 统一发放奖励
     $reward = array();
     $this->get_game('Reward')->gen_reward_array($reward_detail_battle_correct, $reward);
     $this->get_game('Reward')->gen_reward_array($reward_detail_buff, $reward);
     $this->get_game('Reward')->gen_reward_array($reward_detail_monster, $reward);
     if (!empty($reward)) {
         if ($exception_flag == 1) {
             # 异常情况下发邮件
             # 生成奖励邮件附件信息
             $attachment = array();
             $reward_detail = $this->get_game('Reward')->get_reward_detail_by_reward($reward);
             foreach ($reward_detail as $item_idx => $item_num) {
                 $attachment[] = array("prop_id" => $item_idx, "prop_num" => $item_num);
             }
             # 邮件发送
             $phrase_id = $battle_result ? 14 : 15;
             $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id);
             $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 429);
         } else {
             $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '429'));
             $this->write_check_strict($re, 3010943);
         }
     }
     # 更新挑战日志
     $battle_log = array('battle_seq' => $battle_seq, 'player_id' => $player_id, 'tgt_player_id' => $tgt_player_id, 'battle_status' => 1, 'battle_result' => $battle_result);
     $re = $this->get_data('Challenge')->update_challenge_battle_log($battle_log);
     $this->write_check($re, 3010955);
     # 记录挑战MYSQL日志
     $player_rank_after = $player_rank_info['rank'];
     # 发起方战后排名
     $challenge_log_info = array('player_id' => $player_id, 'tgt_player_id' => $tgt_player_id, 'reg_date' => $this->current_time, 'battle_seq' => $battle_seq, 'player_rank_before' => $player_rank_before, 'player_rank_after' => $player_rank_after, 'player_fake_rank_before' => $player_frank_before, 'player_fake_rank_after' => $player_frank_after, 'tgt_player_rank_before' => $tgt_player_rank_before, 'fight_with_monster' => $fight_with_monster, 'fight_with_dummy' => $fight_with_dummy, 'challenge_status_after' => $player_rank_info['challenge_status'], 'status' => $battle_result);
     $re = $this->get_data('Challenge')->record_challenge_log($challenge_log_info);
     $this->write_check($re, 3010975);
     # 系统公告与广播信息只对应挑战发起方,包括获取天梯第一名和天梯连胜
     $replace_info1 = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 1050), array('rep_type' => 0, 'rep_val' => $tgt_player_id));
     $replace_info2 = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 1050), array('rep_type' => 7, 'txt' => $player_info['challenge_cont_win']));
     # 挑战发起者胜利 && 挑战发起者战前与战后排名不一致[因为胜利,所以排名一定是提高] && 挑战发起者战后排名是第一名
     if ($battle_result && $player_rank_before != $player_rank_info['rank'] && $player_rank_info['rank'] == 1) {
         $this->get_game('SystemNotice')->push_sys_notice($player_id, 1050, 2, $replace_info1, $player_rank_info['rank']);
         # 排名第一
     }
     $this->get_game('SystemNotice')->push_sys_notice($player_id, 1050, 1, $replace_info2, $player_info['challenge_cont_win']);
     # 连胜
     $this->commit();
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $this->get_game('Reward')->add_reward_log();
     #if ($exception_flag == 0) { # 战斗超时时,也是走异常结算逻辑,但却需要推送结算协议给前端
     $reward_string = $this->get_game('Reward')->get_reward_string_by_reward_detail($reward_detail_battle_correct);
     # 挑战奖励通用字符串
     # 合并$reward_detail_monster和$reward_detail_buff
     $extra_reward_array = array();
     if (!empty($reward_detail_monster)) {
         foreach ($reward_detail_monster as $item_idx => $item_num) {
             $extra_reward_array[$item_idx] += $item_num;
         }
     }
     if (!empty($reward_detail_buff)) {
         foreach ($reward_detail_buff as $item_idx => $item_num) {
             $extra_reward_array[$item_idx] += $item_num;
         }
     }
     $extra_string = $this->get_game('Reward')->get_reward_string_by_reward_detail($extra_reward_array);
     $player_rank_before_display = $this->get_display_rank($player_rank_before, $player_cstatus_before, $player_frank_before);
     # 发起方战前显示排名
     $player_rank_after_display = $this->get_display_rank($player_rank_info['rank'], $player_rank_info['challenge_status'], $player_rank_info['fake_rank']);
     # 发起方战后显示排名
     $data = array('result' => $battle_result, 'reward' => $reward_string, 'extra_reward' => $extra_string, 'rank' => $player_rank_after_display, 'raw_rank' => $player_rank_before_display);
     # 推送FLASH结果与奖励信息
     Protocol::input($player_id, 8, 12, 1203, $data);
     #}
     # 日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 102, 102, 1);
     #引导任务
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 7, 1);
     # 记录行为
     Com_Log::write('xgame.challenge', "{$player_id}\t" . "finish_challenge_battle\tend\t" . "{$battle_seq}\t" . "{$winner_player_id}\t" . "{$loser_player_id}\t");
     #Protocol::input($player_id,7,4,429,array(null)); # C++不需要下行
     $protocols = Protocol::get_protocol();
     Protocol::out(GATEWAY_IP);
     # 异步处理时,推送协议需要手动调用out执行
     return null;
 }