Esempio n. 1
0
 public function fix_hero_fit_data()
 {
     $player_ids = array(363, 120, 443, 6715, 14732, 354, 6144, 2242, 1165, 66868, 190, 11616, 65210, 4192, 6253, 14187, 136, 2874, 2258, 15272, 10760, 3059, 68758, 2003, 634, 3175, 5810, 3790, 65974, 221, 132, 93, 411, 3434, 55, 65738, 3508, 13260, 69386, 68686, 11935, 11655, 19, 1024, 3427, 3217, 72420, 2974);
     $union_attr = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'union_hero_attr');
     foreach ($player_ids as $player_id) {
         $hero_list = $this->get_data('PlayerHero')->get_player_hero_list($player_id);
         foreach ($hero_list as $hero_id => $hero_info) {
             $hero_info = Com_FmtData::cus_json_decode($hero_info);
             if (!empty($hero_info) && $hero_info['fit'] > 4) {
                 $attr_table = $this->get_game('Hero')->get_hero_attr_table($hero_info['hero_code']);
                 if (!empty($attr_table)) {
                     $skill_data = $this->get_game('Hero')->create_hero_skill_data($attr_table);
                     $hero_info['skill_list'] = $skill_data;
                     $hero_info['fit'] = 0;
                     $hero_info['fit_life'] = 0;
                     $hero_info['fit_attack'] = 0;
                     $hero_info['fit_def'] = 0;
                     $hero_info['fit_grow'] = 0;
                     $hero_info['fit_attr_per'] = '';
                     $hero_info['fit_other_attr'] = '';
                     $hero_info['fit_expend_record'] = '';
                     $hero_info['fight'] = $this->get_game('Hero')->calc_fight($hero_info['player_id'], $hero_info, $hero_info['fit'], $hero_info['rune_hole_list'], $hero_info['star_add_attr_per'], $hero_info['skill_list'], $union_attr);
                     $this->start_trans();
                     $update_field = array('fight', 'skill_list', 'fit', 'fit_life', 'fit_attack', 'fit_def', 'fit_grow', 'fit_attr_per', 'fit_other_attr', 'fit_expend_record');
                     //更新redis,sql数据
                     $update_res = $this->get_game('Hero')->update_db($player_id, $update_field, $hero_info, 519);
                     if (!$update_res) {
                         echo '10104' . '|' . $hero_id;
                         exit;
                     }
                     $this->commit();
                 }
             }
         }
         Protocol_Player::p2c_part_update($player_id, array('hero_info' => array()));
     }
 }
