Пример #1
0
 /**
  * @Purpose:
  * 金蛋活动资源挽回接口
  * @param $player_id 玩家ID
  * @param $player_level 玩家等级
  * @param $times 奖励次数
  */
 public function egg_active_resource_retrieve($player_id, $player_level, $times = 1)
 {
     $player_id = intval($player_id);
     $player_level = intval($player_level);
     $times = intval($times);
     $num_list = array(49, 77, 111);
     $prop_list = array();
     $fb_id = 0;
     $num = 0;
     $Activity_table = Cache_ActivityHall::getInstance()->get_activity_hall_info(array('category' => 9), true);
     if (!empty($Activity_table) && Com_Array::is_good_arr($Activity_table)) {
         foreach ($Activity_table as $key => $activity_data) {
             if ($player_level >= $activity_data['join_min_lvl'] && $player_level <= $activity_data['join_max_lvl']) {
                 $fb_id = $activity_data['id'];
                 $num = $num_list[$key];
                 break;
             }
         }
     }
     if ($fb_id > 0 && $num > 0) {
         $prop_list = $this->get_egg_map_reward_field($fb_id, $num);
         if (!empty($prop_list) && Com_Array::is_good_arr($prop_list)) {
             foreach ($prop_list as $key => $prop) {
                 $prop_list[$key]['num'] *= $times;
             }
         }
     }
     return $prop_list;
 }
Пример #2
0
 /**
  *
  * @param unknown $instant_ntf 0:提前通知 1:到点通知
  * @param unknown $type_id 活动id
  * @param unknown $category 玩法类型
  */
 public function activity_send_notice($player_id, $instant_ntf, $sid)
 {
     $player_id = intval($player_id);
     $instant_ntf = intval($instant_ntf);
     $sid = intval($sid);
     #{活动名}活动10分钟后开启,请广大玩家做好准备,海量丰厚奖励等着你!
     #{活动名}活动开启了,立刻参与,活动奖励轻松获得!
     $activity_info = Cache_ActivityHall::getInstance()->get_activity_info($sid);
     if (!Com_Array::is_good_arr($activity_info)) {
         return false;
     }
     $code = $activity_info['func_id'];
     $arrPushConfig = Cache_PushUpgrade::getInstance()->get_upgrade_info($code, $instant_ntf + 1);
     if (!Com_Array::is_good_arr($arrPushConfig)) {
         return false;
     }
     $replace_info = array();
     $replace_info[] = array('rep_type' => 7, 'txt' => $activity_info['name']);
     if ($arrPushConfig['go_name']) {
         $replace_info[] = array('rep_type' => 1, 'rep_val' => $code, 'txt' => strval($arrPushConfig['go_name']));
     } else {
         $replace_info[] = array('rep_type' => 7, 'txt' => '');
     }
     $msg = Language_Message::make_message($arrPushConfig['code'], $replace_info, 0, '', true);
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, $arrPushConfig['need_broadcas'], 1, 2, $sid);
 }
Пример #3
0
 public function get_now_sids($player_id, $level)
 {
     $activity_sid = array(4001 => 11, 4002 => 11, 4003 => 11, 4011 => 7, 4012 => 7, 4013 => 7, 4014 => 7, 4015 => 7, 4016 => 7, 4017 => 7, 4018 => 7, 4019 => 7, 4041 => 8, 4042 => 8, 4043 => 8, 4401 => 12, 4402 => 12, 4403 => 12, 4301 => 10, 4302 => 10, 4303 => 10);
     $hall_list = Cache_ActivityHall::getInstance()->get_Activity_set();
     $data = $this->get_game('ActivityHall')->get_res_activity_list($level, 1, $hall_list, $player_id);
     //日常
     $arr_sid = array();
     foreach ($data as $act) {
         if (in_array($act['status'], array(0, 1, 2)) && isset($activity_sid[$act['tid']])) {
             $arr_sid[$activity_sid[$act['tid']]] = $act['tid'];
         }
     }
     $data = $this->get_game('ActivityHall')->get_res_activity_list($level, 2, $hall_list, $player_id);
     //常规
     foreach ($data as $act) {
         if (in_array($act['status'], array(0, 1, 2)) && isset($activity_sid[$act['tid']])) {
             $arr_sid[$activity_sid[$act['tid']]] = $act['tid'];
         }
     }
     $this->_player_func = $arr_sid;
     return true;
 }
