Exemplo n.º 1
0
 /**
  * 获取邮件列表
  * @param $player_id
  * @param $mail_id
  * @return null|array
  */
 public function get_mail_info($player_id)
 {
     $player_id = intval($player_id);
     $objmail = $this->get_data('PlayerMail');
     $data = $objmail->get_player_mail_info($player_id);
     Com_Array::multisort($data, array('createtime' => 'desc', 'state' => 'desc', 'isread' => 'asc'));
     $data = array_slice($data, 0, 50);
     $unread_num = 0;
     foreach ($data as $key => $val) {
         if ($val['expiretime'] <= time()) {
             unset($data[$key]);
             $ret = $objmail->del_player_mail($player_id, $val["mail_id"]);
             continue;
         }
         if ($val['isread'] == 0) {
             $unread_num++;
         }
         $countdown = $val['expiretime'] - time();
         $data[$key]['countdown'] = $countdown < 0 ? 0 : $countdown;
     }
     Com_Log::write('xgame.mail', "{$player_id}\t" . json_encode($data));
     #同步一下未读取数量
     $this->get_data('PlayerMail')->set_unread_mail_num($player_id, $unread_num);
     #Com_Log::write('xgame.mail', "$player_id\t".json_encode($data));
     return $data;
 }
Exemplo n.º 2
0
 public function get_item_compose_info($player_level)
 {
     if ($player_level <= 0) {
         return false;
     }
     #$sql = "select * from item_compose where req_lv <= $player_level order by sort_priority";
     $sql = "select * from item_compose where req_lv <= {$player_level}";
     $cache_lv = ceil($player_level / 10) * 10;
     $compose_list = $this->select_all($sql, $this->get_cache_key(array('req_lv' => $cache_lv)));
     $compose_info = array();
     # 升序排序
     Com_Array::multisort($compose_list, array('sort_priority' => 'asc'));
     # 列表结构转为哈希结构
     foreach ($compose_list as $index => $comp_info) {
         $compose_info[$comp_info['comp_type']][$comp_info['comp_sub_type']][$comp_info['target_id']] = $comp_info;
     }
     return $compose_info;
 }
Exemplo n.º 3
0
 public function get_wing_equips_for_swallow($player_id, $player_prop_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     $this->param_check_numeric(array($player_id));
     $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (empty($player_prop_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     $player_props = $this->get_data('PlayerProp')->get_player_prop_by_item_position($player_id, 1);
     Com_Array::multisort($player_props, array('quality' => 'desc', 'level' => 'desc'));
     # 过滤不允许该装备吞噬的装备
     $player_props = $this->filter_unvalid_props($player_prop_info, $player_props);
     $out_1514 = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => array()));
     foreach ($player_props as $k => $v) {
         $out_1514[1]['grid_list'][] = $v['grid'];
     }
     return $out_1514;
 }
Exemplo n.º 4
0
 /**
  * 获取随机任务列表
  */
 public function get_task_random_list($player_id, $task_info = null, $player_info = null)
 {
     if (is_null($task_info)) {
         $task_info = $this->get_data('PlayerTask')->get_task_info($player_id, array('random_val', 'random_refresh_time'));
     }
     if (is_null($player_info) || !isset($player_info['level'])) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('level'));
     }
     $out = array();
     $out['list'] = array();
     $now_time = time();
     $refresh_time = $task_info['random_refresh_time'] - $now_time;
     //        Com_Log::write("get_task_random_list.".$player_id,var_export($refresh_time,true));
     if ($refresh_time <= 0) {
         $task_info = $this->get_random_tasks($player_id);
         $refresh_time = $task_info['random_refresh_time'] - $now_time;
     }
     if ($task_info['random_val']) {
         Com_Array::multisort($task_info['random_val'], 'order', 'asc');
         foreach ($task_info['random_val'] as $val) {
             if (empty($val['task_id'])) {
                 continue;
             }
             $val['due_time'] = $val['due_time'] - $now_time;
             $val['due_time'] = $val['due_time'] > 0 ? $val['due_time'] : 0;
             $task_award = $this->get_award($player_info['level'], $val['quality'], $val['task_id']);
             $val['task_award'] = '';
             if ($task_award) {
                 foreach ($task_award as $award) {
                     if (!empty($val['task_award'])) {
                         $val['task_award'] .= "|" . $award['id'] . ":" . $award['num'];
                     } else {
                         $val['task_award'] .= $award['id'] . ":" . $award['num'];
                     }
                 }
             }
             $out['list'][] = $this->format_task_random_struct($val);
         }
     }
     $out['refresh_time'] = $refresh_time > 0 ? $refresh_time : 0;
     return $out;
 }
Exemplo n.º 5
0
 /**
  * 获取技能对应的符文列表信息
  * seq 指向
  * @param unknown $skill_id
  * @param unknown $skill_status >1表示已激活,0表示未激活
  * @param unknown $player_detail_skill_rune_info
  * @return boolean|multitype:NULL number Ambigous <boolean, unknown>
  */
 protected function get_skill_rune_list_info($skill_id, $skill_status, $skill_level, $player_detail_skill_rune_info, $func = null, $skill_rune_cote_info = null)
 {
     if (empty($player_detail_skill_rune_info)) {
         $player_detail_skill_rune_info = array();
     }
     $skill_rune_info = Cache_SkillRune::getInstance()->get_skill_rune_list_group($skill_id);
     # 按照符文序号排序
     Com_Array::multisort($skill_rune_info, array('rune_seq' => 'asc'));
     $seq = 0;
     $arr_data = array();
     $auto_active_rune_cote = array();
     # 需要自动激活的符文栏列表
     if (is_array($skill_rune_info)) {
         foreach ($skill_rune_info as $rinfo) {
             $data = array();
             $data['rune_id'] = $rinfo['sid'];
             # 符文激活状态:0未激活不可激活[序号靠前符文尚未激活];1未激活但可激活;2已激活
             if (isset($player_detail_skill_rune_info[$rinfo['sid']])) {
                 $data['flag'] = 2;
                 $data['rune_level'] = $player_detail_skill_rune_info[$rinfo['sid']]['level'];
                 $seq = $rinfo['rune_seq'];
             } elseif ($rinfo['rune_seq'] == $seq + 1 && !empty($skill_status) && $skill_level >= $rinfo['require_skill_level']) {
                 $data['flag'] = 1;
                 $data['rune_level'] = 1;
             } else {
                 $data['flag'] = 0;
                 $data['rune_level'] = 1;
             }
             # 符文栏激活状态:0未激活,1已激活
             $data['cote_status'] = 0;
             if (isset($skill_rune_cote_info[$rinfo['sid']])) {
                 # 已解锁的符文栏
                 $data['cote_status'] = 1;
             }
             if (empty($rinfo['consumption_item_id']) && empty($rinfo['comsumption_item_num'])) {
                 # 可自动解锁的符文栏
                 $data['cote_status'] = 1;
                 $auto_active_rune_cote[] = $rinfo['sid'];
             }
             # next_rune_id: 暂时无效,未知使用逻辑
             $data['next_rune_id'] = $rinfo['sid'];
             if (in_array($func, array(401, 405))) {
                 $arr_data[] = array('flag' => $data['flag'], 'rune_id' => $data['rune_id'], 'rune_level' => $data['rune_level']);
             } else {
                 $arr_data[] = array('rune_id' => $data['rune_id'], 'rune_level' => $data['rune_level'], 'next_rune_id' => $data['next_rune_id'], 'flag' => $data['flag'], 'cote_status' => $data['cote_status']);
             }
         }
     }
     return array($arr_data, $auto_active_rune_cote);
 }
Exemplo n.º 6
0
 public function get_rank()
 {
     $player_list = $this->redis()->zsets_all($this->cacheKeyPrefix_duel_team_rank, false, 0, 99, true);
     $total = count($player_list);
     if ($total) {
         $ret = array();
         foreach ($player_list as $player_id => $win) {
             $player_info = $this->get_data('Player')->get_player_info($player_id, array('player_id', 'name', 'career_type', 'level', 'union_name', 'sum_fpower'));
             $temp = array();
             $temp['player_id'] = $player_id;
             $temp['name'] = $player_info['name'];
             $temp['career_type'] = $player_info['career_type'];
             $temp['level'] = $player_info['level'];
             $temp['union_name'] = isset($player_info['union_name']) && $player_info['union_name'] ? $player_info['union_name'] : '无';
             $temp['sum_fpower'] = $player_info['sum_fpower'];
             $temp['win'] = $win;
             $ret[] = $temp;
         }
         if ($total > 1) {
             Com_Array::multisort($ret, array('win' => 'desc', 'sum_fpower' => 'desc'));
         }
         return $ret;
     } else {
         return array();
     }
 }
