Example #1
0
 private function _cal_invest_remain_time()
 {
     $fund_issue_time = Cache_Const::getInstance()->get_const('fund_issue_time');
     $server_start_time = strtotime(SERVER_FIRST_START_TIME);
     if (empty($fund_issue_time)) {
         # 无法获取功能发布时间,无法区分新服老服,只能使用开服时间
         $deadline = Com_Util::get_date_end($server_start_time) + ($this->fund_valid_deposit_day - 1) * 86400;
     } else {
         if ($server_start_time > $fund_issue_time) {
             # 新服
             $deadline = Com_Util::get_date_end($server_start_time) + ($this->fund_valid_deposit_day - 1) * 86400;
         } else {
             # 老服,使用功能发布时间
             $deadline = Com_Util::get_date_end($fund_issue_time) + ($this->fund_valid_deposit_day - 1) * 86400;
         }
     }
     $remain_time = max(0, $deadline - $this->current_time);
     return $remain_time;
 }
Example #2
0
 public function get_answer_right_reward($player_id, $question_id, $map_id, $player_list)
 {
     if (empty($map_id) || empty($question_id) || empty($player_list)) {
         $this->throw_error('10107');
         //参数错误!
     }
     $athena_question_reward_id = Cache_Const::getInstance()->get_const('athena_question_reward_id', 0, 1);
     # 掉落道具ID
     $athena_question_reward_ratio = Cache_Const::getInstance()->get_const('athena_question_reward_ratio', 0, 1);
     # 掉落概率
     $athena_question_reward_stint = Cache_Const::getInstance()->get_const('athena_question_reward_stint', 0, 1);
     # 掉落获取次数上限
     $involved_num = count($player_list);
     # 参与人数
     for ($i = 0; $i < $involved_num; $i++) {
         $player_info = $this->get_data('Player')->get_player_info($player_list[$i], array('player_id', 'level', 'vip', 'privilege_level'));
         if (empty($player_info)) {
             continue;
             # 不阻挡别人发奖
         }
         if (Com_Random::probability($athena_question_reward_ratio, 10000)) {
             $gain_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_list[$i], $this->daily_answer_right_reward_gain_num);
             if ($gain_num >= $athena_question_reward_stint) {
                 continue;
             }
             $reward = array();
             $reward[] = array('type' => 'drop', 'item_id' => $athena_question_reward_id, 'item_num' => 1);
             $re = $this->get_game('Reward')->send_reward($player_list[$i], $reward, array('cmd_id' => '549'), 1);
             $this->write_check_strict($re, 3010334);
             # 更新奖励获取次数
             $re = $this->get_data('PlayerDailyTime')->add_used_time($player_list[$i], $this->daily_answer_right_reward_gain_num, 1);
             $this->write_check($re, 3010338);
             # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
             $ret = $this->get_game('Reward')->add_reward_log(true);
             /**
             				$reward_fmt = array();
             				$reward_fmt[] = array(
             					'type' 		=> $item_id,
             					'item_id'	=> $item_id,
             					'item_num'	=> $item_num,
             				);
             
             				# 告知Flash奖励
             				Protocol::input($player_list[$i], 8, 11, 1154, array('reward' => $reward_fmt));
             				**/
             Com_Log::debug_write('xgame.athena_question', "{$player_list[$i]} get answer right reward" . json_encode($reward));
         }
     }
     return null;
 }