Esempio n. 1
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. 2
0
 public function active_dower($player_id, $dower_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_dower);
     $this->param_check_numeric(array($player_id, $dower_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level', 'vip', 'privilege_level', 'crystal'));
     # 更新等级和修改时间
     $active_dower_list = $this->get_data('PlayerDower')->get_player_dower($player_id);
     $before_level = isset($active_dower_list[$dower_id]) ? $active_dower_list[$dower_id]['dower_lv'] : 0;
     if (isset($active_dower_list[$dower_id])) {
         $active_dower_list[$dower_id]['dower_lv'] += 1;
         $active_dower_list[$dower_id]['mod_time'] = $this->current_time;
     } else {
         $active_dower_list[$dower_id] = array('dower_id' => $dower_id, 'dower_lv' => 1, 'player_id' => $player_id, 'mod_time' => $this->current_time);
     }
     # 获取天赋配置信息
     $dower_info = Cache_Dower::getInstance()->get_dower_info($dower_id, $active_dower_list[$dower_id]['dower_lv'], 1);
     if ($player_info['level'] < $dower_info['unlock']) {
         $this->throw_error('80605');
         # 玩家等级不足
     }
     $this->start_trans();
     # 消耗魔晶
     if (!empty($dower_info['cost_crystal'])) {
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'crystal', $dower_info['cost_crystal'], 1);
         $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '613');
         $this->write_check($re, 3010895);
     }
     # 消耗材料
     if (!empty($dower_info['item_id']) && !empty($dower_info['item_num'])) {
         # deduct_prop_by_prop_id方法中有判断道具是否足够,故外层不判断
         $arr_logs_consume = array();
         $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 613);
         $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $dower_info['item_id'], $dower_info['item_num'], $arr_logs_consume, 0, $log_param);
         $this->write_check($re, 3010904);
     }
     # 更新玩家已激活天赋信息
     $re = $this->get_data('PlayerDower')->update_player_dower($player_id, $active_dower_list[$dower_id]);
     $this->write_check($re, 3010909);
     # 获取玩家已经启用的天赋信息
     $get_field = Protocol_Player::get_player_attr_detail_key();
     $get_field[] = 'skill_starmap_info';
     $get_field[] = 'skill_info';
     $get_field[] = 'skill_rune_info';
     $get_field[] = 'dower_info';
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, $get_field);
     $player_detail['dower_info'][$dower_id] = array('slot_idx' => 0, 'dower_id' => $dower_id, 'dower_lv' => $active_dower_list[$dower_id]['dower_lv']);
     $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('dower_info' => $player_detail['dower_info']));
     $this->write_check($re, 3010915);
     $this->commit();
     #引导任务
     #if (empty($before_level)) { # 激活才触发,升级不触发
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 13, 1);
     # 升级也算
     #}
     # --------------------------------------------------------------------
     # 806同步道具变更
     # --------------------------------------------------------------------
     $ndata = array();
     if (!empty($arr_logs_consume)) {
         foreach ($arr_logs_consume as $k => $v) {
             # 消耗的道具
             $ndata[] = $v;
         }
     }
     Protocol_Prop::prop_806($player_id, $ndata);
     # --------------------------------------------------------------------
     # 脏数据同步
     # --------------------------------------------------------------------
     //同步人物属性
     $arr_part_update['dower_info'] = '';
     $arr_part_update['player_data'] = array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']));
     Protocol_Player::p2c_part_update($player_id, $arr_part_update);
     $out_613 = array('dower_id' => $dower_id, 'dower_lv' => $active_dower_list[$dower_id]['dower_lv']);
     # 成就相关埋点
     $this->handle_dower_refer_achieve($player_id);
     # 旧的仍然保留
     $achieve_val = "1:" . $active_dower_list[$dower_id]['dower_lv'] . ":" . $dower_id;
     $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 48, $achieve_val, 4);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $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, 'dower_id' => $dower_id, 'dower_name' => $dower_info['name'], 'before_level' => $before_level, 'after_level' => $active_dower_list[$dower_id]['dower_lv']);
     Log_Skill::getInstance()->add_log($log_info, 'dower');
     return $out_613;
 }