Exemplo n.º 7
0
 public function get_event_reward($player_id, $event_id, $reward_id, $event_template)
 {
     $this->param_check_numeric(array($player_id, $event_id, $reward_id));
     # 加锁失败
     if (!Com_Lock::lock("lock|get_event_reward|player_id={$player_id}")) {
         $this->throw_error('170501');
         # 系统繁忙
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level', 'map_id')));
     if ($player_info['map_id'] == 2100) {
         $this->throw_error('12012');
         # 请在完成序章后领取
     }
     # 获取活动配置
     $event_info = $this->get_data('Event')->get_event_info($event_id);
     if (empty($event_info) || empty($event_info['event_reward_info'])) {
         $this->throw_error('12004');
         # 无效的活动,未找到活动配置信息
     }
     $reward_id_array = explode(':', $event_info['event_reward_info']);
     if (!in_array($reward_id, $reward_id_array)) {
         $this->throw_error('12006');
         # 无效的奖励,未找到活动奖励配置信息
     }
     # NOTE: 因为允许在活动结束后领奖,所以领奖时不用活动开启时间段[open_date_head,open_date_tail]做检测
     if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) {
         $this->throw_error('12005');
         # 未到或已超过活动奖励领取时间
     }
     # 获取奖励配置
     $reward_info = $this->get_data('Event')->get_reward_info($reward_id);
     if (empty($reward_info) || empty($reward_info['cond_func'])) {
         $this->throw_error('12006');
         # 无效的奖励,未找到活动奖励配置信息
     }
     if (!empty($reward_info['valid_date_head']) || !empty($reward_info['valid_date_tail'])) {
         if ($reward_info['valid_date_head'] > $this->current_time || $reward_info['valid_date_tail'] < $this->current_time) {
             $this->throw_error('12007');
             # 未到或已超过活动奖励有效时间
         }
     }
     /**
     		# --------------------------------------------------------------------
     		# 活动领奖周期内的领奖次数上限判断
     		# --------------------------------------------------------------------
     		if (!empty($event_info['event_reward_stint']) && !empty($event_info['event_reward_cycle'])) {
     			# 向上取整获取最大领奖期数
     			$max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $event_info['event_reward_cycle']);
     			for($i = 1; $i <= $max_cycle; $i++) {
     				$cycle_head = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * ($i - 1); 	# 领奖周期首部时间
     				$cycle_tail = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * $i - 1;		# 领奖周期尾部时间,减一是为了相邻两个区间没有交集
     				if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内
     					continue; 
     				} else {
     					# 获取该周期内的领奖次数
     					list($reward_record, $reward_record_count) = $this->get_data('Event')->get_event_reward_record_part($player_id, $event_id, $cycle_head, $cycle_tail);
     					if ($reward_record_count >= $event_info['event_reward_stint']) {
     						$this->throw_error('12008'); # 已达到活动领奖周期内的领取次数上限
     					}
     					break;
     				}
     			}
     		}
     
     		# --------------------------------------------------------------------
     		# 奖励领奖周期内的领奖次数上限判断,NOTO:没有考虑循环奖励的领取上限不仅由reward_gain_stint决定,还由循环达成数loop_num决定
     		# --------------------------------------------------------------------
     		if (!empty($reward_info['reward_gain_stint']) && !empty($reward_info['reward_gain_cycle'])) {
     			# 向上取整获取最大领奖期数
     			$max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $reward_info['reward_gain_cycle']);
     			for($i = 1; $i <= $max_cycle; $i++) {
     				$cycle_head = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * ($i - 1); 	# 领奖周期首部时间
     				$cycle_tail = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * $i - 1;		# 领奖周期尾部时间,减一是为了相邻两个区间没有交集
     				if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内
     					continue; 
     				} else {
     					# 获取该周期内的领奖次数
     					list($reward_record, $reward_record_count) = $this->get_data('Event')->exactly_get_event_reward_record_part($player_id, $event_id, $reward_id, $cycle_head, $cycle_tail);
     					if ($reward_record_count >= $reward_info['reward_gain_stint']) {
     						$this->throw_error('12009'); # 已达到奖励领奖周期内的领取次数上限
     					}
     					break;
     				}
     			}
     		}
     		**/
     # 进度计算
     $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']);
     $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params);
     # 剩余领奖次数计算
     list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward_info, $ret);
     if (empty($real_remain_gain_num)) {
         $this->throw_error('12009');
         # 已达到奖励领奖周期内的领取次数上限
     }
     # --------------------------------------------------------------------
     # 奖励达成条件判断
     # --------------------------------------------------------------------
     # 进度计算
     $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']);
     $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params);
     if (empty($ret['status'])) {
         $this->throw_error('12010');
         # 未达到奖励的领取条件
     }
     # --------------------------------------------------------------------
     # 发奖 + 消耗道具 + 并刷新奖励信息
     # --------------------------------------------------------------------
     $this->start_trans();
     # 消耗道具
     if (!empty($reward_info['consume_info'])) {
         $consume_currency = false;
         $arr_logs_consume = array();
         $reward_item_info_arr = explode("|", $reward_info['consume_info']);
         $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2304);
         foreach ($reward_item_info_arr as $item_info) {
             list($item_id, $item_num) = explode(":", $item_info);
             $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id);
             if ($item_key == 'prop') {
                 # 消耗道具
                 # deduct_prop_by_prop_id方法中有判断道具是否足够,故外层不判断
                 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $item_id, $item_num, $arr_logs_consume, 0, $log_param);
                 $this->write_check($re, 3010311);
             } else {
                 # 消耗资源
                 $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $item_key, $item_num);
                 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $item_key, $item_num, 1, $item_id);
                 $consume_currency = true;
             }
         }
         if ($consume_currency) {
             $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2304', array(), $arr_consume);
             $this->write_check($re, 3010332);
         }
     }
     # 奖励道具
     $reward = array();
     $reward_detail = array();
     if (!empty($reward_info['reward_info'])) {
         $reward_item_info_arr = explode("|", $reward_info['reward_info']);
         foreach ($reward_item_info_arr as $item_info) {
             list($item_id, $item_num, $item_tag) = explode(":", $item_info);
             $reward_detail[$item_id] = $item_num;
         }
     }
     $this->get_game('Reward')->gen_reward_array($reward_detail, $reward);
     $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2304', 'bind_flag' => 0));
     $this->write_check_strict($re, 3010347);
     # 记录奖励领取日志
     $re = $this->get_data('Event')->record_player_event_reward($player_id, $event_id, $reward_id, $this->current_time);
     $this->write_check($re, 3010351);
     $this->commit();
     # 蛋疼的次数同步埋点
     if ($event_template == 2) {
         # 充值回馈需要同步次数变更
         $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260);
     }
     # 粘806 + 通知道具变更信息
     $ndata = array();
     if (!empty($arr_logs_consume)) {
         foreach ($arr_logs_consume as $k => $v) {
             # 消耗的道具
             $ndata[] = $v;
         }
         Protocol_Prop::prop_806($player_id, $ndata);
     }
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $ret = $this->get_game('Reward')->add_reward_log(true);
     #-----------------------------------------------------------------
     # 重新获取奖励项列表
     #-----------------------------------------------------------------
     $event_reward_list = array();
     $special_reward_list = array();
     if (!empty($event_info['event_reward_info'])) {
         $reward_id_array = explode(':', $event_info['event_reward_info']);
         #echo "</br>===============".$event_info['event_id']."==================</br>";
         #var_export($reward_id_array);
         $reward_info = $this->get_data('Event')->multi_get_reward_info($reward_id_array);
         #var_export($reward_info);
         # 对奖励列表升序排序
         Com_Array::multisort($reward_info, array('reward_priority' => 'asc'));
         foreach ($reward_info as $reward) {
             #echo "</br>===============reward_id:".$reward['reward_id']."==================</br>";
             # 获取奖励的具体道具列表
             $reward_item_list = array();
             if (!empty($reward['reward_info'])) {
                 $reward_item_info_arr = explode("|", $reward['reward_info']);
                 foreach ($reward_item_info_arr as $item_info) {
                     list($item_id, $item_num, $item_tag) = explode(":", $item_info);
                     $item_config = Cache_Prop::getInstance()->get_prop_info($item_id);
                     $item_config['item_num'] = $item_num;
                     $item_struct = Struct_Prop::get_prop_struct($item_config);
                     $reward_item_list[$item_id] = $item_struct;
                     if ($item_tag == $this->reward_item_tag_for_special) {
                         $special_reward_list[$item_id] = $item_struct;
                     }
                 }
             }
             # 进度计算
             $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward['reward_id'], 'reward_type' => $reward['reward_type'], 'reward_billing_cycle' => $reward['reward_billing_cycle']);
             $ret = $this->call_cond_func($player_id, $reward['cond_func'], $reward['cond_func_relation'], $sys_params);
             # 剩余领奖次数计算
             list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward, $ret);
             # 领奖状态判定
             if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) {
                 $reward_status = 0;
                 # 未到或已超过活动奖励领取时间
             } elseif ((!empty($reward['valid_date_head']) || !empty($reward['valid_date_tail'])) && ($reward['valid_date_head'] > $this->current_time || $reward['valid_date_tail'] < $this->current_time)) {
                 $reward_status = 0;
                 # 未到或已超过活动奖励有效时间
             } elseif (empty($real_remain_gain_num)) {
                 # 用实际剩余领奖次数判断领奖状态
                 $reward_status = 0;
             } else {
                 $reward_status = $ret['status'];
             }
             # 可领奖总数计算
             if ($reward_status) {
                 $can_receive_reward_num += 1;
             }
             $event_reward_list[] = array('reward_id' => $reward['reward_id'], 'reward_cond' => $reward['cond_desc'], 'reward_item_list' => $reward_item_list, 'reward_progress_head' => $ret['progress_head'], 'reward_progress_tail' => $ret['progress_tail'], 'reward_remain_gain_num' => $reward_remain_gain_num, 'reward_status' => $reward_status, 'reward_type' => $reward['reward_type'], 'consume_info' => $reward['consume_info'], 'reward_gain_stint' => $config_gain_stint);
         }
     }
     $out_2304 = array('event_tag' => $event_info['event_tag'], 'event_id' => $event_id, 'event_reward_list' => $event_reward_list, 'event_template' => $event_template);
     # 记录行为
     Com_Log::write('xgame.event', "{$player_id}\t" . "get_event_reward\t" . "{$event_id}\t" . "{$reward_id}\t");
     return $out_2304;
 }
Exemplo n.º 8
0
 /**
  * 公会成员
  * 
  */
 public function union_player_list($union_id, $page = 1, $num = 10)
 {
     $union_id = intval($union_id);
     $page = intval($page);
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $unionPlayerList = $objUnionPlayerData->get_union_player_info($union_id);
     $player_list = array();
     $all_list = array();
     if ($unionPlayerList) {
         $objPlayerData = $this->get_data('Player');
         foreach ($unionPlayerList as $player_id => $value) {
             $playerInfo = $objPlayerData->get_player_info($player_id, array("login_time", "name", "level", "is_online", "vip"));
             $today_dedicate = $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "union_player_contribute");
             $all_list[$player_id] = array('player_id' => $player_id, 'vip' => intval($playerInfo['vip']), 'name' => $playerInfo['name'], 'level' => $playerInfo['level'], 'job_id' => intval($value['job_id']), 'today_dedicate' => intval($today_dedicate), 'total_dedicate' => intval($value['total_dedicate']), 'login_time' => $playerInfo['login_time'], 'is_online' => $playerInfo['is_online'], 'add_time' => $value['add_time']);
             $his_total_dedicate = intval($value['his_total_dedicate']);
             if (intval($value['his_total_dedicate']) == 0) {
                 if ($all_list[$player_id]['today_dedicate'] > $all_list[$player_id]['total_dedicate']) {
                     $his_total_dedicate = $all_list[$player_id]['today_dedicate'];
                 } else {
                     $his_total_dedicate = $all_list[$player_id]['total_dedicate'];
                 }
                 $value['his_total_dedicate'] = intval($his_total_dedicate);
                 if ($value['his_total_dedicate'] > 0) {
                     $this->get_data("UnionPlayer")->update_union_player_info($union_id, $player_id, $value);
                 }
             }
             $is_hidden_vip = 0;
             if (intval($playerInfo['vip']) > 0) {
                 $vip_info = $this->get_data('VipReward')->get_reward_log($player_id);
                 $is_hidden_vip = $vip_info['is_hidden_vip'];
             }
             $all_list[$player_id]['his_total_dedicate'] = intval($his_total_dedicate);
             $all_list[$player_id]['is_hidden_vip'] = $is_hidden_vip;
         }
         $alllist = Com_Array::multisort($all_list, array('is_online' => 'desc', 'job_id' => 'asc', 'level' => 'desc', 'today_dedicate' => 'desc', 'total_dedicate' => 'desc'));
         $player_list = $this->get_page_list($all_list, $page, $num);
     }
     $max_page = count($all_list) > 0 ? ceil(count($all_list) / $num) : 1;
     $data = array();
     $data['list'] = $player_list;
     $data['now_time'] = time();
     $data['page'] = $page;
     $data['max_page'] = $max_page;
     return $data;
 }
