Exemplo n.º 1
0
 public static function get_fashion_struct($data)
 {
     if (empty($data)) {
         return array();
     }
     return array(0 => intval($data['flag']), 1 => Struct_Prop::get_item_box_struct($data));
 }
Exemplo n.º 2
0
 public static function get_prop_change_struct($data)
 {
     if (Com_Array::is_good_arr($data['prop_list'])) {
         //格式化符文背包信息列表
         foreach ($data['prop_list'] as $key => $val) {
             $data['prop_list'][$key] = Struct_Prop::get_item_box_struct($val);
         }
     }
     return array(0 => intval($data['type']), 1 => intval($data['result']), 2 => $data['prop_list']);
 }
Exemplo n.º 3
0
 /**
  * 登陆的时候前端加载道具数据
  * @param $player_id
  * @param $item_position
  * @return array
  */
 public function get_player_item($player_id, $item_position, $player_info = null)
 {
     $item_position = explode(':', $item_position);
     $arrPlayerPropList = $this->get_data("PlayerProp")->get_player_all_prop($player_id);
     $out = array();
     $arrBagConfigList = Cache_Bag::getInstance()->get_bag_extend_countdown();
     if (empty($player_info) || !isset($player_info['vip'])) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('vip', 'bag_num', 'storage_num'));
     }
     foreach ($item_position as $pos) {
         if ($pos == 1) {
             $max_num = $this->get_max_bag_storage_num($player_id, 1, $player_info);
         } elseif ($pos == 2) {
             $max_num = $this->get_max_bag_storage_num($player_id, 2, $player_info);
         } elseif ($pos == 3) {
             $max_num = $this->_max_body_part;
         } else {
             $max_num = 0;
         }
         $out[$pos] = array('pos' => $pos, 'max_num' => $max_num, 'item_boxs' => array());
         //            Com_Log::write('xgame.vip_bag_storage_num',"{$player_id}--{$player_info['vip']}--get_player_item");
         //            Com_Log::write('xgame.vip_bag_storage_num',json_encode($out));
     }
     if (!empty($arrPlayerPropList)) {
         foreach ($arrPlayerPropList as $ppid => $val) {
             if (in_array($val['item_position'], $item_position)) {
                 $out[$val['item_position']]['item_boxs'][] = Struct_Prop::get_item_box_struct($val);
             }
         }
     }
     return $out;
 }
