Ejemplo n.º 1
0
 public static function factory($db = 'game', $reload = false, $remote_settings = array())
 {
     if (!isset(self::$_dbs[$db]) || $reload) {
         $dbConfig = TenYear::get_val('dbConfig');
         switch ($db) {
             case 'setting':
                 self::$_dbs[$db] = new DbClient($dbConfig['setting']['host'], $dbConfig['setting']['user'], $dbConfig['setting']['pass'], $dbConfig['setting']['name'], $dbConfig['pconnect']);
                 break;
             case 'game':
                 self::$_dbs[$db] = new DbClient($dbConfig['game']['host'], $dbConfig['game']['user'], $dbConfig['game']['pass'], $dbConfig['game']['name'], $dbConfig['pconnect']);
                 break;
             case 'log':
                 self::$_dbs[$db] = new DbClient($dbConfig['log']['host'], $dbConfig['log']['user'], $dbConfig['log']['pass'], $dbConfig['log']['name'], $dbConfig['pconnect']);
                 break;
             case 'cross':
                 // 跨服配置
                 self::$_dbs[$db] = new DbClient($dbConfig['cross']['host'], $dbConfig['cross']['user'], $dbConfig['cross']['pass'], $dbConfig['cross']['name'], $dbConfig['pconnect']);
                 break;
             case 'global_game':
                 #全局playerid
                 self::$_dbs[$db] = new DbClient($dbConfig['global_game']['host'], $dbConfig['global_game']['user'], $dbConfig['global_game']['pass'], $dbConfig['global_game']['name'], $dbConfig['pconnect']);
                 break;
             default:
                 return false;
         }
     }
     return self::$_dbs[$db];
 }
Ejemplo n.º 2
0
 public function run()
 {
     $objAccount = TenYear::getInstance('Data_Account');
     $objPlayerInitGame = TenYear::getInstance('Game_PlayerInit');
     for ($i = 1; $i <= 10; $i++) {
         $strUserAccount = "ggmmhg100" . $i;
         $playerid = $objAccount->get_pid_byaccount($strUserAccount);
         $player_character = Cache_PlayerRole::getInstance()->get_player_role();
         if (!$playerid) {
             $name = $strUserAccount;
             $playerid = $objAccount->add_account($strUserAccount, $name);
             //                $character = ($i%4)+1;
             $character = rand(3, 4);
             $arrCharacter = $player_character[$character];
             $arrData = array();
             $arrData['player_id'] = $playerid;
             $arrData['user_account'] = $strUserAccount;
             $arrData['name'] = $name;
             $arrData['career_type'] = $arrCharacter['career_type'];
             $arrData['avatar'] = $arrCharacter['avatar'];
             $arrData['sex'] = $arrCharacter['sex'];
             $arrData['ad_info'] = '';
             $arrData['client_ip'] = '127.0.0.1';
             $arrData['exec'] = 1;
             $affectedRows = $objPlayerInitGame->active($arrData);
             if ($affectedRows) {
                 $sql = "replace into test_account (player_id,user_account,career_type) values ('{$playerid}','{$strUserAccount}','{$arrCharacter['career_type']}')";
                 $result = $this->query($sql);
                 if ($result) {
                     echo "{$strUserAccount}\n";
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function achieve_repair($player_id)
 {
     # 修复一下符文成就相关的数据[NOTE:刷新成就相关脏数据用]
     TenYear::getInstance(TenYear::game_name('PlayerSkill'))->handle_rune_refer_achieve($player_id);
     # 修复一下天赋成就相关的数据[NOTE:刷新成就相关脏数据用]
     TenYear::getInstance(TenYear::game_name('PlayerSkill'))->handle_dower_refer_achieve($player_id);
     echo $player_id . "sync suc \n";
 }
Ejemplo n.º 4
0
 public static function getMongoUtilObject()
 {
     $mongoConfig = TenYear::get_val('mongoConfig');
     $config = array('host' => $mongoConfig['host'], 'port' => $mongoConfig['port'], 'option' => array('connect' => true), 'db_name' => $mongoConfig['db'], 'username' => $mongoConfig['user'], 'password' => $mongoConfig['pass']);
     $mongoUtilObj = new MongoUtil();
     $mongoUtilObj->init($config);
     $mongoUtilObj->selectCollection($mongoConfig['collection']);
     return $mongoUtilObj;
 }
Ejemplo n.º 5
0
 protected function get_cross($name, $isOne = false)
 {
     $className = TenYear::cross_name($name);
     if ($isOne) {
         return new $className();
     }
     $this->_objData[$className]++;
     return TenYear::getInstance($className);
 }
Ejemplo n.º 6
0
 public function doAction()
 {
     $userInfo_json = base64_decode($_POST['data']);
     $userInfo_array = json_decode($userInfo_json, true);
     $state = isset($userInfo_array['state']) ? $userInfo_array['state'] : "";
     $ips = isset($userInfo_array['ips']) ? $userInfo_array['ips'] : "";
     $data = array();
     $res = array();
     if (!empty($state) && !in_array($state, $this->state)) {
         $data['status'] = 8;
         exit;
     } else {
         $data['status'] = 0;
     }
     if ($state == 'open') {
         #开服
         #Protocol::input(0, 7, 4, 514, array('type_id'=>1,'role_id'=>0));
         #Protocol::out();
         $res['status'] = 1;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
         } else {
             $data['status'] = 0;
         }
     } elseif ($state == 'close') {
         #关服维护
         Protocol::input(0, 7, 4, 514, array('type_id' => 1, 'role_id' => 0));
         Protocol::out();
         $res['status'] = 0;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
             TenYear::getInstance();
             $objSession = TenYear::getInstance('session');
             $objSession->del_all_session();
         } else {
             $data['status'] = 0;
         }
     } elseif ('write_ip' == $state) {
         #白名单
         $res['write_ip'] = $ips;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
         } else {
             $data['status'] = 0;
         }
     } elseif ('black_id' == $state) {
         #黑名单
         $res['black_id'] = $ips;
         if ($this->get_data('Online')->set_server_state($res)) {
             $data['status'] = 1;
         } else {
             $data['status'] = 0;
         }
     }
     echo json_encode($data);
     return;
 }
Ejemplo n.º 7
0
 /**
  * 删除对象 
  */
 protected function flush_obj()
 {
     foreach ($this->_objGame as $className => $count) {
         TenYear::delInstance($className);
     }
     foreach ($this->_objData as $className => $count) {
         TenYear::delInstance($className);
     }
 }
Ejemplo n.º 8
0
 public function handle_dirty_data()
 {
     $player_id_list = $this->get_whole_player_list();
     if (empty($player_id_list)) {
         return false;
     }
     foreach ($player_id_list as $player_id) {
         $player_info = TenYear::getInstance('Data_Player')->get_player_info($player_id);
         $arr_player_detail = TenYear::getInstance('Data_PlayerDetail')->get_player_detail($player_id, array('skill_info', 'skill_rune_info'));
         $skill_list_all = Cache_Skill::getInstance()->get_skill_list($player_info['career_type']);
         $skill_list_distinct = Cache_Skill::getInstance()->get_distinct_skill_list($player_info['career_type']);
         if (empty($skill_list_distinct)) {
             echo "Warning: player_id={$player_id}|career_type=" . $player_info['career_type'] . "\n";
             continue;
             #$this->throw_error('60022'); # 没有符合玩家职业的技能配置信息
         }
         # 该步操作除了获取hash结构外,重置了每个技能的max_level为有效信息
         $skill_hash_all = TenYear::getInstance('Game_PlayerSkill')->convert_skill_list_to_hash($skill_list_all);
         $exception_flag = 0;
         # 0无异常 >1异常
         foreach ($skill_list_distinct as $val) {
             if ($val['display'] == 0) {
                 continue;
             }
             $skill_id = $val['sid'];
             # 问题玩家
             if (isset($arr_player_detail['skill_info'][$skill_id]) && $arr_player_detail['skill_info'][$skill_id]['level'] > $skill_hash_all[$skill_id][1]['max_level']) {
                 echo "Warning: player_id={$player_id}|skill_id={$skill_id}|origin_level=" . $arr_player_detail['skill_info'][$skill_id]['level'] . "|max_level=" . $skill_hash_all[$skill_id][1]['max_level'] . "\n";
                 $arr_player_detail['skill_info'][$skill_id]['level'] = $skill_hash_all[$skill_id][1]['max_level'];
                 $exception_flag += 1;
             }
             if (isset($arr_player_detail['skill_rune_info'][$skill_id])) {
                 # 重置每个技能的符文为最大等级的激活状态
                 $rune_list_all = Cache_SkillRune::getInstance()->get_skill_rune_list_by_skill_id($skill_id);
                 $rune_hash_all = TenYear::getInstance('Game_PlayerSkill')->convert_rune_list_to_hash($rune_list_all);
                 foreach ($rune_hash_all as $rune_id => $rune_lv_info) {
                     if (isset($arr_player_detail['skill_rune_info'][$skill_id][$rune_id]) && $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] > $rune_lv_info[1]['max_level']) {
                         echo "Warning: player_id={$player_id}|skill_id={$skill_id}|rune_id={$rune_id}|origin_level=" . $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] . "|max_level=" . $rune_lv_info[1]['max_level'] . "\n";
                         $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] = $rune_lv_info[1]['max_level'];
                         $exception_flag += 1;
                     }
                 }
             }
         }
         if (!empty($exception_flag)) {
             # 修正等级
             /**
             				TenYear::getInstance('Data_PlayerDetail')->update_player_detail(
             					$player_id,
             					array('skill_info'=>$arr_player_detail['skill_info'], 'skill_rune_info' => $arr_player_detail['skill_rune_info'])
             				);
             				**/
         }
     }
     echo "End ...\n";
 }