Пример #4
0
 /**
  * 获取进入游戏的初始化数据
  * @param $player_id
  * @return mixed
  */
 public function get_player_init_info($player_id, &$playerInfo = null, $calc_buff_attr = false)
 {
     $playerInfo = $this->get_data('Player')->get_player_info($player_id);
     if (empty($playerInfo)) {
         return array();
     }
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id);
     $objPlayerAttr = $this->get_game('PlayerAttr');
     $objPlayerAttr->set_player_item($playerInfo);
     $objPlayerAttr->set_player_detail_item($player_detail);
     $syndata = $objPlayerAttr->get_player_attr($player_id, $calc_buff_attr);
     $objPlayerAttr->clear();
     //$syndata = $objPlayerAttr->get_player_attr($player_detail);
     $syndata['dower_info'] = $player_detail['dower_info'];
     $skill_infos = $this->get_game('PlayerSkill')->skill_list($player_id, $playerInfo, $player_detail);
     $syndata['skill_infos'] = $skill_infos['skill_infos'];
     $syndata['fairy_info'] = $skill_infos['fairy_info'];
     $syndata['hook_settings'] = $player_detail['hook_settings'];
     if (empty($syndata['hook_settings'])) {
         $syndata['hook_settings'] = $this->init_onhook_settings();
     }
     //        $equip = $this->get_game('Prop')->get_player_equip($player_id);
     $player_prop = $this->get_player_prop_info($player_id, $playerInfo['level']);
     $syndata['potion_dh_cnt'] = $player_prop['potion_dh_cnt'];
     $syndata['potion_hot_cnt'] = $player_prop['potion_hot_cnt'];
     $syndata['mp_potion_cnt'] = $player_prop['mp_potion_cnt'];
     $equip = $player_prop['equit'];
     $syndata['equip_skill'] = array();
     if (!empty($equip)) {
         $syndata['equip'] = array();
         foreach ($equip as $key => $prop) {
             if (!empty($prop['equip_view'])) {
                 if (is_string($prop['equip_view'])) {
                     $syndata['equip'][$key] = $prop['equip_view'];
                 } else {
                     $syndata['equip'][$key] = implode(':', $prop['equip_view']);
                 }
                 if ($syndata['equip'][$key] == '0:0:0:0' || $syndata['equip'][$key] == '0:0:0') {
                     $syndata['equip'][$key] = '';
                 }
                 //                    $prop_config = Cache_Prop::getInstance()->get_prop_info($prop['prop_id']);
                 ////                        $syndata['equip'][$key] = '0:0:0:0';
                 //                    $syndata['equip'][$key] = $prop_config['equip_views'];
             }
             //装备技能
             if (!empty($prop['star_map_desc'])) {
                 if (is_string($prop['star_map_desc'])) {
                     $prop['star_map_desc'] = json_decode($prop['star_map_desc'], true);
                 }
                 if (isset($prop['star_map_desc']['activate']['skill'])) {
                     $syndata['equip_skill'][$key] = $prop['star_map_desc']['activate']['skill'];
                 }
             }
         }
     }
     //套装更新了 衣服的equip_view
     $fashion_fit = $player_detail['fashion_fit'];
     $fashion_info = $player_detail['fashion_info'];
     if ($fashion_fit) {
         $meditation_flag = isset($player_detail['player_settings'][34]) ? $player_detail['player_settings'][34] : 0;
         $fashions = Cache_Fashion::getInstance()->get_fashion(array_values($fashion_fit));
         $now = time();
         if ($meditation_flag == 0) {
             if (isset($fashion_fit[1])) {
                 if ($fashion_info[$fashion_fit[1]]['timeliness'] > 0) {
                     $timeliness = $fashion_info[$fashion_fit[1]]['timeliness'] - $now;
                     if ($timeliness) {
                         $syndata['equip'][3] = $fashions[$fashion_fit[1]]['equip_view'];
                     }
                 } else {
                     $syndata['equip'][3] = $fashions[$fashion_fit[1]]['equip_view'];
                 }
             }
             if (isset($fashion_fit[2])) {
                 if ($fashion_info[$fashion_fit[2]]['timeliness'] > 0) {
                     $timeliness = $fashion_info[$fashion_fit[2]]['timeliness'] - $now;
                     if ($timeliness) {
                         $syndata['equip'][0] = $fashions[$fashion_fit[2]]['equip_view'];
                     }
                 } else {
                     $syndata['equip'][0] = $fashions[$fashion_fit[2]]['equip_view'];
                 }
             }
         }
     }
     #获取泳装
     $syndata['swim_suit'] = Cache_UnionSwim::getInstance()->get_swim_suit($playerInfo['career_type'], 0 + intval($playerInfo['vip']));
     if ($playerInfo['level'] > 15) {
         #减轻玩家刚激活时候的压力
         $hero_list = $this->get_data('PlayerHero')->get_fight_hero($player_id);
         if ($hero_list) {
             list($hero_id1, $hero_code1) = each($hero_list);
             if ($hero_id1) {
                 $hero_info = $this->get_game('Hero')->get_player_hero_attr($player_id, $hero_id1);
                 $syndata['hero_info'] = $hero_info;
                 $syndata['hero_code'] = $hero_code1;
                 $syndata['hero_state'] = 1;
                 $syndata['hero_level'] = $hero_info['hero_level'];
                 $syndata['hero_fit_level'] = $hero_info['fit'];
             } else {
                 $syndata['hero_code'] = 0;
                 $syndata['hero_state'] = 0;
                 $syndata['hero_info'] = array();
                 $syndata['hero_fit_level'] = 0;
             }
         }
         list($hero_id2, $hero_code2) = each($hero_list);
         if ($hero_id2) {
             $after_hero_info = $this->get_game('Hero')->get_player_hero_attr($player_id, $hero_id2);
             $syndata['hero2_info'] = $after_hero_info;
             $syndata['hero2_code'] = $hero_code2;
             $syndata['hero2_state'] = 1;
             $syndata['hero2_level'] = $after_hero_info['hero_level'];
             $syndata['hero2_fit_level'] = $after_hero_info['fit'];
         } else {
             $syndata['hero2_code'] = 0;
             $syndata['hero2_state'] = 0;
             $syndata['hero2_info'] = array();
             $syndata['hero2_fit_level'] = 0;
         }
     } else {
         $syndata['hero_code'] = 0;
         $syndata['hero_state'] = 0;
         $syndata['hero_info'] = array();
         $syndata['hero_fit_level'] = 0;
         $syndata['hero2_code'] = 0;
         $syndata['hero2_state'] = 0;
         $syndata['hero2_info'] = array();
         $syndata['hero2_fit_level'] = 0;
     }
     //竞技场信息
     if ($playerInfo['level'] > 22) {
         #减轻玩家刚激活时候的压力
         $my_arena_info = $this->get_data('KFArena')->get_kf_arena_info($player_id);
     } else {
         $my_arena_info = array();
     }
     if (!empty($my_arena_info)) {
         $syndata['dw'] = $my_arena_info['dw'];
         $syndata['dw_lv'] = $my_arena_info['dw_lv'];
         $syndata['score'] = $my_arena_info['score'];
         $syndata['dw_star'] = $my_arena_info['dw_star'];
     }
     $syndata['city_id'] = empty($playerInfo['city_id']) ? 2100 : $playerInfo['city_id'];
     $syndata['city_x'] = empty($playerInfo['city_x']) ? 3382 : $playerInfo['city_x'];
     $syndata['city_y'] = empty($playerInfo['city_y']) ? 3538 : $playerInfo['city_y'];
     $task_data = $this->get_data('PlayerTask')->get_task_info($player_id);
     if ($task_data['main_val']) {
         list($task_id, $task_info) = each($task_data['main_val']);
         if ($task_info['target']) {
             $tar = reset($task_info['target']);
             $syndata['city_escort_map_sid'] = $tar['city_id'];
             $syndata['city_escort_target_x'] = $tar['pro_addr_x'];
             $syndata['city_escort_target_y'] = $tar['pro_addr_y'];
             $pro_npc = explode("|", $tar['pro_npc']);
             $syndata['city_escort_npc_sid'] = $pro_npc[0];
         }
         $syndata['task_id'] = $task_id;
         $syndata['task_step'] = $task_info['step'];
         if ($task_info['task_status'] == 1) {
             $syndata['task_start_status'] = 1;
         } else {
             $syndata['task_start_status'] = 0;
         }
     } else {
         $syndata['city_escort_map_sid'] = 0;
         $syndata['city_escort_target_x'] = 0;
         $syndata['city_escort_target_y'] = 0;
         $syndata['city_escort_npc_sid'] = 0;
     }
     if ($player_detail['equip_wing'] && isset($player_detail['wing_info'][$player_detail['equip_wing']])) {
         $wing_table_task = Cache_PlayerWing::getInstance()->get_player_wing_data(array('id' => $player_detail['wing_info'][$player_detail['equip_wing']]['id'], 'level' => $player_detail['wing_info'][$player_detail['equip_wing']]['lvl']));
         #$wing_table_task = $this->get_game('PlayerWing')->get_cache_table_data('player_wing_table', array('id' => $player_detail['wing_info'][$player_detail['equip_wing']]['id'], 'level' => $player_detail['wing_info'][$player_detail['equip_wing']]['lvl']));
         $syndata['wing'] = $wing_table_task['avatar'];
         $syndata['wing_skill_id'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][0]);
         $syndata['wing_skill_id2'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][1]);
         $syndata['wing_skill_id3'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][2]);
     } else {
         $syndata['wing'] = '';
         $syndata['wing_skill_id'] = 0;
         $syndata['wing_skill_id2'] = 0;
         $syndata['wing_skill_id3'] = 0;
     }
     $syndata['title_id'] = $playerInfo['title_id'];
     $player_settings = $player_detail['player_settings'];
     if (isset($player_settings[37]) && $player_settings[37] == 1) {
         $syndata['meditation_status'] = 1;
     } elseif (isset($player_settings[38]) && $player_settings[38] == 1) {
         $syndata['meditation_status'] = 2;
     } else {
         $syndata['meditation_status'] = 0;
     }
     $syndata['medal_id'] = intval($playerInfo['medal_id']);
     $syndata['like_times'] = intval($playerInfo['like_times']);
     $syndata['flowers'] = intval($playerInfo['flowers']);
     $syndata['union_id'] = intval($playerInfo['union_id']);
     $syndata['union_name'] = $playerInfo['union_name'];
     $syndata['union_job'] = $playerInfo['union_job'];
     $syndata['min_attack_interval'] = 0;
     //默认给0就好了
     if ($playerInfo['level'] > 28) {
         $set = Cache_ActivityHall::getInstance()->get_Activity_set(4001);
         if (!empty($set)) {
             $used_athena_count = $this->get_game('Athena')->get_athena_remaining_count($player_id, 4001);
             #同步雅典娜次数给c++
             $left_athena_num = $set[0]['max_times'] - $used_athena_count;
             if ($left_athena_num < 0) {
                 $left_athena_num = 0;
             }
             $syndata['athena_remaining_count'] = $left_athena_num;
         } else {
             $syndata['athena_remaining_count'] = 0;
         }
         $set = Cache_ActivityHall::getInstance()->get_Activity_set(4011);
         if (!empty($set)) {
             $used_num = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "world_boss_count");
             #同步世界boss次数给c++
             $left_worldboss_num = $set[0]['max_times'] - $used_num;
             if ($left_worldboss_num < 0) {
                 $left_worldboss_num = 0;
             }
             $syndata['worldboss_remaining_count'] = $left_worldboss_num;
         } else {
             $syndata['worldboss_remaining_count'] = 0;
         }
         #神之试炼当前剩余次数
         $syndata['trial_of_god_remaining_cnt'] = $this->get_game('Trial')->get_left_times($player_id);
         #抢矿当前剩余次数
         $syndata['mineral_remaining_count'] = $this->get_game('GrabMine')->get_grabmine_remain_involved_num($player_id);
         #跨服切磋次数
         $syndata['kf_3vs3_remaining_count'] = $this->get_game('KFDuel')->get_left_times($player_id);
         #毁灭奥克兰次数
         $syndata['count_boss_oakland'] = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "count_boss_oakland");
         $syndata['count_monsters_oakland'] = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "count_monsters_oakland");
         $syndata['count_chest_oakland'] = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "count_chest_oakland");
     } else {
         $syndata['athena_remaining_count'] = 2;
         $syndata['worldboss_remaining_count'] = 2;
         $syndata['trial_of_god_remaining_cnt'] = 1;
         $syndata['mineral_remaining_count'] = 1;
         $syndata['kf_3vs3_remaining_count'] = 1;
         $syndata['count_boss_oakland'] = 0;
         $syndata['count_monsters_oakland'] = 0;
         $syndata['count_chest_oakland'] = 0;
     }
     if ($playerInfo['vip']) {
         $vip_info = $this->get_data('VipReward')->get_reward_log($player_id);
         $syndata['is_hidden_vip'] = isset($vip_info['is_hidden_vip']) ? $vip_info['is_hidden_vip'] : 0;
     } else {
         $syndata['is_hidden_vip'] = 0;
     }
     if ($playerInfo['privilege_level']) {
         #vip特权倒计时
         $syndata['privilege_left_time'] = $this->get_game('VipSpecial')->get_left_time($player_id);
     }
     #已开启翅膀
     $syndata['had_on_swings'] = $this->get_game('PlayerWing')->get_activation_wing_interface($player_id, $player_detail['wing_info']);
     //        $syndata['wing'] = "";
     //        $syndata['wing_skill_id'] = 0;
     //        var_dump($player_detail['wing_info']);
     # 魔法议会称号
     $magic_plm_title_id = $this->get_game('MagicParliament')->get_magic_parliament_title_id($player_id);
     if (!empty($magic_plm_title_id)) {
         $title_conf = Cache_MagicParliament::getInstance()->get_title_conf($magic_plm_title_id);
         $syndata['magic_plm_title_buff_id'] = $title_conf['buff_id'];
         $syndata['magic_plm_title_buff_expire_time'] = $this->get_game('MagicParliament')->get_magic_parliamen_flush_time();
     } else {
         $syndata['magic_plm_title_buff_id'] = 0;
         $syndata['magic_plm_title_buff_expire_time'] = 0;
     }
     $syndata['show_title'] = SHOW_TITLE;
     return $syndata;
 }
