Ejemplo n.º 1
0
 /**
  * 道具属性结构体
  * @param $data
  * @return array
  */
 public static function get_item_additions(&$data)
 {
     $attr_index = Cache_ItemKey::getInstance()->get_item_key();
     $role_index = Cache_RoleKey::getInstance()->get_item_key();
     //        echo "sub_type:".$data['sub_type']."<br>";
     $out = array();
     $arr_other = array();
     $fpower_calc = array();
     $fpower_base_calc = array();
     if ($data['type'] == 1 || $data['type'] == 6) {
         if (empty($data['player_prop_id'])) {
             //                $attrData = Cache_EquipBaseAttr::getInstance()->get_equip_base_attr($data['sub_type'],$data['quality'],$data['level'],$data['star_level']);
             $obj = new Game_Prop();
             $attrData = $obj->get_equip_attr($data);
             unset($obj);
             //                Com_Log::log($attrData,'cache_prop',1);
             $data['base_attr'] = $attrData['base_attr'];
             $data['addition_attr'] = $attrData['addition_attr'];
             $data['base_attr'] = $attrData['base_attr'];
             $data['level'] = $attrData['level'];
             $data['intensive_level'] = $attrData['intensive_level'];
             $data['intensive_desc'] = $attrData['intensive_desc'];
         }
         # ----------------------------------------------------------------
         # 星图加成信息
         # ----------------------------------------------------------------
         $star_map = array();
         $we_swallow_revise_info = array();
         if (!empty($data['star_map_desc'])) {
             if (is_string($data['star_map_desc'])) {
                 $data['star_map_desc'] = json_decode($data['star_map_desc'], true);
             }
             $star_map = self::parse_star_map($data['star_map_desc']);
         }
         # ----------------------------------------------------------------
         # 基础属性
         # ----------------------------------------------------------------
         if (!empty($data['base_attr'])) {
             if (is_string($data['base_attr'])) {
                 $data['base_attr'] = json_decode($data['base_attr'], true);
             }
             list($key, $val) = each($data['base_attr']);
             //基础属性 就一个
             # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min
             if ($key == 'atk' || $key == 'atk_max') {
                 $key = 'atk_min';
             }
             $fpower_base_calc[$key] += $val;
             # ----------------------------------------------------------------
             # 强化属性加成
             # ----------------------------------------------------------------
             if (!empty($data['intensive_desc'])) {
                 if (is_string($data['intensive_desc'])) {
                     $data['intensive_desc'] = json_decode($data['intensive_desc'], true);
                 }
                 list($i_key, $i_val) = each($data['intensive_desc']);
                 //强化属性
                 if ($i_key == 'atk' || $i_key == 'atk_max') {
                     $i_key = 'atk_min';
                 }
                 if (isset($star_map['intensify'])) {
                     $i_val += ceil($i_val * ($star_map['intensify'] / 10000));
                     //星图加成
                 }
                 $fpower_calc[$i_key] += $i_val;
             }
             $fpower_calc[$key] += $val;
             $out[] = array(0 => intval($attr_index['equip_base_val']), 1 => array(0 => $role_index[$key], 1 => ceil($val), 2 => 0, 3 => $i_val));
         }
         # ----------------------------------------------------------------
         # 附加属性
         # ----------------------------------------------------------------
         if (!empty($data['addition_attr']) && is_array($data['addition_attr'])) {
             $out_additional = array();
             foreach ($data['addition_attr'] as $key => $val) {
                 # --------------------------------------------------------
                 # 翅膀装备吞噬属性加成
                 # --------------------------------------------------------
                 if (!empty($data['we_swallow_info']) && is_array($data['we_swallow_info']['swallow_attr'])) {
                     if (isset($data['we_swallow_info']['swallow_attr'][$key])) {
                         $add_val = $data['we_swallow_info']['swallow_attr'][$key];
                         if ($key == 'atk' || $key == 'atk_max') {
                             $key = 'atk_min';
                         }
                         $fpower_calc[$key] += $add_val;
                     }
                 }
                 # --------------------------------------------------------
                 # 星图加成
                 # --------------------------------------------------------
                 if (isset($star_map['additional'])) {
                     $val += $val * ($star_map['additional'] / 10000);
                 }
                 # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min
                 if ($key == 'atk' || $key == 'atk_max') {
                     $key = 'atk_min';
                 }
                 $fpower_base_calc[$key] += $val;
                 if (in_array($key, Cache_AttrConfig::getInstance()->get_percent_key())) {
                     $show_type = 1;
                     //前端显示百分比
                 } else {
                     $show_type = 0;
                 }
                 $out_additional[] = array(0 => $role_index[$key], 1 => ceil($val), 2 => $show_type, 3 => ceil($add_val), 'sort_priority' => self::$_sort_priority[$key]);
                 $fpower_calc[$key] += $val;
             }
             # 排序
             Com_Array::multisort($out_additional, array('sort_priority' => 'asc'));
             unset($out_additional['sort_priority']);
             $out[] = array(0 => $attr_index['equip_additional'], 1 => $out_additional);
         }
         # ----------------------------------------------------------------
         # 洗练属性
         # ----------------------------------------------------------------
         if ($data['type'] == 1) {
             # 只有装备类才获取
             if (empty($data['refine_attr']) || empty($data['refine_info'])) {
                 # 为空显示默认洗练属性
                 if (!Com_Util::is_first_charge_item($data['prop_id'])) {
                     list($data['refine_attr'], $data['refine_info']) = TenYear::getInstance('Game_EquipRefine')->extend_refine($data['sub_type'], $data['level']);
                 }
             }
             if (!empty($data['refine_attr']) && is_array($data['refine_attr'])) {
                 $out_refine = array();
                 $attr_perfection_sum = 0;
                 $attr_progress_sum = 0;
                 foreach ($data['refine_attr'] as $attr_seq => $attr_info) {
                     # --------------------------------------------------------
                     # 注意,这两项的取值必须在key做转换之前,否则在key转换后可能导致取不到值
                     # --------------------------------------------------------
                     $attr_limit = $data['refine_info']['attr_info'][$attr_seq]['refine_attr_value'] + $data['refine_info']['attr_info'][$attr_seq]['attr_stint'];
                     $attr_ratio = $data['refine_info']['attr_info'][$attr_seq]['attr_ratio'];
                     $attr_progress = ceil($data['refine_info']['attr_info'][$attr_seq]['en_refine_attr_value'] / $data['refine_info']['attr_info'][$attr_seq]['attr_stint'] * 10000);
                     # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min
                     if (!is_array($attr_info)) {
                         continue;
                     }
                     # TODO: 为了兼容旧的洗练数据,以后要清档上功能,可以除去这行
                     list($key, $val) = each($attr_info);
                     if ($key == 'atk' || $key == 'atk_max') {
                         $key = 'atk_min';
                     }
                     $fpower_base_calc[$key] += $val;
                     $fpower_calc[$key] += $val;
                     $out_refine[] = array(0 => $role_index[$key], 1 => ceil($val), 2 => 0, 3 => $attr_limit, 'sort_priority' => self::$_sort_priority[$key]);
                     $attr_perfection_sum += $attr_ratio;
                     $attr_progress_sum += $attr_progress;
                 }
                 # 排序
                 Com_Array::multisort($out_refine, array('sort_priority' => 'asc'));
                 unset($out_refine['sort_priority']);
                 $out[] = array(0 => $attr_index['equip_refine'], 1 => $out_refine);
                 $out[] = array(0 => $attr_index['equip_refine_perfection'], 1 => ceil($attr_perfection_sum / 5));
                 $out[] = array(0 => $attr_index['equip_en_refine_progress'], 1 => ceil($attr_progress_sum / $data['refine_info']['last_refine_type']));
             }
         }
         #策划要一个道具的基础属性战力
         $fpower_base = Formula_Fpower::calc_fpower($fpower_base_calc);
         $out[] = array(0 => intval($attr_index['raw_fpower']), 1 => $fpower_base);
         # ----------------------------------------------------------------
         # 强化等级
         # ----------------------------------------------------------------
         if (!empty($data['intensive_level'])) {
             $out[] = array(0 => $attr_index['intensive_level'], 1 => $data['intensive_level']);
         }
         # ----------------------------------------------------------------
         # 最大强化等级
         # ----------------------------------------------------------------
         if ($data['type'] == 1) {
             # 只有装备类才获取
             $intensify_lv_limit = TenYear::getInstance('Game_EquipIntensifier')->get_intensify_lv_limit_by_item_level($data['level']);
             $out[] = array(0 => $attr_index['intensify_max'], 1 => $intensify_lv_limit);
         }
         # ----------------------------------------------------------------
         # 强化属性
         # ----------------------------------------------------------------
         if (!empty($data['intensive_desc'])) {
             if (is_string($data['intensive_desc'])) {
                 $data['intensive_desc'] = json_decode($data['intensive_desc'], true);
             }
             $val = 0;
             list($key, $val) = each($data['intensive_desc']);
             //强化属性
             # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min
             if ($key == 'atk' || $key == 'atk_max') {
                 $key = 'atk_min';
             }
             if (isset($star_map['intensify'])) {
                 $val += ceil($val * ($star_map['intensify'] / 10000));
                 //星图加成
             }
             $fpower_calc[$key] += $val;
             $out[] = array(0 => $attr_index['equip_strengthen_val'], 1 => $val);
         }
         # ----------------------------------------------------------------
         # 翅膀装备吞噬等级与经验
         # ----------------------------------------------------------------
         if ($data['type'] == 6) {
             # 只有翅膀装备类才获取
             if (!empty($data['we_swallow_info'])) {
                 $out[] = array(0 => $attr_index['wing_equip_swallow_lv'], 1 => $data['we_swallow_info']['swallow_lv']);
                 $out[] = array(0 => $attr_index['wing_equip_swallow_exp'], 1 => $data['we_swallow_info']['swallow_exp']);
             } else {
                 $out[] = array(0 => $attr_index['wing_equip_swallow_lv'], 1 => 0);
                 $out[] = array(0 => $attr_index['wing_equip_swallow_exp'], 1 => 0);
             }
         }
         # ----------------------------------------------------------------
         # 镶嵌宝石属性
         # ----------------------------------------------------------------
         $gem_item = array();
         $gem_configs = array();
         $hole_stint = TenYear::getInstance('Game_EquipInlayGems')->get_prop_inlay_gem_hole_stint($data);
         # 孔位上限
         for ($i = 1; $i <= $hole_stint; $i++) {
             //镶嵌部分
             if (!empty($data['inlay_gems'][$i])) {
                 $gem_id = $data['inlay_gems'][$i];
                 if (!isset($gem_configs[$gem_id])) {
                     $gem_configs[$gem_id] = Cache_Forge::getInstance()->get_inlay_gems_by_id($gem_id);
                 }
                 $attr = self::parse_gem_config_attr($gem_configs[$gem_id]);
                 $out_additional = array();
                 $gem_fpower = 0;
                 if (!empty($attr)) {
                     foreach ($attr as $key => $val) {
                         if ($key == 'atk' || $key == 'atk_max') {
                             $key = 'atk_min';
                         }
                         if (isset($star_map['gem'])) {
                             $val += ceil($val * ($star_map['gem'] / 10000));
                             //星图加成
                         }
                         /**
                                                     if(in_array($key,Cache_AttrConfig::getInstance()->get_percent_key())){
                                                         $show_type = 1; //前端显示百分比
                         
                                                     }
                                                     else{
                                                         $show_type = 0;
                                                     }
                         							**/
                         if (isset($role_index[$key])) {
                             $fpower_calc[$key] += $val;
                             $out_additional[] = array(0 => $role_index[$key], 1 => intval($val));
                         }
                     }
                     $gem_fpower += Formula_Fpower::calc_fpower($attr);
                 }
                 $gem_item[] = array(0 => $i, 1 => self::get_prop_struct($gem_configs[$gem_id]), 2 => $gem_fpower, 3 => $out_additional);
                 //0 sid  1 战力 2 属性
             } else {
                 $gem_item[] = array(0 => $i, 1 => array(), 2 => 0, 3 => array());
                 //0 sid  1 战力 2 属性
             }
         }
         $out[] = array(0 => $attr_index['gem'], 1 => $gem_item);
         //星图属性
         if (isset($data['star_map_id']) && $data['star_map_id'] > 0) {
             $star_attr = array();
             $star_map_config = Cache_Prop::getInstance()->get_prop_info($data['star_map_id']);
             $star_attr['star'] = self::get_prop_struct($star_map_config);
             $star_attr['power'] = 0;
             //战力计算
             $star_attr['property'] = array();
             $star_map_info = Cache_Forge::getInstance()->get_star_map_config_byid($data['star_map_id']);
             if ($star_map_info) {
                 foreach ($star_map_info as $k => $v) {
                     $a = array();
                     $a['addition_type'] = self::$_star_map_attr_enum[$v['data']];
                     #$a['addition_key'] = $v['data'];
                     $a['addition_val'] = $v['data_value'];
                     if (isset($attr_index[$k])) {
                         //                            if(!isset($attr_index[$k])){
                         //                                Com_Log::log($k,'addition',1);
                         //                            }
                         $a['condition_type'] = 0;
                         $a['condition_key'] = array('k' => $attr_index[$k], 'v' => $v['limit_value'], 'per' => 0);
                     } else {
                         if ($k == 'inlay_gems_lv') {
                             $a['condition_type'] = 1;
                         } elseif ($k == 'inlay_gems') {
                             $a['condition_type'] = 2;
                         } elseif ($k == 'activate') {
                             $a['condition_type'] = 3;
                         }
                         $a['condition_key'] = array('k' => 0, 'v' => $v['limit_value'], 'per' => 0);
                     }
                     $star_attr['property'][] = $a;
                 }
             }
             $out[] = array(0 => $attr_index['star'], 1 => $star_attr);
         }
         # ----------------------------------------------------------------
         # 吞噬属性:需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充
         # ----------------------------------------------------------------
         list($allow_swallow_sub_type, $allow_swallow_id) = TenYear::getInstance('Game_EquipSwallow')->get_swallow_restriction_info($data['sub_type']);
         $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;
             }
             $swallow[$swallow_info['swallow_id']] = array('swallow_id' => $swallow_info['swallow_id'], 'swallow_lv' => 0, 'swallow_exp' => 0);
         }
         if (!empty($data['swallow_info'])) {
             foreach ($data['swallow_info'] as $swallow_id => $swallow_info) {
                 $swallow[$swallow_id] = array('id' => $swallow_info['swallow_id'], 'lv' => $swallow_info['swallow_lv'], 'value' => $swallow_info['swallow_exp']);
             }
         }
         $out[] = array(0 => $attr_index['swallow'], 1 => $swallow);
         if (!empty($data['equip_view'])) {
             if (is_string($data['equip_view'])) {
                 $equip_view = $data['equip_view'];
             } else {
                 $equip_view = implode(':', $data['equip_view']);
             }
             if ($equip_view == '0:0:0:0' || $equip_view == '0:0:0') {
                 $equip_view = '';
             }
         }
         $out[] = array(0 => $attr_index['equip_view'], 1 => $equip_view);
         if (!empty($fpower_calc)) {
             //                Com_Log::log('============[start]===========','equip_fpower',1);
             //                Com_Log::log("prop_id:{$data['prop_id']}",'equip_fpower',1);
             //                Com_Log::log($fpower_calc,'equip_fpower',1);
             $data['fpower'] = Formula_Fpower::calc_fpower($fpower_calc);
             //                Com_Log::log("fpower:{$data['fpower']}",'equip_fpower',1);
             //                Com_Log::log('============[end]===========','equip_fpower',1);
         } else {
             $data['fpower'] = 0;
         }
     }
     foreach (self::$_out_base_keys as $key) {
         if ($key == 'bind_type') {
             #特殊处理下
             if (isset($attr_index[$key]) && isset($data['bind_flag'])) {
                 $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data['bind_flag']));
             }
         } elseif ($key == 'star_level') {
             if ($data['star_level'] > 10) {
                 $data['star_level'] = $data['show_star'];
             }
             $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data['star_level']));
         } else {
             if (isset($attr_index[$key]) && isset($data[$key]) && !empty($data[$key])) {
                 $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data[$key]));
             }
         }
     }
     return $out;
 }