Exemplo n.º 9
0
 /**
  * 多维排序
  * @param $limit_num 数量
  * @return int
  */
 public function get_total_rank_list_by_multisort($limit_num = 99)
 {
     $data = array();
     $rank_list = $this->redis()->zsets_all($this->_cacheKeyKfDuelTotalRank, false, 0, $limit_num);
     if ($rank_list) {
         foreach ($rank_list as $player_id) {
             $player_info = $this->get_player_info($player_id);
             $data[] = $player_info;
         }
         if (count($data) > 1) {
             Com_Array::multisort($data, array('score' => 'desc', 'sum_fpower' => 'desc'));
         }
     }
     return $data;
 }
Exemplo n.º 10
0
 public function get_main_dungeon_rank_cache($real_time = false)
 {
     $main_dungeon_list = array();
     if ($real_time) {
         $list = $this->redis()->zsets_all($this->main_dungeon_rank, false, 0, 99, true);
         if (!empty($list) && Com_Array::is_good_arr($list)) {
             foreach ($list as $player_id => $star) {
                 $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type', 'sum_fpower', 'level'));
                 $main_dungeon_list[$player_id] = array('player_id' => $player_id, 'name' => $player_info['name'], 'career_type' => $player_info['career_type'], 'level' => $player_info['level'], 'star' => $star, 'fight' => $player_info['sum_fpower']);
             }
         }
     } else {
         $rank_list = $this->redis()->hash_get($this->main_dungeon_rank_cache);
         $main_dungeon_list = $rank_list['main_dungeon_rank'];
         if (empty($main_dungeon_list)) {
             $main_dungeon_list = $this->update_main_dungeon_rank_cache();
         }
         $main_dungeon_list = Com_FmtData::cus_json_decode($main_dungeon_list);
     }
     if (Com_Array::is_good_arr($main_dungeon_list)) {
         Com_Array::multisort($main_dungeon_list, array('star' => 'desc', 'fight' => 'desc'));
     }
     return empty($main_dungeon_list) ? $main_dungeon_list : array_values($main_dungeon_list);
 }
Exemplo n.º 11
0
 /**
  * @Purpose:
  * 内部获取翅膀装备最大强化等级
  * @Param $player_id 玩家ID
  * @Param $level_type 等级类型(1:强化等级)
  */
 public function get_wing_equip_level_max($player_id, $level_type)
 {
     $player_id = intval($player_id);
     $level_type = intval($level_type);
     $max_level = 0;
     $type_list = array(1 => 'intensive_level');
     $equipment_list = array();
     $equipment_list1 = $this->get_prop_list_by_type($player_id, $this->wing_type);
     $equipment_list2 = $this->get_prop_list_by_type($player_id, $this->wing_type, 0, $this->wing_pos);
     if (!empty($equipment_list1) && Com_Array::is_good_arr($equipment_list1)) {
         if (!empty($equipment_list2) && Com_Array::is_good_arr($equipment_list2)) {
             $equipment_list = array_merge($equipment_list1, $equipment_list2);
         } else {
             $equipment_list = $equipment_list1;
         }
     } else {
         $equipment_list = $equipment_list2;
     }
     if (Com_Array::is_good_arr($equipment_list)) {
         Com_Array::multisort($equipment_list, array($type_list[$level_type] => 'desc'));
         $equipment = reset($equipment_list);
         if (!empty($equipment)) {
             if ($equipment[$type_list[$level_type]] > $max_level) {
                 $max_level = $equipment[$type_list[$level_type]];
             }
         }
     }
     return $max_level;
 }
Exemplo n.º 12
0
 /**
  * 多维排序
  * @return array
  */
 public function get_rank_list_by_multisort()
 {
     $time = $this->get_revise_time();
     $week = date('W', $time);
     $data = array();
     $rank_list = $this->redis()->zsets_all($this->get_adcache_key($week, 5), false);
     if ($rank_list) {
         foreach ($rank_list as $union_id) {
             $item = $this->get_data('UnionInfo')->get_union_info($union_id, array('create_player_id', 'create_player_name'));
             $union_info = $this->get_week_union_info($union_id, $week);
             $union_info['create_player_id'] = $item['create_player_id'];
             $union_info['create_player_name'] = $item['create_player_name'];
             $data[] = $union_info;
         }
         if (count($data) > 1) {
             Com_Array::multisort($data, array('score' => 'desc', 'union_level' => 'desc', 'sum_fpower' => 'desc'));
         }
     }
     return $data;
 }
Exemplo n.º 13
0
 /**
  * 综合战力面包
  * @param $player_id
  */
 public function get_global_panel($player_id)
 {
     $out = array('grade_total' => 0, 'target_grade_power' => 0, 'compare' => 0, 'grade_list' => array());
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('sum_fpower', 'level'));
     $grade = $this->get_power_grade(0, $player_info['sum_fpower'], $player_info['level']);
     $out['grade_total'] = $grade;
     $next_power = $this->get_next_power_grade(0, $grade, $player_info['level']);
     $out['target_grade_power'] = $next_power - $player_info['sum_fpower'];
     $out['target_grade_power'] = $out['target_grade_power'] < 0 ? 0 : $out['target_grade_power'];
     $all_num = $this->get_data('Player')->get_player_num();
     $all_fpower_num = $this->get_data('Player')->get_player_num_by_fpower(intval($player_info['sum_fpower']));
     $out['compare'] = $all_fpower_num / $all_num * 100;
     $arr_order = array();
     $data = $this->get_equip_panel($player_id);
     $arr_order[1] = array('type' => 1, 'grade' => $data['grade']['grade']);
     $equip = reset($data['equip'][0]['advise']);
     $out['grade_list'][1] = array('grade' => $data['grade'], 'commend_type' => $equip['advise'][0]['recommend'], 'advise' => $equip['advise'][0]['desc'], 'func_id' => $equip['advise'][0]['btn_func_id'], 'func_param' => $equip['advise'][0]['btn_params']);
     $data = $this->get_skill_panel($player_id);
     $arr_order[2] = array('type' => 2, 'grade' => $data['grade']['grade']);
     if ($data['skill_advise'][0]) {
         $skill = $data['skill_advise'][0];
     } elseif ($data['dower_advise'][0]['advise']) {
         $skill = $data['dower_advise'][0];
     } else {
         $skill = array();
     }
     $out['grade_list'][2] = array('grade' => $data['grade'], 'commend_type' => $skill['advise'][0]['recommend'], 'advise' => $skill['advise'][0]['desc'], 'func_id' => $skill['advise'][0]['btn_func_id'], 'func_param' => $skill['advise'][0]['btn_params']);
     $data = $this->get_fairy_panel($player_id);
     $arr_order[3] = array('type' => 3, 'grade' => $data['grade']['grade']);
     if (!empty($data['girls'][0]['advise'])) {
         $girls = reset($data['girls'][0]['advise']);
     } else {
         $girls = array();
     }
     $out['grade_list'][3] = array('grade' => $data['grade'], 'commend_type' => $girls['advise'][0]['recommend'], 'advise' => $girls['advise'][0]['desc'], 'func_id' => $girls['advise'][0]['btn_func_id'], 'func_param' => $girls['advise'][0]['btn_params']);
     $data = $this->get_hero_panel($player_id);
     $arr_order[4] = array('type' => 4, 'grade' => $data['grade']['grade']);
     if (!empty($data['empty_heroes'])) {
         $heroes['advise'][0] = reset($data['empty_heroes'][0]['advise']);
     } else {
         $heroes = reset($data['heroes'][0]['advise']);
     }
     $out['grade_list'][4] = array('grade' => $data['grade'], 'commend_type' => $heroes['advise'][0]['recommend'], 'advise' => $heroes['advise'][0]['desc'], 'func_id' => $heroes['advise'][0]['btn_func_id'], 'func_param' => $heroes['advise'][0]['btn_params']);
     $data = $this->get_wing_panel($player_id);
     $arr_order[5] = array('type' => 5, 'grade' => $data['grade']['grade']);
     $wing = reset($data['wings'][0]['advise']);
     $out['grade_list'][5] = array('grade' => $data['grade'], 'commend_type' => $wing['advise'][0]['recommend'], 'advise' => $wing['advise'][0]['desc'], 'func_id' => $wing['advise'][0]['btn_func_id'], 'func_param' => $wing['advise'][0]['btn_params']);
     $data = $this->get_sq_panel($player_id);
     $arr_order[6] = array('type' => 6, 'grade' => $data['grade']['grade']);
     $sqs = reset($data['sps'][0]['advise']);
     $out['grade_list'][6] = array('grade' => $data['grade'], 'commend_type' => $sqs['advise'][0]['recommend'], 'advise' => $sqs['advise'][0]['desc'], 'func_id' => $sqs['advise'][0]['btn_func_id'], 'func_param' => $sqs['advise'][0]['btn_params']);
     $arr_order = Com_Array::multisort($arr_order, array('grade' => 'asc'));
     $i = 0;
     foreach ($arr_order as $val) {
         if ($i < 2) {
             $out['grade_list'][$val['type']]['commend_type'] = 1;
         } else {
             $out['grade_list'][$val['type']]['commend_type'] = 0;
         }
         ++$i;
     }
     return $out;
 }
Exemplo n.º 14
0
 public function get_cond_ids($player_id, $allow_empty = 0, $player_info = null)
 {
     if (is_null($player_info) || !isset($player_info['level']) || !isset($player_info['vip'])) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip'));
     }
     //		Com_Log::write('xgame.questionnaire', "get_cond_ids\t".var_export($player_info, true));
     $questionnaire_list = $this->get_data('ActivityQuestions')->get_questionnaire_list_for_open($player_id, $player_info['level'], $player_info['vip'], 2);
     //		Com_Log::write('xgame.questionnaire', "get_cond_ids\t".var_export($questionnaire_list, true));
     if (empty($questionnaire_list)) {
         if ($allow_empty) {
             Protocol::input($player_id, 8, 7, 7001, array(0 => array()));
         }
         return;
     }
     $questionnaire_log = $this->get_data('ActivityQuestions')->get_log_ids($player_id);
     foreach ($questionnaire_list as $questionnaire_id => $val) {
         if (isset($questionnaire_log[$questionnaire_id])) {
             unset($questionnaire_list[$questionnaire_id]);
         }
     }
     if (empty($questionnaire_list)) {
         if ($allow_empty) {
             Protocol::input($player_id, 8, 7, 7001, array(0 => array()));
         }
         return;
     }
     # 多余一份时,只取start_level最大的一份推送
     Com_Array::multisort($questionnaire_list, array('start_level' => 'desc'));
     $need_questionnaire = reset($questionnaire_list);
     $out_7001[] = array($need_questionnaire['questionnaire_id']);
     Protocol::input($player_id, 8, 7, 7001, $out_7001);
     //		Com_Log::write('xgame.questionnaire', "get_cond_ids\t".var_export($out_7001, true));
 }