Ejemplo n.º 9
0
 public function add_unions($player_id, $friend_id)
 {
     try {
         $objdata = TenYear::getInstance(TenYear::game_name('PlayerFriend'));
         $objdata->add_unions($player_id, $friend_id);
         echo "send success {$player_id}";
     } catch (Exception $e) {
         $error = "Exception: " . $e->getFile() . " line:" . $e->getLine() . " " . $e->getMessage();
         echo $error;
     }
 }
Ejemplo n.º 10
0
 public static function factory($group = 'game', $reload = false)
 {
     if (!REDIS_CLUSTER) {
         $group = 'game';
     }
     if (!isset(self::$_cache[$group]) || $reload) {
         $settings = TenYear::get_val('redisConfig');
         if (empty($settings) || !isset($settings[$group])) {
             return false;
         }
         self::$_cache[$group] = new RedisClient($settings[$group]);
     }
     return self::$_cache[$group];
 }
Ejemplo n.º 11
0
 public static function factory($group = 'setting', $reload = false)
 {
     if (!isset(self::$_mems[$group]) || $reload) {
         if (isset(self::$_mems[$group])) {
             unset(self::$_mems[$group]);
         }
         $settings = TenYear::get_val('memcachedConfig');
         if (!isset($settings[$group])) {
             //
             return false;
         }
         self::$_mems[$group] = new MMemcached($settings, $group);
     }
     return self::$_mems[$group];
 }
Ejemplo n.º 12
0
 public function flush_memcache()
 {
     $settings = TenYear::get_val('memcachedConfig');
     #var_export($settings);
     if (!empty($settings['game']['host']) && !empty($settings['game']['port'])) {
         $cmd = "echo 'flush_all' | nc {$settings['game']['host']} {$settings['game']['port']}";
         echo "{$cmd} ...\n";
         $last_line = system($cmd, $retval);
         if ($retval !== 0) {
             $this->throw_exception(array('message' => 'Failed to flush memcache ...', 'code' => 3));
         }
     } else {
         $this->throw_exception(array('message' => 'Failed to get memcache configuration ...', 'code' => 4));
     }
 }
Ejemplo n.º 13
0
 public static function get_search_list($data)
 {
     $ret = array();
     if ($data) {
         foreach ($data as $key => $val) {
             $is_hidden_vip = 0;
             if (intval($val['vip']) > 0) {
                 $vip_info = TenYear::getInstance('Data_VipReward')->get_reward_log(intval($val['player_id']));
                 $is_hidden_vip = intval($vip_info['is_hidden_vip']);
             }
             $ret[$key] = array(0 => intval($val['player_id']), 1 => $val['name'], 2 => intval($val['level']), 3 => intval($val['sum_fpower']), 4 => $val['avatar'], 5 => intval($val['vip']), 6 => intval($val['is_friend']), 7 => intval($val['type']), 8 => $is_hidden_vip);
         }
     }
     return $ret;
 }
Ejemplo n.º 14
0
 public function fb()
 {
     $sql = "select * from test_account";
     $this->query($sql);
     $arr_player = array();
     while ($this->next_record()) {
         $player_id = $this->get_field('player_id');
         $arr_player[] = $player_id;
     }
     foreach ($arr_player as $player_id) {
         $obj = TenYear::getInstance(TenYear::game_name('PlayerFB'));
         $obj->get_chapter_fb_info($player_id, 0, 0);
         echo "player:{$player_id} suc\n";
     }
 }
