Esempio 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;
 }
Esempio n. 2
0
 /**
  * 获取玩家基础属性
  *
  * @param unknown_type $player_id
  * @return unknown
  */
 protected function get_player_base_attr($player_id, $calc_buff_attr)
 {
     if (is_null($this->_playerItem)) {
         $this->_playerItem = $this->get_data('Player')->get_player_info($player_id);
     }
     $this->_player = $this->_playerItem;
     if (empty($this->_player)) {
         //玩家不存在
         $this->_player = '20001';
         return false;
     }
     if (empty($this->_playerDetailItem)) {
         $this->_playerDetailItem = $this->get_data('PlayerDetail')->get_player_detail($this->_player['player_id']);
     }
     //基础属性
     //        $baseAttrData = $this->_playerDetailItem['base_attr'];
     //        if(isset($baseAttrData['base_attr'])) $baseAttrData=$baseAttrData['base_attr']; //先这样写有的数据错了等可以清空数据库了 删除
     //        if (is_array($baseAttrData)) {
     //            foreach ($baseAttrData as $key=>$value) {
     //                $this->_player[$key] += $value;
     //            }
     //        }
     $baseAttrData = $this->getInitPlayerAttrData($this->_player['career_type']);
     if (is_array($baseAttrData)) {
         foreach ($baseAttrData as $key => $value) {
             $this->_player[$key] += $value;
             //                    if($key == 'atk_min'){
             //                        Com_Log::write('player_attr_atk_'.$this->_player['player_id'],"base {$value}");
             //                    }
         }
     }
     $this->_player['atk_min'] = $this->_player['atk_max'] = Formula_Player::get_upgrade_atk($this->_player['atk_min'], $this->_player['level']);
     //        Com_Log::write('player_attr_atk_'.$this->_player['player_id'],"atk_min {$this->_player['atk_min']}");
     $this->_player['arm'] = $this->_player['arm'] = Formula_Player::get_upgrade_arm($this->_player['arm'], $this->_player['level']);
     $this->_player['hp'] = $this->_player['hp'] = Formula_Player::get_upgrade_hp($this->_player['hp'], $this->_player['level']);
     if ($this->_player['map_id'] == 2100) {
         $this->_player['atk_min'] += 500;
         #策划要求序章攻击加500
     }
     $equip_move_speed = 0;
     if (!empty($this->_playerDetailItem['equip_attr'])) {
         foreach ($this->_playerDetailItem['equip_attr'] as $key => $value) {
             if ($key == 'move_speed') {
                 $equip_move_speed = $value;
             } else {
                 $this->_player[$key] += $value;
             }
         }
     }
     if (!empty($this->_playerDetailItem['fairy_attr_1'])) {
         foreach ($this->_playerDetailItem['fairy_attr_1'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     if (!empty($this->_playerDetailItem['fairy_attr_2'])) {
         foreach ($this->_playerDetailItem['fairy_attr_2'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     if (!empty($this->_playerDetailItem['fashion_attr'])) {
         foreach ($this->_playerDetailItem['fashion_attr'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     if (!empty($this->_playerDetailItem['union_achieve_attr'])) {
         foreach ($this->_playerDetailItem['union_achieve_attr'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     if (!empty($this->_playerDetailItem['achieve_attr_1'])) {
         foreach ($this->_playerDetailItem['achieve_attr_1'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     if (!empty($this->_playerDetailItem['achieve_attr_2'])) {
         foreach ($this->_playerDetailItem['achieve_attr_2'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     # 培养属性加成
     if (!empty($this->_playerDetailItem['train_attr_info']) && is_array($this->_playerDetailItem['train_attr_info'])) {
         foreach ($this->_playerDetailItem['train_attr_info'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     # --------------------------------------------------------------------
     # 培养套装激活效果计算
     # --------------------------------------------------------------------
     $train_set_attr_addition = $this->get_game('Train')->get_player_train_set_attr_addition($this->_player['player_id'], $this->_playerItem, $this->_playerDetailItem);
     # 培养套装加成信息
     if (!empty($train_set_attr_addition)) {
         foreach ($train_set_attr_addition as $attr_key => $attr_val) {
             if (!is_numeric($attr_key)) {
                 # 忽略技能等级的加成
                 $this->_player[$attr_key] += $attr_val;
             }
         }
     }
     # --------------------------------------------------------------------
     #---------------------------------------------------------------------
     #翅膀属性
     #---------------------------------------------------------------------
     if (!empty($this->_playerDetailItem['equip_wing'])) {
         $wing_attr = $this->_playerDetailItem['wing_info'][$this->_playerDetailItem['equip_wing']];
         $addition = 0;
         $attr_addition = array();
         if ($this->_playerDetailItem['equip_wing'] == 7) {
             if (isset($this->_playerDetailItem['wing_info'][8]) && $this->_playerDetailItem['wing_info'][8]['activation'] == 2) {
                 $add_config = Cache_WingAddition::getInstance()->get_wing_addition($this->_playerDetailItem['wing_info'][8]['lvl']);
                 $addition = $add_config['addition'] / 10000;
                 $attr_addition = $this->_playerDetailItem['wing_info'][8]['attr'];
                 if (!empty($this->_playerDetailItem['wing_info'][8]['equip_attr']) && Com_Array::is_good_arr($this->_playerDetailItem['wing_info'][8]['equip_attr'])) {
                     foreach ($this->_playerDetailItem['wing_info'][8]['equip_attr'] as $attr_type => $attr_val) {
                         $attr_addition[$attr_type] += ceil($attr_val);
                     }
                 }
                 foreach ($attr_addition as $attr_type => $attr_val) {
                     $attr_addition[$attr_type] = $attr_val * $addition;
                 }
             }
         }
         if ($this->_playerDetailItem['equip_wing'] == 8) {
             if (isset($this->_playerDetailItem['wing_info'][7]) && $this->_playerDetailItem['wing_info'][7]['activation'] == 2) {
                 $add_config = Cache_WingAddition::getInstance()->get_wing_addition($this->_playerDetailItem['wing_info'][7]['lvl']);
                 $addition = $add_config['addition'] / 10000;
                 $attr_addition = $this->_playerDetailItem['wing_info'][7]['attr'];
                 if (!empty($this->_playerDetailItem['wing_info'][7]['equip_attr']) && Com_Array::is_good_arr($this->_playerDetailItem['wing_info'][7]['equip_attr'])) {
                     foreach ($this->_playerDetailItem['wing_info'][7]['equip_attr'] as $attr_type => $attr_val) {
                         $attr_addition[$attr_type] += ceil($attr_val);
                     }
                 }
                 foreach ($attr_addition as $attr_type => $attr_val) {
                     $attr_addition[$attr_type] = $attr_val * $addition;
                 }
             }
         }
         $w_attr = array();
         if (!empty($wing_attr['attr'])) {
             foreach ($wing_attr['attr'] as $key => $value) {
                 $w_attr[$key] += $value;
             }
         }
         if (!empty($wing_attr['equip_attr'])) {
             foreach ($wing_attr['equip_attr'] as $key => $value) {
                 $w_attr[$key] += $value;
             }
         }
         if (!empty($attr_addition)) {
             foreach ($attr_addition as $key => $value) {
                 $w_attr[$key] += $value;
             }
         }
         if (!empty($w_attr)) {
             foreach ($w_attr as $key => $value) {
                 $this->_player[$key] += $value;
             }
         }
     }
     #---------------------------------------------------------------------
     #文斌的属性
     #---------------------------------------------------------------------
     if (!empty($this->_playerDetailItem['player_grade_attr'])) {
         foreach ($this->_playerDetailItem['player_grade_attr'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     #---------------------------------------------------------------------
     #帮会的属性
     #---------------------------------------------------------------------
     if (!empty($this->_playerDetailItem['union_player_attr'])) {
         foreach ($this->_playerDetailItem['union_player_attr'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     #---------------------------------------------------------------------
     #声望的属性
     #---------------------------------------------------------------------
     if (!empty($this->_playerDetailItem['fame_attr'])) {
         foreach ($this->_playerDetailItem['fame_attr'] as $key => $value) {
             $this->_player[$key] += $value;
         }
     }
     if (!empty($this->_playerDetailItem['vip_special_attr'])) {
         foreach ($this->_playerDetailItem['vip_special_attr'] as $key => $value) {
             $this->_player[$key] += $this->_player[$key] * ($value / 10000);
         }
     }
     if ($calc_buff_attr) {
         #TODO:看这个参数是不是要算buff属性 现在是排行查看的时候要计算 登陆的时候获取人物帐数据的的时候不用
         if (!empty($this->_playerDetailItem['dower_info'])) {
             $arr_buff = array();
             foreach ($this->_playerDetailItem['dower_info'] as $val) {
                 $dower = Cache_Dower::getInstance()->get_dower_info($val['dower_id'], $val['dower_lv']);
                 if (!empty($dower)) {
                     $skillPassive = Cache_SkillPassive::getInstance()->get_skill_passive_info(array('sid' => $dower['skill_id'], 'level' => $val['dower_lv']));
                     if (!empty($skillPassive['buff_id1'])) {
                         $arr_buff[] = $skillPassive['buff_id1'];
                     }
                     if (!empty($skillPassive['buff_id2'])) {
                         $arr_buff[] = $skillPassive['buff_id2'];
                     }
                 }
             }
             if ($arr_buff) {
                 $buff_data = Cache_SkillBuff::getInstance()->get_buff_data($arr_buff);
                 if ($buff_data) {
                     foreach ($buff_data as $val) {
                         $attr_key = $this->get_game('BuffData')->get_attr_by_buff_type($val['param1']);
                         if ($val['buff_type'] == 'mod_fight_attr') {
                             $this->_playerDetailItem['buff_attr'][$attr_key] += $val['param2'];
                         }
                         if ($val['buff_type'] == 'mod_fight_attr_%') {
                             $this->_playerDetailItem['buff_attr_per'][$attr_key] += $val['param2'];
                         }
                     }
                 }
             }
         }
         #---------------------------------------------------------------------
         #buff属性
         #---------------------------------------------------------------------
         if (!empty($this->_playerDetailItem['buff_attr'])) {
             foreach ($this->_playerDetailItem['buff_attr'] as $key => $value) {
                 if ($key == 'hp' || $key == 'atk_min' || $key == 'arm') {
                     $this->_player[$key] += intval($this->_player[$key] * ($value / 10000));
                 }
             }
         }
         #---------------------------------------------------------------------
         #buff百分比属性
         #---------------------------------------------------------------------
         if (!empty($this->_playerDetailItem['buff_attr_per'])) {
             foreach ($this->_playerDetailItem['buff_attr_per'] as $key => $value) {
                 if ($key == 'hp' || $key == 'atk_min' || $key == 'arm') {
                     $this->_player[$key] += intval($this->_player[$key] * ($value / 100));
                 }
             }
         }
     }
     //        #vip特权加成  vip升级的时候挪到
     //
     //        $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($this->_player['privilege_level'],10066);
     //
     //        if($vip_level_config){
     //            $this->_player['hp'] += $this->_player['hp'] * ($vip_level_config['max_times']/10000);
     //        }
     //        $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($this->_player['privilege_level'],10067);
     //        if($vip_level_config){
     //            $this->_player['atk_min'] += $this->_player['atk_min'] * ($vip_level_config['max_times']/10000);
     //        }
     //        $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($this->_player['privilege_level'],10068);
     //        if($vip_level_config){
     //            $this->_player['arm'] += $this->_player['arm'] * ($vip_level_config['max_times']/10000);
     //        }
     if ($equip_move_speed > 0) {
         $this->_player['move_speed'] = $this->_player['move_speed'] * (1 + $equip_move_speed / 10000);
     }
     ###统一向上取整
     foreach (Cache_AttrConfig::get_attr() as $key) {
         $this->_player[$key] = intval($this->_player[$key]);
     }
     return $this->_player;
 }
Esempio n. 3
0
 public function sync($data)
 {
     if (empty($data)) {
         return;
     }
     $data = json_decode($data, true);
     if (!isset($data['player_id'])) {
         return;
     }
     $player_id = $data['player_id'];
     $arr_update = $data['arr_update'];
     $gateway = $data['gateway'];
     //测试环境 推送到不同的gateway
     //        echo $gateway."\n";
     SynPlayer::init($player_id);
     SynPlayer::set_player($player_id);
     if (isset($arr_update['load']) && $arr_update['load'] == 1) {
         #登陆的时候加载下数据
         SynPlayer::init_syn_data(null);
         SynPlayer::set_syn_data($arr_update['init_data']);
         return;
     }
     ########################################################
     $objPlayerBase = $this->get_game('PlayerBase');
     $objFpowerCalc = $this->get_game('FpowerCalc');
     $objPlayer = $this->get_data('Player');
     $objDetail = $this->get_data('PlayerDetail');
     $objPlayerSkill = $this->get_game('PlayerSkill');
     $objPlayerAchieve = $this->get_game('PlayerAchieve');
     $objFairy = $this->get_data('Fairy');
     $objHero = $this->get_game('Hero');
     $objPlayerHero = $this->get_data('PlayerHero');
     $objPlayerWing = $this->get_game('PlayerWing');
     ########################################################
     $player_detail = null;
     $playerInfo = null;
     if (isset($arr_update['player_data'])) {
         $player_detail = $arr_update['player_data']['player_detail'];
         $playerInfo = $arr_update['player_data']['player'];
         if (isset($arr_update['player_data']['player_detail']) && empty($player_detail)) {
             $player_detail = $objDetail->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
         }
         if (isset($arr_update['player_data']['player']) && empty($playerInfo)) {
             $playerInfo = $objPlayer->get_player_info($player_id);
         }
         // Com_Log::write("sync.".$player_id,"player_data".var_export($arr_update['player_data'],true));
     }
     //Com_Log::write("sync.".$player_id,"player_detail".var_export($player_detail,true));
     //Com_Log::write("sync.".$player_id,"playerInfo".var_export($playerInfo,true));
     $cur_data = SynPlayer::get_uval();
     //        Com_Log::write('potion_hot_cnt_'.$player_id,var_export($cur_data,true));
     if (empty($cur_data)) {
         SynPlayer::init_syn_data(null);
         $init_data = $objPlayerBase->get_player_init_info($player_id);
         SynPlayer::set_syn_data($init_data);
         $cur_data = SynPlayer::get_uval();
         if (isset($arr_update['potion_dh_cnt'])) {
             $arr_update['potion_dh_cnt'] = 0;
         }
         #初次同步 如果有这些同步就置为0
         if (isset($arr_update['potion_hot_cnt'])) {
             $arr_update['potion_hot_cnt'] = 0;
         }
         if (isset($arr_update['mp_potion_cnt'])) {
             $arr_update['mp_potion_cnt'] = 0;
         }
     }
     $syn_item = array();
     $player_info = array();
     if (isset($arr_update['attr']) || isset($arr_update['fairy_info']) || isset($arr_update['hero_info'])) {
         //更新人物属性
         //            Com_Log::write('sync_player',"############################[start]##################################");
         //            Com_Log::write('sync_player',"cur_data:".var_export($cur_data,true));
         $player_info = $this->get_player_info($player_id, $playerInfo, $player_detail);
         $attr = Cache_AttrConfig::getInstance()->get_attr();
         //            Com_Log::write('sync_player',"attr:".var_export($attr,true));
         $attr_mag = array();
         $level = $cur_data[36];
         //            Com_Log::write("sync_level.".$player_id,"level:{$level}");
         foreach ($attr as $key) {
             $cur_val = $cur_data[SynPlayer::get_attr_inde($key)];
             $now_val = intval($player_info[$key]);
             //                Com_Log::write('sync_player.'.$player_id,"key:{$key} cur_val:{$cur_val} now_val:{$now_val}");
             //                echo "key:{$key} cur_val:{$cur_val} now_val:{$now_val}\n";
             if ($cur_val != $now_val) {
                 $diff_val = $now_val - $cur_val;
                 if ($level <= 20 && $diff_val < 0) {
                     //                        continue;
                 } else {
                     if ($diff_val < 0) {
                         $diff_val = $diff_val * -1;
                         $color = "FC0100";
                         $symbol = "-";
                     } else {
                         $color = "66FD34";
                         $symbol = "+";
                     }
                     if ($key != 'atk_max') {
                         $param = array(array('rep_type' => 6, 'rep_val' => $key), array('rep_type' => 7, 'rep_val' => $symbol, 'rep_color' => $color), array('rep_type' => 7, 'rep_val' => $diff_val, 'rep_color' => $color));
                         $attr_mag[] = Language_Message::make_message('10116', $param);
                     }
                 }
             }
             $syn_item[$key] = $now_val;
             //                Com_Log::write('sync_player',"############################[end]##################################");
         }
         if (!empty($attr_mag)) {
             if (isset($arr_update['exp'])) {
                 $msg_out = array(0 => $attr_mag, 1 => 2000);
             } else {
                 $msg_out = array(0 => $attr_mag, 1 => 0);
             }
             Protocol::input($player_id, 8, 7, 742, $msg_out);
         }
     }
     $update_fpower = array();
     if (isset($arr_update['wing']) || isset($arr_update['dower_info']) || isset($arr_update['hero_info']) || isset($arr_update['attr']) || isset($arr_update['fairy_info']) || isset($arr_update['skill_infos'])) {
         if (empty($player_info)) {
             $player_info = $this->get_player_info($player_id, $playerInfo, $player_detail);
         }
         Com_Log::write("player_fpower." . $player_id, "############################[start]#####################################");
         Com_Log::write("player_fpower." . $player_id, "player_info:" . var_export($player_info, true));
         Com_Log::write("player_fpower." . $player_id, "player_detail:" . var_export($player_detail, true));
         //            Com_Log::write("sync_player_fpower.".$player_id,"player_info:".var_export($player_info,true));
         //            Com_Log::write("sync_player_fpower.".$player_id,"player_detail:".var_export($player_detail,true));
         $objFpowerCalc->set_player_info($player_info);
         $objFpowerCalc->set_player_detail($player_detail);
         $player_fpower = $this->get_game('FpowerCalc')->calc_player_fpower($data['player_id']);
         $player_info['fpower'] = $update_fpower['fpower'] = $player_fpower['fpower'];
         $update_fpower['buff_fpower'] = $syn_item['buff_fpower'] = $player_fpower['buff_fpower'];
         if (isset($arr_update['attr'])) {
             $update_fpower['equip_fpower'] = $objFpowerCalc->calc_equip_fpower($player_id);
             $player_info['equip_fpower'] = $syn_item['equip_fpower'] = $update_fpower['equip_fpower'];
             $update_fpower['sq_fpower'] = $objFpowerCalc->calc_sq_fpower($player_id);
             $player_info['sq_fpower'] = $syn_item['sq_fpower'] = $update_fpower['sq_fpower'];
         }
         if (isset($arr_update['fairy_info'])) {
             $update_fpower['fairy_fpower'] = $objFpowerCalc->calc_fairy_fpower($player_id);
             $player_info['fairy_fpower'] = $syn_item['fairy_fpower'] = $update_fpower['fairy_fpower'];
         }
         if (isset($arr_update['hero_info'])) {
             $update_fpower['hero_fpower'] = $objFpowerCalc->calc_hero_fpower($player_id);
             $player_info['hero_fpower'] = $syn_item['hero_fpower'] = $update_fpower['hero_fpower'];
         }
         if (isset($arr_update['skill_infos']) || isset($arr_update['dower_info'])) {
             $update_fpower['skill_fpower'] = $objFpowerCalc->calc_skill_fpower($player_id);
             $player_info['skill_fpower'] = $syn_item['skill_fpower'] = $update_fpower['skill_fpower'];
         }
         if (isset($arr_update['wing'])) {
             $update_fpower['wing_fpower'] = $objFpowerCalc->calc_wing_fpower($player_id);
             $player_info['wing_fpower'] = $syn_item['wing_fpower'] = $update_fpower['wing_fpower'];
         }
         if ($update_fpower) {
             $update_fpower['fpower'] = $player_info['fpower'] + $player_info['sq_fpower'] + $player_info['skill_fpower'] + $player_info['equip_fpower'];
             Com_Log::write("player_fpower." . $player_id, "fpower:{$player_info['fpower']} sq_fpower:{$player_info['sq_fpower']} skill_fpower:{$player_info['skill_fpower']} equip_fpower:{$player_info['equip_fpower']}");
             $sum_fpower = $update_fpower['fpower'] + $player_info['hero_fpower'] + $player_info['fairy_fpower'] + $player_info['wing_fpower'] + $update_fpower['buff_fpower'];
             Com_Log::write("player_fpower." . $player_id, "hero_fpower:{$player_info['hero_fpower']} fairy_fpower:{$player_info['fairy_fpower']} wing_fpower:{$player_info['wing_fpower']} buff_fpower:{$update_fpower['buff_fpower']}");
             $update_fpower['sum_fpower'] = $sum_fpower;
             if ($sum_fpower > $player_info['max_sum_fpower']) {
                 $update_fpower['max_sum_fpower'] = $sum_fpower;
             }
             $yesterday_max_sum_fpower = $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, 'yesterday_max_sum_fpower');
             if (intval($yesterday_max_sum_fpower) == 0) {
                 $grab_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id);
                 if (!empty($grab_treasure_info)) {
                     $yesterday_max_sum_fpower = intval($player_info['max_sum_fpower']) ? $player_info['max_sum_fpower'] : $player_info['sum_fpower'];
                     $this->get_data("PlayerDailyTime")->set_used_time($player_id, 'yesterday_max_sum_fpower', $yesterday_max_sum_fpower);
                 }
             }
             $objPlayer->update_player_info($player_id, $update_fpower);
             $syn_item['fpower'] = $update_fpower['fpower'];
             $syn_item['sum_fpower'] = $sum_fpower;
             Com_Log::write("player_fpower." . $player_id, "sum_fpower:{$sum_fpower} fpower:{$update_fpower['fpower']}");
             $this->get_data("Player")->set_player_sum_fpower($player_id, $sum_fpower);
             if ($player_info['level'] > 20) {
                 if (!isset($player_info['union_id'])) {
                     $playerInfo = $objPlayer->get_player_info($player_id);
                 }
                 $this->get_data("UnionInfo")->set_union_player_sum_fpower($player_info['union_id'], $player_id, $sum_fpower);
             }
             $objPlayerAchieve->async_trigger_achieve_target($player_id, 1, $sum_fpower, 2, $player_info['level']);
         }
         $objFpowerCalc->clear_static();
         unset($arr_update['attr']);
         Com_Log::write("player_fpower." . $player_id, "############################[end]#####################################");
     }
     if (isset($arr_update['equip_model']) || isset($arr_update['fashion_fit'])) {
         if (empty($arr_update['equip_model'])) {
             $arr_update['equip_model'] = $this->get_equip_views($player_id);
         }
         if (!isset($player_detail['fashion_fit']) || !isset($player_detail['player_settings'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('fashion_fit', 'player_settings'));
         }
         $fashion_fit = $player_detail['fashion_fit'];
         $meditation_flag = isset($player_detail['player_settings'][34]) ? $player_detail['player_settings'][34] : 0;
         if ($meditation_flag == 0) {
             if ($fashion_fit) {
                 $fashions = Cache_Fashion::getInstance()->get_fashion(array_values($fashion_fit));
                 if ($fashions) {
                     if (isset($fashion_fit[1])) {
                         $arr_update['equip_model'][3] = $fashions[$fashion_fit[1]]['equip_view'];
                     }
                     if (isset($fashion_fit[2])) {
                         $arr_update['equip_model'][0] = $fashions[$fashion_fit[2]]['equip_view'];
                     }
                 }
             }
         }
         $syn_item['equip'] = $arr_update['equip_model'];
         unset($arr_update['equip_model']);
     }
     if (isset($arr_update['meditation'])) {
         if (!isset($player_detail['player_settings'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('player_settings'));
         }
         $player_settings = $player_detail['player_settings'];
         if (isset($player_settings[37]) && $player_settings[37] == 1) {
             $syn_item['meditation_status'] = 1;
         } elseif (isset($player_settings[38]) && $player_settings[38] == 1) {
             $syn_item['meditation_status'] = 2;
         } else {
             $syn_item['meditation_status'] = 0;
         }
     }
     # 冥想功能开启状态同步
     if (isset($arr_update['meditation_open_status'])) {
         if (empty($arr_update['meditation_open_status'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('func_open'));
         } else {
             $player_detail = $arr_update['meditation_open_status'];
         }
         if (isset($player_detail['func_open']['44'])) {
             $syn_item['meditation_open_status'] = 1;
         } else {
             $syn_item['meditation_open_status'] = 0;
         }
     }
     if (isset($arr_update['equip_swallow'])) {
         $syn_item['equip_swallow'] = $arr_update['equip_swallow'];
         unset($arr_update['equip_swallow']);
     }
     if (isset($arr_update['equip_skill'])) {
         $syn_item['equip_skill'] = $arr_update['equip_skill'];
         unset($arr_update['equip_skill']);
     }
     //        $log_skill = false;
     if (isset($arr_update['skill_infos'])) {
         //Com_Log::write("skill_infos.".$player_id,"player_info:".var_export($arr_update,true));
         //Com_Log::write("skill_infos.".$player_id,"player_info:".var_export($playerInfo,true));
         //Com_Log::write("skill_infos.".$player_id,"player_deatail:".var_export($player_detail,true));
         $skill_infos = $objPlayerSkill->skill_list($player_id, $playerInfo, $player_detail);
         //            Com_Log::write('sync_skill_infos.'.$player_id,var_export($skill_infos['skill_infos'],true));
         $syn_item['skill_infos'] = $skill_infos['skill_infos'];
         //            $log_skill = true;
         unset($arr_update['skill_infos']);
     }
     if (isset($arr_update['fairy_info'])) {
         $fairy_list = $objFairy->get_player_fairy_list($player_id);
         $syn_item['fairy_info'] = array();
         if (!empty($fairy_list)) {
             foreach ($fairy_list as $keys => $val) {
                 foreach ($val['combination_list'] as $value) {
                     //获取有镶嵌的属性ID
                     if ($value['state'] > 1) {
                         $val['triggers'][] = $value['state'];
                     }
                 }
                 $syn_item['fairy_info'][] = $val;
             }
         }
         unset($arr_update['fairy_info']);
     }
     if (isset($arr_update['hero_info'])) {
         $hero_list = $this->get_data('PlayerHero')->get_fight_hero($player_id);
         if ($hero_list) {
             list($hero_id1, $hero_code1) = each($hero_list);
             if ($hero_id1) {
                 $hero_info = $this->get_game('Hero')->get_player_hero_attr($player_id, $hero_id1);
                 $syn_item['hero_info'] = $hero_info;
                 $syn_item['hero_code'] = $hero_code1;
                 $syn_item['hero_state'] = 1;
                 $syn_item['hero_level'] = $hero_info['hero_level'];
                 $syn_item['hero_fit_level'] = $hero_info['fit'];
             } else {
                 $syn_item['hero_code'] = 0;
                 $syn_item['hero_state'] = 0;
                 $syn_item['hero_info'] = array();
                 $syn_item['hero_fit_level'] = 0;
             }
             list($hero_id2, $hero_code2) = each($hero_list);
             if ($hero_id2) {
                 $after_hero_info = $this->get_game('Hero')->get_player_hero_attr($player_id, $hero_id2);
                 $syn_item['hero2_info'] = $after_hero_info;
                 $syn_item['hero2_code'] = $hero_code2;
                 $syn_item['hero2_state'] = 1;
                 $syn_item['hero2_level'] = $after_hero_info['hero_level'];
                 $syn_item['hero2_fit_level'] = $after_hero_info['fit'];
             } else {
                 $syn_item['hero2_code'] = 0;
                 $syn_item['hero2_state'] = 0;
                 $syn_item['hero2_info'] = array();
                 $syn_item['hero2_fit_level'] = 0;
             }
         } else {
             $syn_item['hero_code'] = 0;
             $syn_item['hero_state'] = 0;
             $syn_item['hero_info'] = array();
             $syn_item['hero_fit_level'] = 0;
             $syn_item['hero2_code'] = 0;
             $syn_item['hero2_state'] = 0;
             $syn_item['hero2_info'] = array();
             $syn_item['hero2_fit_level'] = 0;
         }
         unset($arr_update['hero_info']);
     }
     if (isset($arr_update['dower_info'])) {
         if (!isset($player_detail['dower_info'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('dower_info'));
         }
         $syn_item['dower_info'] = $player_detail['dower_info'];
         unset($arr_update['dower_info']);
     }
     if (isset($arr_update['hook_settings'])) {
         if (empty($arr_update['hook_settings'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('hook_settings'));
         } else {
             $player_detail = $arr_update['hook_settings'];
         }
         $syn_item['hook_settings'] = $player_detail['hook_settings'];
         unset($arr_update['hook_settings']);
     }
     if (isset($arr_update['wing'])) {
         if (!isset($player_detail['equip_wing']) || !isset($player_detail['wing_info'])) {
             $player_detail = $objDetail->get_player_detail($player_id, array('equip_wing', 'wing_info'));
         }
         if ($player_detail['equip_wing'] && isset($player_detail['wing_info'][$player_detail['equip_wing']])) {
             $wing_table_task = $objPlayerWing->get_cache_table_data('player_wing_table', array('id' => $player_detail['wing_info'][$player_detail['equip_wing']]['id'], 'level' => $player_detail['wing_info'][$player_detail['equip_wing']]['lvl']));
             $syn_item['wing'] = $wing_table_task[0]['avatar'];
             $syn_item['wing_skill_id'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][0]);
             $syn_item['wing_skill_id2'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][1]);
             $syn_item['wing_skill_id3'] = intval($player_detail['wing_info'][$player_detail['equip_wing']]['skill_id'][2]);
         } else {
             $syn_item['wing'] = '';
             $syn_item['wing_skill_id'] = 0;
             $syn_item['wing_skill_id2'] = 0;
             $syn_item['wing_skill_id3'] = 0;
         }
         unset($arr_update['wing']);
     }
     ##################[同步当前任务]#####################################
     if (isset($arr_update['city_escort_map_sid'])) {
         $syn_item['city_escort_map_sid'] = $arr_update['city_escort_map_sid'];
         unset($arr_update['city_escort_map_sid']);
     }
     if (isset($arr_update['city_escort_target_x'])) {
         $syn_item['city_escort_target_x'] = $arr_update['city_escort_target_x'];
         unset($arr_update['city_escort_target_x']);
     }
     if (isset($arr_update['city_escort_target_y'])) {
         $syn_item['city_escort_target_y'] = $arr_update['city_escort_target_y'];
         unset($arr_update['city_escort_target_y']);
     }
     if (isset($arr_update['city_escort_npc_sid'])) {
         $syn_item['city_escort_npc_sid'] = $arr_update['city_escort_npc_sid'];
         unset($arr_update['city_escort_npc_sid']);
     }
     if (isset($arr_update['task_id'])) {
         $syn_item['task_id'] = $arr_update['task_id'];
         unset($arr_update['task_id']);
     }
     if (isset($arr_update['task_step'])) {
         $syn_item['task_step'] = $arr_update['task_step'];
         unset($arr_update['task_step']);
     }
     if (isset($arr_update['task_start_status'])) {
         $syn_item['task_start_status'] = $arr_update['task_start_status'];
         unset($arr_update['task_start_status']);
     }
     ##################[同步当前任务]#######################################
     #########################[竞技场同步]##################################
     if (isset($arr_update['dw'])) {
         $syn_item['dw'] = $arr_update['dw'];
         unset($arr_update['dw']);
     }
     if (isset($arr_update['dw_lv'])) {
         $syn_item['dw_lv'] = $arr_update['dw_lv'];
         unset($arr_update['dw_lv']);
     }
     if (isset($arr_update['score'])) {
         $syn_item['score'] = $arr_update['score'];
         unset($arr_update['score']);
     }
     if (isset($arr_update['dw_star'])) {
         $syn_item['dw_star'] = $arr_update['dw_star'];
         unset($arr_update['dw_star']);
     }
     #########################[竞技场同步]##################################
     if (isset($arr_update['potion_dh_cnt'])) {
         #修改直接回血药剂数量
         $cur_data = SynPlayer::get_uval();
         $cur_val = intval($cur_data[SynPlayer::POTION_DH_CNT]);
         $syn_item['potion_dh_cnt'] = $cur_val + intval($arr_update['potion_dh_cnt']);
         unset($arr_update['potion_dh_cnt']);
     }
     if (isset($arr_update['potion_hot_cnt'])) {
         #修改缓慢回血药剂数量
         $cur_data = SynPlayer::get_uval();
         $cur_val = intval($cur_data[SynPlayer::POTION_HOT_CNT]);
         $syn_item['potion_hot_cnt'] = $cur_val + intval($arr_update['potion_hot_cnt']);
         unset($arr_update['potion_hot_cnt']);
     }
     if (isset($arr_update['mp_potion_cnt'])) {
         #修改回蓝药剂数量
         $cur_data = SynPlayer::get_uval();
         $cur_val = intval($cur_data[SynPlayer::MP_POTION_CNT]);
         $syn_item['mp_potion_cnt'] = $cur_val + intval($arr_update['mp_potion_cnt']);
         unset($arr_update['mp_potion_cnt']);
     }
     if (isset($arr_update['light_fairy_name'])) {
         #光女神名字
         $syn_item['light_fairy_name'] = $arr_update['light_fairy_name'];
         //            Com_Log::write('light_fairy_name_'.$player_id,$arr_update['light_fairy_name']);
         unset($arr_update['light_fairy_name']);
     }
     if (isset($arr_update['dark_fairy_name'])) {
         #按女神名字
         $syn_item['dark_fairy_name'] = $arr_update['dark_fairy_name'];
         //            Com_Log::write('dark_fairy_name'.$player_id,$arr_update['dark_fairy_name']);
         unset($arr_update['dark_fairy_name']);
     }
     if (isset($arr_update['athena_remaining_count'])) {
         #守护女神次数
         $syn_item['athena_remaining_count'] = $arr_update['athena_remaining_count'];
         unset($arr_update['athena_remaining_count']);
     }
     if (isset($arr_update['worldboss_remaining_count'])) {
         #世界boss次数
         $syn_item['worldboss_remaining_count'] = $arr_update['worldboss_remaining_count'];
         unset($arr_update['worldboss_remaining_count']);
     }
     if (isset($arr_update['had_on_swings'])) {
         #已开启翅膀
         $syn_item['had_on_swings'] = $arr_update['had_on_swings'];
         unset($arr_update['had_on_swings']);
     }
     if (isset($arr_update['trial_of_god_remaining_cnt'])) {
         #神之试炼当前剩余次数
         $syn_item['trial_of_god_remaining_cnt'] = $arr_update['trial_of_god_remaining_cnt'];
         unset($arr_update['trial_of_god_remaining_cnt']);
     }
     if (isset($arr_update['is_hidden_vip'])) {
         #vip显示状态
         $syn_item['is_hidden_vip'] = $arr_update['is_hidden_vip'];
         unset($arr_update['is_hidden_vip']);
     }
     if (isset($arr_update['mineral_remaining_count'])) {
         #抢矿剩余次数
         $syn_item['mineral_remaining_count'] = $arr_update['mineral_remaining_count'];
         unset($arr_update['mineral_remaining_count']);
     }
     if (isset($arr_update['privilege_left_time'])) {
         #vip特权剩余时间
         $syn_item['privilege_left_time'] = $arr_update['privilege_left_time'];
         unset($arr_update['privilege_left_time']);
     }
     if (isset($arr_update['kf_3vs3_remaining_count'])) {
         #跨服切磋次数
         $syn_item['kf_3vs3_remaining_count'] = $arr_update['kf_3vs3_remaining_count'];
         unset($arr_update['kf_3vs3_remaining_count']);
     }
     //毁灭奥克兰次数
     if (isset($arr_update['count_boss_oakland'])) {
         $syn_item['count_boss_oakland'] = $arr_update['count_boss_oakland'];
         unset($arr_update['count_boss_oakland']);
     }
     if (isset($arr_update['count_boss_oakland'])) {
         $syn_item['count_boss_oakland'] = $arr_update['count_boss_oakland'];
         unset($arr_update['count_boss_oakland']);
     }
     if (isset($arr_update['count_chest_oakland'])) {
         $syn_item['count_chest_oakland'] = $arr_update['count_chest_oakland'];
         unset($arr_update['count_chest_oakland']);
     }
     if (!empty($arr_update)) {
         //            Com_Log::write("sync_publish.".$player_id,var_export($arr_update,true));
         #Com_Log::write('nut','---1--'.json_encode($arr_update));
         foreach ($arr_update as $key => $val) {
             $syn_item[$key] = $val;
             #先临时这样写
             #Com_Log::write('nut','---3--'.json_encode($arr_update));
             $currency_key = Cache_Currency::get_currency_key();
             if (empty($val) && !in_array($key, $currency_key)) {
                 if (!isset($player_info[$key])) {
                     $player_info = $this->get_player_info($player_id);
                 }
                 $syn_item[$key] = $player_info[$key];
             } else {
                 $syn_item[$key] = $val;
             }
             if ($key == 'silver') {
                 if ($player_id == 1895663) {
                     Com_Log::write('xgame.p2c_part_update_tmp', json_encode($syn_item));
                 }
                 $objPlayerAchieve->async_trigger_achieve_target($player_id, 23, $syn_item[$key], 2, $player_info['level']);
                 //出发成就
             }
             if ($key == 'gold') {
                 $objPlayerAchieve->async_trigger_achieve_target($player_id, 25, $syn_item[$key], 4, $player_info['level']);
             }
         }
     }
     #Com_Log::debug_write("sync.".$player_id, "arr_update".json_encode($arr_update));
     #Com_Log::debug_write("sync.".$player_id, "player_info".json_encode($player_info));
     unset($objPlayerBase, $objFpowerCalc, $objPlayer, $objDetail, $objPlayerSkill, $objPlayerAchieve, $objFairy, $objHero, $objPlayerHero, $objPlayerWing);
     SynPlayer::set_syn_data($syn_item);
     $data = SynPlayer::get_data();
     //        if(isset($data['u'][225])){
     //            Com_Log::write('silver_'.$player_id,"silver:{$data['u'][225]}");
     //        }
     //        if($log_skill){
     //            Com_Log::write('sync_skill_infos.'.$player_id,var_export($data['m'],true));
     //            Com_Log::write('sync_skill_infos.'.$player_id,var_export($data['u'],true));
     //        }
     Protocol::input($player_id, 7, 4, 417, array(0 => $data['m'], 1 => $data['u']));
     Protocol::out($gateway);
 }
Esempio n. 4
0
 /**
  * @Purpose:
  * 格式化配置表字段,拆分指定格式数据
  * @Param $field 数据字段
  * @Return 返回数组
  */
 private function format_table_field($field)
 {
     $rtn_data = array();
     $data = explode("|", $field);
     if (Com_Array::is_good_arr($data)) {
         foreach ($data as $second_layer) {
             list($type, $value) = explode(":", $second_layer);
             if (in_array($type, Cache_AttrConfig::get_percent_key())) {
                 $rtn_data[$type] = $value;
             } else {
                 $rtn_data[$type] = $value;
             }
         }
     } else {
         list($type, $value) = explode(":", $data);
         if (in_array($type, Cache_AttrConfig::get_percent_key())) {
             $rtn_data[$type] = $value;
         } else {
             $rtn_data[$type] = $value;
         }
     }
     return $rtn_data;
 }
Esempio n. 5
0
 public static function set_hero_info2($data)
 {
     ##################【英雄属性】#######################################
     foreach (Cache_AttrConfig::get_attr() as $key) {
         $data[$key] = ceil($data[$key]);
     }
     self::push_value(self::HERO2_HP, intval($data['hp']));
     self::push_value(self::HERO2_ATTAK, intval($data['atk_min']));
     self::push_value(self::HERO2_ARMOR, intval($data['arm']));
     if (isset($data['mp'])) {
         self::push_value(self::HERO2_MP, intval($data['mp']));
     }
     if (isset($data['attack_speed'])) {
         self::push_value(self::HERO2_ATTACK_SPEED, intval($data['attack_speed']));
     }
     if (isset($data['crit_chance'])) {
         self::push_value(self::HERO2_CRIT_CHANCE, intval($data['crit_chance']));
     }
     if (isset($data['crit_damage'])) {
         self::push_value(self::HERO2_CRIT_DAMAGE, intval($data['crit_damage']));
     }
     if (isset($data['penetrate_damage'])) {
         self::push_value(self::HERO2_PENETRATE_DAMAGE, intval($data['penetrate_damage']));
     }
     if (isset($data['damage_dodge'])) {
         self::push_value(self::HERO2_DAMAGE_DODGE, intval($data['damage_dodge']));
     }
     if (isset($data['magic_reduction'])) {
         self::push_value(self::HERO2_MAGIC_REDUCTION, intval($data['magic_reduction']));
     }
     if (isset($data['controlled_reduction'])) {
         self::push_value(self::HERO2_CONTROLLED_REDUCTION, intval($data['controlled_reduction']));
     }
     if (isset($data['damage_reduction'])) {
         self::push_value(self::HERO2_DAMAGE_REDUCTION, intval($data['damage_reduction']));
     }
     if (isset($data['penetrate_damage_defense'])) {
         self::push_value(self::HERO2_PENETRATE_DAMAGE_DEFENSE, intval($data['penetrate_damage_defense']));
     }
     if (isset($data['uncrit_prop'])) {
         self::push_value(self::HERO2_UNCRIT_PROP, intval($data['uncrit_prop']));
     }
     if (isset($data['uncrit_damage'])) {
         self::push_value(self::HERO2_UNCRIT_DAMAGE, intval($data['uncrit_damage']));
     }
     if (isset($data['hp_restore'])) {
         self::push_value(self::HERO2_HP_RESTORE, intval($data['hp_restore']));
     }
     if (isset($data['hit_restore_heath'])) {
         self::push_value(self::HERO2_HIT_RESTORE_HEATH, intval($data['hit_restore_heath']));
     }
     if (isset($data['hp_suck'])) {
         self::push_value(self::HERO2_HP_SUCK, intval($data['hp_suck']));
     }
     if (isset($data['mp_restore'])) {
         self::push_value(self::HERO2_MP_RESTORE, intval($data['mp_restore']));
     }
     if (isset($data['hit_restore_mp'])) {
         self::push_value(self::HERO2_HIT_RESTORE_MP, intval($data['hit_restore_mp']));
     }
     if (isset($data['move_speed'])) {
         self::push_value(self::HERO2_MOVE_SPEED, intval($data['move_speed']));
     }
     if (isset($data['rebound_damage'])) {
         self::push_value(self::HERO2_REBOUND_DAMAGE, intval($data['rebound_damage']));
     }
     if (isset($data['weapon_master'])) {
         self::push_value(self::HERO2_WEAPON_MASTER, intval($data['weapon_master']));
     }
     if (isset($data['atk_luck'])) {
         self::push_value(self::HERO2_ATK_LUCK, intval($data['atk_luck']));
     }
     if (isset($data['hit_rate'])) {
         self::push_value(self::HERO2_HIT_RATE, intval($data['hit_rate']));
     }
     if (isset($data['skill_cooling'])) {
         self::push_value(self::HERO2_SKILL_COOLING, intval($data['skill_cooling']));
     }
     #百分比属性 英雄专用
     if (isset($data['hero_hit_rate_per'])) {
         self::push_value(self::HERO2_HIT_RATE_PER, intval($data['hero_hit_rate_per']));
     }
     if (isset($data['hero_dodge_per'])) {
         self::push_value(self::HERO2_DODGE_PER, intval($data['hero_dodge_per']));
     }
     if (isset($data['hero_crit_chance_per'])) {
         self::push_value(self::HERO2_CRIT_CHANCE_PER, intval($data['hero_crit_chance_per']));
     }
     if (isset($data['hero_crit_damage_per'])) {
         self::push_value(self::HERO2_CRIT_DAMAGE_PER, intval($data['hero_crit_damage_per']));
     }
     if (isset($data['hero_uncrit_chance_per'])) {
         self::push_value(self::HERO2_UNCRIT_CHANCE_PER, intval($data['hero_uncrit_chance_per']));
     }
     if (isset($data['hero_uncrit_damage_per'])) {
         self::push_value(self::HERO2_UNCRIT_DAMAGE_PER, intval($data['hero_uncrit_damage_per']));
     }
     ###################【英雄属性】#############################################
     //        self::push_value(self::HERO2_LEVEL,intval($data['hero_level']));
     if (!empty($data['general_skill_id'])) {
         self::push_value(self::HERO2_SKILL0, intval($data['general_skill_id']));
         self::push_value(self::HERO2_SKILL0_LEVEL, intval(1));
     } else {
         self::push_value(self::HERO2_SKILL0, intval($data['general_skill_id']));
         self::push_value(self::HERO2_SKILL0_LEVEL, intval(0));
     }
     if (!empty($data['skill_list'])) {
         $skill1 = array_shift($data['skill_list']);
         if (!empty($skill1) && $skill1['state'] > 0) {
             self::push_value(self::HERO2_SKILL1, intval($skill1['id']));
             self::push_value(self::HERO2_SKILL1_LEVEL, intval($skill1['lvl']));
         } else {
             self::push_value(self::HERO2_SKILL1, intval(0));
             self::push_value(self::HERO2_SKILL1_LEVEL, intval(0));
         }
         $skill2 = array_shift($data['skill_list']);
         if (!empty($skill2) && $skill2['state'] > 0) {
             self::push_value(self::HERO2_SKILL2, intval($skill2['id']));
             self::push_value(self::HERO2_SKILL2_LEVEL, intval($skill2['lvl']));
         } else {
             self::push_value(self::HERO2_SKILL2, intval(0));
             self::push_value(self::HERO2_SKILL2_LEVEL, intval(0));
         }
         $skill3 = array_shift($data['skill_list']);
         if (!empty($skill3) && $skill3['state'] > 0) {
             self::push_value(self::HERO2_SKILL3, intval($skill3['id']));
             self::push_value(self::HERO2_SKILL3_LEVEL, intval($skill3['lvl']));
         } else {
             self::push_value(self::HERO2_SKILL3, intval(0));
             self::push_value(self::HERO2_SKILL3_LEVEL, intval(0));
         }
         $skill4 = array_shift($data['skill_list']);
         if (!empty($skill4) && $skill4['state'] > 0) {
             self::push_value(self::HERO2_SKILL4, intval($skill4['id']));
             self::push_value(self::HERO2_SKILL4_LEVEL, intval($skill4['lvl']));
         } else {
             self::push_value(self::HERO2_SKILL4, intval(0));
             self::push_value(self::HERO2_SKILL4_LEVEL, intval(0));
         }
         $skill5 = array_shift($data['skill_list']);
         if (!empty($skill5) && $skill5['state'] > 0) {
             self::push_value(self::HERO2_SKILL5, intval($skill5['id']));
             self::push_value(self::HERO2_SKILL5_LEVEL, intval($skill5['lvl']));
         } else {
             self::push_value(self::HERO2_SKILL5, intval(0));
             self::push_value(self::HERO2_SKILL5_LEVEL, intval(0));
         }
         $skill6 = array_shift($data['skill_list']);
         if (!empty($skill6) && $skill6['state'] > 0) {
             self::push_value(self::HERO2_SKILL6, intval($skill6['id']));
             self::push_value(self::HERO2_SKILL6_LEVEL, intval($skill6['lvl']));
         } else {
             self::push_value(self::HERO2_SKILL6, intval(0));
             self::push_value(self::HERO2_SKILL6_LEVEL, intval(0));
         }
     } else {
         self::push_value(self::HERO2_SKILL1, intval(0));
         self::push_value(self::HERO2_SKILL1_LEVEL, intval(0));
         self::push_value(self::HERO2_SKILL2, intval(0));
         self::push_value(self::HERO2_SKILL2_LEVEL, intval(0));
         self::push_value(self::HERO2_SKILL3, intval(0));
         self::push_value(self::HERO2_SKILL3_LEVEL, intval(0));
         self::push_value(self::HERO2_SKILL4, intval(0));
         self::push_value(self::HERO2_SKILL4_LEVEL, intval(0));
         self::push_value(self::HERO2_SKILL5, intval(0));
         self::push_value(self::HERO2_SKILL5_LEVEL, intval(0));
         self::push_value(self::HERO2_SKILL6, intval(0));
         self::push_value(self::HERO2_SKILL6_LEVEL, intval(0));
     }
 }