Esempio n. 2
0
 /**
  * @Purpose:
  * 获取fb_list字段数据
  * @param $used_day_times 已使用的日次数
  * @param $add_day_times 已增加的日次数
  * @param $map_vip_table map_vip配置表
  * @param $player_info 玩家信息(必须包含'level', 'vip', 'career_type')
  */
 private function get_fb_list_field($player_id, $used_day_times, $add_day_times, $map_vip_table = null, $player_info = null)
 {
     if (empty($map_vip_table)) {
         $map_vip_table = Cache_MapVip::getInstance()->get_map_vip_info();
         if (!Com_Array::is_good_arr($map_vip_table)) {
             $this->throw_error('113601');
             #map_vip配置表读取错误
         }
     }
     if (empty($player_info) || !isset($player_info['level']) || !isset($player_info['vip']) || !isset($player_info['career_type']) || !isset($player_info['privilege_level'])) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'career_type', 'privilege_level'));
     }
     $rtn_data = array();
     if (Com_Array::is_good_arr($map_vip_table)) {
         $fb_data = $this->get_data('PlayerFB')->get_player_fb_info($player_id);
         $chapter_info = Com_FmtData::cus_json_decode($fb_data['chapter_info']);
         foreach ($map_vip_table as $mv_info) {
             $mv_data = array();
             $mv_data['fb_id'] = intval($mv_info['map_id']);
             $mv_data['fb_name'] = $mv_info['name'] ? $mv_info['name'] : '';
             $mv_data['level_desc'] = $mv_info['level_limit_desc'] ? $mv_info['level_limit_desc'] : '';
             $mv_data['vip_desc'] = $mv_info['vip_level_limit_desc'] ? $mv_info['vip_level_limit_desc'] : '';
             $mv_data['state'] = 3;
             #等级不足
             if (!isset($player_info['level']) || intval($player_info['level']) < $mv_info['level_limit']) {
                 $mv_data['state'] = 0;
             } else {
                 if (!isset($player_info['vip']) || intval($player_info['vip']) < $mv_info['vip_level_limit']) {
                     $mv_data['state'] = 1;
                 } else {
                     if ($used_day_times >= $this->vip_day_num_limit + $add_day_times) {
                         $mv_data['state'] = 2;
                     }
                 }
             }
             $prop_list = array();
             if (!empty($mv_info['drop_prop'])) {
                 $prop_list = $this->format_prop_currency_struct_table($mv_info['drop_prop']);
             }
             $mv_data['drop_equip'] = array();
             if (!empty($mv_info['drop_equip'])) {
                 $mv_data['drop_equip'] = $this->format_prop_currency_struct_table($mv_info['drop_equip'], $player_info['career_type']);
             }
             if (Com_Array::is_good_arr($prop_list)) {
                 foreach ($prop_list as $prop_data) {
                     $mv_data['drop_equip'][] = $prop_data;
                 }
             }
             $mv_data['is_sweep'] = 0;
             if ($player_info['vip'] > 2) {
                 $cur_fb = $chapter_info[99][99][$mv_info['map_id']];
                 if (!empty($cur_fb) && isset($cur_fb['gl']) && $cur_fb['gl'] > 0) {
                     $mv_data['is_sweep'] = 1;
                 }
             }
             $map_grade_table = Cache_PlayerFB::getInstance()->get_map_grade_info(array('map_id' => $mv_info['map_id'], 'grade' => 1));
             if (empty($map_grade_table)) {
                 $this->throw_error('10109');
                 #配置表读取错误
             }
             #3S下预计获得的经验
             $mv_data['exp'] = 0;
             $map_vip_level_table = Cache_MapVip::getInstance()->get_map_vip_level_add_info(array('level' => $player_info['level']));
             if (!empty($map_vip_level_table['add']) && is_string($map_vip_level_table['add'])) {
                 $add_info = explode(":", $map_vip_level_table['add']);
                 if (isset($add_info[1])) {
                     $mv_data['exp'] = $add_info[1] * ($map_grade_table['award'] / 100);
                 }
             }
             #buff药加成
             $player_detail_buff_exp_addition = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'buff_exp_addition');
             $buff_exp_addition = $player_detail_buff_exp_addition['exp'];
             $this->create_monster_data($mv_info['map_id'], 1, $player_info['level'], $mv_data['exp'], $buff_exp_addition);
             $rtn_data[] = $mv_data;
         }
     }
     return $rtn_data;
 }