Пример #5
0
 public function get_battle_list($player_id)
 {
     $grab_domain_conf = Cache_UnionGrabDomain::getInstance()->get_base_conf();
     if (empty($grab_domain_conf)) {
         $this->throw_error(10222, 6010159);
     }
     $ntime = $time = time();
     $flush_time = strtotime('05:00');
     $week = $this->get_week($time);
     $time = $this->get_data('UnionGrabDomain')->get_revise_time($time);
     $wk = date('W', $time);
     $week_start = $grab_domain_conf['week_start'];
     $week_end = $grab_domain_conf['week_end'];
     $start_time = strtotime($grab_domain_conf['start_time']);
     $show = 0;
     $rank = 0;
     $score = 0;
     $battle_list = array();
     $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id');
     if ($union_id) {
         $grab_week_union_info = $this->get_data('UnionGrabDomain')->get_week_union_info($union_id, $wk);
         if ($grab_week_union_info) {
             $score = $grab_week_union_info['score'];
             $rank = $this->get_data('UnionGrabDomain')->get_my_rank($union_id);
             $round = 1;
             for ($i = $week_start; $i <= $week_end; $i++) {
                 $day = date('Ymd', $time + ($i - $week) * 86400);
                 $grab_union_info = $this->get_data('UnionGrabDomain')->get_union_info($day, $union_id);
                 if ($grab_union_info) {
                     $show = 1;
                     switch ($grab_union_info['result']) {
                         case 0:
                             //未打和进行中
                             if ($ntime < $flush_time) {
                                 $status = 0;
                                 $need_time = 0;
                             } elseif ($ntime < $start_time) {
                                 $status = 1;
                                 $need_time = $start_time - $ntime;
                             } else {
                                 $status = 2;
                                 $need_time = 0;
                             }
                             $day_score = 0;
                             break;
                         case 1:
                             //结束-胜利
                             $status = 3;
                             $need_time = 0;
                             $day_score = 3;
                             break;
                         case 2:
                             //结束-平
                             $status = 3;
                             $need_time = 0;
                             $day_score = 1;
                             break;
                         case 3:
                             //结束-失败
                             $status = 3;
                             $need_time = 0;
                             $day_score = 0;
                             break;
                     }
                     $opp_union_name = $this->get_data('UnionInfo')->get_union_info($grab_union_info['opp_union_id'], 'union_name');
                     $result = $grab_union_info['result'];
                 } else {
                     $status = 0;
                     $need_time = 0;
                     $opp_union_name = '暂无';
                     $result = 0;
                     $day_score = 0;
                 }
                 $temp['round'] = $round;
                 $temp['status'] = $status;
                 $temp['need_time'] = $need_time;
                 $temp['opp_union_name'] = $opp_union_name;
                 $temp['result'] = $result;
                 $temp['day_score'] = $day_score;
                 $battle_list[] = $temp;
                 $round++;
             }
         }
     }
     $num = $this->get_union_num();
     $set = Cache_ActivityHall::getInstance()->get_Activity_set(9095);
     /*if($num){
     			$show_content = sprintf($set[0]['show_content'],$num);
     		}else{
     			$show_content = '活动未开启';
     		}*/
     $ret = array('show' => $show, 'rank' => $rank, 'score' => $score, 'battle_list' => $battle_list, 'num' => $num, 'sid' => $set[0]['sid']);
     return $ret;
 }