Exemplo n.º 15
0
 public function fund_income($player_id, $fund_id, $income_offset)
 {
     $this->param_check_numeric(array($player_id, $fund_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level'));
     # 获取基金配置信息
     $fund_conf = Cache_Finance::getInstance()->get_fund_conf($fund_id);
     if (empty($fund_conf)) {
         $this->throw_error(110001);
         # 获取基金信息失败
     }
     # 获取玩家某种类型基金的投资情况
     list($invest_acc, $invest_lvl, $invest_time) = $this->get_data('Finance')->get_player_fund_invest_log_by_type($player_id, $fund_conf['fund_type']);
     # 获取玩家某种类型基金的收益情况
     list($income_log_hash_1, $income_log_hash_2) = $this->get_data('Finance')->get_player_fund_income_log_by_type($player_id, $fund_conf['fund_type']);
     # 获取基金收益配置信息
     switch ($fund_conf['fund_type']) {
         case 1:
             # 时间基金
             $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_time($fund_conf['fund_id']);
             $current_income_offset = $this->_cal_income_offset($invest_time);
             break;
         case 2:
             # 等级基金
             if (!empty($invest_lvl)) {
                 $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_level_2($fund_conf['fund_id'], $invest_lvl);
             } else {
                 $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_level_2($fund_conf['fund_id'], $player_info['level']);
             }
             $current_income_offset = $player_info['level'];
             break;
         default:
             $income_conf_list = array();
             break;
     }
     # 判断达成条件
     if ($current_income_offset < $income_offset) {
         $this->throw_error(110002);
         # 未达成该档基金收益领取条件
     }
     # 判断是否已领取过
     if (isset($income_log_hash_1[$fund_id][$income_offset])) {
         $this->throw_error(110003);
         # 已领取过该档基金收益
     }
     # 判断是发直接收益,还是补差收益
     $income_type = 0;
     $income_num = 0;
     if (isset($income_log_hash_2[$income_offset])) {
         $income_type = 1;
         # 按价格由高到低排序
         Com_Array::multisort($income_log_hash_2[$income_offset], array('fund_price' => 'desc'));
         $income_log_info = reset($income_log_hash_2[$income_offset]);
         $income_num = $income_conf_list[$income_offset]['income'] - $income_log_info['income_num'];
     } else {
         $income_num = $income_conf_list[$income_offset]['income'];
     }
     $this->start_trans();
     # 发放免费奖励
     $reward = array(array('type' => 'ticket', 'item_id' => $this->fund_income_cur_id, 'item_num' => $income_num));
     if (!empty($reward)) {
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2704'), 1);
         $this->write_check_strict($re, 3010411);
     }
     # 记录收益领取日志
     $income_log = array('player_id' => $player_id, 'fund_id' => $fund_id, 'income_offset' => $income_offset, 'fund_type' => $fund_conf['fund_type'], 'fund_price' => $fund_conf['fund_price'], 'income_time' => $this->current_time, 'income_num' => $income_num, 'income_type' => $income_type);
     $re = $this->get_data('Finance')->insert_fund_income_log($income_log);
     $this->write_check($re, 3010277);
     $this->commit();
     # 刷新基金列表
     $out_2701 = $this->get_fund_list($player_id, $fund_conf['fund_type']);
     Protocol::input($player_id, 3, 27, 2701, $out_2701);
     # 记录行为
     Com_Log::debug_write('xgame.finance', "{$player_id}\t" . "fund_income\t" . "{$fund_id}\t" . "{$income_offset}\t");
     $out_2704 = array('fund_type' => $fund_conf['fund_type']);
     return $out_2704;
 }
Exemplo n.º 16
0
 /**
  * 发送未主动领取的排名奖励
  * @param $offset 偏移量 多少分钟之前
  * @return bool 
  */
 public function send_mail_rank_reward($offset = 0)
 {
     if (!$offset) {
         $offset = 60;
     }
     $time = time() - $offset * 60;
     //$time = strtotime('2015-07-07 20:10:00');//test
     //配置
     $kf_duel_conf = Cache_CrossDuel::getInstance()->get_battle_conf(41001);
     //时间
     $hi = date('H:i', $time);
     if ($hi >= $kf_duel_conf['reward_time']) {
         return true;
     }
     //周几
     $week = date('w', $time);
     if (!$week) {
         //周日
         $week = 7;
     }
     $conf_week = explode(',', $kf_duel_conf['reward_day_of_week']);
     if (!in_array($week, $conf_week)) {
         return true;
     }
     //几点结算
     $reward_time = explode(':', $kf_duel_conf['reward_time']);
     $rhour = $reward_time[0];
     $pre_settle_date = Cache_CrossDuel::getInstance()->get_pre_settle_time($time);
     $rday = substr($pre_settle_date, 4, 2);
     $all_rank = $this->get_cross('KFDuel')->get_rank($pre_settle_date);
     if ($all_rank) {
         $rank = 0;
         $top_num = 0;
         $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(12);
         $top_list = array();
         //100名以后
         foreach ($all_rank as $player_id) {
             $rank++;
             $player_info = $this->get_cross('KFDuel')->get_cross_player_info($player_id, $pre_settle_date);
             if ($player_info) {
                 if ($rank <= 100) {
                     //前100多维排序
                     $top_list[] = $player_info;
                     $top_num++;
                     continue;
                 }
                 if ($player_info['server_id'] == SERVER_ID) {
                     if (!$player_info['reward_status']) {
                         $rank_reward_str = Cache_CrossDuel::getInstance()->get_config_rank_reward($player_info['sid'], $player_info['player_level']);
                         $rank_reward_add_str = Cache_CrossDuel::getInstance()->get_config_rank_reward_add($player_info['sid'], $rank);
                         $reward_detail = $this->get_game('Reward')->get_reward_detail_other_way($rank_reward_str, $rank_reward_add_str, 1);
                         //发邮件
                         $content = sprintf($phrase_config['content'], $rday, $rhour, $rank);
                         $attachment = array();
                         foreach ($reward_detail as $key => $val) {
                             $attachment[] = array("prop_id" => $key, "prop_num" => $val);
                         }
                         $this->get_game('Mail')->async_trigger_mail($player_info['player_id'], $phrase_config['title'], $content, $attachment, $phrase_config['sender'], 1, 1235, 0);
                         $update['reward_status'] = 1;
                         $this->get_cross('KFDuel')->set_kf_duel_rank($player_info['player_id'], $pre_settle_date, $update, false);
                     }
                     $this->get_cross('KFDuel')->set_player_expire($player_info['player_id'], $pre_settle_date);
                     //设置玩家信息过期时间
                 }
             }
         }
         //前100名
         if ($top_list) {
             if ($top_num > 1) {
                 Com_Array::multisort($top_list, array('score' => 'desc', 'sum_fpower' => 'desc'));
             }
             $rank = 1;
             foreach ($top_list as $player_info) {
                 if ($player_info['server_id'] == SERVER_ID) {
                     if (!$player_info['reward_status']) {
                         $rank_reward_str = Cache_CrossDuel::getInstance()->get_config_rank_reward($player_info['sid'], $player_info['player_level']);
                         $rank_reward_add_str = Cache_CrossDuel::getInstance()->get_config_rank_reward_add($player_info['sid'], $rank);
                         $reward_detail = $this->get_game('Reward')->get_reward_detail_other_way($rank_reward_str, $rank_reward_add_str, 1);
                         //发邮件
                         $content = sprintf($phrase_config['content'], $rday, $rhour, $rank);
                         $attachment = array();
                         foreach ($reward_detail as $key => $val) {
                             $attachment[] = array("prop_id" => $key, "prop_num" => $val);
                         }
                         $this->get_game('Mail')->async_trigger_mail($player_info['player_id'], $phrase_config['title'], $content, $attachment, $phrase_config['sender'], 1, 1235, 0);
                         $update['reward_status'] = 1;
                         $this->get_cross('KFDuel')->set_kf_duel_rank($player_info['player_id'], $pre_settle_date, $update, false);
                     }
                     $this->get_cross('KFDuel')->set_player_expire($player_info['player_id'], $pre_settle_date);
                     //设置玩家信息过期时间
                 }
                 $rank++;
             }
         }
         $this->get_cross('KFDuel')->set_rank_expire($pre_settle_date);
         //设置排名过期时间
     }
     return true;
 }
Exemplo n.º 17
0
 public function get_fund_deal_log($player_id)
 {
     # 获取全服所有玩家基金的投资日志
     $deal_log_list = $this->get_data('Finance')->get_all_player_fund_deal_log();
     # 获取全服所有玩家基金的收益日志
     $income_log_list = $this->get_data('Finance')->get_all_player_fund_income_log();
     # 合并投资与收益日志 && 按时间倒序排序
     $log_list = array_merge($deal_log_list, $income_log_list);
     Com_Array::multisort($log_list, array('reg_time' => 'desc'));
     #var_export($log_list);
     $log_history = array();
     if (!empty($log_list)) {
         $fund_type_name_hash = Cache_Finance::getInstance()->get_fund_type_name_hash();
         foreach ($log_list as $log) {
             $pinfo = $this->get_data('Player')->get_player_info($log['player_id'], array('name'));
             $reg_time = date('m-d H:i', $log['reg_time']);
             if (isset($log['deal_time'])) {
                 $code = 110011;
                 # 基金存入消息提示内容
                 $reward_list = array(array('txt' => '', 'type' => 2, 'value' => $this->fund_invest_cur_id, 'param' => $log['invest_num']));
             } elseif (isset($log['income_time'])) {
                 $code = 110012;
                 # 基金收益消息提示内容
                 $reward_list = array(array('txt' => '', 'type' => 2, 'value' => $this->fund_income_cur_id, 'param' => $log['income_num']));
             }
             $params = array(array(array('txt' => '', 'type' => 7, 'value' => $reg_time, 'param' => '')), array(array('txt' => $pinfo['name'], 'type' => 0, 'value' => $log['player_id'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $fund_type_name_hash[$log['fund_type']], 'param' => '')), $reward_list);
             $dynamic_text = array('code' => $code, 'content' => array(), 'params' => $params);
             $log_history[] = $dynamic_text;
         }
     }
     $out_2702 = array('log_history' => $log_history);
     return $out_2702;
 }
Exemplo n.º 18
0
 public function reset_reward($reward, $prop, $player_id)
 {
     if (!empty($reward)) {
         Com_Array::multisort($reward, array('item_id' => 'asc'));
         if (!empty($prop)) {
             foreach ($reward as &$v) {
                 if (isset($v['prop_config'])) {
                     unset($v['prop_config']);
                 }
                 if ($v['item_id'] > 100) {
                     foreach ($prop as $pv) {
                         if ($pv['prop_id'] == $v['item_id']) {
                             if (isset($pv['overlay_num'])) {
                                 $pv['item_num'] = $pv['overlay_num'];
                             }
                             $v['attrs'] = Struct_Prop::get_prop_struct($pv);
                             $arr_replace = array();
                             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
                             $arr_replace[] = array('rep_type' => 1, 'rep_val' => 1030);
                             $arr_replace[] = array('rep_type' => 2, 'rep_val' => $v['item_id']);
                             $need_b = Cache_Prop::getInstance()->get_prop_info($v['item_id']);
                             $this->get_game('SystemNotice')->push_sys_notice($player_id, 1030, 0, $arr_replace, 0, $need_b['need_broad_cast']);
                         }
                     }
                 } else {
                     $v['attrs'] = array();
                 }
             }
         } else {
             foreach ($reward as &$v) {
                 $v['attrs'] = array();
             }
         }
     }
     return $reward;
 }
Exemplo n.º 19
0
 public function get_fund_income_conf_list_level_2($fund_id, $player_level)
 {
     if (empty($fund_id) || empty($player_level)) {
         return false;
     }
     # 确定玩家等级段
     $sql = "select distinct buy_level_upper from fund_income_level where fund_id = {$fund_id}";
     $records = $this->select_all($sql, $this->get_cache_key(array('fund_id' => $fund_id, 'distinct' => 1), $this->prefix_fund_income_level));
     # 按价格由高到低排序
     Com_Array::multisort($records, array('buy_level_upper' => 'asc'));
     $buy_level_upper;
     foreach ($records as $record) {
         if ($player_level <= $record['buy_level_upper']) {
             $buy_level_upper = $record['buy_level_upper'];
             break;
         }
     }
     $sql = "select * from fund_income_level where fund_id = {$fund_id} and buy_level_upper = {$buy_level_upper}";
     $records = $this->select_all($sql, $this->get_cache_key(array('fund_id' => $fund_id, 'buy_level_upper' => $buy_level_upper), $this->prefix_fund_income_level));
     $income_conf_hash = array();
     if (!empty($records)) {
         foreach ($records as $record) {
             $income_conf_hash[$record['income_offset']] = $record;
         }
     }
     return $income_conf_hash;
 }
Exemplo n.º 20
0
 public static function attr_sort_2($attr_list)
 {
     if (empty($attr_list)) {
         return $attr_list;
     }
     $attr_hash = array();
     foreach ($attr_list as $key => $val) {
         if (is_numeric($val['attr_key'])) {
             $val['attr_key_origin'] = Cache_RoleKey::getInstance()->get_attr_key_by_index($val['attr_key']);
         } else {
             $val['attr_key_origin'] = $val['attr_key'];
         }
         $val['sort_priority'] = self::$_sort_priority[$val['attr_key_origin']];
         $attr_hash[$key] = $val;
     }
     Com_Array::multisort($attr_hash, array('sort_priority' => 'asc'));
     foreach ($attr_hash as $attr_idx => $attr_val) {
         unset($attr_val['sort_priority']);
         unset($attr_val['attr_key_origin']);
         $attr_hash[$attr_idx] = $attr_val;
     }
     return $attr_hash;
 }
Exemplo n.º 21
0
 /**
  * @Purpose:
  * 内部获取女神最大强化等级
  * @Param $player_id 玩家ID
  * @Param $level_type 等级类型(1:强化等级)
  */
 public function get_fairy_train_level_max($player_id, $level_type)
 {
     $player_id = intval($player_id);
     $level_type = intval($level_type);
     $max_level = 0;
     $type_list = array(1 => 'train_level');
     $data = $this->get_data('Fairy')->get_player_fairy_list($player_id);
     if (Com_Array::is_good_arr($data)) {
         Com_Array::multisort($data, array($type_list[$level_type] => 'desc'));
         $fairy = reset($data);
         if (!empty($fairy)) {
             if ($fairy[$type_list[$level_type]] > $max_level) {
                 $max_level = $fairy[$type_list[$level_type]];
             }
         }
     }
     return $max_level;
 }
Exemplo n.º 22
0
 /**
  *
  * @param $player_id
  * @param $item_unique_id  0缓慢回血药剂 或者  1直接回血药剂
  */
 public function prop_use_by_drug($player_id, $item_unique_id)
 {
     if ($item_unique_id == 'hot') {
         $props = $this->get_game('Prop')->get_prop_list_by_type($player_id, 2, 1);
     } elseif ($item_unique_id == 'dh') {
         $props = $this->get_game('Prop')->get_prop_list_by_type($player_id, 2, 6);
     } elseif ($item_unique_id == 'mp') {
         $props = $this->get_game('Prop')->get_prop_list_by_type($player_id, 2, 11);
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type', 'level', 'exp', 'level_exp', 'silver', 'gold', 'ticket', 'chips', 'honor', 'kf_coin', 'vip', 'crystal', 'fame', 'fame_level', 'fame_level_exp', 'kf_score', 'privilege_level'));
     if (empty($props)) {
         $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('hook_settings', 'hook_status'));
         if ($player_detail['hook_settings']['onhook_drug_option'] & 1) {
             #开启自动选项
             $ttl = $this->exist_drgu_lock($player_id);
             if ($ttl) {
                 return array('error_code' => 4, 'cooldown_msec' => intval($ttl));
                 //还在冷却中
             }
             if ($item_unique_id == 'hot') {
                 $prop_configs = Cache_Prop::getInstance()->get_prop_by_type(2, 1);
             } elseif ($item_unique_id == 'dh') {
                 $prop_configs = Cache_Prop::getInstance()->get_prop_by_type(2, 6);
             } elseif ($item_unique_id == 'mp') {
                 $prop_configs = Cache_Prop::getInstance()->get_prop_by_type(2, 11);
             }
             if (!empty($prop_configs)) {
                 if ($player_detail['hook_settings']['onhook_hp_order'] == 0) {
                     $prop_configs = Com_Array::multisort($prop_configs, array('level' => 'desc'));
                     #按等级排序 从小到大
                 } else {
                     $prop_configs = Com_Array::multisort($prop_configs, array('level' => 'asc'));
                     #按等级排序 从小到大
                 }
                 $prop_info = array();
                 foreach ($prop_configs as $val) {
                     if ($val['prop_id'] == '50074' || $val['prop_id'] == '50004') {
                         continue;
                     }
                     #策划要把这两种药先去了
                     if ($player_info['level'] >= $val['level']) {
                         $prop_info[] = $val;
                         break;
                     }
                 }
                 if (!empty($prop_info)) {
                     $prop_info = reset($prop_info);
                 } else {
                     return array('error_code' => 2, 'cooldown_msec' => 0);
                     //没有这个道具
                 }
                 if ($prop_info['buy_type'] == 0) {
                     $cur_key = 'silver';
                 } else {
                     $cur_key = Cache_Currency::getInstance()->get_key($prop_info['buy_type']);
                     if (is_array($cur_key)) {
                         #如果没有类型默认金币
                         $cur_key = 'silver';
                     }
                 }
                 $arr_consume = array();
                 if ('gold' == $cur_key) {
                     $arr_consume = array('price' => $prop_info['buy_price'], 'gold' => $prop_info['buy_price'], 'ticket' => 0, 'count' => 1);
                     #数据中心推送
                 } elseif ('ticket' == $cur_key) {
                     $arr_consume = array('price' => $prop_info['buy_price'], 'gold' => 0, 'ticket' => $prop_info['buy_price'], 'count' => 1);
                     #数据中心推送
                 }
                 $result = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cur_key, $prop_info['buy_price'], 0);
                 if ($result === true) {
                     #这地方相当于购买并使用功能
                     $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 409, array(), $arr_consume);
                     $this->add_drug_lock($player_id);
                     if ($result) {
                         return array('error_code' => 0, 'cooldown_msec' => 0, 'item_sid' => intval($prop_info['prop_id']));
                     }
                 } else {
                     return array('error_code' => 6, 'cooldown_msec' => 0);
                     //服务器内部错误
                 }
             } else {
                 return array('error_code' => 2, 'cooldown_msec' => 0);
                 //没有这个道具
             }
         } else {
             #没有勾选自动购买选项
             return array('error_code' => 2, 'cooldown_msec' => 0);
             //没有这个道具
         }
     }
     $player_prop = reset($props);
     $result = $this->get_game('Prop')->deduct_prop_by_ppid($player_id, $player_prop['player_prop_id'], 1, array('cmd_id' => 409, 'level' => $player_info['level'], 'vip' => $player_info['vip']), $player_prop);
     if (!$result) {
         return array('error_code' => 6, 'cooldown_msec' => 0);
         //服务器内部错误
     }
     return array('error_code' => 0, 'cooldown_msec' => 0, 'item_sid' => $player_prop['prop_id']);
 }
Exemplo n.º 23
0
 private function get_today_dedicate($roles)
 {
     if (1 == count($roles)) {
         return $roles[0]['player_id'] . ',' . $roles[0]['player_id'] . ',' . $roles[0]['player_id'];
     } elseif (2 == count($roles)) {
         $roles_1 = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($roles[0]['player_id'], "union_player_contribute");
         $roles_2 = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($roles[1]['player_id'], "union_player_contribute");
         if ($roles_1 >= $roles_2) {
             return $roles[0]['player_id'] . ',' . $roles[1]['player_id'] . ',' . $roles[0]['player_id'];
         } else {
             return $roles[1]['player_id'] . ',' . $roles[0]['player_id'] . ',' . $roles[1]['player_id'];
         }
     } elseif (count($roles) > 2) {
         foreach ($roles as &$val) {
             $val['today_dedicate'] = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($val['player_id'], "union_player_contribute");
         }
         Com_Array::multisort($roles, 'today_dedicate', 'desc');
         return $roles[0]['player_id'] . ',' . $roles[1]['player_id'] . ',' . $roles[2]['player_id'];
     }
 }
Exemplo n.º 24
0
 public function init_magic_parliament_deatil($player_id, $plm_id)
 {
     $this->param_check_numeric(array($player_id, $plm_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level'));
     # 获取议会配置信息
     $plm_conf = Cache_MagicParliament::getInstance()->get_parliament_conf($plm_id);
     if (empty($plm_conf)) {
         $this->throw_error('100002');
         # 获取魔法议会配置失败
     }
     # 根据称号要求,获取本服前N名玩家列表,并转换成以排位为key的哈希
     $player_rank_hash = $this->get_player_rank_hash_for_title();
     $plm_info_hash = array();
     # 获取玩家当日赴会次数|特权使用次数|免费奖励领取次数
     $attend_meeting_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_attend_meeting_num_prefix, $plm_conf['plm_id']));
     $use_privilege_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_use_privilege_num_prefix, $plm_conf['plm_id']));
     $free_reward_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     $attend_meeting_status = $plm_conf['attend_meeting_stint'] > $attend_meeting_num ? 1 : 0;
     # 否达成议会特权要求
     $title_conf = Cache_MagicParliament::getInstance()->get_title_conf($plm_conf['use_privilege_req_title_id']);
     $hold_title = false;
     for ($i = $title_conf['req_fame_rank_min']; $i <= $title_conf['req_fame_rank_max']; $i++) {
         if (isset($player_rank_hash[$i]) && $player_rank_hash[$i]['player_id'] == $player_id && $player_rank_hash[$i]['fame'] >= $title_conf['req_fame']) {
             $hold_title = true;
             break;
         }
     }
     $privilege_status = 0;
     if ($hold_title && $use_privilege_num < $plm_conf['use_privilege_stint']) {
         $privilege_status = 1;
     }
     # 议会人气值
     if ($plm_conf['plm_id'] == $this->sage_plm_id) {
         $popularity = $this->get_cross('PlayerDailyTime')->get_any_used_time($this->get_redis_key($this->daily_popularity_prefix, $plm_conf['plm_id']));
     } else {
         $popularity = $this->get_data('PlayerDailyTime')->get_any_used_time($this->get_redis_key($this->daily_popularity_prefix, $plm_conf['plm_id']));
     }
     # 议会免费奖励领取上限
     $free_reward_gain_stint = $this->get_free_reward_gain_stint($plm_id, $plm_conf);
     $free_reward_num_remain = max($free_reward_gain_stint - $free_reward_num, 0);
     $free_reward_status = $free_reward_num_remain > 0 ? 1 : 0;
     # 获取人气值修正信息 && 等级修正信息 && 合并两个修正为一个
     $revise_info_1 = Cache_MagicParliament::getInstance()->get_revise_1($plm_conf['plm_id'], $popularity);
     $revise_info_2 = Cache_MagicParliament::getInstance()->get_revise_2($plm_conf['plm_id'], $player_info['level']);
     if (empty($revise_info_1)) {
         $this->throw_error('100003');
         # 获取人气值修正信息配置失败
     }
     if (empty($revise_info_2)) {
         $this->throw_error('100004');
         # 获取等级修正信息配置失败
     }
     # 所有议会配置信息哈希
     $plm_conf_hash = Cache_MagicParliament::getInstance()->get_all_parliament_conf_hash();
     if (empty($plm_conf_hash)) {
         $this->throw_error('100002');
         # 获取魔法议会配置失败
     }
     # 历史行为日志
     $action_log_list = $this->get_data('MagicParliament')->get_action_log($plm_id, $this->action_log_num);
     Com_Array::multisort($action_log_list, array('reg_time' => 'asc'));
     $action_log_history = array();
     if (!empty($action_log_list)) {
         foreach ($action_log_list as $action_log) {
             $pinfo = $this->get_data('Player')->get_player_info($action_log['player_id'], array('name'));
             $reg_time = date('m-d H:i', $action_log['reg_time']);
             $reward_info = json_decode($action_log['reward_info'], true);
             $reward_list = array();
             if (!empty($reward_info)) {
                 foreach ($reward_info as $item_id => $item_num) {
                     $reward_list[] = array('txt' => '', 'type' => 2, 'value' => $item_id, 'param' => $item_num);
                 }
             }
             $code = 0;
             switch ($action_log['action_type']) {
                 case 1:
                     # 赴会
                     $code = 100011;
                     # 赴会消息提示内容
                     $params = array(array(array('txt' => '', 'type' => 7, 'value' => $reg_time, 'param' => '')), array(array('txt' => $pinfo['name'], 'type' => 0, 'value' => $action_log['player_id'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $plm_conf_hash[$plm_id]['plm_name'], 'param' => '')), $reward_list);
                     break;
                 case 2:
                     # 特权
                     $code = 100012;
                     # 行使特权消息提示内容
                     $params = array(array(array('txt' => '', 'type' => 7, 'value' => $reg_time, 'param' => '')), array(array('txt' => $pinfo['name'], 'type' => 0, 'value' => $action_log['player_id'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $plm_conf_hash[$plm_id]['privilege_name'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $plm_conf_hash[$plm_id]['plm_name'], 'param' => '')), $reward_list);
                     break;
                 case 3:
                     # 领取免费奖励
                     $code = 100013;
                     # 领取免费奖励消息提示内容
                     $params = array(array(array('txt' => '', 'type' => 7, 'value' => $reg_time, 'param' => '')), array(array('txt' => $pinfo['name'], 'type' => 0, 'value' => $action_log['player_id'], 'param' => '')), $reward_list);
                     break;
             }
             $dynamic_text = array('code' => $code, 'content' => array(), 'params' => $params);
             $action_log_history[] = $dynamic_text;
         }
     }
     # 修正特权奖励与消耗
     $use_privilege_cost_res = $this->get_game('Reward')->get_revised_value($plm_conf['use_privilege_cost_res'], array($revise_info_1['privilege_cost_revise'], $revise_info_2['privilege_cost_revise']));
     $use_privilege_reward = $this->get_game('Reward')->get_revised_value($plm_conf['use_privilege_reward'], array($revise_info_1['privilege_reward_revise'], $revise_info_2['privilege_reward_revise']));
     $plm_info_hash[$plm_conf['plm_id']] = array('plm_id' => $plm_conf['plm_id'], 'attend_meeting_info' => array('attend_meeting_cost' => $plm_conf['attend_meeting_res_cost'], 'attend_meeting_reward' => $plm_conf['attend_meeting_reward'], 'attend_meeting_status' => $attend_meeting_status), 'privilege_info' => array('privilege_cost' => $use_privilege_cost_res, 'privilege_reward' => $use_privilege_reward, 'privilege_status' => $privilege_status), 'free_reward_info' => array('free_reward' => $plm_conf['free_reward'], 'free_reward_status' => $free_reward_status, 'remain_num' => $free_reward_num_remain), 'popularity' => intval($popularity), 'history' => $action_log_history);
     $out_2503 = $plm_info_hash[$plm_id];
     #var_export($out_2503);
     return $out_2503;
 }
Exemplo n.º 25
0
 public function equip_panel($player_id, $type)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_intensifier);
     # 参数检查
     $this->param_check_numeric(array($player_id, $type));
     if (in_array($type, array(3))) {
         # 获取背包宝石列表
         $equips = $this->get_game('Prop')->get_prop_list_by_type($player_id, $this->compose_gem_type, $this->compose_gem_sub_type);
     } elseif (in_array($type, array(1, 2, 4, 5, 6, 7, 8))) {
         # 获取背包装备列表
         $equips = $this->get_game('Prop')->get_prop_list_by_type($player_id, 1);
         /**
         			if ($type == 2) { # 镶嵌时,quality <=1 的装备没有镶嵌属性,需要过滤掉这部分装备,仅在此处限制不行,此处指限制背包,没限制身上穿戴中
         				foreach($equips as $pprop_id => $prop){
         					if ($prop['quality'] <= 1) {
         						unset($equips[$pprop_id]);
         					}
         				}
         			}
         			**/
     }
     Com_Array::multisort($equips, array('quality' => 'desc', 'level' => 'desc'));
     $out_814 = array('equip_list' => array('item_position' => 1, 'grid_list' => array()), 'bless_item_info_list' => array());
     foreach ($equips as $key => $val) {
         $out_814['equip_list']['grid_list'][] = $val['grid'];
     }
     return $out_814;
 }