Esempio n. 3
0
 /**
  * 删除公会玩家
  */
 public function del_union_player($union_id, $player_id)
 {
     if ($this->is_trans()) {
         $bDealCheck = $this->set_redis_pre_action(null, array($this->redis(), 'hash_delete'), array($this->get_cache_key($union_id), $player_id));
     } else {
         $bDealCheck = $this->redis()->hash_delete($this->get_cache_key($union_id), $player_id);
     }
     if ($bDealCheck) {
         /* $delsql = "delete from `union_player` where player_id={$player_id}";
         			$this->query($delsql); */
         //Com_Log::log($delsql,'union_player.log',1);
         $this->set_union_expel_list($union_id);
         //			$this->get_data('PlayerDetail')->update_player_detail($player_id,array('union_achieve_attr'=>array()));
         $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level'));
         Protocol_Player::p2c_part_update($player_id, array('attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']))));
     }
     return $bDealCheck;
 }
Esempio n. 4
0
 /**
  * 重新计算下装备下属性 在穿脱 强化身上的装备
  * @param $player_id
  * @return mixed
  */
 public function equip_attr($player_id)
 {
     $get_field = Protocol_Player::get_player_attr_detail_key();
     $get_field[] = 'skill_starmap_info';
     $get_field[] = 'skill_info';
     $get_field[] = 'skill_rune_info';
     $get_field[] = 'dower_info';
     $get_field[] = 'fashion_fit';
     $get_field[] = 'player_settings';
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, $get_field);
     # 需要将星图对技能的加成信息初始化为空后,再重新计算身上装备的星图对技能的加成信息,否则,skill_starmap_info只增不减
     # 即每次重新计算身上装备的属性时,都重新计算skill_starmap_info
     $player_detail['skill_starmap_info'] = array();
     $equip_lists = $this->get_game('Prop')->get_player_equip($player_id);
     $arr_equip_attr = array();
     $equip_skill = array();
     $equip_swallow = array();
     if (!empty($equip_lists)) {
         $equip_suit_quality = array();
         $equip_suit_strength = array();
         $equip_suit_star = array();
         $equip_suit_inlay = 0;
         $equip_level = array();
         foreach ($equip_lists as $equip) {
             if ($equip['grid'] < 10) {
                 $equip_level[$equip['level']] += 1;
                 $equip_suit_quality[$equip['quality']] += 1;
                 if ($equip['intensive_level']) {
                     $equip_suit_strength[$equip['intensive_level']] += 1;
                 }
                 $equip_suit_star[$equip['star_level']] += 1;
             }
             if (is_string($equip['base_attr'])) {
                 $base_attr = json_decode($equip['base_attr'], true);
             } else {
                 $base_attr = $equip['base_attr'];
             }
             $star_map = array();
             if (!empty($equip['star_map_desc'])) {
                 if (is_string($equip['star_map_desc'])) {
                     $equip['star_map_desc'] = json_decode($equip['star_map_desc'], true);
                 }
                 $star_map = Struct_Prop::parse_star_map($equip['star_map_desc']);
                 # 星图觉醒技能信息更新到player_detail表的skill_starmap_info中
                 if (!empty($equip['career_type']) && !empty($star_map['skill'])) {
                     foreach ($star_map['skill'] as $career_type => $skill_info) {
                         if ($equip['career_type'] != $career_type) {
                             continue;
                         }
                         $player_detail['skill_starmap_info'][$skill_info['skill_id']] += $skill_info['skill_level'];
                     }
                 }
             }
             # 吞噬属性
             if (!empty($equip['swallow_info']) && is_array($equip['swallow_info'])) {
                 foreach ($equip['swallow_info'] as $swallow_id => $swallow_info) {
                     $swallow_config = Cache_Forge::getInstance()->get_swallow_config($swallow_id, $swallow_info['swallow_lv']);
                     $equip_swallow[$swallow_id] += intval($swallow_config['swallow_param']);
                 }
             }
             if (!empty($base_attr)) {
                 //计算基础属性
                 foreach ($base_attr as $key => $val) {
                     $val += $val * (intval($star_map['equip_attr']) / 100);
                     //星图加成
                     if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') {
                         $arr_equip_attr['atk_min'] += $val;
                     } else {
                         $arr_equip_attr[$key] += $val;
                     }
                 }
             }
             if (intval($equip['addition_attr']) > 0) {
                 foreach ($equip['addition_attr'] as $key => $val) {
                     if (isset($star_map['additional'])) {
                         $val += ceil($val * ($star_map['additional'] / 10000));
                         //星图加成
                     }
                     if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') {
                         $arr_equip_attr['atk_min'] += $val;
                     } else {
                         $arr_equip_attr[$key] += $val;
                     }
                 }
             }
             # ------------------------------------------------------------
             # 洗练属性处理
             # ------------------------------------------------------------
             if (!empty($equip['refine_attr'])) {
                 foreach ($equip['refine_attr'] as $attr_seq => $attr_info) {
                     if (!is_array($attr_info)) {
                         continue;
                     }
                     # TODO: 为了兼容旧的洗练数据,以后要清档上功能,可以除去这行
                     list($key, $val) = each($attr_info);
                     # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min
                     if ($key == 'atk' || $key == 'atk_max') {
                         $key = 'atk_min';
                     }
                     $arr_equip_attr[$key] += $val;
                 }
             }
             if (is_string($equip['intensive_desc'])) {
                 $intensive_desc = json_decode($equip['intensive_desc'], true);
             } else {
                 $intensive_desc = $equip['intensive_desc'];
             }
             if (!empty($intensive_desc)) {
                 foreach ($intensive_desc as $key => $val) {
                     $val += $val * (intval($star_map['intensify']) / 10000);
                     //星图加成
                     if ($key == 'atk' || $key == 'atk_min' || $key == 'atk_max') {
                         $arr_equip_attr['atk_min'] += $val;
                     } else {
                         $arr_equip_attr[$key] += $val;
                     }
                 }
             }
             $gem_configs = array();
             if (is_string($equip['inlay_gems'])) {
                 $inlay_gems = json_decode($equip['intensive_desc'], true);
             } else {
                 $inlay_gems = $equip['inlay_gems'];
             }
             if (!empty($inlay_gems)) {
                 foreach ($inlay_gems as $gem_id) {
                     if (!isset($gem_configs[$gem_id])) {
                         $gem_configs[$gem_id] = Cache_Forge::getInstance()->get_inlay_gems_by_id($gem_id);
                     }
                     if ($equip['grid'] < 10) {
                         $equip_suit_inlay += $gem_configs[$gem_id]['lv'];
                     }
                     $attr = Struct_Prop::parse_gem_config_attr($gem_configs[$gem_id]);
                     if (!empty($attr)) {
                         foreach ($attr as $key => $val) {
                             if ($key == 'atk' || $key == 'atk_min' || $key == 'atk_max') {
                                 $arr_equip_attr['atk_min'] += $val;
                             } else {
                                 $arr_equip_attr[$key] += $val;
                             }
                         }
                     }
                 }
             }
         }
         //套装加成
         $item_flags = Cache_ItemFlag::getInstance()->get_item_flag_info(1);
         $level_count = count($equip_level);
         if (!empty($item_flags)) {
             $flags_addition = array();
             foreach ($item_flags as $flag) {
                 if ($flag['type'] == 'quality') {
                     $conditions = explode("|", $flag['condition']);
                     $fnum = explode(":", $flag['flag']);
                     $add_flag = 0;
                     foreach ($conditions as $c) {
                         $condition = explode(":", $c);
                         if ($condition[0] == 'quality' && $this->get_conditions_num($equip_suit_quality, $condition[1]) >= $fnum[1]) {
                             $add_flag += 1;
                         }
                         if ($condition[0] == 'level' && $this->get_conditions_num($equip_level, $condition[1]) >= $fnum[1]) {
                             $add_flag += 1;
                         }
                         if ($condition[0] == 'star' && $this->get_conditions_num($equip_suit_star, $condition[1]) >= $fnum[1]) {
                             $add_flag += 1;
                         }
                     }
                     if (count($conditions) == $add_flag) {
                         $flag_attr = json_decode($flag['attr'], true);
                         $flags_addition['quality'] = $flag_attr;
                         # 改同一类型覆盖了
                         //                            Com_Log::write('equip_flags.'.$player_id,"quality_flag_attr:".var_export($flag_attr,true));
                         //                            foreach($flag_attr as $key=>$val){
                         //                                $arr_equip_attr[$key] += $val['val'];
                         //                            }
                     }
                 } elseif ($flag['type'] == 'strength') {
                     $conditions = explode("|", $flag['condition']);
                     $fnum = explode(":", $flag['flag']);
                     $add_flag = 0;
                     foreach ($conditions as $c) {
                         $condition = explode(":", $c);
                         if ($condition[0] == 'intensive_level' && $this->get_conditions_num($equip_suit_strength, $condition[1]) >= $fnum[1]) {
                             $add_flag += 1;
                         }
                     }
                     if (count($conditions) == $add_flag) {
                         $flag_attr = json_decode($flag['attr'], true);
                         $flags_addition['strength'] = $flag_attr;
                         //                            Com_Log::write('equip_flags.'.$player_id,"strength_flag_attr:".var_export($flag_attr,true));
                         //                            foreach($flag_attr as $key=>$val){
                         //                                $arr_equip_attr[$key] += $val['val'];
                         //                            }
                     }
                 } elseif ($flag['type'] == 'inlay') {
                     $fnum = explode(":", $flag['flag']);
                     if ($equip_suit_inlay >= $fnum[1]) {
                         $flag_attr = json_decode($flag['attr'], true);
                         $flags_addition['inlay'] = $flag_attr;
                         //                            Com_Log::write('equip_flags.'.$player_id,"inlay_flag_attr:".var_export($flag_attr,true));
                         //                            foreach($flag_attr as $key=>$val){
                         //                                $arr_equip_attr[$key] += $val['val'];
                         //                            }
                     }
                 }
             }
         }
         if (!empty($flags_addition)) {
             foreach ($flags_addition as $flag_attr) {
                 foreach ($flag_attr as $key => $val) {
                     $arr_equip_attr[$key] += $val['val'];
                 }
             }
         }
     }
     $equip_model = array();
     for ($i = 0; $i < 10; $i++) {
         if (isset($equip_lists[$i])) {
             if (!empty($equip_lists[$i]['equip_view'])) {
                 if (is_string($equip_lists[$i]['equip_view'])) {
                     $equip_model[$i] = $equip_lists[$i]['equip_view'];
                 } else {
                     $equip_model[$i] = implode(':', $equip_lists[$i]['equip_view']);
                     //先这样 不想清理数据了  下次清理完数据改了
                 }
                 if ($equip_model[$i] == '0:0:0:0' || $equip_model[$i] == '0:0:0') {
                     $equip_model[$i] = '';
                 }
             } else {
                 $equip_model[$i] = '';
             }
         }
     }
     $player_detail['equip_attr'] = $arr_equip_attr;
     $player_detail['skill_starmap_info'] = $player_detail['skill_starmap_info'];
     $result = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('equip_attr' => $arr_equip_attr, 'skill_starmap_info' => $player_detail['skill_starmap_info']));
     if ($result) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level'));
         //同步人物属性
         $arr_part_update['attr'] = '';
         $arr_part_update['player_data'] = array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']));
         $arr_part_update['equip_skill'] = $equip_skill;
         $arr_part_update['equip_model'] = $equip_model;
         $arr_part_update['equip_swallow'] = $equip_swallow;
         $arr_part_update['skill_infos'] = '';
         Protocol_Player::p2c_part_update($player_id, $arr_part_update);
     }
     return $result;
 }