Пример #6
0
 public function get_reward($player_id, $sid, $wave, $time, $friend)
 {
     $player_id = intval($player_id);
     $sid = intval($sid);
     $wave = intval($wave);
     $time = intval($time);
     if (!$sid || !$player_id) {
         $this->throw_error(10107, 2010009);
     }
     #判断次数
     $set = Cache_ActivityHall::getInstance()->get_Activity_set(4001);
     if (!empty($set)) {
         $max_time = $set[0]['max_times'];
     }
     $used = $this->get_athena_remaining_count($player_id, $sid);
     if ($used > $max_time) {
         #次数超过不发奖励
         $res = array();
         $res['sid'] = $sid;
         $res['wave'] = $wave;
         $res['time'] = $time;
         $res['reward'] = array();
         $res['new'] = 0;
         #是否创记录
         $res['old_wave'] = 0;
         $res['old_time'] = 0;
         Protocol::input($player_id, 8, 11, 1111, $res);
     }
     #添加好友亲密度
     $this->add_firend_point($player_id, $friend);
     $new = 1;
     $p_info = $this->get_data('Player')->get_player_info($player_id, array('gm'));
     #只记录普通账号记录
     if ($p_info['gm'] == 0 || $p_info['gm'] == 3) {
         #保存记录-------
         $insert_data = array('sid' => $sid, 'player_id' => $player_id, 'waves' => $wave, 'times' => $time, 'add_time' => time());
         $player_info = $this->get_data('Athena')->get_player_info($player_id, $sid);
         if (!empty($player_info) && isset($player_info['player_id'])) {
             #更新记录
             if ($player_info['waves'] < $wave || $player_info['waves'] == $wave && $time > $player_info['times']) {
                 $this->get_data('Athena')->update_player_info($player_id, $sid, $insert_data);
                 $new = 1;
             } else {
                 $new = 0;
             }
         } else {
             #添加记录
             if ($insert_data['waves'] > 0) {
                 $this->get_data('Athena')->update_player_info($player_id, $sid, $insert_data);
             }
             $player_info['waves'] = 0;
             $player_info['times'] = 0;
         }
     } else {
         $player_info['waves'] = 0;
         $player_info['times'] = 0;
     }
     #-----------
     $res = array();
     $res['sid'] = $sid;
     $res['wave'] = $wave;
     $res['time'] = $time;
     $res['reward'] = array();
     $res['new'] = $new;
     #是否创记录
     $res['old_wave'] = $player_info['waves'];
     $res['old_time'] = $player_info['times'];
     $rewards = Cache_Athena::getInstance()->get_athena_reward($sid);
     if ($rewards && $wave > 0) {
         $reward_ids = array();
         foreach ($rewards as $val) {
             if ($val['sid'] == $sid && $wave == $val['waves']) {
                 $reward_ids = explode('|', $val['rewards']);
             }
         }
         if (!empty($reward_ids)) {
             foreach ($reward_ids as $v) {
                 $temp = explode(':', $v);
                 if (count($temp) > 1) {
                     // $temp_reward= Cache_FbLoot::getInstance()->get_loot($temp[0]);
                     $temp_reward = array('type' => Cache_Currency::getInstance()->get_key($temp[0]), 'item_id' => $temp[0], 'item_num' => $temp[1]);
                     $vip_exp = $this->get_vip_add_exp($player_id);
                     #vip 增加经验收益
                     if ($temp[0] == 1) {
                         $temp_reward['item_num'] *= 1 + $vip_exp;
                     }
                     #vip 增加金币收益
                     if ($temp[0] == 3) {
                         $temp_reward['item_num'] *= 1 + $vip_exp;
                     }
                     array_push($res['reward'], $temp_reward);
                 } else {
                     $this->throw_error(10222, 2010010);
                 }
             }
         } else {
             $this->throw_error(10222, 2010012);
         }
         $_event_log = array('player_id' => $player_id, 'reg_time' => time(), 'map_id' => $sid, 'against_npc_num' => $wave);
         $this->get_game('Event')->async_deal_event_log($_event_log);
     } else {
         //$this->throw_error(10222);#配置表错误
         $res['reward'] = array();
     }
     $reward_log = array('sid' => $sid, 'player_id' => $player_id, 'rewards' => json_encode($res['reward']), 'static' => 0, 'waves' => $wave, 'times' => $time, 'add_time' => time());
     $res['reward_id'] = $this->get_data('Athena')->add_player_reward_log($reward_log);
     if ($res['reward_id'] > 0) {
         Protocol::input($player_id, 8, 11, 1111, $res);
         if ($wave > 0) {
             #公告广播
             $arr_replace = array();
             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
             $arr_replace[] = array('rep_type' => 7, 'txt' => $wave);
             $this->get_game('SystemNotice')->push_sys_notice($player_id, 4001, 0, $arr_replace, $wave);
         }
     } else {
         $this->throw_error(10110, 2010013);
     }
     #任务埋点
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 24, 1);
 }