Ejemplo n.º 15
0
 public function update_day()
 {
     if (!Com_Db::factory($this->db)->ping()) {
         echo "ping log db fail\n";
         return false;
     }
     $time = time();
     $logsDir = DATA_PATH . "/logsdata";
     $logsBackupDir = DATA_PATH . "/logsbackup";
     $dbConfig = TenYear::get_val('dbConfig');
     $dirhandle = opendir($logsDir);
     if ($dirhandle) {
         while (($file = readdir($dirhandle)) !== false) {
             if ($file != '.' && $file != '..') {
                 $backfile = $logsBackupDir . '/' . $file;
                 $file = $logsDir . '/' . $file;
                 if (filemtime($file) < strtotime(date('Y-m-d 04:00:00', $time))) {
                     $status = 0;
                     $shell = "/data/mysql/bin/mysql -h{$dbConfig['log']['host']} -u{$dbConfig['log']['user']} -p{$dbConfig['log']['pass']} -e \"use {$dbConfig['log']['name']}; source {$file};\"";
                     echo $shell . "\n";
                     passthru($shell, $status);
                     if ($status == 0) {
                         echo "source sucess\n";
                         unlink($file);
                     } else {
                         echo "source fail status {$status}\n";
                         if (!is_dir($logsBackupDir)) {
                             mkdir($logsBackupDir);
                         }
                         shell_exec("mv {$file} {$backfile}");
                         echo "mv {$file} {$backfile}\n";
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 16
0
 public function run()
 {
     $keys = Com_AdCache::factory('player')->keys("data|player:*");
     if (!empty($keys)) {
         foreach ($keys as $key) {
             $player_info = $this->redis()->hash_get($key, array('player_id', 'level', 'union_id'));
             if (intval($player_info['player_id']) <= 0) {
                 continue;
             }
             if (intval($player_info['level']) < 20) {
                 continue;
             }
             $objPlayerProp = TenYear::getInstance(TenYear::data_name('PlayerProp'));
             $player_props = $objPlayerProp->get_player_all_prop($player_info['player_id']);
             foreach ($player_props as $prop) {
                 if (isset($prop['intensive_level'])) {
                     echo "player_id={$player_info['player_id']}|player_prop_id={$prop['player_prop_id']}\n";
                     $objPlayerAchieve = TenYear::getInstance(TenYear::game_name('PlayerAchieve'));
                     $objPlayerAchieve->async_trigger_achieve_target($player_info['player_id'], 6, "1:" . $prop['quality'] . ":" . $prop['star_level'] . ":" . intval($prop['intensive_level']) . ":{$prop['player_prop_id']}", 4);
                 }
             }
         }
     }
 }
Ejemplo n.º 17
0
 public static function getInstance()
 {
     return TenYear::getInstance(__CLASS__);
 }
Ejemplo n.º 18
0
 public function __construct()
 {
     parent::__construct();
     TenYear::setInstance('TenYear', $this);
 }
Ejemplo n.º 19
0
<?php

/**
 * 异步GloryShop日志备份服务 
 * @author wanghui@uuzu.com
 * @date 2015-4-20
 */
require dirname(__FILE__) . '/../global.php';
TenYear::getInstance();
ini_set('default_socket_timeout', -1);
Com_AdCache::factory()->set_timeout(0);
Com_Replication::set_interval_time(300);
//注册player_detail同步方法
$objPlayerDetail = new Data_GloryShop();
Com_Replication::register('player_glory_shop', array($objPlayerDetail, 'get_player_log'), array($objPlayerDetail, 'replace_to_mysql'));
//开始执行同步
Com_Replication::start();
Ejemplo n.º 20
0
 public static function get_vip_special_reward_add_coeff($func_id, $player_vip, $player_privilege_level, $player_id)
 {
     $vip_limit_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id($func_id);
     if ($vip_limit_type['fun_type'] == 1 && !empty($player_vip)) {
         $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, $func_id);
     } elseif ($vip_limit_type['fun_type'] == 2 && !empty($player_privilege_level)) {
         $left_time = TenYear::getInstance('Game_VipSpecial')->get_left_time($player_id);
         if ($left_time > 0) {
             $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_privilege_level, $func_id);
         }
     }
     $vip_add_coeff = !empty($vip_limit_info) ? $vip_limit_info['max_times'] / 10000 : 0;
     return $vip_add_coeff;
 }
Ejemplo n.º 21
0
 public static function load_settings($settings_varname)
 {
     if (empty($settings_varname)) {
         die("System configuration file error");
     }
     define("OPERATOR_ID", isset($settings_varname['OPERATOR_ID']["varvalue"]) ? $settings_varname['OPERATOR_ID']["varvalue"] : 1);
     define("GAME_ID", isset($settings_varname['GAME_ID']["varvalue"]) ? $settings_varname['GAME_ID']["varvalue"] : 100);
     define("SERVER_ID", $settings_varname['SERVER_ID']["varvalue"]);
     define("AREA_ID", $settings_varname['AREA_ID']["varvalue"]);
     #区id
     define("SERVER_KEY", $settings_varname['SERVER_KEY']["varvalue"]);
     define("SERVER_TITLE", $settings_varname['SERVER_TITLE']["varvalue"]);
     define("QQ_PINGTA", isset($settings_varname['QQ_PINGTA']["varvalue"]) ? $settings_varname['QQ_PINGTA']["varvalue"] : 0);
     #QQ平台朋友[pengyou]或者空间[qzone]
     define("SHOW_TITLE", $settings_varname['SHOW_TITLE']["varvalue"]);
     #跨服显示用户的前缀用
     define("SERVER_DOMAIN", $settings_varname['SERVER_DOMAIN']["varvalue"]);
     define("MAIN_DOMAIN_URL", $settings_varname['MAIN_DOMAIN_URL']["varvalue"]);
     define("PROCESS_MAIN_IP", $settings_varname['PROCESS_MAIN_IP']["varvalue"]);
     define("MEDIA_SERVER_HOST", $settings_varname['MEDIA_SERVER_HOST']["varvalue"]);
     define("GATEWAY_DOMAIN", $settings_varname['GATEWAY_DOMAIN']["varvalue"]);
     define("GATEWAY_IP", $settings_varname['GATEWAY_IP']["varvalue"]);
     define("GATEWAY_PORT", $settings_varname['GATEWAY_PORT']["varvalue"]);
     define("SERVER_PORT", $settings_varname['SERVER_PORT']["varvalue"]);
     define("LINK_PAY_URL", isset($settings_varname['LINK_PAY_URL']["varvalue"]) ? $settings_varname['LINK_PAY_URL']["varvalue"] : "");
     define("LINK_PAY_URL", isset($settings_varname['LINK_PAY_URL']["varvalue"]) ? $settings_varname['LINK_PAY_URL']["varvalue"] : "");
     define("SERVER_START_TIME", isset($settings_varname['SERVER_START_TIME']["varvalue"]) ? $settings_varname['SERVER_START_TIME']["varvalue"] : 0);
     define("SERVER_STOP_TIME", isset($settings_varname['SERVER_STOP_TIME']["varvalue"]) ? $settings_varname['SERVER_STOP_TIME']["varvalue"] : 0);
     define("SERVER_STOP_ALLOW_IP", isset($settings_varname['SERVER_STOP_ALLOW_IP']["varvalue"]) ? $settings_varname['SERVER_STOP_ALLOW_IP']["varvalue"] : "");
     define("NOT_ALLOW_IP", isset($settings_varname['NOT_ALLOW_IP']["varvalue"]) ? $settings_varname['NOT_ALLOW_IP']["varvalue"] : "");
     define("SERVER_FIRST_START_TIME", $settings_varname['SERVER_FIRST_START_TIME']["varvalue"]);
     define("LINK_CLIENT_URL", isset($settings_varname['LINK_CLIENT_URL']["varvalue"]) ? $settings_varname['LINK_CLIENT_URL']["varvalue"] : "");
     define("ADULT_URL", isset($settings_varname['ADULT_URL']["varvalue"]) ? $settings_varname['ADULT_URL']["varvalue"] : "http://www.youzu.com");
     define("CROSS_ARENA_ID", isset($settings_varname['CROSS_ARENA_ID']["varvalue"]) ? $settings_varname['CROSS_ARENA_ID']["varvalue"] : 1);
     //跨服竞技场id
     define("SERVER_CPU_NUM", isset($settings_varname['SERVER_CPU_NUM']["varvalue"]) ? $settings_varname['SERVER_CPU_NUM']["varvalue"] : 4);
     //服务器CPU数量
     $dbConfig = array();
     $dbConfig["pconnect"] = isset($settings_varname['DBPCONNECT']["varvalue"]) ? $settings_varname['DBPCONNECT']["varvalue"] : 0;
     $dbConfig["setting"]["host"] = $settings_varname['DB_SETTING_HOST']["varvalue"];
     $dbConfig["setting"]["user"] = $settings_varname['DB_SETTING_USER']["varvalue"];
     $dbConfig["setting"]["pass"] = $settings_varname['DB_SETTING_PASS']["varvalue"];
     $dbConfig["setting"]["name"] = $settings_varname['DB_SETTING_NAME']["varvalue"];
     $dbConfig["game"]["host"] = $settings_varname['DBHOST']["varvalue"];
     $dbConfig["game"]["user"] = $settings_varname['DBUSER']["varvalue"];
     $dbConfig["game"]["pass"] = $settings_varname['DBPASS']["varvalue"];
     $dbConfig["game"]["name"] = $settings_varname['DBNAME']["varvalue"];
     $dbConfig["log"]["host"] = $settings_varname['DB_LOG_HOST']["varvalue"];
     $dbConfig["log"]["user"] = $settings_varname['DB_LOG_USER']["varvalue"];
     $dbConfig["log"]["pass"] = $settings_varname['DB_LOG_PASS']["varvalue"];
     $dbConfig["log"]["name"] = $settings_varname['DB_LOG_NAME']["varvalue"];
     $dbConfig["cross"]["host"] = $settings_varname['DB_CROSS_HOST']["varvalue"];
     $dbConfig["cross"]["user"] = $settings_varname['DB_CROSS_USER']["varvalue"];
     $dbConfig["cross"]["pass"] = $settings_varname['DB_CROSS_PASS']["varvalue"];
     $dbConfig["cross"]["name"] = $settings_varname['DB_CROSS_NAME']["varvalue"];
     $dbConfig["global_game"]["host"] = $settings_varname['DB_GLOBAL_HOST']["varvalue"];
     $dbConfig["global_game"]["user"] = $settings_varname['DB_GLOBAL_USER']["varvalue"];
     $dbConfig["global_game"]["pass"] = $settings_varname['DB_GLOBAL_PASS']["varvalue"];
     $dbConfig["global_game"]["name"] = $settings_varname['DB_GLOBAL_NAME']["varvalue"];
     TenYear::set_val('dbConfig', $dbConfig);
     $memcachedConfig = array();
     $memcachedConfig['setting']["host"] = $settings_varname['MEMCACHE_SETTING_HOST']["varvalue"];
     $memcachedConfig['setting']["port"] = $settings_varname['MEMCACHE_SETTING_PORT']["varvalue"];
     $memcachedConfig['setting']["sock"] = $settings_varname['MEMCACHE_SETTING_SOCK']["varvalue"];
     $memcachedConfig['game']['host'] = $settings_varname['MEMCACHE_GAME_HOST']["varvalue"];
     $memcachedConfig['game']['port'] = $settings_varname['MEMCACHE_GAME_PORT']["varvalue"];
     $memcachedConfig['game']["sock"] = $settings_varname['MEMCACHE_GAME_SOCK']["varvalue"];
     $memcachedConfig['cross']['host'] = $settings_varname['MEMCACHE_CROSS_HOST']["varvalue"];
     $memcachedConfig['cross']['port'] = $settings_varname['MEMCACHE_CROSS_PORT']["varvalue"];
     $memcachedConfig['cross']["sock"] = $settings_varname['MEMCACHE_CROSS_SOCK']["varvalue"];
     TenYear::set_val('memcachedConfig', $memcachedConfig);
     $mongoConfig = array();
     $mongoConfig['host'] = $settings_varname['MONGO_HOST']['varvalue'];
     $mongoConfig['port'] = $settings_varname['MONGO_PORT']['varvalue'];
     $mongoConfig['db'] = $settings_varname['MONGO_DB']['varvalue'];
     $mongoConfig['collection'] = $settings_varname['MONGO_COLLECTION']['varvalue'];
     TenYear::set_val('mongoConfig', $mongoConfig);
     $redisConfig = array();
     $redisConfig['game']['host'] = $settings_varname['REDIS_HOST']['varvalue'];
     $redisConfig['game']['port'] = $settings_varname['REDIS_PORT']['varvalue'];
     $redisConfig['game']['sock'] = $settings_varname['REDIS_SOCK']['varvalue'];
     if (isset($settings_varname['REDIS_QUEUE_HOST'])) {
         $redisConfig['queue']['host'] = $settings_varname['REDIS_QUEUE_HOST']['varvalue'];
         $redisConfig['queue']['port'] = $settings_varname['REDIS_QUEUE_PORT']['varvalue'];
         $redisConfig['queue']['sock'] = $settings_varname['REDIS_QUEUE_SOCK']['varvalue'];
     } else {
         $redisConfig['queue']['host'] = $settings_varname['REDIS_HOST']['varvalue'];
         $redisConfig['queue']['port'] = $settings_varname['REDIS_PORT']['varvalue'];
         $redisConfig['queue']['sock'] = $settings_varname['REDIS_SOCK']['varvalue'];
     }
     if (isset($settings_varname['REDIS_PLAYER_HOST'])) {
         $redisConfig['player']['host'] = $settings_varname['REDIS_PLAYER_HOST']['varvalue'];
         $redisConfig['player']['port'] = $settings_varname['REDIS_PLAYER_PORT']['varvalue'];
         $redisConfig['player']['sock'] = $settings_varname['REDIS_PLAYER_SOCK']['varvalue'];
     } else {
         $redisConfig['player']['host'] = $settings_varname['REDIS_HOST']['varvalue'];
         $redisConfig['player']['port'] = $settings_varname['REDIS_PORT']['varvalue'];
         $redisConfig['player']['sock'] = $settings_varname['REDIS_SOCK']['varvalue'];
     }
     if (isset($settings_varname['REDIS_CROSS_HOST'])) {
         $redisConfig['cross']['host'] = $settings_varname['REDIS_CROSS_HOST']['varvalue'];
         $redisConfig['cross']['port'] = $settings_varname['REDIS_CROSS_PORT']['varvalue'];
         $redisConfig['cross']['sock'] = $settings_varname['REDIS_CROSS_SOCK']['varvalue'];
     } else {
         $redisConfig['cross']['host'] = $settings_varname['REDIS_HOST']['varvalue'];
         $redisConfig['cross']['port'] = $settings_varname['REDIS_PORT']['varvalue'];
         $redisConfig['cross']['sock'] = $settings_varname['REDIS_SOCK']['varvalue'];
     }
     if (isset($settings_varname['REDIS_TASK_HOST'])) {
         $redisConfig['task']['host'] = $settings_varname['REDIS_TASK_HOST']['varvalue'];
         $redisConfig['task']['port'] = $settings_varname['REDIS_TASK_PORT']['varvalue'];
         $redisConfig['task']['sock'] = $settings_varname['REDIS_TASK_SOCK']['varvalue'];
     } else {
         $redisConfig['task']['host'] = $settings_varname['REDIS_HOST']['varvalue'];
         $redisConfig['task']['port'] = $settings_varname['REDIS_PORT']['varvalue'];
         $redisConfig['task']['sock'] = $settings_varname['REDIS_SOCK']['varvalue'];
     }
     //没有设置queue redis或者game redis和queue redis配置不一致时 集群关闭
     //		define('REDIS_CLUSTER', isset($redisConfig['queue']) ? ($redisConfig['game'] != $redisConfig['queue']) : false);
     define('REDIS_CLUSTER', true);
     TenYear::set_val('redisConfig', $redisConfig);
     #跨服配置
     $remote_server = array();
     if (isset($settings_varname['REMOTE_SERVER'])) {
         $servers = explode('|', $settings_varname['REMOTE_SERVER']['varvalue']);
         if (!empty($servers)) {
             foreach ($servers as $server) {
                 $info = explode(':', $server);
                 $remote_server[$info[0]]['host'] = $info[1];
                 $remote_server[$info[0]]['port'] = $info[2];
                 $remote_server[$info[0]]['player_port'] = $info[3];
             }
         }
     }
     TenYear::set_val('remote_server', $remote_server);
 }
Ejemplo n.º 22
0
 /**
  * 获取玩家基本信息
  *
  * @param array $objDataInfo
  * @return unknown
  */
 public function get_userInfo($objDataInfo)
 {
     $page = $objDataInfo['page'] ? $objDataInfo['page'] : '1';
     $page_size = $objDataInfo['page_size'] ? $objDataInfo['page_size'] : '10';
     $server_id = $objDataInfo['server_id'];
     $player_id = $objDataInfo['player_id'];
     $user_account = $objDataInfo['user_account'];
     $name = $objDataInfo['name'];
     $gm = $objDataInfo['gm'];
     $created_at = $objDataInfo['created_at'];
     $cash = $objDataInfo['cash'];
     $vip = $objDataInfo['vip'];
     $level = $objDataInfo['level'];
     $serverId = $objDataInfo['serverId'];
     $condition = '';
     if ($player_id) {
         $condition .= " player_id like '%" . $player_id . "%' AND";
     }
     if ($user_account) {
         $condition .= " user_account like '%" . $user_account . "%' AND";
     }
     if (is_numeric($gm)) {
         $condition .= " gm =" . $gm . " AND";
     }
     if ($name) {
         $condition .= " name like '%" . $name . "%' AND";
     }
     if ($created_at[0]) {
         $condition .= " reg_time >= " . strtotime($created_at[0]) . " AND";
     }
     if ($created_at[1]) {
         $condition .= " reg_time <= " . strtotime($created_at[1]) . " AND";
     }
     if ($level[0]) {
         $condition .= " level >= " . $level[0] . " AND";
     }
     if ($level[1]) {
         $condition .= " level <= " . $level[1] . " AND";
     }
     if ($vip[0]) {
         $condition .= " vip >= " . $vip[0] . " AND";
     }
     if ($vip[1]) {
         $condition .= " vip <= " . $vip[1] . " AND";
     }
     if ($condition) {
         $condition = 'where ' . $condition;
         $condition = substr($condition, 0, -3);
     }
     $page_total_num_sql = 'select count(`player_id`) as total from player ' . $condition;
     $page_total_num = $this->get_one($page_total_num_sql, null);
     $page_num = ceil($page_total_num['total'] / $page_size);
     $page_num_sql = 'select * from player ' . $condition . ' limit ' . ($page * $page_size - $page_size) . ',' . $page_size;
     $userInfoData = $this->select_all($page_num_sql);
     foreach ($userInfoData as $k => $v) {
         $data_player = $this->get_data('Player');
         $player_info = $data_player->get_player_info($v['player_id']);
         if (!$player_info) {
             continue;
         }
         foreach ($player_info as $field => $val) {
             if (!array_key_exists($field, $v)) {
                 continue;
             }
             if ($field == "reg_time") {
                 $userInfoData[$k]['reg_time'] = date('Y-m-d H:i:s', $player_info['reg_time']);
             } elseif ($field == "login_time") {
                 $userInfoData[$k]['login_time'] = date('Y-m-d H:i:s', $player_info['login_time']);
             } else {
                 $userInfoData[$k][$field] = $val;
             }
         }
         /*
         $userInfoData[$k]['reg_time'] = date('Y-m-d H:i:s',$player_info['reg_time']);
         $userInfoData[$k]['login_time'] = date('Y-m-d H:i:s',$player_info['login_time']);
         unset($player_info['reg_time'],$player_info['login_time']);
         $userInfoData[$k] = $userInfoData[$k] + $player_info;
         */
         //获取声望等级
         if (isset($v['fame_level'])) {
             $fame_level = isset($player_info['fame_level']) ? $player_info['fame_level'] : $v['fame_level'];
             $fameInfo = Cache_PlayerFame::getInstance()->get_player_fame_info($fame_level);
             if (!empty($fameInfo)) {
                 $userInfoData[$k]['fame_level'] = $fameInfo['title'];
             } else {
                 $userInfoData[$k]['fame_level'] = '无名';
             }
         }
         //VIP特权
         $vip_special_info = $this->get_data('VipSpecial')->get_vip_special_info($v['player_id']);
         $privilege_left_date = 0;
         $privilege_level = 0;
         if (!empty($vip_special_info)) {
             $privilege_level = $vip_special_info['vip_special_level'];
             $privilege_left_date = $vip_special_info['left_date'];
         }
         $userInfoData[$k]['privilege_level'] = $privilege_level;
         $userInfoData[$k]['privilege_left_date'] = $privilege_left_date;
         //获取公会贡献值
         if (!empty($player_info['union_id'])) {
             $gh_con = $this->get_data('UnionPlayer')->get_union_player_info($player_info['union_id'], $v['player_id']);
             $userInfoData[$k]['gh_con'] = $gh_con['total_dedicate'];
         } else {
             $userInfoData[$k]['gh_con'] = 0;
         }
     }
     $dbConfig = TenYear::get_val("dbConfig");
     $tableFieldsSql = "SELECT COLUMN_NAME as `field`, COLUMN_COMMENT as `comment` FROM INFORMATION_SCHEMA.COLUMNS  WHERE TABLE_NAME = 'player' AND TABLE_SCHEMA = '" . $dbConfig["game"]["name"] . "'";
     $tableFields = $this->get_list($tableFieldsSql);
     $fields = array();
     if (!empty($tableFields)) {
         foreach ($tableFields as $comments) {
             $fields[$comments['field']] = $comments['comment'];
         }
         $fields['gh_con'] = "公会贡献值";
     }
     $userInfoData['all_page'] = $page_total_num['total'];
     $userInfoData['fields'] = $fields;
     return $userInfoData;
 }
Ejemplo n.º 23
0
}
echo "游戏数据库:{$dbConfig['game']['name']}, 服务器id:" . SERVER_ID . ", 当前玩家数量:{$playerNum}, 确认清档请输入yes | no退出\n";
fscanf(STDIN, "%s", $input);
if ($input != 'yes') {
    exit;
}
$dataFiles = array(DATA_PATH . '/cache', DATA_PATH . '/fightreport', DATA_PATH . '/logs', DATA_PATH . '/logsdata', DATA_PATH . '/replicationdata');
foreach ($dataFiles as $file) {
    if (!is_dir($file)) {
        mkdir($file, 755);
    }
    shell_exec("chown -R nobody:nobody {$file}");
    sleep(1);
}
sleep(1);
$dbConfig = TenYear::get_val('dbConfig');
$truncate_file = dirname(__FILE__) . '/../Server/truncate.sql';
if (is_file($truncate_file)) {
    echo "mysql -hlocalhost -u{$dbConfig['game']['user']} -p{$dbConfig['game']['pass']} -e \" use {$dbConfig['game']['name']}; source {$truncate_file};\"";
    shell_exec("mysql -hlocalhost -u{$dbConfig['game']['user']} -p{$dbConfig['game']['pass']} -e \" use {$dbConfig['game']['name']}; source {$truncate_file};\"");
}
ini_set('default_socket_timeout', -1);
Com_AdCache::factory()->set_timeout(0);
$auto_player_id = Com_AdCache::factory()->get('auto_player_id');
$auto_player_max_id = Com_AdCache::factory()->get('auto_player_max_id');
$auto_union_id = Com_AdCache::factory()->get('auto_union_id');
$auto_union_max_id = Com_AdCache::factory()->get('auto_union_max_id');
Com_AdCache::factory()->flushAll();
Com_AdCache::factory('queue')->flushAll();
sleep(1);
if ($auto_player_id) {
Ejemplo n.º 24
0
# 生成天梯与竞技场假人数据
# ----------------------------------------------------------------------------
file_put_contents($logFile, "生成天梯与竞技场假人数据...\n", FILE_APPEND);
$output = array();
exec("/usr/local/webserver/php/bin/php " . PROJECT_ROOT . "/test/generate_dummy_role.php 0", $output, $return_val);
if ($return_val) {
    # return_val不为0表示脚本报异常,执行失败
    file_put_contents($logFile, "生成天梯与竞技场假人数据失败...\n", FILE_APPEND);
    exit;
}
file_put_contents($logFile, "生成天梯与竞技场假人数据成功...\n", FILE_APPEND);
# ----------------------------------------------------------------------------
# 对空天梯榜前20名插入机器人
# ----------------------------------------------------------------------------
try {
    $result = TenYear::getInstance('Game_Challenge')->fill_empty_challenge();
    if ($result) {
        echo '对空天梯榜前20名插入机器人成功...\\n';
    } else {
        echo '对空天梯榜前20名插入机器人失败[天梯榜不为空]...\\n';
    }
} catch (Exception $e) {
    echo 'Caught Exception: [code = ', $e->getCode(), "] ", $e->getMessage(), " ", $e->getFile(), " ", $e->getline(), "\n";
    echo '对空天梯榜前20名插入机器人失败...\\n';
}
# ----------------------------------------------------------------------------
shell_exec("sudo /etc/init.d/memcached restart");
shell_exec("/usr/local/webserver/php/bin/php /data/code/web/crontab/process.php");
shell_exec("sudo /etc/init.d/mfc++server start");
file_put_contents($logFile, "清档成功", FILE_APPEND);
file_put_contents($logFile1, time());
Ejemplo n.º 25
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;
 }
Ejemplo n.º 26
0
 public function set_dummy_role_in_ladder_other($player_id_list_hash)
 {
     $obj_game_challenge = TenYear::getInstance('Game_Challenge');
     $obj_data_challenge = TenYear::getInstance('Data_Challenge');
     $cur_auto_challenge_rank = $obj_data_challenge->get_auto_challenge_rank_value();
     # 当前天梯榜入榜人数
     $challenge_partition_boundary = $obj_game_challenge->challenge_partition_boundary;
     # 天梯榜上限人数
     $player_id_list = array_values($player_id_list_hash);
     $player_count = count($player_id_list);
     echo "Current player_count = {$player_count} ...\n";
     echo "Current auto_challenge_rank = {$cur_auto_challenge_rank} ...\n";
     $offset = $challenge_partition_boundary > $player_count ? $player_count - $cur_auto_challenge_rank : $challenge_partition_boundary - $cur_auto_challenge_rank;
     echo "Current offset = {$offset} ...\n";
     $max_rank = $obj_data_challenge->get_new_challenge_rank($offset);
     echo "Current max_rank = {$max_rank} ...\n";
     for ($i = $cur_auto_challenge_rank + 1; $i <= $max_rank; $i++) {
         $rank_info = array('player_id' => $player_id, 'rank' => $i, 'mod_date' => $this->challenge_current_time, 'latest_reward_time' => 0, 'is_in_battle' => 0, 'in_battle_time' => 0, 'challenge_status' => 0, 'fake_rank' => 0, 'fake_battle_num' => 0, 'fake_rank_list' => array());
         $re = $obj_data_challenge->update_challenge_rank_info($rank_info);
     }
     echo "Total {$i} player take part in ladder...\n";
 }
Ejemplo n.º 27
0
 private function flush_sum_fpower_for_dummy($player_id)
 {
     $objFpowerCalc = TenYear::getInstance(TenYear::game_name('FpowerCalc'));
     $fpower_arr = $objFpowerCalc->calc_player_fpower($player_id);
     # 人物模块战力
     $equip_fpower = $objFpowerCalc->calc_equip_fpower($player_id);
     # 装备模块战力
     $sq_fpower = $objFpowerCalc->calc_sq_fpower($player_id);
     # 圣器模块战力
     $fairy_fpower = $objFpowerCalc->calc_fairy_fpower($player_id);
     # 女神模块战力
     $hero_fpower = $objFpowerCalc->calc_hero_fpower($player_id);
     # 英雄模块战力
     $skill_fpower = $objFpowerCalc->calc_skill_fpower($player_id);
     # 技能模块战力
     $wing_fpower = $objFpowerCalc->calc_wing_fpower($player_id);
     # 翅膀模块战力
     #var_export($fpower);
     $fpower = $fpower_arr['fpower'] + $sq_fpower + $skill_fpower + $equip_fpower;
     $sum_fpower = $fpower + $hero_fpower + $fairy_fpower + $wing_fpower;
     #echo "fpower:{$fpower} sq_fpower:{$sq_fpower} equip_fpower:{$equip_fpower} skill_fpower:{$skill_fpower} wing_fpower:{$wing_fpower} hero_fpower:{$hero_fpower} fairy_fpower:{$fairy_fpower}\n";
     #echo "sum_fpower:{$sum_fpower}\n";
     TenYear::getInstance('Data_Player')->update_player_info($player_id, array('fpower' => $fpower, 'sum_fpower' => $sum_fpower));
 }
Ejemplo n.º 28
0
 /**
  * 获取前三
  * @return int
  */
 public function get_top_three($settle_date)
 {
     //$data = $this->redis()->get($this->_cacheKeyKfDuelTopList);//取缓存数据
     //if($data){
     //	$out = json_decode($data,true);
     //	return $out;
     //}else{
     $data = $this->get_rank_list_by_multisort($settle_date, 10);
     if ($data) {
         $rank = 1;
         $out = array();
         $objApi = TenYear::getInstance('Com_Uzapi');
         foreach ($data as $cross_player_info) {
             if ($rank > 3) {
                 break;
             }
             $avatar = $this->get_game('KFArena')->get_player_avatar($cross_player_info['player_id'], 0, $cross_player_info['career_type']);
             /*
             					if(SERVER_ID == $cross_player_info['server_id']){
             						$avatar = $this->get_game('KFArena')->get_player_avatar($cross_player_info['player_id'],0,$cross_player_info['career_type']);
             					}else{
             						$avatar = array();
             						$param = array(
             									"action"=>"PlayerInfo",
             									"command"=>"get_player_avatar",
             									"player_id"=>$cross_player_info['player_id'],
             									'career_type'=>$cross_player_info['career_type']
             								);
             						$objApi->setReqData($param);
             						$ip = $this->get_cross('Base')->get_server_ip($cross_player_info['server_id']);
             						$objApi->setServerUrl($ip);
             						$response = $objApi->sendRequest();
             						if(!empty($response['return'])){
             							$avatar =  $response['return'];
             						} else {
             							$avatar = array();
             						}
             					}*/
             $out[] = array('player_id' => $cross_player_info['player_id'], 'name' => $cross_player_info['player_name'], 'power' => $cross_player_info['sum_fpower'], 'rank' => $rank, 'avatar' => $avatar, 'server_id' => $cross_player_info['server_id']);
             $rank++;
         }
         //$this->redis()->set($this->_cacheKeyKfDuelTopList, json_encode($out), 300);
         return $out;
     }
     //}
     return array();
 }
Ejemplo n.º 29
0
 private function handle_fashion_for_dummy($player_id, $fashion_id)
 {
     $arr_list = explode('|', $fashion_id);
     if (!empty($arr_list)) {
         $arr_fashion_fit = array();
         $arr_fashion_info = array();
         $arr_fashion_attr = array();
         foreach ($arr_list as $fid) {
             $fashion = Cache_Fashion::getInstance()->get_fashion($fid);
             $arr_fashion_fit[$fashion['type']] = $fid;
             $arr_fashion_info[$fid] = array('type' => $fashion['type']);
             $attrs = explode("|", $fashion['attr_val']);
             if ($attrs) {
                 foreach ($attrs as $attr) {
                     $val = explode(":", $attr);
                     $arr_fashion_attr[$val[0]] += $val[1];
                 }
             }
         }
         TenYear::getInstance('Data_PlayerDetail')->update_player_detail($player_id, array('fashion_info' => $arr_fashion_info, 'fashion_fit' => $arr_fashion_fit, 'fashion_attr' => $arr_fashion_attr));
     }
 }
Ejemplo n.º 30
0
 /**
  * 获取挑战双方战斗信息
  * @param unknown $player_id
  * @param unknown $opponent_player_id  对手玩家ID
  * @return multitype:number
  */
 public function grab_treasure_battle($player_id, $opponent_player_id, $need_pieces_id, $battle_log_id = 0)
 {
     $opponent_player_id = intval($opponent_player_id);
     $battle_log_id = intval($battle_log_id);
     $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("player_id", "is_dummy", "server_id"));
     if (empty($opponent_player_info)) {
         $opponent_player_info = $this->get_data("Player")->get_player_info($opponent_player_id, array("player_id", "is_dummy", "server_id"));
         if (empty($opponent_player_info)) {
             $this->throw_error('20002');
             #获取玩家信息失败
         }
         $opponent_player_info['server_id'] = SERVER_ID;
     }
     list($prop_id, $pieces_index) = explode("_", $need_pieces_id);
     $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($need_pieces_id);
     if (empty($pieceConfig)) {
         $this->throw_error('80003', "5010905{$prop_id}{$pieces_index}");
     }
     $grab_prop_config = Cache_GrabTreasureBase::getInstance()->get_grab_treasure_id($prop_id);
     if (empty($grab_prop_config)) {
         $this->throw_error('80003', "5010900{$prop_id}");
         //游戏配置出错,请联系客服!
     }
     #限制挑战玩家在推荐列表中或抢回日志列表中
     if ($battle_log_id == 2) {
         $recommend_player_list = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id, "recommend_player_list");
         #操作不符法
         if (empty($recommend_player_list) || !in_array($opponent_player_id, $recommend_player_list)) {
             $this->throw_error('173702', "5010916");
         }
     } else {
         $log_data = $this->get_game("GrabTreasure")->grab_treasure_log($player_id, 1, 100);
         if (empty($log_data['list'])) {
             $this->throw_error('173702', "5010923");
         }
         $is_allow_grab = 0;
         foreach ($log_data['list'] as $val) {
             if ($val["is_allow_grab"] == 1 && $val['grab_player_id'] == $opponent_player_id) {
                 $is_allow_grab = 1;
                 break;
             }
         }
         if ($is_allow_grab == 0) {
             $this->throw_error('173702', "5010932");
         }
     }
     $quality = $grab_prop_config['quality'];
     # 当天剩余可用挑战次数验证
     $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info($this->grab_treasure_battle_buy_type, 1);
     $battle_times = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grab_treasure_battle_times');
     $battle_buy_times = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grab_treasure_battle_buy_times');
     if (empty($battle_times)) {
         $battle_times = 0;
     }
     if (empty($battle_buy_times)) {
         $battle_buy_times = 0;
     }
     $battle_times_max = $battle_buy_times * $buy_times_info['per_num'] + $this->grab_treasure_max_times;
     if ($battle_times >= $battle_times_max) {
         $this->throw_error('113706');
         # 剩余可用挑战次数不足
     }
     $cd_acc_lock = $this->get_data('GrabTreasure')->get_battle_cd_acc_lock($player_id);
     # 获取挑战CD时间累计锁状态
     $battle_remain_cd = $this->get_data('GrabTreasure')->get_battle_remain_cd($player_id);
     # 获取:挑战剩余cd时间
     $safe_remain_cd = $this->get_cross('GrabTreasure')->get_safe_remain_cd($player_id);
     # 获取保护时间
     $allow_battle = 1;
     if (!empty($cd_acc_lock)) {
         # CD时间累计锁打开,不再允许CD累计
         if ($battle_remain_cd > 0) {
             $allow_battle = 0;
         }
     } else {
         # CD时间累计锁关闭,允许CD累计
         if ($battle_remain_cd >= $this->grab_treasure_battle_cd_stint) {
             $allow_battle = 0;
         }
     }
     if ($allow_battle == 0) {
         $this->throw_error('122201');
         # 夺宝战斗CD中[上次超过上限后CD尚未清零,CD累计锁尚未关闭]
     }
     #对手是否挑战中
     $is_in_battle = $this->get_cross("GrabTreasure")->get_battle_lock($opponent_player_id);
     if ($is_in_battle) {
         $this->throw_error("122203");
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array("is_online", "privilege_level"));
     $is_online = $player_info["is_online"];
     #对方在线保护状态不可挑战
     $safe_remain_cd = $this->get_cross('GrabTreasure')->get_safe_remain_cd($opponent_player_id);
     # 获取保护时间
     if ($safe_remain_cd > 0) {
         #离线玩家没有开启保护模式
         if ($is_online) {
             $this->throw_error('122202');
         }
     }
     #验证对手是否存在该碎片
     if ($opponent_player_info['is_dummy'] == 0) {
         $grab_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($opponent_player_id);
         if ($grab_treasure_info) {
             if (!isset($grab_treasure_info['quality_piece_ids'][$quality]) || empty($grab_treasure_info['quality_piece_ids'][$quality])) {
                 if ($battle_log_id > 0) {
                     $log_data = $this->get_cross('GrabTreasureLog')->get_grab_treasure_log($player_id, $battle_log_id);
                     if (!empty($log_data)) {
                         $log_data['is_allow_grab'] = 0;
                         $this->get_cross('GrabTreasureLog')->update_grab_treasure_info($player_id, $battle_log_id, $log_data);
                     }
                 }
                 $this->throw_error('122801');
                 #碎片已被其它玩家抢光
             }
         }
     }
     $player_data = $this->get_game('PlayerBase')->get_player_whole_attr($player_id);
     if (SERVER_ID == $opponent_player_info['server_id']) {
         $opponent_player_data = $this->get_game('PlayerBase')->get_player_whole_attr($opponent_player_id);
     } else {
         $param = array("action" => "PlayerInfo", "command" => "get_player_whole_attr", "player_id" => $opponent_player_id);
         $objApi = TenYear::getInstance('Com_Uzapi');
         $objApi->setReqData($param);
         $ip = $this->get_cross('Base')->get_server_ip($opponent_player_info['server_id']);
         $objApi->setServerUrl($ip);
         $response = $objApi->sendRequest();
         if (!empty($response['return'])) {
             $opponent_player_data = $response['return'];
         } else {
             $opponent_player_data = array();
         }
     }
     SynPlayer::set_syn_data($player_data);
     $synPlayerData = SynPlayer::get_data();
     SynPlayer::set_syn_data($opponent_player_data);
     $synTgtPlayerData = SynPlayer::get_data();
     $data = array('ladder_id' => 0, 'role_id_0' => $player_data['player_id'], 'role_name_0' => $player_data['name'], 'career_type_0' => $player_data['career_type'], 'masks_0' => $synPlayerData['m'], 'values_0' => $synPlayerData['u'], 'role_id_1' => $opponent_player_data['player_id'], 'role_name_1' => $opponent_player_data['name'], 'career_type_1' => $opponent_player_data['career_type'], 'masks_1' => $synTgtPlayerData['m'], 'values_1' => $synTgtPlayerData['u']);
     # 获取唯一的战斗序列号
     $battle_seq = $this->get_cross('GrabTreasure')->get_new_grab_treasure_battle_seq();
     $data['ladder_id'] = $battle_seq;
     $this->start_trans();
     $is_add_battle_cd = 1;
     #特权免CD
     if ($player_info['privilege_level'] > 0) {
         $left_cd = $this->get_game('VipSpecial')->get_left_time($player_id);
         if ($left_cd > 0) {
             $vip_info = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10080);
             if (!empty($vip_info)) {
                 if ($player_info['privilege_level'] >= $vip_info['vip_level']) {
                     $is_add_battle_cd = 0;
                 }
             }
         }
     }
     if ($is_add_battle_cd) {
         $re = $this->get_data('GrabTreasure')->add_battle_cd($player_id, $this->grab_treasure_battle_cd_time);
         $this->write_check($re, 5010726);
     }
     # 更新挑战次数
     $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'grab_treasure_battle_times', 1);
     $this->write_check($re, 5010731);
     #对手挑战中
     if ($opponent_player_info['is_dummy'] == 0) {
         $re = $this->get_cross("GrabTreasure")->add_battle_lock($opponent_player_id);
         $this->write_check($re, 5010765);
     }
     $update_data["battle_need_piece_id"] = $need_pieces_id;
     $update_data["battle_piece_quality"] = $quality;
     $update_data["battle_log_id"] = $battle_log_id;
     $re = $this->get_cross('GrabTreasure')->update_grab_treasure($player_id, $update_data);
     $this->write_check($re, 5010787);
     $this->commit();
     $battle_id_info = array('player_id' => $player_id, 'opponent_player_id' => $opponent_player_id);
     $this->get_data("GrabTreasure")->add_battle_id_info($battle_seq, $battle_id_info);
     #一旦掠夺其他玩家的保护,会取消自己的保护时间
     $this->get_cross("GrabTreasure")->clear_safe_remain_cd($player_id);
     # 推送C++战斗双方属性信息
     Protocol::input($player_id, 7, 4, 540, $data);
     unset($data['masks_0'], $data['values_0'], $data['masks_1'], $data['values_1']);
     $data_json = json_encode($data);
     Com_Log::debug_write('xgame.grab_treasure', "{$player_id}\t" . "grab_treasure_battle\t" . "{$data_json}\t");
     $out = array('result' => 1);
     #夺宝N次添加引导任务
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 35, 1);
     $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 3016, 1);
     return $out;
 }