Esempio n. 5
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. 6
0
 protected function get_player_info($player_id, $playerInfo = null, $player_detail = null)
 {
     $objPlayer = $this->get_data('Player');
     $objPlayerDetail = $this->get_data('PlayerDetail');
     //        if(empty($playerInfo)){
     $playerInfo = $objPlayer->get_player_info($player_id);
     //        }
     if (empty($player_detail)) {
         $player_detail = $objPlayerDetail->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
     }
     $objPlayerAttr = $this->get_game('PlayerAttr');
     $objPlayerAttr->clear();
     $objPlayerAttr->set_player_item($playerInfo);
     $objPlayerAttr->set_player_detail_item($player_detail);
     $player_item = $objPlayerAttr->get_player_attr($player_id);
     unset($objPlayer, $objPlayerDetail, $objPlayerAttr);
     return $player_item;
 }
Esempio n. 7
0
 /**
  * 激活等级
  * @Param $player_id 玩家ID
  * @Param $page 页数
  * @Param $level 等级
  */
 public function activation_grade($player_id, $page, $level)
 {
     #当前等级的目标信息
     $grade_configs = $this->get_cache_table_data('pgf_table', array('level' => $level));
     if (empty($grade_configs)) {
         $this->throw_error('10109');
         #配置表读取错误
     }
     $grade_config = $grade_configs[0];
     #获取玩家目标礼信息;
     $player_grade_info = $this->get_data('PlayerGradeFunc')->get_player_grade_func_info($player_id);
     $grade_reward_info = array();
     if ($player_grade_info['grade_info'] && !is_array($player_grade_info['grade_info'])) {
         $grade_reward_info = json_decode($player_grade_info['grade_info'], true);
     }
     if (!empty($grade_reward_info) && in_array($grade_config['sid'], $grade_reward_info)) {
         $this->throw_error('230001');
         #当前目标礼已经解锁
     }
     #获取玩家等级
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level', 'map_id'));
     $player_level = $player_info['level'];
     if ($player_level < $grade_config['level']) {
         $this->throw_error('230002');
         #还未到解锁等级,无法解锁
     }
     #激活目标礼列表
     array_push($grade_reward_info, $grade_config['sid']);
     $active_times = count($grade_reward_info);
     $update_data['player_id'] = $player_id;
     $update_data['grade_info'] = json_encode($grade_reward_info);
     $update_data['add_time'] = time();
     #激活属性
     $attr_add = $this->format_table_attr($grade_config['attr_add']);
     if (!Com_Array::is_good_arr($attr_add)) {
         $this->throw_error('10110');
         #数据错误
     }
     #增加玩家属性
     $grade_attr_info = array();
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
     $player_grade_attr = $player_detail['player_grade_attr'];
     foreach ($attr_add as $type => $value) {
         $player_grade_attr[$type] += $value;
         $grade_attr_info[$type][] = $type;
         $grade_attr_info[$type][] = $player_grade_attr[$type];
     }
     $this->start_trans();
     #更新目标值
     $update_res = $this->get_data('PlayerGradeFunc')->update_player_grade_func($player_id, $update_data);
     if (!$update_res) {
         $this->throw_error('10104');
     }
     #更新目标属性
     $player_detail['player_grade_attr'] = $player_grade_attr;
     $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('player_grade_attr' => $player_grade_attr));
     if (!$update_res) {
         $this->throw_error('10104');
     }
     $this->commit();
     #推送剩余的激活次数
     if ($player_info['map_id'] != 2100 && !empty($player_info['level'])) {
         $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1170, $player_info['level'] - $active_times);
         Protocol::out();
     }
     #更新属性战力信息
     Protocol_Player::p2c_part_update($player_id, array('attr' => 0, 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']))));
     return array(intval($page), intval($level), intval(2), $grade_attr_info ? $grade_attr_info : array());
 }
Esempio n. 8
0
 public function check_fashion_timer($player_id, $player_detail = null)
 {
     if (is_null($player_detail)) {
         $get_field = Protocol_Player::get_player_attr_detail_key();
         $get_field[] = 'player_settings';
         $get_field[] = 'fashion_info';
         $get_field[] = 'fashion_fit';
         $get_field[] = 'fashion_attr';
         $objPlayerDetail = $this->get_data('PlayerDetail');
         $player_detail = $objPlayerDetail->get_player_detail($player_id, $get_field);
     }
     $fashion_info = $player_detail['fashion_info'];
     $fashion_fit = $player_detail['fashion_fit'];
     $min_timeliness = 0;
     if ($fashion_info) {
         $now = time();
         $up_flag = false;
         foreach ($fashion_info as $sid => $val) {
             if ($val['timeliness'] <= $now) {
                 unset($fashion_info[$sid]);
                 if (isset($fashion_fit[$fashion_info[$sid]['type']]) && $fashion_fit[$fashion_info[$sid]['type']] == $sid) {
                     unset($fashion_fit[$fashion_info[$sid]['type']]);
                 }
                 $up_flag = true;
             } else {
                 $min_timeliness = min($min_timeliness, $val['timeliness']);
             }
         }
         if ($up_flag) {
             $attr = array();
             $fashion_configs = Cache_Fashion::getInstance()->get_fashion(array_keys($fashion_info));
             foreach ($fashion_configs as $fashion) {
                 if ($fashion['attr_val']) {
                     $attr_parse = $this->parse_data($fashion['attr_val']);
                     if ($attr_parse) {
                         foreach ($attr_parse as $key => $val) {
                             $attr[$key] += $val;
                         }
                     }
                 }
             }
             $res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('fashion_info' => $fashion_info, 'fashion_attr' => $attr, 'fashion_fit' => $fashion_fit));
             if ($res) {
                 $player_detail['fashion_attr'] = $attr;
                 $player_detail['fashion_fit'] = $fashion_fit;
                 $player_detail['fashion_info'] = $fashion_info;
                 $arr_part_update['fashion_fit'] = '';
                 $arr_part_update['attr'] = '';
                 $arr_part_update['player_data'] = array('player_detail' => $player_detail);
                 Protocol_Player::p2c_part_update($player_id, $arr_part_update);
             }
         }
     }
     if ($min_timeliness) {
         $params['type'] = 101838;
         $params['id'] = $player_id;
         $params['timeout'] = $min_timeliness;
         $params['param1'] = 0;
         $params['param2'] = 0;
         $params['param3'] = 0;
         $params['param4'] = 0;
         Protocol::input(0, 7, 4, 516, $params);
         Protocol::out();
     }
 }