コード例 #1
0
ファイル: PlayerAttr.php プロジェクト: bluefan/phpsource
 /**
  * 获取玩家基础属性
  *
  * @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;
 }
コード例 #2
0
ファイル: FpowerCalc.php プロジェクト: bluefan/phpsource
 /**
  * 计算人物模块的战力
  * @param $player_id
  */
 public function calc_player_fpower($player_id)
 {
     //$player_info = $this->get_data('Player')->get_player_info($player_id,array('career_type','level'));
     //$player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id,array('achieve_attr_1','achieve_attr_2','player_grade_attr','union_player_attr','fame_attr'));
     $player_info = is_null($this->player_info) ? $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level')) : $this->player_info;
     $player_detail = is_null($this->player_detail) || !isset($this->player_detail['buff_attr']) || !isset($this->player_detail['buff_attr_per']) || !isset($this->player_detail['achieve_attr_1']) || !isset($this->player_detail['achieve_attr_2']) || !isset($this->player_detail['player_grade_attr']) || !isset($this->player_detail['union_player_attr']) || !isset($this->player_detail['fame_attr']) ? $this->get_data('PlayerDetail')->get_player_detail($player_id, array('achieve_attr_1', 'achieve_attr_2', 'union_achieve_attr', 'player_grade_attr', 'union_player_attr', 'fame_attr', 'vip_special_attr', 'buff_attr', 'buff_attr_per', 'fashion_attr')) : $this->player_detail;
     $base_attr = $this->get_game('PlayerAttr')->getInitPlayerAttrData($player_info['career_type']);
     $attr = array();
     #人物基础属性
     if (is_array($base_attr)) {
         foreach ($base_attr as $key => $value) {
             if ($key != 'move_speed') {
                 //人物的移动速度 不算倒战力那
                 $attr[$key] += $value;
             }
         }
     }
     $attr['atk_min'] = $this->_player['atk_max'] = Formula_Player::get_upgrade_atk($attr['atk_min'], $player_info['level']);
     $attr['arm'] = $this->_player['arm'] = Formula_Player::get_upgrade_arm($attr['arm'], $player_info['level']);
     $attr['hp'] = $this->_player['hp'] = Formula_Player::get_upgrade_hp($attr['hp'], $player_info['level']);
     #人物成就属性
     if (!empty($player_detail['achieve_attr_1'])) {
         foreach ($player_detail['achieve_attr_1'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     if (!empty($player_detail['achieve_attr_2'])) {
         foreach ($player_detail['achieve_attr_2'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     if (!empty($player_detail['union_achieve_attr'])) {
         foreach ($player_detail['union_achieve_attr'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     if (!empty($player_detail['player_grade_attr'])) {
         foreach ($player_detail['player_grade_attr'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     #---------------------------------------------------------------------
     #帮会的属性
     #---------------------------------------------------------------------
     if (!empty($player_detail['union_player_attr'])) {
         foreach ($player_detail['union_player_attr'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     #---------------------------------------------------------------------
     #声望的属性
     #---------------------------------------------------------------------
     if (!empty($player_detail['fame_attr'])) {
         foreach ($player_detail['fame_attr'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     #---------------------------------------------------------------------
     #vip特权
     #---------------------------------------------------------------------
     if (!empty($player_detail['vip_special_attr'])) {
         foreach ($player_detail['vip_special_attr'] as $key => $value) {
             $attr[$key] += $attr[$key] * ($value / 10000);
         }
     }
     if (!empty($player_detail['fashion_attr'])) {
         foreach ($player_detail['fashion_attr'] as $key => $value) {
             $attr[$key] += $value;
         }
     }
     $base_fpower = ceil(Formula_Fpower::calc_fpower($attr));
     #---------------------------------------------------------------------
     #buff属性
     #---------------------------------------------------------------------
     $fpower_buff_attr = array();
     if (!empty($player_detail['buff_attr'])) {
         foreach ($player_detail['buff_attr'] as $key => $value) {
             if ($key == 'attack_speed' || $key == 'crit_chance' || $key == 'damage_dodge') {
                 $fpower_buff_attr[$key] = $value / 10000;
             } else {
                 $attr[$key] += $value / 10000;
             }
         }
     }
     $fpower = Formula_Fpower::calc_fpower($attr);
     #---------------------------------------------------------------------
     #buff百分比属性
     #---------------------------------------------------------------------
     //        $fpower_buff_attr_per = array();
     if (!empty($player_detail['buff_attr_per'])) {
         foreach ($player_detail['buff_attr_per'] as $key => $value) {
             $fpower += $fpower * ($value / 100);
             //                if($key == 'hp' || $key == 'atk_min' || $key == 'arm')
             //                    $attr[$key] += $attr[$key] * ($value/100);
             //                else
             //                    $fpower_buff_attr_per[$key] = $value/100;
         }
     }
     Com_Log::write("fpower_buff." . $player_id, "fpower:" . var_export($fpower, true));
     Com_Log::write("fpower_buff." . $player_id, "fpower_buff_attr:" . var_export($fpower_buff_attr, true));
     if (!empty($fpower_buff_attr)) {
         foreach ($fpower_buff_attr as $key => $value) {
             $fpower += $fpower * $value;
         }
     }
     //        Com_Log::write("fpower_buff.".$player_id,"fpower_buff_attr_per:".var_export($fpower_buff_attr_per,true));
     //        if(!empty($fpower_buff_attr_per)){
     //            foreach($fpower_buff_attr_per as $key => $value){
     //                $fpower += $fpower*$value;
     //            }
     //        }
     $fpower = ceil($fpower);
     //        Com_Log::write("fpower_buff.".$player_id,"base_fpower:".var_export($base_fpower,true));
     //        Com_Log::write("fpower_buff.".$player_id,"fpower:".var_export($fpower,true));
     $buff_fpower = $fpower - $base_fpower;
     $buff_fpower = $buff_fpower < 0 ? 0 : $buff_fpower;
     //        Com_Log::write("fpower_buff.".$player_id,"buff_fpower:".var_export($buff_fpower,true));
     return array('fpower' => $base_fpower, 'buff_fpower' => $buff_fpower);
 }