Ejemplo n.º 2
0
 private function filter_unvalid_props($player_prop_info, $player_props)
 {
     if (empty($player_props)) {
         return $player_props;
     }
     foreach ($player_props as $key => $val) {
         # 过滤非装备道具
         if ($val['type'] != $this->equip_type) {
             unset($player_props[$key]);
         }
         # 过滤自身
         if ($val['player_prop_id'] == $player_prop_info['player_prop_id']) {
             unset($player_props[$key]);
         }
         # 过滤首充装备
         if (Com_Util::is_first_charge_item($val['prop_id'])) {
             unset($player_props[$key]);
         }
         # 过滤非相同类型与子类型
         if ($val['type'] != $player_prop_info['type'] || $val['sub_type'] != $player_prop_info['sub_type']) {
             unset($player_props[$key]);
         }
         # 过滤等级不符合要求装备
         if ($val['level'] < $player_prop_info['level']) {
             unset($player_props[$key]);
         } elseif ($val['level'] == $player_prop_info['level']) {
             # 过滤品质不符合要求装备
             if ($val['quality'] < $player_prop_info['quality']) {
                 unset($player_props[$key]);
             } elseif ($val['quality'] == $player_prop_info['quality']) {
                 # 过滤星级不符合要求装备
                 if ($val['star_level'] <= $player_prop_info['star_level']) {
                     unset($player_props[$key]);
                 }
             }
         }
     }
     return $player_props;
 }