Esempio n. 3
0
 /**
  * @Purpose:
  * 数据修复检测
  */
 public function hero_repair($player_id)
 {
     //获取玩家所有英雄
     $data = $this->get_data('PlayerHero')->get_player_hero_list($player_id);
     #获取英雄公会科技属性加成
     $union_attr = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'union_hero_attr');
     $union_attr = Com_FmtData::cus_json_decode($union_attr);
     if (!empty($data) && Com_Array::is_good_arr($data)) {
         $this->start_trans();
         foreach ($data as $key => $val) {
             $val = Com_FmtData::cus_json_decode($val);
             if (!empty($val) && isset($val['hero_id']) && !empty($val['hero_id'])) {
                 $is_update = false;
                 if (!isset($val['repair_flag']) || $val['repair_flag'] < 1) {
                     //获取升级增加的属性
                     $add_attr = $this->get_upgrade_add_attr($val['hero_code'], $val['level'], $val['fit_grow']);
                     $val['life'] = $add_attr['life'];
                     $val['attack'] = $add_attr['attack'];
                     $val['def'] = $add_attr['def'];
                     //战斗力计算
                     $val['fight'] = $this->calc_fight($val['player_id'], $val, $val['fit'], $val['rune_hole_list'], $val['star_add_attr_per'], $val['skill_list'], $union_attr);
                     $is_update = true;
                 }
                 if ($is_update) {
                     $val['repair_flag'] = $this->repair_flag;
                     //更新redis,sql数据
                     $update_res = $this->update_db($val['player_id'], array('fight', 'life', 'attack', 'def', 'repair_flag'), $val, 504);
                     if (!$update_res) {
                         $this->throw_error('10104');
                     }
                 }
             }
         }
         $this->commit();
     }
 }
Esempio n. 4
0
 /**
  * @Purpose:
  * 内部增加活动时间接口
  * @Param $union_id 公会ID
  * @Param $type 活动类型
  * @Param $time 增加的活动时间(单位:秒)
  */
 public function add_activities_time_interface($union_id, $type, $time)
 {
     $union_id = intval($union_id);
     #获取公会活动天数据
     $uad_data = $this->get_data('UnionActivities')->get_union_activities_daily_info($union_id, 'uad', 'day');
     $uad_data['add_time'] = Com_FmtData::cus_json_decode($uad_data['add_time']);
     if ($time > 0) {
         $type = intval($type);
         $time = intval($time);
         $uad_data['add_time'][$type] += $time;
         $update_uad['add_time'] = json_encode($uad_data['add_time']);
         $is_commit = false;
         if (!$this->is_trans()) {
             $this->start_trans();
             $is_commit = true;
         }
         #更新活动天数据
         $this->get_data('UnionActivities')->update_union_activities_daily_data($union_id, 'uad', $update_uad);
         if ($is_commit) {
             $this->commit();
         }
     }
 }