Exemplo n.º 4
0
 public function equip_starmap_do($player_id, $player_prop_id, $star_spid)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     $this->param_check_numeric(array($player_id));
     # 没有玩家信息
     $player_info = $this->get_data('Player')->get_player_info($player_id);
     if (empty($player_info)) {
         $this->throw_error('10104');
     }
     # 玩家没有该装备
     $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');
     }
     if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) {
         $this->throw_error('81103');
         # 首充装备不允许觉醒
     }
     # 824展示协议返回数据
     $out_824 = array('player_prop_id' => $player_prop_id, 'star_pid' => $star_spid, 'box_up' => array(), 'box_down' => array());
     $before_starmap_desc = $player_prop_info['star_map_desc'];
     # 判断行为类型:flag=0星图卸载;flag=1星图安装;flag=2星图替换
     if (empty($star_spid)) {
         if (empty($player_prop_info['star_map_id'])) {
             $this->throw_error('80031');
             //该装备未曾安装星图!
         }
         $flag = 0;
     } else {
         $flag = empty($player_prop_info['star_map_id']) ? 1 : 2;
     }
     # 检查旧星图配置信息【卸载||替换】
     if ($flag == 0 || $flag == 2) {
         $starmap_config_forSend = Cache_Prop::getInstance()->get_prop_info($player_prop_info['star_map_id']);
         if (!$starmap_config_forSend) {
             $this->throw_error('80033');
             //没有该星图的配置信息!
         }
     }
     # 检查新星图配置信息【安装||替换】
     if ($flag == 1 || $flag == 2) {
         $starmap_info_forInstall = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $star_spid);
         if (!$starmap_info_forInstall) {
             $this->throw_error('80032');
             //玩家没有该星图!
         }
         $out_824['box_up'] = array('pos' => $starmap_info_forInstall['item_position'], 'index' => $starmap_info_forInstall['grid']);
         $starmap_config_forInstall = Cache_Prop::getInstance()->get_prop_info($starmap_info_forInstall['prop_id']);
         if (!$starmap_config_forInstall) {
             $this->throw_error('80033');
             //没有该星图的配置信息!
         }
         $starmap_config = Cache_Forge::getInstance()->get_starmap_info($starmap_info_forInstall['prop_id']);
         # 允许的装备种类检查
         if (!empty($starmap_config[0]['require_sub_type'])) {
             $require_sub_type = explode(":", $starmap_config[0]['require_sub_type']);
             if (!in_array($player_prop_info['sub_type'], $require_sub_type)) {
                 $this->throw_error('80035');
                 //该觉醒石不允许镶嵌在该种类的装备上
             }
         }
         # 要求的等级检查
         if (!empty($starmap_config[0]['require_equip_level']) && $player_prop_info['level'] < $starmap_config[0]['require_equip_level']) {
             $this->throw_error('80040');
             # 装备等级低于觉醒石要求等级,不允许镶嵌
         }
     }
     $this->start_trans();
     if ($flag == 0 || $flag == 2) {
         //发放旧星图【卸载||替换】
         $reward = array();
         $sendarrLogs = array();
         $reward[] = array('type' => 'prop', 'item_id' => $player_prop_info['star_map_id'], 'item_num' => 1);
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 824));
         #send_reward失败时,会返回各种失败情况的错误码
         $this->write_check_strict($re, 3010130);
         $sendarrLogs = $this->get_game('Reward')->get_prop_log();
         $out_824['box_down'] = array('pos' => $sendarrLogs[0]['item_position'], 'index' => $sendarrLogs[0]['grid']);
         if ($flag == 2) {
             //扣除新星图【替换】
             $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $starmap_info_forInstall, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 824));
             $this->write_check($re, 3010136);
         }
     } else {
         //扣除新星图【安装】
         $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $starmap_info_forInstall, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 824));
         $this->write_check($re, 3010140);
     }
     # 更新装备状态
     if ($flag) {
         # 【安装||替换】
         $player_prop_info['star_map_id'] = $starmap_info_forInstall['prop_id'];
         $player_prop_info['star_map_desc'] = $this->get_latest_starmap_desc($player_prop_info);
     } else {
         # 【卸载】
         $player_prop_info['star_map_id'] = '';
         $player_prop_info['star_map_desc'] = array();
     }
     $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('star_map_id' => $player_prop_info['star_map_id'], 'star_map_desc' => $player_prop_info['star_map_desc']));
     $this->write_check($re, 3010152);
     $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_install' => $starmap_info_forInstall ? $starmap_info_forInstall['player_prop_id'] : 0, 'item_id_install' => $starmap_info_forInstall ? $starmap_info_forInstall['prop_id'] : 0, 'player_prop_id_uninstall' => $sendarrLogs ? $sendarrLogs[0]['player_prop_id'] : 0, 'item_id_uninstall' => $sendarrLogs ? $sendarrLogs[0]['prop_id'] : 0, 'before_starmap_desc' => $before_starmap_desc, 'after_starmap_desc' => $player_prop_info['star_map_desc']);
     Log_Forge::getInstance()->add_log($log_info, 'starmap');
     if ($flag == 1 || $flag == 2) {
         # 安装和替换才算
         # 引导任务埋点
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 25, 1);
     }
     $this->handle_starmap_refer_achieve($player_id);
     # 刷新玩家属性
     if ($player_prop_info['item_position'] == 3) {
         $this->get_game('EquipAttr')->equip_attr($player_id);
     }
     # 通知道具变更 粘包806
     $this->get_game('Reward')->add_reward_log();
     # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志
     $ndata = array();
     $ndata[] = $player_prop_info;
     /**
     		//发放的星图
     		if($flag == 0 || $flag == 2) {
     			foreach($sendarrLogs as $key => $val) {
     				$ndata[] = $val;
     			}
     		}
     		**/
     //扣除的星图
     if ($flag == 1 || $flag == 2) {
         $starmap_info_forInstall['item_num'] -= 1;
         $ndata[] = $starmap_info_forInstall;
     }
     Protocol_Prop::prop_806($player_id, $ndata);
     //获取 星图
     $player_star_map = $this->get_game('Prop')->get_prop_list_by_type($player_id, $this->starmap_type, $this->starmap_sub_type);
     # 过滤不允许镶嵌该装备的星图
     $player_star_map = $this->filter_unvalid_starmap($player_prop_info, $player_star_map);
     $data = array();
     if ($player_star_map) {
         foreach ($player_star_map as $k => $v) {
             $data[] = Struct_Prop::get_item_box_struct($v);
         }
     }
     $emp = array(0 => $player_prop_id, 1 => $data);
     Protocol::input($player_id, 3, 8, 824, $out_824);
     Protocol::input($player_id, 3, 8, 823, $emp);
 }