Ejemplo n.º 3
0
 public function wing_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', 'career_type'));
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
     # 1515展示协议返回数据,1515协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充
     $out_1515 = array('player_ppid' => $player_prop_id, 'swallow_ppids' => $swallow_equips, 'item_struct' => 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);
     $before_player_prop_info = $player_prop_info;
     if (empty($player_prop_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     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_1515['swallow_ppids'] = "";
             return $out_1515;
         }
     }
     # 计算吞噬属性最大等级
     $swallow_lv_max = $this->get_we_swallow_lv_max($player_prop_info['vocation_limit'], $player_detail);
     $swallow_config_max = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($swallow_lv_max);
     if (empty($swallow_config_max)) {
         $this->throw_error('80047');
         # 未找到翅膀装备吞噬配置信息
     }
     $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['we_swallow_info']) ? array() : $player_prop_info['we_swallow_info'];
     $player_prop_id_slave = "";
     $item_id_slave = "";
     $onekey_prop_list = array();
     # 保存允许一键吞噬的装备ID列表
     foreach ($swallow_equips as $pprop_id) {
         if (!empty($type)) {
             # 实际吞噬
             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 ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) {
                 $this->throw_error('80044');
                 # 装备品质未达到被吞噬要求
             }
             if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) {
                 $this->throw_error('80045');
                 # 装备已达到最大吞噬等级
             }
         } else {
             # 非实际吞噬
             if (!empty($onekey)) {
                 # 一键勾选
                 if (empty($player_prop_details[$pprop_id])) {
                     continue;
                 }
                 if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) {
                     continue;
                 }
                 if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) {
                     continue;
                 }
                 if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) {
                     continue;
                 }
             } else {
                 # 单项勾选,单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环
                 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 ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) {
                     $message = array('texts' => array(array('code' => 80044, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 装备品质未达到被吞噬要求
                     break;
                 }
                 if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) {
                     $message = array('texts' => array(array('code' => 80045, 'content' => array(), 'params' => array())), 'delay' => 0);
                     Protocol::input($player_id, 3, 7, 742, $message);
                     # 装备已达到最大吞噬等级
                     break;
                 }
             }
         }
         $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']] * (1 + intval($player_prop_details[$pprop_id]['level'] / 5) / 4);
         if (isset($player_prop_info['we_swallow_info'])) {
             $player_prop_info['we_swallow_info']['swallow_exp'] += $add_swallow_exp;
         } else {
             $player_prop_info['we_swallow_info'] = array('swallow_lv' => 0, 'swallow_exp' => $add_swallow_exp, 'swallow_attr' => array());
         }
     }
     # 根据吞噬属性的exp,刷新吞噬属性的lv
     if (!empty($player_prop_info['we_swallow_info'])) {
         $swallow_config = Cache_Forge::getInstance()->get_we_swallow_config_by_exp($player_prop_info['we_swallow_info']['swallow_exp']);
         if (!empty($swallow_config)) {
             $player_prop_info['we_swallow_info']['swallow_lv'] = min($swallow_config['swallow_lv'], $swallow_lv_max);
             # 根据最大lv,修正经验值
             if ($player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) {
                 $player_prop_info['we_swallow_info']['swallow_exp'] = $swallow_config_max['swallow_exp'] - 1;
             }
         } else {
             $this->throw_error('80047');
             # 未找到翅膀装备吞噬配置信息
         }
     }
     # 根据吞噬等级,计算吞噬加成附加属性
     $we_swallow_revise_info = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($player_prop_info['we_swallow_info']['swallow_lv']);
     if (empty($we_swallow_revise_info)) {
         $this->throw_error('80047');
         # 未找到翅膀装备吞噬配置信息
     }
     foreach ($player_prop_info['addition_attr'] as $attr_key => $attr_val) {
         $attr_val = ceil($attr_val * $we_swallow_revise_info['attr_revise_ratio'] / 10000) + $we_swallow_revise_info[$attr_key];
         $player_prop_info['we_swallow_info']['swallow_attr'][$attr_key] = $attr_val;
     }
     if (empty($type)) {
         # 修正被吞噬的装备列表,去除吞噬属性达到上限及之后的其它装备
         $out_1515['swallow_ppids'] = empty($onekey_prop_list) ? "" : implode(":", $onekey_prop_list);
         $out_1515['item_struct'] = Struct_Prop::get_prop_struct($player_prop_info);
         if (empty($out_1515['swallow_ppids']) && !empty($onekey)) {
             # 没有能被吞噬的装备
             $message = array('texts' => array(array('code' => 80046, 'content' => array(), 'params' => array())), 'delay' => 0);
             Protocol::input($player_id, 3, 7, 742, $message);
             # 没有可以被吞噬的装备
         }
         return $out_1515;
     }
     $out_1516 = 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('we_swallow_info' => $player_prop_info['we_swallow_info'], 'we_swallow_version' => $this->we_swallow_version));
     $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' => 1516));
         $this->write_check($re, 3010182);
     }
     # 刷新玩家翅膀战力与镶嵌装备的附加属性及战力
     if ($player_prop_info['item_position'] == $this->wing_pos) {
         $wing_attr = $player_detail['wing_info'][$player_prop_info['vocation_limit']];
         # 修正缓存的翅膀装备吞噬信息
         $wing_attr['equipment'][$player_prop_info['sub_type']]['we_swallow_info'] = $player_prop_info['we_swallow_info'];
         $wing_attr['equip_attr'] = $this->get_game('PlayerWing')->get_wing_equip_attr($wing_attr['equipment']);
         # 减去吞噬之前的战力
         Struct_Prop::get_item_additions($before_player_prop_info);
         $wing_attr['fight'] -= $before_player_prop_info['fpower'];
         $wing_attr['equipment_fight'] -= $before_player_prop_info['fpower'];
         if ($wing_attr['fight'] < 0) {
             $wing_attr['fight'] = 0;
         }
         if ($wing_attr['equipment_fight'] < 0) {
             $wing_attr['equipment_fight'] = 0;
         }
         # 加上吞噬之后的战力
         $player_prop_info_cp = $player_prop_info;
         Struct_Prop::get_item_additions($player_prop_info_cp);
         $wing_attr['fight'] += $player_prop_info_cp['fpower'];
         $wing_attr['equipment_fight'] += $player_prop_info_cp['fpower'];
         # 更新wing_info
         $player_detail['wing_info'][$player_prop_info['vocation_limit']] = $wing_attr;
         $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info']));
         $this->write_check($re, 3010242);
         #更新翅膀排行
         if ($player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight'] > 0) {
             $wing_fight = $player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight'];
             $this->get_data('RankList')->update_wing_rank($player_id, $player_prop_info['vocation_limit'], $wing_fight);
         }
     }
     $this->commit();
     # 成就相关埋
     $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 39, $player_prop_info['we_swallow_info']['swallow_lv'], 8);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $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['we_swallow_info'], 'before_swallow_lv' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_lv'], 'after_swallow_lv' => $player_prop_info['we_swallow_info']['swallow_lv'], 'before_swallow_exp' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_exp'], 'after_swallow_exp' => $player_prop_info['we_swallow_info']['swallow_exp']);
     Log_Forge::getInstance()->add_log($log_info, 'we_swallow');
     # 通知翅膀属性变更
     if ($player_prop_info['item_position'] == $this->wing_pos) {
         #同步翅膀属性
         $str = $this->get_game('PlayerWing')->get_activation_wing_interface($player_id, $player_detail['wing_info']);
         Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']))));
     }
     # 通知道具变更806
     $ndata = array();
     $ndata[] = $player_prop_info;
     foreach ($player_prop_details as $key => &$val) {
         $val['item_num'] -= 1;
         $out_1516[1]['grid_list'][] = $val['grid'];
         $ndata[] = $val;
     }
     Protocol_Prop::prop_806($player_id, $ndata);
     # 刷装备1506[翅膀装备强化面板]与1514[可吞噬道具列表]
     $out_1506 = $this->get_game('PlayerWing')->equipment_intensify_panel($player_id, 4);
     $out_1514 = $this->get_wing_equips_for_swallow($player_id, $player_prop_id);
     Protocol::input($player_id, 3, 15, 1506, $out_1506);
     Protocol::input($player_id, 3, 15, 1514, $out_1514);
     # 记录行为
     Com_Log::write('xgame.forge_we_swallow', "{$player_id}\t" . "we_swallow\t" . "{$type}\t" . "{$player_prop_id}\t" . implode(",", $swallow_equips));
     return $out_1516;
 }