Esempio n. 5
0
 /**
  * @Purpose:
  * 更新翅膀装备属性
  * @Param $wing_equipment_list 装备在翅膀上的装备列表
  */
 public function get_wing_equip_attr($wing_equipment_list)
 {
     $rtn_attr = array();
     if (!empty($wing_equipment_list) && Com_Array::is_good_arr($wing_equipment_list)) {
         $equip_level = array();
         $equip_quality = array();
         $equip_intensify = array();
         $equip_star = array();
         foreach ($wing_equipment_list as $equip) {
             #品质,等级,强化等级,星级计数
             $equip_level[$equip['level']] += 1;
             $equip_quality[$equip['quality']] += 1;
             if ($equip['intensive_level']) {
                 $equip_intensify[$equip['intensive_level']] += 1;
             }
             $equip_star[$equip['star_level']] += 1;
             #计算基础属性
             $equip['base_attr'] = Com_FmtData::cus_json_decode($equip['base_attr']);
             if (!empty($equip['base_attr']) && Com_Array::is_good_arr($equip['base_attr'])) {
                 foreach ($equip['base_attr'] as $key => $val) {
                     if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') {
                         $rtn_attr['atk_min'] += ceil($val);
                     } else {
                         $rtn_attr[$key] += ceil($val);
                     }
                 }
             }
             #计算附加属性
             $equip['addition_attr'] = Com_FmtData::cus_json_decode($equip['addition_attr']);
             if (!empty($equip['addition_attr']) && Com_Array::is_good_arr($equip['addition_attr'])) {
                 foreach ($equip['addition_attr'] as $key => $val) {
                     if ($key == 'atk' || $key == 'atk_max' || $key == 'atk_min') {
                         $rtn_attr['atk_min'] += ceil($val);
                     } else {
                         $rtn_attr[$key] += ceil($val);
                     }
                 }
             }
             #计算强化属性
             $equip['intensive_desc'] = Com_FmtData::cus_json_decode($equip['intensive_desc']);
             if (!empty($equip['intensive_desc']) && Com_Array::is_good_arr($equip['intensive_desc'])) {
                 foreach ($equip['intensive_desc'] as $key => $val) {
                     if ($key == 'atk' || $key == 'atk_min' || $key == 'atk_max') {
                         $rtn_attr['atk_min'] += ceil($val);
                     } else {
                         $rtn_attr[$key] += ceil($val);
                     }
                 }
             }
             # 计算吞噬属性
             if (!empty($equip['we_swallow_info']) && is_array($equip['we_swallow_info'])) {
                 foreach ($equip['we_swallow_info']['swallow_attr'] as $key => $val) {
                     if ($key == 'atk' || $key == 'atk_max') {
                         $key = 'atk_min';
                     }
                     $rtn_attr[$key] += ceil($val);
                 }
             }
         }
         #套装加成
         $flags_attr = array();
         $item_flags = Cache_ItemFlag::getInstance()->get_item_flag_info(2);
         if (!empty($item_flags) && Com_Array::is_good_arr($item_flags)) {
             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_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_star, $condition[1]) >= $fnum[1]) {
                             $add_flag += 1;
                         }
                     }
                     if (count($conditions) == $add_flag) {
                         $flag_attr = json_decode($flag['attr'], true);
                         $flags_attr['quality'] = $flag_attr;
                     }
                 } 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_intensify, $condition[1]) >= $fnum[1]) {
                             $add_flag += 1;
                         }
                     }
                     if (count($conditions) == $add_flag) {
                         $flag_attr = json_decode($flag['attr'], true);
                         $flags_attr['intensify'] = $flag_attr;
                     }
                 }
             }
         }
         #计算套装加成属性
         if (!empty($flags_attr) && Com_Array::is_good_arr($flags_attr)) {
             foreach ($flags_attr as $flag_attr) {
                 foreach ($flag_attr as $key => $val) {
                     $rtn_attr[$key] += ceil($val['val']);
                 }
             }
         }
     }
     return $rtn_attr;
 }
Esempio n. 6
0
 public function get_main_dungeon_rank_cache($real_time = false)
 {
     $main_dungeon_list = array();
     if ($real_time) {
         $list = $this->redis()->zsets_all($this->main_dungeon_rank, false, 0, 99, true);
         if (!empty($list) && Com_Array::is_good_arr($list)) {
             foreach ($list as $player_id => $star) {
                 $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type', 'sum_fpower', 'level'));
                 $main_dungeon_list[$player_id] = array('player_id' => $player_id, 'name' => $player_info['name'], 'career_type' => $player_info['career_type'], 'level' => $player_info['level'], 'star' => $star, 'fight' => $player_info['sum_fpower']);
             }
         }
     } else {
         $rank_list = $this->redis()->hash_get($this->main_dungeon_rank_cache);
         $main_dungeon_list = $rank_list['main_dungeon_rank'];
         if (empty($main_dungeon_list)) {
             $main_dungeon_list = $this->update_main_dungeon_rank_cache();
         }
         $main_dungeon_list = Com_FmtData::cus_json_decode($main_dungeon_list);
     }
     if (Com_Array::is_good_arr($main_dungeon_list)) {
         Com_Array::multisort($main_dungeon_list, array('star' => 'desc', 'fight' => 'desc'));
     }
     return empty($main_dungeon_list) ? $main_dungeon_list : array_values($main_dungeon_list);
 }
