Esempio n. 1
0
 /**
  * 穿戒指的时候返回一个可用的位置 如果位置都有道具默认吧3位置替换掉
  * @param $player_id
  * @return array
  */
 protected function get_ring_body_part($player_id)
 {
     $arr_aim_prop_detail_6 = $this->get_data('PlayerProp')->get_prop_by_grid($player_id, 3, 6);
     if (empty($arr_aim_prop_detail_6)) {
         return array('grid' => 6, 'detail' => array());
     }
     $arr_aim_prop_detail_8 = $this->get_data('PlayerProp')->get_prop_by_grid($player_id, 3, 8);
     if (empty($arr_aim_prop_detail_8)) {
         return array('grid' => 8, 'detail' => array());
     }
     $detail6 = $arr_aim_prop_detail_6;
     Struct_Prop::get_item_additions($detail6);
     $detail8 = $arr_aim_prop_detail_8;
     Struct_Prop::get_item_additions($detail8);
     $prop_detail = array();
     $grid = 0;
     if ($detail6['fpower'] <= $detail8['fpower']) {
         $prop_detail = $arr_aim_prop_detail_6;
         $grid = 6;
     } else {
         $prop_detail = $arr_aim_prop_detail_8;
         $grid = 8;
     }
     return array('grid' => $grid, 'detail' => $prop_detail);
 }
Esempio n. 2
0
 /**
  * @Purpose:
  * 数据修复检测
  */
 public function data_repair($player_id, $player_detail = array())
 {
     $player_id = intval($player_id);
     if (empty($player_detail)) {
         $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
     }
     $data = $player_detail['wing_info'];
     if (Com_Array::is_good_arr($data)) {
         $is_update = false;
         foreach ($data as $wing_id => $wing_data) {
             if ($wing_data['activation'] == 2 && $wing_data['condition'][0] == 4) {
                 if ($wing_data['repair_flag'] < $this->repair_flag) {
                     if (Com_Array::is_good_arr($wing_data['equipment'])) {
                         foreach ($wing_data['equipment'] as $pos => $equipment) {
                             if ($wing_data['repair_flag'] < 4) {
                                 $wing_data['equipment'][$pos] = array();
                                 $arr_remove_prop_detail = $equipment;
                                 Struct_Prop::get_item_additions($arr_remove_prop_detail);
                                 $arr_config = Cache_Prop::getInstance()->get_prop_info($arr_remove_prop_detail['prop_id']);
                                 $arr_remove_prop_detail['type'] = $arr_config['type'];
                                 $wing_data['fight'] -= $arr_remove_prop_detail['fpower'];
                                 $wing_data['fight'] = $wing_data['fight'] > 0 ? $wing_data['fight'] : 0;
                                 $wing_data['equipment_fight'] -= $arr_remove_prop_detail['fpower'];
                                 $wing_data['equipment_fight'] = $wing_data['equipment_fight'] > 0 ? $wing_data['equipment_fight'] : 0;
                                 # ----------------------------------------
                                 # 修复已穿戴装备的属性[在Data/PlayerProp.php中会修复的所有属性][吞噬属性+附加属性]
                                 # ----------------------------------------
                                 $equipment = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $equipment['player_prop_id']);
                                 $wing_data['equipment'][$pos] = $equipment;
                                 $wing_data['equip_attr'] = $this->get_wing_equip_attr($wing_data['equipment']);
                                 $arr_prop_detail = $equipment;
                                 Struct_Prop::get_item_additions($arr_prop_detail);
                                 $arr_config = Cache_Prop::getInstance()->get_prop_info($arr_prop_detail['prop_id']);
                                 $arr_prop_detail['type'] = $arr_config['type'];
                                 $wing_data['fight'] += $arr_prop_detail['fpower'];
                                 $wing_data['equipment_fight'] += $arr_prop_detail['fpower'];
                                 $data[$wing_id] = $wing_data;
                             }
                         }
                     }
                 }
                 if ($wing_data['repair_flag'] < 3 && $wing_data['fight'] > 0) {
                     $this->get_data('RankList')->update_wing_rank($player_id, $wing_id, $wing_data['fight']);
                 }
                 $data[$wing_id]['repair_flag'] = $this->repair_flag;
                 $is_update = true;
             }
         }
         if ($is_update) {
             $this->start_trans();
             $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $data));
             if (!$update_res) {
                 $this->throw_error('10104');
             }
             $this->commit();
             $player_detail['wing_info'] = $data;
             #同步属性
             $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level'));
             $str = $this->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']))));
         }
     }
 }
Esempio 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;
 }
Esempio n. 4
0
 /**
  * 装备模块的战力
  * @param $player_id
  */
 public function calc_equip_fpower($player_id)
 {
     $equips = $this->get_game('Prop')->get_player_equip($player_id);
     $sum_power = 0;
     if (!empty($equips)) {
         foreach ($equips as $prop) {
             Struct_Prop::get_item_additions($prop);
             $sum_power += $prop['fpower'];
         }
     }
     //        $sum_power = 0;
     //        $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id,array('equip_attr'));
     //        if(!empty($player_detail['equip_attr'])){
     //            $attr = array();
     //            foreach($player_detail['equip_attr'] as $key=>$value){
     //                $attr[$key] += $value;
     //            }
     //            $sum_power = Formula_Fpower::calc_fpower($attr);
     //        }
     return ceil($sum_power);
 }