Ejemplo n.º 4
0
 public function enhanced_refine($player_id, $player_prop_id, $refine_attr_seq, $add_success_rate)
 {
     #$this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_enhanced_refine);
     $this->param_check_numeric(array($player_id, $refine_attr_seq));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (!$player_equip_info) {
         $this->throw_error('80013');
         # 玩家没有该装备!
     }
     if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) {
         $this->throw_error('81105');
         # 首充装备不允许精练
     }
     $out_850 = array('player_prop_id' => $player_prop_id, 'result' => 0);
     # 洗练属性检查
     if (empty($player_equip_info['refine_info'])) {
         $this->throw_error('81008');
         # 洗练属性为空,不能精炼
     }
     # 获取洗练属性key
     /**
     		foreach ($player_equip_info['refine_info']['attr_info'] as $attr_seq => $attr_info) {
     			if ($attr_info['attr_seq'] == $refine_attr_seq) {
     				$en_refine_attr_key = $attr_info['attr_key'];
     				break;
     			}
     		}
     		**/
     if (!isset($player_equip_info['refine_info']['attr_info'][$refine_attr_seq])) {
         $this->throw_error('81009');
         # 精炼属性异常,选择的精炼属性不存在
     }
     $refine_info = $player_equip_info['refine_info'];
     $refine_attr = $player_equip_info['refine_attr'];
     $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']);
     if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] >= $player_equip_info['level'] && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) {
         $this->throw_error('81010');
         # 精炼属性已满
     }
     # 计算成功率 + 货币消耗
     $refine_info_mod = $this->get_en_refine_success_rate_and_cost_currency($refine_info);
     list($cost_currency_type, $cost_currency_value) = explode(":", $refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_cost_currency']);
     if ($add_success_rate) {
         $refine_info_mod['en_refine_success_rate'] += $this->add_success_rate;
     }
     $before_refine_attr = isset($player_equip_info['refine_attr']) ? $player_equip_info['refine_attr'] : array();
     $before_refine_info = isset($player_equip_info['refine_info']) ? $player_equip_info['refine_info'] : array();
     # 更新洗练属性 + 消耗货币
     $this->start_trans();
     $success_flag = false;
     if (Com_Random::probability($refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_success_rate'], 10000)) {
         if ($refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']) {
             $delta = ceil($refine_info_mod['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']);
         } else {
             $delta = 0;
         }
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] += $delta;
         if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] > $refine_info['attr_info'][$refine_attr_seq]['attr_stint']) {
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['attr_stint'];
         }
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] += 1;
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] = 0;
         $refine_info['attr_info'][$refine_attr_seq]['attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['refine_attr_value'] + $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'];
         # 升级
         $en_refine_lv_stint = $this->get_en_refine_lv_stint($player_equip_info['level']);
         $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']);
         if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] < $en_refine_lv_stint && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) {
             # 获取精练属性基础值
             $attr_value_info_en_refine_old = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] += $this->en_refine_lv_delta;
             $attr_value_info_en_refine = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             if (empty($attr_value_info_en_refine)) {
                 $this->throw_error('81011');
                 # 获取洗练属性值配置失败
             }
             $attr_key = $refine_info['attr_info'][$refine_attr_seq]['attr_key'];
             $attr_ratio = $refine_info['attr_info'][$refine_attr_seq]['attr_ratio'];
             $refine_info['attr_info'][$refine_attr_seq]['attr_limit'] = ceil(($attr_value_info_en_refine[$attr_key] - $attr_value_info_en_refine_old[$attr_key]) * ($attr_ratio / 10000));
             $en_refine_conf = Cache_Refine::getInstance()->get_equip_enhanced_refine_base_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             $refine_info['attr_info'][$refine_attr_seq]['attr_section'] = $en_refine_conf['section'];
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] = 0;
         }
         $refine_attr[$refine_attr_seq] = array($refine_info['attr_info'][$refine_attr_seq]['attr_key'] => $refine_info['attr_info'][$refine_attr_seq]['attr_value']);
         $out_850['result'] = 1;
         $success_flag = true;
     } else {
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] += 1;
         # 连续失败精炼次数
     }
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     if ($add_success_rate) {
         $cost_currency_key_other = Cache_Currency::getInstance()->get_key($this->add_success_rate_cost_cur_type);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key_other, $this->add_success_rate_cost_cur_value, 1, 0);
     }
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '850');
     $this->write_check($re, 3010132);
     $update_field = array('refine_attr' => $refine_attr, 'refine_info' => $refine_info);
     $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $update_field);
     $this->write_check($re, 3010414);
     $this->commit();
     # 提示购买成功消息
     if ($success_flag) {
         $message = array('texts' => array(array('code' => 81014, 'content' => array(), 'params' => array(array(array('txt' => '', 'type' => 6, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_key'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_value'] - $before_refine_info['attr_info'][$refine_attr_seq]['attr_value'], 'param' => ''))))), 'delay' => 0);
     } else {
         $message = array('texts' => array(array('code' => 81015, 'content' => array(), 'params' => array())), 'delay' => 0);
     }
     Protocol::input($player_id, 3, 7, 742, $message);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $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_id, 'item_id_master' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'item_position' => $player_equip_info['item_position'], 'action_type' => 2, 'before_refine_attr' => $before_refine_attr, 'after_refine_attr' => $player_equip_info['refine_attr'], 'before_refine_info' => $before_refine_info, 'after_refine_info' => $player_equip_info['refine_info']);
     Log_Forge::getInstance()->add_log($log_info, 'refine');
     # 刷新玩家属性
     if ($player_equip_info['item_position'] == 3) {
         $this->get_game('EquipAttr')->equip_attr($player_id);
     }
     # 粘806 + 通知道具变更信息
     $player_equip_info['refine_attr'] = $update_field['refine_attr'];
     $player_equip_info['refine_info'] = $update_field['refine_info'];
     $ndata = array($player_equip_info);
     Protocol_Prop::prop_806($player_id, $ndata);
     $out_849 = $this->get_enhanced_refine_info($player_id, $player_prop_id, $refine_attr_seq);
     Protocol::input($player_id, 3, 8, 849, $out_849);
     return $out_850;
 }