Пример #7
0
 private function daily_task_rule_apply($player_id, $task_info)
 {
     if ($task_info['task_step_type'] == 100 || $task_info['task_step_type'] == 101) {
         # [主线|挑战]副本类型日常任务
         $rule = Cache_TaskDaily::getInstance()->get_task_daily_rule($task_info['task_step_type']);
         if (empty($rule)) {
             $this->throw_error('10019');
             # 日常任务特殊规则未配置
         }
         # 随机副本权重列表
         $weight_list = explode(":", $rule['rule_param2']);
         if (empty($weight_list) || $rule['rule_param1'] != count($weight_list)) {
             $this->throw_error('10020');
             # 日常任务特殊规则配置错误
         }
         if ($task_info['task_step_type'] == 100) {
             $map_list = $this->get_game('PlayerFB')->get_pass_fb_last_interface($player_id, $rule['rule_param1']);
             Com_Log::write('xgame.dailytask', "player_id:{$player_id}:task_step_type:100" . json_encode($map_list));
             if (empty($map_list)) {
                 #$this->throw_error('10021'); # 特定类型的日常任务无法生成
                 $map_info = Cache_PlayerFB::getInstance()->get_player_fb_info($this->task_first_fb_map_id);
                 $map_list[] = array('map_id' => $this->task_first_fb_map_id, 'difficulty' => $map_info['difficulty']);
             }
             # 考虑map_list可能少于weight_list,先去除无效的索引
             for ($i = count($map_list); $i < $rule['rule_param1']; $i++) {
                 unset($weight_list[$i]);
             }
             $rand_idx = Com_Random::get_probability_key($weight_list);
             # 随机一个索引
             $task_info['dup_id'] = $map_list[$rand_idx]['map_id'];
             # 要求通关的副本ID
             # 处理难度加星
             if (!empty($rule['rule_param3'])) {
                 $star_add_info = explode("|", $rule['rule_param3']);
                 $star_add_hash = array();
                 foreach ($star_add_info as $key => $val) {
                     list($difficulty, $star_add) = explode(":", $val);
                     $star_add_hash[$difficulty] = $star_add;
                 }
                 $task_info['star'] += $star_add_hash[$map_list[$rand_idx]['difficulty']];
             }
             # 处理要求通关的水平以及通关水平加星
             if (!empty($rule['rule_param4'])) {
                 $clear_grade_info = explode("|", $rule['rule_param4']);
                 $weight_hash = array();
                 $star_add_hash = array();
                 foreach ($clear_grade_info as $key => $val) {
                     list($clear_grade, $weight, $star_add) = explode(":", $val);
                     $weight_hash[$clear_grade] = $weight;
                     $star_add_hash[$clear_grade] = $star_add;
                 }
                 $rand_clear_grade = Com_Random::get_probability_key($weight_hash);
                 # 随机一个通关水平
                 $task_info['star'] += $star_add_hash[$rand_clear_grade];
                 $task_info['dup_cle_grade'] = $rand_clear_grade;
             }
             # 星级边界值修正
             $task_info['star'] = min($task_info['star'], $this->task_star_stint);
         } elseif ($task_info['task_step_type'] == 101) {
             $map_list = $this->get_game('PlayerPVE')->get_last_three_chapter_id($player_id, $rule['rule_param1']);
             Com_Log::write('xgame.dailytask', "task_step_type:101" . json_encode($map_list));
             if (empty($map_list)) {
                 #$this->throw_error('10021'); # 特定类型的日常任务无法生成
                 $map_list[] = $this->task_first_pve_map_id;
             }
             $map_list = array_reverse($map_list);
             # 倒序
             # 考虑map_list可能少于weight_list,先去除无效的索引
             for ($i = count($map_list); $i < $rule['rule_param1']; $i++) {
                 unset($weight_list[$i]);
             }
             $rand_idx = Com_Random::get_probability_key($weight_list);
             # 随机一个索引
             $task_info['dup_id'] = $map_list[$rand_idx];
             # 要求通关的副本ID
         }
     } else {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('level'));
         if ($task_info['task_step_type'] == 103) {
             # 守卫雅典娜副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 2);
         } elseif ($task_info['task_step_type'] == 104) {
             # 世界BOSS副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 1);
         } elseif ($task_info['task_step_type'] == 105) {
             # 抢矿副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 4);
         } elseif ($task_info['task_step_type'] == 116) {
             # 通关副本ID
             #$task_info['dup_id'] = $task_info['city_id'];
         } elseif ($task_info['task_step_type'] == 117) {
             $task_info['dialog_task_id'] = Cache_TaskDaily::getInstance()->get_task_daily_dialog_id($player_info['level']);
         } elseif ($task_info['task_step_type'] == 10) {
             # 随机一个关联的采集主线任务ID
             $main_task_id = Cache_TaskDaily::getInstance()->get_task_daily_collection_id($player_info['level']);
             $main_task_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($main_task_id, 1);
             if (empty($main_task_step_config) || !is_array($main_task_step_config)) {
                 Com_Log::write('xgame.dailytask', "task_step_type:10\t" . $main_task_id);
             } else {
                 $main_task_step_config['kill_npc_sid'] = $main_task_step_config['task_id'];
                 $task_info = array_merge($main_task_step_config, $task_info);
                 # 显示需要使用task_daily_base表的task_id,故而合并时,task_info靠后
             }
         }
     }
     return $task_info;
 }