Exemplo n.º 5
0
 /**
  * @Purpose:
  * 获取精灵升级信息
  * @Method Name: get_fairy_upgrade_info()
  * @Parameter: $player_id 玩家ID
  * @Parameter: $fairy_id 精灵ID
  * @Return: mixed 精灵升级信息
  */
 public function get_fairy_upgrade_info($player_id, $fairy_id)
 {
     $player_id = intval($player_id);
     //获取玩家精灵数据
     $obj_player_fairy_data = $this->get_data('Fairy');
     $data = $obj_player_fairy_data->get_player_fairy_info($fairy_id);
     if (!$data) {
         $this->throw_error('10112');
     }
     //获取指定类型精灵配置表数据
     $fairy_list_table = $this->get_fairy_table_data_by_type($data['type']);
     if (!$fairy_list_table[0]['change_name_expend']) {
         $this->throw_error('10109');
         //配置表读取错误
     }
     $data['grow'] = $obj_player_fairy_data->get_fairy_grow($fairy_id, 'grow');
     //是否满级
     $is_level = $this->is_next_level($data, false);
     if ($is_level === true) {
         $rtn_data['next_level'] = $data['level'];
         $rtn_data['next_star'] = 0;
         $rtn_data['fairy_code'] = $data['fairy_code'];
         return Struct_Fairy::get_fairy_upgrade_panel_struct($rtn_data);
     } else {
         if ($is_level !== false) {
             return $is_level;
         }
     }
     //获取下级精灵数据
     $get_fairy_res = $this->get_next_fairy_data($data, $fairy_data, false);
     if ($get_fairy_res !== true) {
         $this->throw_error($get_fairy_res);
     }
     //获取消耗道具数据
     $get_item_res = $this->get_item_data($data['fairy_code'], $data['star'], $item_data);
     if ($get_item_res !== true) {
         $this->throw_error($get_item_res);
     }
     //获取玩家背包道具信息
     $obj_prop_game = $this->get_game('Prop');
     $item_list = $obj_prop_game->get_prop_list_by_prop_id($player_id, $item_data['item']);
     //格式化数据结构
     $rtn_data['item_box'] = Struct_Prop::get_item_box_struct($item_list[0]);
     //获取精灵属性数据
     $rtn_data['next_level'] = $fairy_data['lvl'];
     $rtn_data['grow_value'] = $data['grow'];
     $rtn_data['shield_limit'] = $fairy_data['shield_lvl'];
     $rtn_data['Attr_id'] = $fairy_data['attribute'];
     $rtn_data['open_hole'] = $fairy_data['skill_hole'];
     $rtn_data['next_star'] = $fairy_data['star'];
     $rtn_data['fairy_code'] = $data['fairy_code'];
     $rtn_data['auto_buy'] = $data['auto_buy'];
     //获取下一级精灵配置表ID
     $fairy_other_table = $this->get_fairy_table_data_Multiple($data['type'], $data['level'] + 1);
     $rtn_data['next_fairy_code'] = $fairy_other_table['sid'];
     //获取成长值过期时间
     $rtn_data['expire_time'] = $obj_player_fairy_data->get_fairy_grow_expire($fairy_id);
     $rtn_data['expire_time'] = $rtn_data['expire_time'] > 0 && $rtn_data['expire_time'] <= 86400 ? $rtn_data['expire_time'] : 0;
     $fairy_level_table = $this->get_fairy_lvl_tabel_data($data['fairy_code'], $data['star']);
     if (!$fairy_level_table) {
         $this->throw_error('10109');
         //配置表读取错误
     }
     /*
     #获取玩家声望等级
     $player_fame_level = $this->get_data('Player')->get_player_info($player_id, 'fame_level');
     $fame_table = Cache_PlayerFame::getInstance()->get_player_fame_info($player_fame_level);
     $rtn_data['cur_fame_level'] = $fame_table['title'];
     */
     if ($fairy_level_table['fame'] > 0) {
         $fame_table = Cache_PlayerFame::getInstance()->get_player_fame_info($fairy_level_table['fame']);
         if (!$fame_table) {
             $this->throw_error('10109');
             //配置表读取错误
         }
         $rtn_data['need_fame_level'] = $fame_table['title'];
     }
     return Struct_Fairy::get_fairy_upgrade_panel_struct($rtn_data);
 }