Ejemplo n.º 5
0
 private function filter_unvalid_props($player_prop_info, $player_props)
 {
     if (empty($player_props)) {
         return $player_props;
     }
     # 过滤非装备道具
     foreach ($player_props as $key => $val) {
         if ($val['type'] != $this->equip_type) {
             unset($player_props[$key]);
         }
         # 过滤自身
         if ($val['player_prop_id'] == $player_prop_info['player_prop_id']) {
             unset($player_props[$key]);
         }
         # 过滤掉品质大于>=4的装备,秋水确定于20150811
         if ($val['quality'] >= 4) {
             unset($player_props[$key]);
         }
     }
     $swallow_restriction = Cache_Forge::getInstance()->get_swallow_restriction($player_prop_info['sub_type']);
     if (!empty($swallow_restriction['allow_swallow_sub_type'])) {
         $allow_swallow_sub_type = explode(":", $swallow_restriction['allow_swallow_sub_type']);
         foreach ($player_props as $key => $val) {
             if (!in_array($val['sub_type'], $allow_swallow_sub_type)) {
                 unset($player_props[$key]);
             }
             if (Com_Util::is_first_charge_item($val['prop_id'])) {
                 # 首充装备不允许被吞噬
                 unset($player_props[$key]);
             }
         }
     }
     return $player_props;
 }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
 public function equip_intensify($player_id, $player_prop_id, $auto_buy, $bless_item_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_intensifier);
     # 参数检查
     $this->param_check_numeric(array($player_id, $auto_buy, $bless_item_id), 0);
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (empty($player_equip_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) {
         $this->throw_error('81101');
         # 首充装备不允许强化
     }
     # 获取强化等级上限
     $intensify_lv_limit = $this->get_intensify_lv_limit_by_item_level($player_equip_info['level']);
     if ($player_equip_info['intensive_level'] >= $intensify_lv_limit) {
         $this->throw_error('80310');
         //已满级
     }
     # 强化配置信息检查
     $intensify_config = Cache_Forge::getInstance()->get_intensify_info($player_equip_info['intensive_level'] + 1, 1);
     # 强化所需宝石检查
     $player_gems = 0;
     # 添加了自动购买强化宝石的逻辑,故没有该材料时不能报错
     $player_gems_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $intensify_config['item_id'], 1);
     if (!empty($player_gems_info)) {
         $gems = array_values($player_gems_info);
         foreach ($gems as $key => $val) {
             $player_gems += $val['item_num'];
         }
     }
     # 以下三种情况下的失败,前端要求仍然返回816协议下行,防止自动强化处理异常
     if ($player_info['silver'] < $intensify_config['silver_num']) {
         $extra_816 = array('is_failed' => 2, 'intensive_info' => array());
         Protocol::input($player_id, 3, 8, 816, $extra_816);
         $message = array('texts' => array(array('code' => 10113, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
         #$this->throw_error('10113'); # 银两不足
     }
     if (!$auto_buy && $player_gems < $intensify_config['item_num']) {
         $extra_816 = array('is_failed' => 3, 'intensive_info' => array());
         Protocol::input($player_id, 3, 8, 816, $extra_816);
         $message = array('texts' => array(array('code' => 80312, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
         #$this->throw_error('80312'); # 玩家强化的强化宝石不足!
     }
     if (!empty($bless_item_id)) {
         # 玩家强化的祝福石不足!
         # 强化所需祝福石检查
         $player_bless_item_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $bless_item_id, 1);
         if (empty($player_bless_item_info)) {
             $extra_816 = array('is_failed' => 4, 'intensive_info' => array());
             Protocol::input($player_id, 3, 8, 816, $extra_816);
             $message = array('texts' => array(array('code' => 80320, 'content' => array(), 'params' => array())), 'delay' => 0);
             Protocol::input($player_id, 3, 7, 742, $message);
             return;
         }
     }
     # 成功率判断
     $flag = false;
     if ($player_equip_info['intensive_lose_times'] >= $intensify_config['lose_num']) {
         $flag = true;
     } else {
         $intensify_success_rate = $intensify_config['chance'];
         if (!empty($bless_item_id)) {
             $intensify_bless_info = Cache_Forge::getInstance()->get_intensify_bless_info_by_item_id($bless_item_id, 1);
             $intensify_success_rate += $intensify_bless_info['add_success_rate'];
         }
         if (Com_Random::probability($intensify_success_rate, 10000)) {
             $flag = true;
         }
     }
     # 强化处理
     $before_intensive_desc = $player_equip_info['intensive_desc'];
     $after_intensive_desc = $this->equip_intensify_handle($flag, $player_id, $player_gems, $player_info, $player_equip_info, $intensify_config, $auto_buy, $bless_item_id);
     # 强化成功后,当前装备的强化等级加1
     if ($flag) {
         $player_equip_info['intensive_level'] += 1;
         # 添加好友动态消息
         $prop_info = Cache_Prop::getInstance()->get_prop_info($player_equip_info['prop_id']);
         $param = array(1 => "0|{$player_equip_info['intensive_level']}|1", 2 => "1|{$player_equip_info['prop_id']},{$prop_info['name']},{$player_equip_info['quality']}|2");
         //$this->get_game("PlayerFriend")->add_friend_news_by_type($player_id, 1, 3, 1, $param);
         # --------------------------------------------------------------------
         # 公告
         # --------------------------------------------------------------------
         $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 2, 'rep_val' => $player_equip_info['prop_id'], 'rep_player_id' => $player_id, 'rep_pid' => $player_equip_info['player_prop_id']), array('rep_type' => 7, 'txt' => $player_equip_info['intensive_level']));
         $this->get_game('SystemNotice')->push_sys_notice($player_id, 61, $player_equip_info['intensive_level'], $replace_info);
         # 强化公告
         if ($player_equip_info['type'] == 1) {
             $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 6, "1:" . $player_equip_info['quality'] . ":" . $player_equip_info['star_level'] . ":" . intval($player_equip_info['intensive_level']) . ":{$player_equip_info['player_prop_id']}", 4);
         } else {
             if ($player_equip_info['type'] == 6) {
                 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 35, "1:" . $player_equip_info['quality'] . ":" . $player_equip_info['star_level'] . ":" . intval($player_equip_info['level']) . ":{$player_equip_info['player_prop_id']}", 4);
             }
         }
     } else {
         # 失败时提示消息
         /**
         			$player_equip_info['intensive_lose_times'] += 1;
         			$sure_succeed = $intensify_config['lose_num'] - $player_equip_info['intensive_lose_times']; # 剩余必定成功次数
         			if ($sure_succeed < 0) $sure_secceed = 0;
         			$message = array(
         				'texts'	=> array(
         					array(
         						'code' 		=> 80906, 
         						'content' 	=> array(), 
         						'params' 	=> array(
         							array (
         								array('txt' => '', 'type' => 7, 'value' => $sure_succeed, 'param' => '')
         							),
         						),
         					),
         				),	
         				'delay'	=> 0,
         			);
         			**/
         $message = array('texts' => array(array('code' => 80919, 'content' => array(), 'params' => array())));
         Protocol::input($player_id, 3, 7, 742, $message);
     }
     $out_816 = array();
     $out_816['is_failed'] = $flag ? 0 : 1;
     # 强化成功后,获取下一级强化信息,若已满级,则可忽略满级标识以外信息内容,9->10级时,失败仍然会返回满级标识,进入下面if结构
     if ($player_equip_info['intensive_level'] >= $intensify_lv_limit) {
         $silver_index = Cache_Currency::getInstance()->get_index('silver');
         $out_816['intensive_info'] = array('result' => 1, 'item_pid' => $player_prop_id, 'upgrade_item' => array(), 'success_per' => 0, 'success_num' => 0, 'fail_num' => 0, 'expend_prop' => "{$intensify_config['item_id']}:{$intensify_config['item_num']}", 'expend_currency' => "{$silver_index}:{$intensify_config['silver_num']}", 'max_intensify_lv' => $intensify_lv_limit);
     } else {
         $ret = $this->get_equip_intensify_info($player_id, $player_prop_id);
         $out_816['intensive_info'] = $ret[0];
     }
     # 通知玩家信息变更[必须放在commit之后]
     # 日常活跃度处理
     $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2000);
     # 日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 107, 107, 1);
     # 引导任务埋点
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 15, 1);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $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' => $player_prop_id, 'item_id' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'before_level' => $flag ? $player_equip_info['intensive_level'] - 1 : $player_equip_info['intensive_level'], 'after_level' => $player_equip_info['intensive_level'], 'before_attr_add' => $before_intensive_desc, 'after_attr_add' => $after_intensive_desc);
     Log_Forge::getInstance()->add_log($log_info, 'intensify');
     Protocol::input($player_id, 3, 8, 816, $out_816);
 }