Пример #8
0
 protected function get_start_time()
 {
     $open = Cache_ActivityHall::getInstance()->get_activity_info(8000);
     $start = strtotime($open['start_time']);
     $now = time();
     if ($now < $start) {
         return false;
     }
     return true;
 }
Пример #9
0
 public function get_max_time()
 {
     $hall_list = Cache_ActivityHall::getInstance()->get_Activity_set();
     if (empty($hall_list)) {
         return 0;
     }
     foreach ($hall_list as $v) {
         if ($v['category'] == 1) {
             return $v['max_times'];
         }
     }
     return 0;
 }
Пример #10
0
 /**
  * 结束
  * @param int $sid 活动id 
  * @param array $roles 玩家
  * @param array $mails 是否邮件发送奖励
  * @param int $kill_num 击杀boss数
  * @param int $time 时间
  * @param int $owner_id 房主
  * @param int $for_ranklist 0 结算,1 算排名
  */
 public function game_over($sid, $roles, $mails, $kill_num, $time, $owner_id = 0, $for_ranklist = 0, $roles_dmg = array(), $arr_kill_cnt = array(), $friends)
 {
     $sid = intval($sid);
     $kill_num = intval($kill_num);
     $time = intval($time);
     //排行榜处理
     if ($for_ranklist) {
         //Com_Log::write('zzzwanghui','roles:'.json_encode($roles).'-kill_num:'.$kill_num.'-time:'.$time.'-owner:'.$owner_id.'-dmg:'.json_encode($roles_dmg).'-kills:'.json_encode($arr_kill_cnt));
         if (!empty($roles) && count($roles) == count($arr_kill_cnt) && count($roles_dmg) == count($roles)) {
             $players = array();
             $i = 0;
             $owner_name = '';
             foreach ($roles as $player_id) {
                 if ($player_id > 0) {
                     $temp = $this->get_data('Player')->get_player_info($player_id, array('player_id', 'name', 'career_type', 'level'));
                     $player_info = array('player_id' => $temp['player_id'], 'name' => $temp['name'], 'career_type' => $temp['career_type'], 'level' => $temp['level'], 'sum_fpower' => $roles_dmg[$i], 'kill_num' => $arr_kill_cnt[$i]);
                     $players[] = $player_info;
                     if ($player_id == $owner_id) {
                         $owner_name = $temp['name'];
                     }
                     #添加好友亲密度
                     $this->get_game('Athena')->add_firend_point($player_id, $friends[$i]);
                 }
                 $i++;
             }
             $data = array('owner_id' => $owner_id, 'players' => json_encode($players), 'kill_num' => $kill_num, 'time' => $time, 'reptime' => time());
             $this->get_data('Trial')->update_team_info($data);
         }
         return true;
     }
     //参数判断
     if (!$sid || !is_array($roles) || !is_array($mails)) {
         $this->throw_error(10107, 6010010);
     }
     $p_num = count($roles);
     if ($p_num != count($mails)) {
         $this->throw_error(10107, 6010014);
     }
     //奖励
     $buff = Cache_Trial::getInstance()->get_buff($sid, $kill_num);
     $rewards = Cache_Trial::getInstance()->get_trial_reward();
     //次数
     $set = Cache_ActivityHall::getInstance()->get_Activity_set($sid);
     if (!empty($set)) {
         $max_time = $set[0]['max_times'];
     }
     $record_info = $this->get_data('Trial')->get_record_info($sid);
     for ($i = 0; $i < $p_num; $i++) {
         $player_id = $roles[$i];
         $used = $this->get_trial_remaining_count($player_id, $sid);
         if ($used > $max_time) {
             //次数超过限制
             if (!$mails[$i]) {
                 //在线
                 if ($record_info) {
                     $arr_player = $this->get_data('Player')->get_player_info($record_info['player_id'], array('name', 'career_type'));
                     $record_info['player_name'] = $arr_player['name'];
                     $record_info['career_type'] = $arr_player['career_type'];
                     unset($record_info['add_time']);
                 }
                 $res = array();
                 $res['sid'] = $sid;
                 $res['kill_num'] = $kill_num;
                 $res['time'] = $time;
                 $res['reward'] = array();
                 $res['new'] = 0;
                 #是否创记录
                 $res['old_num'] = 0;
                 $res['old_time'] = 0;
                 $res['record'] = $record_info;
                 $res['reward_id'] = 0;
                 Protocol::input($player_id, 8, 11, 1142, $res);
             }
         } else {
             $new = 1;
             $p_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'gm'));
             //只记录普通账号记录
             if ($p_info['gm'] == 0 || $p_info['gm'] == 3) {
                 $insert_data = array('sid' => $sid, 'player_id' => $player_id, 'kill_num' => $kill_num, 'time' => $time, 'add_time' => time());
                 if (0 == $i) {
                     if (!$record_info || ($record_info['kill_num'] < $kill_num || $record_info['kill_num'] == $kill_num && $time < $record_info['time'])) {
                         $record_info = array('sid' => $sid, 'player_id' => $player_id, 'kill_num' => $kill_num, 'time' => $time, 'add_time' => time());
                         $this->get_data('Trial')->update_record_info($sid, $record_info);
                     }
                 }
                 $player_trial = $this->get_data('Trial')->get_player_info($player_id, $sid);
                 if (!empty($player_trial) && isset($player_trial['player_id'])) {
                     //更新记录
                     if ($player_trial['kill_num'] < $kill_num || $player_trial['kill_num'] == $kill_num && $time < $player_trial['time']) {
                         $this->get_data('Trial')->update_player_info($player_id, $sid, $insert_data);
                         $new = 1;
                     } else {
                         $new = 0;
                     }
                 } else {
                     #添加记录
                     if ($insert_data['kill_num'] > 0) {
                         $this->get_data('Trial')->update_player_info($player_id, $sid, $insert_data);
                     }
                     $player_trial['kill_num'] = 0;
                     $player_trial['time'] = 0;
                 }
             }
             if (!($reward = Cache_Trial::getInstance()->get_reward($p_info['level'], $rewards))) {
                 $this->throw_error(10222, 6010011);
             }
             if ($record_info) {
                 $arr_player = $this->get_data('Player')->get_player_info($record_info['player_id'], array('name', 'career_type'));
                 $record_info['player_name'] = $arr_player['name'];
                 $record_info['career_type'] = $arr_player['career_type'];
                 unset($record_info['add_time']);
             }
             $res = array();
             $res['sid'] = $sid;
             $res['kill_num'] = $kill_num;
             $res['time'] = $time;
             $res['reward'] = array();
             $res['new'] = $new;
             #是否创记录
             $res['old_num'] = $player_trial['kill_num'];
             $res['old_time'] = $player_trial['time'];
             $res['record'] = $record_info;
             $reward_ids = explode('|', $reward);
             if ($reward_ids) {
                 if ($kill_num) {
                     foreach ($reward_ids as $value) {
                         $temp = explode(':', $value);
                         if (count($temp) > 1) {
                             $temp_reward = array('type' => Cache_Currency::getInstance()->get_key($temp[0]), 'item_id' => $temp[0], 'item_num' => $temp[1] * $buff);
                             array_push($res['reward'], $temp_reward);
                         } else {
                             $this->throw_error(10222, 6010015);
                         }
                     }
                 }
                 if ($mails[$i]) {
                     //下线发邮件
                     if ($kill_num) {
                         $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(4071);
                         $content = sprintf($phrase_config['content'], $kill_num);
                         $attachment = array();
                         foreach ($res['reward'] as $value) {
                             $attachment[] = array("prop_id" => $value['item_id'], "prop_num" => $value['item_num']);
                         }
                         $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $content, $attachment, $phrase_config['sender'], 1, 1142, 0);
                     }
                 } else {
                     if ($kill_num) {
                         $result = $this->get_game('Reward')->send_reward($player_id, $res['reward'], array('cmd_id' => 1142, 'bind_flag' => 0), 1);
                         if (true === $result) {
                             $this->get_game('Reward')->add_reward_log();
                             //记录日志
                             $res['reward_id'] = 1;
                         } else {
                             $this->throw_error(10110, 6010009);
                         }
                     } else {
                         $res['reward_id'] = 0;
                     }
                     Protocol::input($player_id, 8, 11, 1142, $res);
                 }
                 # 引导任务埋点
                 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 37, 1);
                 //添加活跃度
                 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 3012, 1);
             } else {
                 $this->throw_error(10222, 6010012);
             }
         }
     }
 }
Пример #11
0
 public function get_grabmine_remain_involved_num($player_id, $player_used_time = null)
 {
     if (is_null($player_used_time)) {
         $grabmine_involved_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grabmine_involved_num');
     } else {
         $grabmine_involved_num = $player_used_time['grabmine_involved_num'];
     }
     if (empty($grabmine_involved_num)) {
         $grabmine_involved_num = 0;
     }
     $activity_id = 4041;
     # 写死一个初级的
     $activity_info = Cache_ActivityHall::getInstance()->get_Activity_set($activity_id);
     $remain_involved_num = $activity_info[0]['max_times'] - $grabmine_involved_num;
     if ($remain_involved_num < 0) {
         $remain_involved_num = 0;
     }
     return $remain_involved_num;
 }