Esempio n. 7
0
 /**
  * @Purpose:
  * 公会商店购买
  * @Param $player_id 玩家ID
  * @Param $shop_id 商品ID
  * @Param $type 商品类型
  * @Param $num 购买数量
  */
 public function union_shop_buy($player_id, $shop_id, $type, $num)
 {
     $player_id = intval($player_id);
     if ($num < 1) {
         $this->throw_error('10107');
         #参数错误
     }
     #获取玩家公会ID,验证公会信息
     $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id');
     if ($union_id < 1) {
         $this->throw_error('171101');
         #未加入公会
     }
     #获取商店数据
     $data = $this->get_data('UnionShop')->get_union_shop_info($union_id);
     if (!$data) {
         $this->throw_error('10110');
         #数据错误
     }
     $shop_type = '';
     $type = intval($type);
     if ($type == 1) {
         $shop_type = 'prop_info';
         $data['player_buy_info'] = Com_FmtData::cus_json_decode($data['player_buy_info']);
     } else {
         if ($type == 2) {
             $shop_type = 'buff_info';
         } else {
             $this->throw_error('1715001');
             #购买失败
         }
     }
     if ($data[$shop_type] && !is_array($data[$shop_type])) {
         $data[$shop_type] = json_decode($data[$shop_type], true);
     }
     $shop_id = intval($shop_id);
     #BUFF存在
     if ($type == 2 && $data[$shop_type][$shop_id]['record'][$player_id]) {
         $this->throw_error('1715001');
         #购买失败
     }
     #商品验证
     if (!$data[$shop_type][$shop_id]) {
         $this->throw_error('1715005');
         #道具不足
     }
     #商品是否解锁
     if ($data[$shop_type][$shop_id]['state'] != 1) {
         $this->throw_error('1715004');
         #道具未解锁
     }
     #购买职务验证
     #获取玩家公会职务
     $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id);
     $job = $player_data['job_id'];
     if ($job > $data[$shop_type][$shop_id]['job_level']) {
         $this->throw_error('1715003');
         #职务过低
     }
     #获取公会商店等级
     $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level');
     #本次更新每个玩家可以购买的道具上限验证
     $union_build_table = Cache_UnionBuild::getInstance()->get_union_build_info_two(array('build_type' => 'shop', 'build_lvl' => $shop_level));
     if ($union_build_table['buy_limit'] > 0 && $data['player_buy_info'][$player_id] + $num > $union_build_table['buy_limit']) {
         $this->throw_error('1715009');
         #本次刷新购买次数已满
     }
     $time = time();
     #道具数量验证
     if ($data[$shop_type][$shop_id]['num'] < $num) {
         #刷新时间验证
         if ($type == 1) {
             $next_refresh = 0;
             $update_prop_res = $this->check_shop_refresh($data['refresh_time'], $data[$shop_type], $next_refresh, $shop_level);
             if ($update_prop_res) {
                 $update_data['refresh_time'] = $data['refresh_time'];
                 #更新玩家购买次数
                 $data['player_buy_info'] = array();
             } else {
                 $this->throw_error('1715005');
                 #道具不足
             }
         } else {
             if ($type == 2) {
                 $record = $data[$shop_type][$shop_id]['record'];
                 if (Com_Array::is_good_arr($record)) {
                     foreach ($record as $pid => $re) {
                         if ($time >= $re['expired_time']) {
                             #增加商品数量
                             if ($data[$shop_type][$shop_id]['num'] + 1 < $data[$shop_type][$shop_id]['num_max']) {
                                 $data[$shop_type][$shop_id]['num']++;
                             } else {
                                 $data[$shop_type][$shop_id]['num'] = $data[$shop_type][$shop_id]['num_max'];
                             }
                             #清除玩家购买记录
                             unset($data[$shop_type][$shop_id]['record'][$pid]);
                         }
                     }
                 }
                 #道具数量验证
                 if ($data[$shop_type][$shop_id]['num'] < $num) {
                     $this->throw_error('1715005');
                     #道具不足
                 }
                 /*
                 #获取公会商店等级
                 $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level');
                 #获取商店配置表
                 $shop_table = $this->get_cache_table_data('shop_table', array('level' => $shop_level, 'type' => $type));
                 if (!$shop_table || !$shop_table[0]['refresh_time'])
                 {
                 	$this->throw_error('10109'); //配置表读取错误
                 }
                 
                 $next_time = $data[$shop_type][$shop_id]['next_refresh_time'];
                 $refresh_time = $shop_table[0]['refresh_time'] * 3600;
                 #更新下次刷新时间
                 $data[$shop_type][$shop_id]['next_refresh_time'] = $time + ($refresh_time - intval(($time - $next_time) % $refresh_time));	
                 */
             } else {
                 $this->throw_error('1715005');
                 #道具不足
             }
         }
     }
     #玩家贡献度验证
     #获取玩家贡献度
     $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id);
     if ($data[$shop_type][$shop_id]['contribution'] * $num > $player_data['total_dedicate']) {
         $this->throw_error('1715006');
         #贡献度不足
     }
     $player_name = $this->get_data('Player')->get_player_info($player_id, "name");
     if ($type == 2) {
         #获取商店配置表
         $shop_table = $this->get_cache_table_data('shop_table', array('level' => $shop_level, 'type' => $type));
         if (!$shop_table || !$shop_table[0]['refresh_time']) {
             $this->throw_error('10109');
             //配置表读取错误
         }
         $refresh_time = $time + $shop_table[0]['refresh_time'] * 3600;
         #更新购买记录
         $data[$shop_type][$shop_id]['record'][$player_id]['player_name'] = $player_name;
         $data[$shop_type][$shop_id]['record'][$player_id]['job'] = $job;
         $data[$shop_type][$shop_id]['record'][$player_id]['buy_time'] = $time;
         $data[$shop_type][$shop_id]['record'][$player_id]['expired_time'] = $refresh_time;
     }
     #扣除商品数量
     $data[$shop_type][$shop_id]['num'] -= $num;
     #扣除贡献度
     $front_amount_dedicate = $player_data['total_dedicate'];
     $dedicate = $data[$shop_type][$shop_id]['contribution'] * $num;
     $player_data['total_dedicate'] -= $dedicate;
     #增加公会记录
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
     $arr_replace[] = array('rep_type' => 7, 'txt' => $data[$shop_type][$shop_id]['name'], 'rep_color' => "ffb901");
     $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, 1715007, $arr_replace);
     $this->start_trans();
     if ($type == 1) {
         #发道具
         $prop_info[] = array('type' => 'prop', 'item_id' => $data[$shop_type][$shop_id]['prop_id'], 'item_num' => $num);
         if (Com_Array::is_good_arr($prop_info)) {
             $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '1715'), 1);
             if ($result !== true) {
                 $this->throw_error('10104');
             }
         }
         #记录玩家购买次数
         $data['player_buy_info'][$player_id] += $num;
         $update_data['player_buy_info'] = json_encode($data['player_buy_info']);
     }
     $update_data[$shop_type] = json_encode($data[$shop_type]);
     #更新商店
     $this->get_data('UnionShop')->update_union_shop($union_id, $update_data);
     #更新玩家贡献度
     $this->get_data('UnionPlayer')->update_union_player_info($union_id, $player_id, $player_data);
     //公会贡献-流水日志
     $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 2, 'item_id' => 11, 'item_num' => $dedicate, 'amount' => $front_amount_dedicate, 'after_amount' => $player_data['total_dedicate'], 'cmd_id' => 1715);
     Log_Common::getInstance()->add_log($log_data);
     $this->commit();
     if ($type == 1) {
         $this->get_game('Reward')->add_reward_log();
     } else {
         if ($type == 2) {
             #通知C++给玩家增加BUFF
             Protocol::input($player_id, 7, 4, 490, array('0' => $player_id, '1' => $data[$shop_type][$shop_id]['prop_id']));
         }
     }
     $this->update_temporary_data($data);
     return array('0' => 1, '1' => $data[$shop_type][$shop_id]['prop_id']);
 }