Ejemplo n.º 8
0
 private function _forward_compatibility_for_refine(&$prop_detail)
 {
     if (empty($prop_detail) || !is_array($prop_detail)) {
         return;
     }
     if ($prop_detail['type'] != 1) {
         return;
     }
     if (empty($prop_detail['refine_attr']) || empty($prop_detail['refine_info'])) {
         if (Com_Util::is_first_charge_item($prop_detail['prop_id'])) {
             return;
         }
         list($refine_attr, $refine_info) = $this->get_game('EquipRefine')->extend_refine($prop_detail['sub_type'], $prop_detail['level']);
         $prop_detail['refine_attr'] = $refine_attr;
         $prop_detail['refine_info'] = $refine_info;
     } else {
         if (Com_Util::is_first_charge_item($prop_detail['prop_id'])) {
             unset($prop_detail['refine_attr']);
             unset($prop_detail['refine_info']);
             return;
         }
         if (intval($prop_detail['refine_version']) < 10) {
             #var_export($prop_detail['refine_info']);
             $refine_lv_stint = $this->get_game('EquipRefine')->get_refine_lv_stint($prop_detail['level']);
             $en_refine_lv_init = $this->get_game('EquipRefine')->get_en_refine_lv_init();
             $en_refine_lv_stint = $this->get_game('EquipRefine')->get_en_refine_lv_stint($prop_detail['level']);
             $attr_value_info_refine = Cache_Refine::getInstance()->get_attr_value_info_refine($refine_lv_stint);
             if ($prop_detail['level'] > $en_refine_lv_init) {
                 $attr_value_info_en_refine = Cache_Refine::getInstance()->get_attr_value_info($prop_detail['level'] - 10);
                 # 可能获得空值
             } else {
                 $attr_value_info_en_refine = array();
                 # 小于初始精炼等级的装备上一精炼等级属性值置空
             }
             $attr_value_info_en_refine_stint = Cache_Refine::getInstance()->get_attr_value_info($en_refine_lv_stint);
             foreach ($prop_detail['refine_info']['attr_info'] as $attr_seq => $attr_info) {
                 $attr_key = $attr_info['attr_key'];
                 $attr_ratio = $attr_info['attr_ratio'];
                 $en_refine_lv = $en_refine_lv_stint;
                 # 当前精炼等级
                 $en_refine_conf = Cache_Refine::getInstance()->get_equip_enhanced_refine_base_info($en_refine_lv);
                 $refine_attr_value = ceil($attr_value_info_refine[$attr_key] * ($attr_ratio / 10000));
                 # 修正洗练属性值
                 $attr_limit = ceil(($attr_value_info_en_refine_stint[$attr_key] - $attr_value_info_en_refine[$attr_key]) * ($attr_ratio / 10000));
                 # 修正当前精炼等级下的精炼属性上限
                 $attr_stint = ceil($attr_value_info_en_refine_stint[$attr_key] * ($attr_ratio / 10000));
                 # 修正最高精炼等级对应的精炼属性上限
                 $attr_section = $en_refine_conf['section'] ? $en_refine_conf['section'] : 10;
                 # 修正当前精炼等级下的精炼分段
                 $en_refine_attr_value = ceil($attr_value_info_en_refine[$attr_key] * $attr_ratio / 10000) + $attr_info['en_refine_success_num'] * ceil($attr_limit / $attr_section);
                 # 修正当前精炼属性值
                 if ($en_refine_attr_value > $attr_stint) {
                     $en_refine_attr_value = $attr_stint;
                 }
                 $attr_value = $refine_attr_value + $en_refine_attr_value;
                 $attr_info_mod = array('attr_seq' => $attr_seq, 'attr_key' => $attr_key, 'attr_value' => $attr_value, 'refine_attr_value' => $refine_attr_value, 'attr_ratio' => $attr_ratio, 'en_refine_lv' => $en_refine_lv, 'en_refine_attr_value' => $en_refine_attr_value, 'attr_limit' => $attr_limit, 'attr_stint' => $attr_stint, 'attr_section' => $attr_section, 'en_refine_success_num' => intval($attr_info['en_refine_success_num']), 'en_refine_failed_cont' => intval($attr_info['en_refine_failed_cont']));
                 $prop_detail['refine_info']['attr_info'][$attr_seq] = $attr_info_mod;
                 $prop_detail['refine_attr'][$attr_seq] = array($attr_key => $prop_detail['refine_info']['attr_info'][$attr_seq]['attr_value']);
             }
             #var_export($prop_detail['refine_info']);
         }
     }
 }