Exemplo n.º 26
0
 public function equip_swallow($type, $player_id, $player_prop_id, $swallow_equips, $onekey = 0)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     $this->param_check_numeric(array($type, $player_id), 0);
     if (empty($swallow_equips)) {
         $this->throw_error('10107');
     }
     # 参数错误
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip'));
     # 828展示协议返回数据,828协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充
     $out_828 = array('player_ppid' => $player_prop_id, 'swallow_ppids' => $swallow_equips, 'swallow_list' => array());
     $swallow_equips = explode(':', $swallow_equips);
     $swallow_equips = array_filter($swallow_equips);
     $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (empty($player_prop_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     # 获取允许吞噬的装备子类型列表
     list($allow_swallow_sub_type, $allow_swallow_id) = $this->get_swallow_restriction_info($player_prop_info['sub_type']);
     # 828展示协议返回数据,828协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充
     $distinct_swallow_list = Cache_Forge::getInstance()->get_distinct_swallow_list();
     foreach ($distinct_swallow_list as $swallow_info) {
         if (!empty($allow_swallow_id) && !in_array($swallow_info['swallow_id'], $allow_swallow_id)) {
             continue;
         }
         $out_828['swallow_list'][$swallow_info['swallow_id']] = array('swallow_id' => $swallow_info['swallow_id'], 'swallow_lv' => 0, 'swallow_exp' => 0);
     }
     if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) {
         if (!empty($type)) {
             # 实际吞噬
             $this->throw_error('81106');
             # 首充装备不允许吞噬
         } else {
             $message = array('texts' => array(array('code' => 81106, 'content' => array(), 'params' => array())), 'delay' => 0);
             Protocol::input($player_id, 3, 7, 742, $message);
             # 首充装备不允许吞噬
             $out_828['swallow_ppids'] = "";
             return $out_828;
         }
     }
     # 计算吞噬属性最大等级
     $swallow_lv_max = $this->get_swallow_lv_max($player_prop_info['level']);
     $player_prop_details = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, $swallow_equips);
     if (empty($player_prop_details)) {
         $this->throw_error('80024');
         //未选择有效的被吞噬装备
     }
     # 被吞噬装备信息
     $before_swallow_info = empty($player_prop_info['swallow_info']) ? array() : $player_prop_info['swallow_info'];
     $player_prop_id_slave = "";
     $item_id_slave = "";
     $onekey_prop_list = array();
     # 保存允许一键吞噬的装备ID列表
     $full_level_flag = false;
     # 是否满级,一键吞噬区分报错信息用
     foreach ($swallow_equips as $pprop_id) {
         if (!empty($type)) {
             # 实际吞噬
             if (!empty($allow_swallow_sub_type) && !in_array($player_prop_details[$pprop_id]['sub_type'], $allow_swallow_sub_type)) {
                 $this->throw_error('80036');
                 # 被吞噬装备包含不允许吞噬的非法装备类型
             }
             if ($player_prop_details[$pprop_id]['quality'] >= 4) {
                 # 品质>=4的装备不允许被吞噬,秋水确定于20150811
                 $this->throw_error('80036');
                 # 被吞噬装备包含不允许吞噬的非法装备类型
             }
             if (empty($player_prop_details[$pprop_id])) {
                 $this->throw_error('80013');
                 # 玩家没有该装备!
             }
             if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) {
                 $this->throw_error('81107');
                 # 首充装备不允许被吞噬
             }
             if (!empty($player_prop_details[$pprop_id]['inlay_gems'])) {
                 $this->throw_error('80041');
                 # 被吞噬装备镶嵌有宝石
             }
             if (!empty($player_prop_details[$pprop_id]['star_map_id'])) {
                 $this->throw_error('80042');
                 # 被吞噬装备镶嵌有觉醒石
             }
             $item_swallow_info = Cache_Forge::getInstance()->get_swallow_map_config($player_prop_details[$pprop_id]['sub_type'], $player_prop_details[$pprop_id]['quality']);
             if (empty($item_swallow_info)) {
                 $this->throw_error('80025');
                 # 该装备子类型没有配置对应的吞噬属性信息!
             }
             if (empty($item_swallow_info['swallow_id'])) {
                 $this->throw_error('80026');
                 # 获取吞噬属性类型失败
             }
             $exp_revise_info = Cache_Forge::getInstance()->get_swallow_exp_revise_config($player_prop_details[$pprop_id]['star_level']);
             if (empty($exp_revise_info) || empty($exp_revise_info['revise_ratio'])) {
                 $this->throw_error('80044');
                 # 获取吞噬经验修正配置失败
             }
         } else {
             # 非实际吞噬
             if (!empty($onekey)) {
                 # 一键勾选
                 if (!empty($allow_swallow_sub_type) && !in_array($player_prop_details[$pprop_id]['sub_type'], $allow_swallow_sub_type)) {
                     continue;
                 }
                 if ($player_prop_details[$pprop_id]['quality'] >= 4) {
                     # 品质>=4的装备不允许被吞噬,秋水确定于20150811
                     continue;
                 }
                 if (empty($player_prop_details[$pprop_id])) {
                     continue;
                 }
                 if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) {
                     continue;
                 }
                 if (!empty($player_prop_details[$pprop_id]['inlay_gems'])) {
                     continue;
                 }
                 if (!empty($player_prop_details[$pprop_id]['star_map_id'])) {
                     continue;
                 }
                 $item_swallow_info = Cache_Forge::getInstance()->get_swallow_map_config($player_prop_details[$pprop_id]['sub_type'], $player_prop_details[$pprop_id]['quality']);
                 if (empty($item_swallow_info) || empty($item_swallow_info['swallow_id'])) {
                     continue;
                 }
                 $exp_revise_info = Cache_Forge::getInstance()->get_swallow_exp_revise_config($player_prop_details[$pprop_id]['star_level']);
                 if (empty($exp_revise_info) || empty($exp_revise_info['revise_ratio'])) {
                     continue;
                 }
             } else {
                 # 单项勾选,单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环
                 if (!empty($allow_swallow_sub_type) && !in_array($player_prop_details[$pprop_id]['sub_type'], $allow_swallow_sub_type)) {
                     $message = array('texts' => array(array('code' => 80036, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 被吞噬装备包含不允许吞噬的非法装备类型
                     break;
                 }
                 if ($player_prop_details[$pprop_id]['quality'] >= 4) {
                     # 品质>=4的装备不允许被吞噬,秋水确定于20150811
                     $message = array('texts' => array(array('code' => 80036, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 被吞噬装备包含不允许吞噬的非法装备类型
                     break;
                 }
                 if (empty($player_prop_details[$pprop_id])) {
                     $message = array('texts' => array(array('code' => 80013, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 玩家没有该装备!
                     break;
                 }
                 if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) {
                     $message = array('texts' => array(array('code' => 81107, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 首充装备不允许被吞噬
                     break;
                 }
                 if (!empty($player_prop_details[$pprop_id]['inlay_gems'])) {
                     $message = array('texts' => array(array('code' => 80041, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 被吞噬装备镶嵌有宝石
                     break;
                 }
                 if (!empty($player_prop_details[$pprop_id]['star_map_id'])) {
                     $message = array('texts' => array(array('code' => 80042, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 被吞噬装备镶嵌有觉醒石
                     break;
                 }
                 $item_swallow_info = Cache_Forge::getInstance()->get_swallow_map_config($player_prop_details[$pprop_id]['sub_type'], $player_prop_details[$pprop_id]['quality']);
                 if (empty($item_swallow_info)) {
                     $message = array('texts' => array(array('code' => 80025, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 该装备子类型没有配置对应的吞噬属性信息!
                     break;
                 }
                 if (empty($item_swallow_info['swallow_id'])) {
                     $message = array('texts' => array(array('code' => 80026, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 获取吞噬属性类型失败
                     break;
                 }
                 $exp_revise_info = Cache_Forge::getInstance()->get_swallow_exp_revise_config($player_prop_details[$pprop_id]['star_level']);
                 if (empty($exp_revise_info) || empty($exp_revise_info['revise_ratio'])) {
                     $message = array('texts' => array(array('code' => 80044, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 获取吞噬经验修正配置失败
                     break;
                 }
             }
         }
         # 计算增加的吞噬属性ID
         $add_swallow_id = $item_swallow_info['swallow_id'];
         # 使用配置数据判断满经验,是为了当策划修改最大吞噬等级算法时,能忽略旧装备中保存的吞噬属性信息最大等级与最大经验两项,提高向前兼容性,Forwards Compatibility
         # 获取吞噬配置信息,一键勾选吞噬是不能报这个错
         $swallow_config = Cache_Forge::getInstance()->get_swallow_config($add_swallow_id, $swallow_lv_max);
         if (isset($player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp']) && $player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] >= $swallow_config['swallow_exp'] - 1) {
             if (!empty($type)) {
                 # 实际吞噬
                 $this->throw_error('80021');
                 # 该装备的该项吞噬属性已满!
             } else {
                 $full_level_flag = true;
                 if (empty($onekey)) {
                     # 单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环
                     $message = array('texts' => array(array('code' => 80021, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     break;
                 } else {
                     # 一键勾选获取吞噬信息不弹提示属性满的消息
                     continue;
                 }
             }
         }
         $player_prop_id_slave .= "{$pprop_id}:";
         $item_id_slave .= $player_prop_details[$pprop_id]['prop_id'] . ":";
         $onekey_prop_list[] = $pprop_id;
         # 计算增加属性值 && 修正经验值
         $add_swallow_exp = self::$swallow_quality_to_exp_map[$player_prop_details[$pprop_id]['quality']];
         $add_swallow_exp = ceil($add_swallow_exp * $exp_revise_info['revise_ratio'] / 10000);
         if (isset($player_prop_info['swallow_info'][$add_swallow_id])) {
             $player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] += $add_swallow_exp;
         } else {
             $player_prop_info['swallow_info'][$add_swallow_id] = array('swallow_id' => $add_swallow_id, 'swallow_lv' => 0, 'swallow_exp' => $add_swallow_exp);
         }
         # 最大经验值保护
         if ($player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] >= $swallow_config['swallow_exp'] - 1) {
             $player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] = $swallow_config['swallow_exp'] - 1;
         }
     }
     #var_export($player_prop_info);
     # 根据吞噬属性的exp,刷新吞噬属性的lv
     if (!empty($player_prop_info['swallow_info'])) {
         foreach ($player_prop_info['swallow_info'] as $sid => $sinfo) {
             $swallow_config = Cache_Forge::getInstance()->get_swallow_config_by_exp($sinfo['swallow_id'], $sinfo['swallow_exp']);
             if (!empty($swallow_config)) {
                 $player_prop_info['swallow_info'][$sid]['swallow_lv'] = $swallow_config['swallow_lv'];
                 #$player_prop_info['swallow_info'][$sid]['swallow_param'] = $swallow_config['swallow_param']; # 不缓存任何配置数据,提高策划修改配置表时的兼容性
             }
             $out_828['swallow_list'][$sid] = array('swallow_id' => $sid, 'swallow_lv' => $player_prop_info['swallow_info'][$sid]['swallow_lv'], 'swallow_exp' => $player_prop_info['swallow_info'][$sid]['swallow_exp']);
         }
         $player_prop_info['swallow_version'] = 2;
         # 新功能版本号,用来区分新旧装备,一遍向下兼容接口有条件刷新
     }
     if (empty($type)) {
         # 修正被吞噬的装备列表,去除吞噬属性达到上限及之后的其它装备
         $out_828['swallow_ppids'] = empty($onekey_prop_list) ? "" : implode(":", $onekey_prop_list);
         if (empty($out_828['swallow_ppids']) && !empty($onekey)) {
             # 没有能被吞噬的装备
             $code = $full_level_flag ? 80021 : 80043;
             $message = array('texts' => array(array('code' => $code, 'content' => array(), 'params' => array())), 'delay' => 0);
             Protocol::input($player_id, 3, 7, 742, $message);
             # 没有可以被吞噬的装备[装备镶嵌有觉醒石,宝石,装备为首充装备,装备获取不到吞噬配置]
         }
         return $out_828;
     }
     $out_829 = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => array()));
     $this->start_trans();
     # 更新吞噬信息
     $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('swallow_info' => $player_prop_info['swallow_info']));
     $this->write_check($re, 3010177);
     # 扣除被吞噬装备
     foreach ($player_prop_details as $k => $v) {
         $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $v, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 829));
         $this->write_check($re, 3010182);
     }
     $this->commit();
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_info['player_prop_id'], 'item_id_master' => $player_prop_info['prop_id'], 'item_type' => $player_prop_info['type'], 'item_sub_type' => $player_prop_info['sub_type'], 'item_quality' => $player_prop_info['quality'], 'item_level' => $player_prop_info['level'], 'item_star_level' => $player_prop_info['star_level'], 'player_prop_id_slave' => rtrim($player_prop_id_slave, ":"), 'item_id_slave' => rtrim($item_id_slave, ":"), 'before_swallow_info' => $before_swallow_info, 'after_swallow_info' => $player_prop_info['swallow_info'], 'swallow_id_1' => 0, 'before_swallow_level_1' => 0, 'after_swallow_level_1' => 0, 'swallow_id_2' => 0, 'before_swallow_level_2' => 0, 'after_swallow_level_2' => 0, 'swallow_id_3' => 0, 'before_swallow_level_3' => 0, 'after_swallow_level_3' => 0, 'swallow_id_4' => 0, 'before_swallow_level_4' => 0, 'after_swallow_level_4' => 0);
     if (!empty($before_swallow_info)) {
         foreach ($before_swallow_info as $sid => $sinfo) {
             $log_info["swallow_id_{$sid}"] = $sid;
             $log_info["before_swallow_level_{$sid}"] = $sinfo['swallow_lv'];
         }
     }
     foreach ($player_prop_info['swallow_info'] as $sid => $sinfo) {
         $log_info["swallow_id_{$sid}"] = $sid;
         $log_info["after_swallow_level_{$sid}"] = $sinfo['swallow_lv'];
     }
     Log_Forge::getInstance()->add_log($log_info, 'swallow');
     # 刷新玩家属性
     if ($player_prop_info['item_position'] == 3) {
         $this->get_game('EquipAttr')->equip_attr($player_id);
     }
     # 通知道具变更806
     $ndata = array();
     $ndata[] = $player_prop_info;
     foreach ($player_prop_details as $key => &$val) {
         $val['item_num'] -= 1;
         $out_829[1]['grid_list'][] = $val['grid'];
         $ndata[] = $val;
     }
     Protocol_Prop::prop_806($player_id, $ndata);
     # 刷装备814[锻造面板]与827[可吞噬道具列表]
     $equips = $this->get_data('PlayerProp')->get_player_prop_by_item_position($player_id, 1);
     Com_Array::multisort($equips, array('quality' => 'desc', 'level' => 'desc'));
     $emp = array();
     $fmp = array();
     if (!empty($equips)) {
         foreach ($equips as $k => $v) {
             if ($v['type'] == 1) {
                 $emp[] = $v['grid'];
             }
         }
         # 过滤不允许该装备吞噬的装备
         $equips = $this->filter_unvalid_props($player_prop_info, $equips);
         foreach ($equips as $k => $v) {
             $fmp[] = $v['grid'];
         }
     }
     $equip_list = array('item_position' => 1, 'grid_list' => $emp);
     $allow_swallow = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => $fmp));
     Protocol::input($player_id, 3, 8, 829, $out_829);
     Protocol::input($player_id, 3, 8, 814, array($equip_list));
     Protocol::input($player_id, 3, 8, 827, $allow_swallow);
     # 记录行为
     Com_Log::write('xgame.forge_swallow', "{$player_id}\t" . "swallow\t" . "{$type}\t" . "{$player_prop_id}\t" . implode(",", $swallow_equips));
     # 日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 108, 108, 1);
     # 每日活跃任务埋点
     $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2001, 1, 1);
     return $out_829;
 }
Exemplo n.º 27
0
 /**
  * 获取赞过我的消息
  */
 public function get_like_player_info($player_id)
 {
     $objlike = $this->get_data('PlayerLike');
     $objfrined = $this->get_data('PlayerFriend');
     $data = $objlike->get_like_data($player_id);
     Com_Array::multisort($data, array('create_time' => 'desc', 'news_id' => 'desc'));
     $player_data = $objfrined->get_player_friend($player_id, array('follow', 'blacklist', 'like_times'));
     $player_freinds = array_keys($player_data['follow']['info']);
     $result = array();
     $show_data = array();
     $add_exp = 0;
     $like_tips_info = $this->get_data('NewsTips')->get_player_newstips($player_id, self::$_like_tips_type);
     if ($data) {
         $show_data = array_slice($data, 0, 20);
         //每次显示最新20条
         foreach ($show_data as $key => $val) {
             $show_data[$key]['is_friend'] = 0;
             if (in_array($val['player_id'], $player_freinds)) {
                 $show_data[$key]['is_friend'] = 1;
             }
             $add_exp += intval($val['exp']);
             $sid = $val['news_id'] . $val['player_id'];
             $ret = $objlike->del_like_data_by_likeid($player_id, $sid);
             if (!$ret) {
                 $ret = $objlike->del_like_data_by_likeid($player_id, $val['news_id']);
                 //打开后清除好友点赞提示
             }
             $this->write_check($ret, 5011398);
         }
         //好友点赞提示数
         $set_data['num'] -= count($show_data);
         $set_data['num'] = $set_data['num'] < 0 ? 0 : $set_data['num'];
         $ret = $objtips = $this->get_data('NewsTips')->update_player_tips($player_id, self::$_like_tips_type, $set_data);
         $this->write_check($ret, 5011404);
     } else {
         $ret = $this->get_data('NewsTips')->update_player_tips($player_id, self::$_like_tips_type, array('num' => 0));
         $this->write_check($ret, 5011407);
     }
     if ($add_exp > 0) {
         #被点赞获得奖励
         $reward = array();
         $reward[] = array('type' => 'exp', 'item_id' => 1, 'item_num' => $add_exp);
         $ret = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '102'));
         if ($ret === true) {
             $this->get_game('Reward')->add_reward_log(true);
         }
     }
     $player_basic_info = $this->get_data('Player')->get_player_info($player_id, array('ticket', 'level', 'gold', 'vip', 'level_exp', 'name'));
     $like_max_times = $this->like_default_times;
     if (intval($player_basic_info['vip']) > 0) {
         $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_basic_info['vip'], 10069);
         $like_max_times = $this->like_default_times + $vip_set['max_times'];
     }
     $today_like_friend = intval($player_data['like_times']['today_like_friend_times']) + intval($player_data['like_times']['today_times']);
     $result['player_id'] = $player_id;
     $result['today_like_player'] = $like_max_times;
     $result['today_like_friend'] = $today_like_friend;
     //赞过+被赞过
     $result['like_info'] = $show_data;
     return Struct_Friend::get_player_likes($result);
 }
Exemplo n.º 28
0
 /**
  * 公会排行列表
  * type类型    2、建筑等级 3、公会战力 
  */
 public function get_union_rank($type)
 {
     switch ($type) {
         case 2:
             $data = $this->get_union_build_rank_list();
             break;
         case 3:
             $data = $this->get_data('UnionInfo')->get_union_sum_fpower_rank_list(1, 100);
             break;
     }
     $union_list = array();
     if (Com_Array::is_good_arr($data)) {
         Com_Array::multisort($data, array('val' => 'desc', 'player_num' => 'desc', 'union_level' => 'desc', 'union_exp' => 'desc'));
         foreach ($data as $key => $val) {
             $item = array();
             $item['rank'] = $key + 1;
             $item['union_name'] = $val['union_name'];
             $item['union_id'] = $val['union_id'];
             $item['create_player_id'] = $val['create_player_id'];
             $item['create_player_name'] = $val['create_player_name'];
             $item['union_player_num'] = $val['player_num'];
             $item['val'] = $val['val'];
             $union_list[] = $item;
             if ($item['rank'] >= 100) {
                 break;
             }
         }
     }
     return $union_list;
 }
Exemplo n.º 29
0
 /**
  * 获取成就称号任务列表
  *
  */
 public function get_achieve_title_task_list($player_id)
 {
     $task_configs = Cache_AchieveConfig::getInstance()->get_achieve_title_config($this->achieve_title_type);
     if (empty($task_configs)) {
         $this->throw_error('10222');
     }
     $playerAchieveCounter = $this->get_data('PlayerAchieveCounter')->get_player_achieve_counter_info($player_id, array('finish_title_ids', 'task_type_progress'));
     $finish_title_ids = $playerAchieveCounter["finish_title_ids"];
     $current_wear_title_id = $this->get_data('Player')->get_player_info($player_id, "title_id");
     foreach ($task_configs as $config) {
         if ($config['operator_id'] != 0 && OPERATOR_ID != $config['operator_id']) {
             continue;
         }
         $item = array();
         $finish_only_player = array();
         $title_state = 0;
         $wear_state = 0;
         //佩戴状态
         $upts = 0;
         $item['achieve_id'] = intval($config['achieve_id']);
         //勋章为一对一
         if (isset($finish_title_ids[$config['title_id']])) {
             $title_state = 1;
             $upts = $finish_title_ids[$config['title_id']];
             if ($config['title_id'] == $current_wear_title_id) {
                 $wear_state = 1;
             }
         }
         if ($config['other_type'] == 1) {
             $achieveOnlyInfo = $this->get_data('PlayerAchieveOnly')->get_player_achieve_only_info($item['achieve_id']);
             if ($achieveOnlyInfo) {
                 $upts = $achieveOnlyInfo['add_time'];
                 $only_player_id = $achieveOnlyInfo['player_id'];
                 $player_info = $this->get_data('Player')->get_player_info($only_player_id, array("name", "career_type"));
                 $finish_only_player = array("player_id" => $only_player_id, "name" => $player_info['name'], "career_type" => $player_info['career_type']);
             }
         }
         #激活可见
         if ($config['visible'] == 0 && $title_state == 0) {
             continue;
         }
         $item['title_state'] = $title_state;
         //1为点亮
         $item['target_info'] = $config['target_info'];
         $item['icon'] = $config['icon'];
         $item['wear_state'] = $wear_state;
         $item['expire_time'] = $config['time'] ? $this->get_achieve_expire_time($config['time']) : 0;
         $item['finish_only_player'] = $finish_only_player;
         $item['tag'] = intval($config['tag']);
         $item['upts'] = $upts;
         $item['reward'] = $this->get_format_achieve_attr($config['reward']);
         $item['target_title'] = $config['title_name'];
         $achieve_info = $this->get_data('PlayerAchieve')->get_player_achieve_info($player_id, $config['title_id']);
         if (isset($playerAchieveCounter["task_type_progress"][$config['achieve_type']])) {
             $achieve_info[$config['achieve_id']]['val'] = $playerAchieveCounter["task_type_progress"][$config['achieve_type']]['val'];
         }
         $item['target_tips'] = str_replace("%s", intval($achieve_info[$config['achieve_id']]['val']), $config['target_tips']);
         if ($title_state == 1) {
             $item['target_tips'] = "";
         }
         if ($config['tag'] == 2 && $title_state == 0) {
             $language_config = Cache_Language::getInstance()->get_language_info(760001);
             $item['target_info'] = $language_config['content'];
             $item['target_tips'] = "";
         }
         $item['resource_type'] = intval($config['resource_type']);
         $item['rank'] = intval($config['rank']);
         $data["achieve_list"][] = $item;
     }
     Com_Array::multisort($data["achieve_list"], array('title_state' => 'desc', 'rank' => 'asc'));
     return $data;
 }