$mysql_conf['host'], 'port' => $mysql_conf['port'], 'user' => $mysql_conf['user'], 'passwd' => $mysql_conf['passwd'], 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] )); return $conn; } protected function getExplode($string) { $delim = "|"; $drop_multiply = explode($delim, $string); $delim1 = ":"; $arr = array(); for ($i = 0; $i < count($drop_multiply); $i++) { $mul = explode($delim1, $drop_multiply[$i]); array_push($arr, $mul); } return $arr; } protected function getParameter($para_id) { $parameter_meta_cluster = require('../res/parameter@parameter.php'); $parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id); $p = array( 'id' => $parameter_meta['id'], 'name' => $parameter_meta['param_name'], 'value' => $parameter_meta['param_value'], ); return $p; } protected function getSeasonPoint($seaPoint_id) { $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); $seaPoint_meta = getSeasonPointConfig($seaPoint_meta_table, $seaPoint_id); $seaPoint = array( 'id' => $seaPoint_meta['id'], 'min' => $seaPoint_meta['min_point'], 'max' => $seaPoint_meta['max_point'], 'des' => $seaPoint_meta['des'], //'reward' => $seaPoint_meta['season_reward'], //'weekreward' => $seaPoint_meta['week_reward'], ); return $seaPoint; } public function getTime() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'time' => phpcommon\getNowTime(), )); } public function getRedInfo() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } $quest_list = array(); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } //任务 $rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); if ($rowCount != 0) { $rows = $conn->execQuery('SELECT * FROM quest WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); if ($rows) { foreach ($rows as $row) { array_push($quest_list, array( 'type' => $row['quest_type'], 'quest_id' => $row['quest_id'], 'quest_num' => $row['quest_num'], 'quest_state' => $row['quest_state'] )); } } } //赛季 //判断当前赛季 $number = 0; $open_time = 0; $end_time = 0; $sea_reward = array(); $sea_reward2 = array(); $rank_status = 0; $season = metatable\getNowSeason(); $number = metatable\getNowSeasonNum(); $open_time = strtotime($season['time1']); $end_time = strtotime($season['time2']); $item_multiply = $this->getExplode($season['season_reward']); $item_multiply2 = $this->getExplode($season['season_reward2']); for($ii = 1; $ii <= count($item_multiply); $ii++) { $rowpass = $conn->execQueryOne('SELECT active_status, honor_status ' . ' FROM passinfo WHERE accountid=:accountid AND passid=:passid;', array( ':accountid' => $account_id, ':passid' => $ii, )); $rank_status = 0; $rank_status2 = 0; if (!$rowpass) { $ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' . ' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' . ' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;', array( ':accountid' => $account_id, ':passid' => $ii, ':create_time' => phpcommon\getNowTime(), ':modify_time' => phpcommon\getNowTime() )); if (!$ret) { die(); return; } $rank_status = 0; $rank_status2 = 0; } else { $rank_status = $rowpass['active_status']; $rank_status2 = $rowpass['honor_status']; } $key = $ii - 1; array_push($sea_reward, array( 'item_id' => $item_multiply[$key][0], 'item_num' => $item_multiply[$key][1], 'time' => $item_multiply[$key][2], 'status' => $rank_status, 'type' => 0, )); array_push($sea_reward2, array( 'item_id' => $item_multiply2[$key][0], 'item_num' => $item_multiply2[$key][1], 'time' => $item_multiply2[$key][2], 'status' => $rank_status2, 'type' => 1, )); } if ($number == 0) { phpcommon\sendError(ERR_USER_BASE + 2, '赛季未开启'); return; } //当前段位及积分 $rank = 1; $rank_score = 0; $max_rank_score = 0; $min_rank_score = 0; $reward = array(); $week_reward = array(); $max_rank = 1; $row = $conn->execQueryOne('SELECT integral, pass_status, score, max_integral FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id, )); if (!$row) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } $pass_status = $row['pass_status']; $rank_status = 0; $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { $seaPoint = $this->getSeasonPoint($ii); if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max'] || $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { $rank = $ii; $min_rank_score = $seaPoint['min']; $max_rank_score = $seaPoint['max'] + 1 - $seaPoint['min']; $rank_score = $row['integral'] - $seaPoint['min'] + 1; if ($seaPoint['max'] == -1) { $max_rank_score = $seaPoint['min']; $rank_score = $row['integral']; } } if ($row['max_integral'] >= $seaPoint['min'] && $row['max_integral'] <= $seaPoint['max'] || $row['max_integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) { $max_rank = $ii; } } //等级积分 $pass_array = metatable\getNowSeasoncard($row['score']); $pass_lv = metatable\getNowSeasoncardInfo($row['score']); $delim1 = '|'; $drop_multiply = explode($delim1, $season['week_reward']); $delim2 = ';'; $mul = explode($delim2, $drop_multiply[$pass_lv - 1]); $delim = ':'; $week_array = array(); for ($i2 = 0; $i2 < count($mul); $i2++) { $mul1 = explode($delim, $mul[$i2]); array_push($week_array, $mul1); } for($s = 0; $s < count($week_array); $s++) { array_push($week_reward, array( 'item_id' => $week_array[$s][0], 'item_num' => $week_array[$s][1], 'time' => $week_array[$s][2], 'status' => $row['pass_status'] )); } //背包 $bag_list = array(); $rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:account_id;', array( ':account_id' => $account_id )); if ($rows) { foreach ($rows as $row){ $active_time = 0; $color_id = 0; $status = $row['status']; if (phpcommon\getNowTime() >= $row['active_time'] && $row['active_time'] != 0) { $ret = $conn->execScript('UPDATE bag SET active_time=0, color_id=0, status=2, modify_time=:modify_time ' . ' WHERE accountid=:account_id AND id=:id;', array( ':account_id' => $account_id, ':id' => $row['id'], ':modify_time' => phpcommon\getNowTime() )); if (!$ret) { die(); return; } $active_time = 0; $color_id = 0; $status = 2; } else { if ($row['active_time'] != 0) { $active_time = $row['active_time']; } $color_id = $row['color_id']; $status = $row['status']; } array_push($bag_list, array( 'id' => $row['id'], 'active_time' => $active_time, 'status' => $status, 'color_id' => $color_id, 'num' => $row['num'], )); } } //吃鸡 $row = $conn->execQueryOne('SELECT daily_order1, daily_order2, daily_order3 FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); if (!$row) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $item_list = array(); $daily_order1 = $row['daily_order1']; $daily_order2 = $row['daily_order2']; $daily_order3 = $row['daily_order3']; $p1 = $this->getParameter(LOGINBOX_TIME1); $p2 = $this->getParameter(LOGINBOX_TIME2); $p3 = $this->getParameter(LOGINBOX_TIME3); $p = $this->getParameter(LOGINBOX_TIME); $pt1 = $p1['value']; $pt2 = $p2['value']; $pt3 = $p3['value']; $pt = $p['value']; $nowTime = floor((phpcommon\getNowTime() - phpcommon\getdayseconds(phpcommon\getNowTime())) / 3600); if ($nowTime < $pt1) { $daily_order1 = 0; $daily_order2 = 0; $daily_order3 = 0; } else if ($nowTime >= $pt1 && $nowTime < $pt1 + $pt) { if ($daily_order1 == 0) { $daily_order1 = 1; } else { $daily_order1 = $row['daily_order1']; } $daily_order2 = 0; $daily_order3 = 0; } else if ($nowTime >= $pt1 + $pt && $nowTime < $pt2) { if ($daily_order1 <= 1) { $daily_order1 = 3; } else { $daily_order1 = $row['daily_order1']; } $daily_order2 = 0; $daily_order3 = 0; } else if ($nowTime >= $pt2 && $nowTime < $pt2 + $pt) { if ($daily_order1 <= 1) { $daily_order1 = 3; } else { $daily_order1 = $row['daily_order1']; } if ($daily_order2 == 0) { $daily_order2 = 1; } else { $daily_order2 = $row['daily_order2']; } $daily_order3 = 0; } else if ($nowTime >= $pt2 + $pt && $nowTime < $pt3) { if ($daily_order1 <= 1) { $daily_order1 = 3; } else { $daily_order1 = $row['daily_order1']; } if ($daily_order2 <= 1) { $daily_order2 = 3; } else { $daily_order2 = $row['daily_order2']; } $daily_order3 = 0; } else if ($nowTime >= $pt3 && $nowTime < $pt3 + $pt) { if ($daily_order1 <= 1) { $daily_order1 = 3; } else { $daily_order1 = $row['daily_order1']; } if ($daily_order2 <= 1) { $daily_order2 = 3; } else { $daily_order2 = $row['daily_order2']; } if ($daily_order3 == 0) { $daily_order3 = 1; } else { $daily_order3 = $row['daily_order3']; } } else if ($nowTime >= $pt3 + $pt) { if ($daily_order1 <= 1) { $daily_order1 = 3; } else { $daily_order1 = $row['daily_order1']; } if ($daily_order2 <= 1) { $daily_order2 = 3; } else { $daily_order2 = $row['daily_order2']; } if ($daily_order3 <= 1) { $daily_order3 = 3; } else { $daily_order3 = $row['daily_order3']; } } $stauts = 0; for ($i = 0; $i < 3; $i++) { if ($i == 0) { $status = $daily_order1; } else if ($i == 1) { $status = $daily_order2; } else if ($i == 2) { $status = $daily_order3; } array_push($item_list, array( 'status' => $status )); } $ret = $conn->execScript('UPDATE user SET daily_order1=:daily_order1, daily_order2=:daily_order2, daily_order3=:daily_order3 ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':daily_order1' => $daily_order1, ':daily_order2' => $daily_order2, ':daily_order3' => $daily_order3 )); if (!$ret) { die(); return; } //登录信息 $rowuser = $conn->execQueryOne('SELECT daily_first_login, first_login, game_times FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); if (!$rowuser) { phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); return; } $ret = $conn->execScript('UPDATE user SET daily_first_login=:daily_first_login, first_login=:first_login ' . 'WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':first_login' => $rowuser['first_login'] + 1, ':daily_first_login' => $rowuser['daily_first_login'] + 1, )); if (!$ret) { die(); return; } //离线奖励 $row = $conn->execQueryOne('SELECT * FROM hang WHERE accountid=:accountid;', array( ':accountid' => $account_id )); if (!$row) { $ret = $conn->execScript('INSERT INTO hang(accountid, hang_time, reward_id, reward_num, create_time, modify_time) ' . ' VALUES(:accountid, :hang_time, 0, 0, :create_time, :modify_time) ' . ' ON DUPLICATE KEY UPDATE accountid=:accountid, hang_time=:hang_time, reward_id=0, reward_num=0, modify_time=:modify_time;', array( ':accountid' => $account_id, ':hang_time' => phpcommon\getNowTime(), ':create_time' => phpcommon\getNowTime(), ':modify_time' => phpcommon\getNowTime() )); if (!$ret) { die(); return; } $num = 0; } else { $addreward = new classes\AddReward(); $p_num = $this->getParameter(OFFLINE_REWARD_NUMBER); $p_time_limit = $this->getParameter(OFFLINE_TIME_LIMIT); $p_val = $this->getParameter(OFFLINE_TIME_UNIT); $val = $addreward->getVipVal($account_id, 8); $max_time = $p_time_limit['value'] + $val; $num = floor((phpcommon\getNowTime() - $row['hang_time']) / $p_val['value'] * $p_num['value']); if ((phpcommon\getNowTime() - $row['hang_time']) >= $max_time) { $num = floor($max_time / $p_val['value'] * $p_num['value']); } $val2 = $addreward->getVipVal($account_id, 6); $num = floor($num + $num * $val2 / 100); } $cost = metatable\getParameterByName('season_card_cost'); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'quest_list' => $quest_list, 'pass_status' => $pass_status, 'season' => $number, 'open_time' => $open_time, 'end_time' => $end_time, 'rank' => $rank, 'rank_score' => $rank_score, 'max_rank_score' => $max_rank_score, 'reward' => $reward, 'week' => $week_reward, 'seareward' => $sea_reward, 'seareward2' => $sea_reward2, 'bag_list' => $bag_list, 'item_list' => $item_list, 'first_login' => $rowuser['first_login'] + 1, 'daily_first_login' => $rowuser['daily_first_login'] + 1, 'game_times' => $rowuser['game_times'], 'min_rank_score' => $min_rank_score, 'cost' => $cost, 'pass_array' => $pass_array, 'onlinenum' => $num, 'max_rank' => $max_rank, )); } public function getOnlineReward() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $conn = $this->getMysql($account_id); if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } $num = 0; $item_list = array(); $all_item_list = array(); $row = $conn->execQueryOne('SELECT * FROM hang WHERE accountid=:accountid;', array( ':accountid' => $account_id )); $addreward = new classes\AddReward(); if (!$row) { $ret = $conn->execScript('INSERT INTO hang(accountid, hang_time, reward_id, reward_num, create_time, modify_time) ' . ' VALUES(:accountid, :hang_time, 0, 0, :create_time, :modify_time) ' . ' ON DUPLICATE KEY UPDATE accountid=:accountid, hang_time=:hang_time, reward_id=0, reward_num=0, modify_time=:modify_time;', array( ':accountid' => $account_id, ':hang_time' => phpcommon\getNowTime(), ':create_time' => phpcommon\getNowTime(), ':modify_time' => phpcommon\getNowTime() )); if (!$ret) { die(); return; } $num = 0; } else { $p_num = $this->getParameter(OFFLINE_REWARD_NUMBER); $p_time_limit = $this->getParameter(OFFLINE_TIME_LIMIT); $p_val = $this->getParameter(OFFLINE_TIME_UNIT); $val = $addreward->getVipVal($account_id, 8); $max_time = $p_time_limit['value'] + $val; $num = floor((phpcommon\getNowTime() - $row['hang_time']) / $p_val['value'] * $p_num['value']); if ((phpcommon\getNowTime() - $row['hang_time']) >= $max_time) { $num = floor($max_time / $p_val['value'] * $p_num['value']); } $val2 = $addreward->getVipVal($account_id, 6); $num = floor($num + $num * $val2 / 100); $item_id = 10001; $ret = $conn->execScript('UPDATE hang SET hang_time=:hang_time, reward_num=:reward_num, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':hang_time' => phpcommon\getNowTime(), ':modify_time' => phpcommon\getNowTime(), //':reward_id' => $item_id, ':reward_num' => $num, )); if (!$ret) { die(); return; } //额外奖励 $val3 = $addreward->getVipVal($account_id, 7); $jilv = metatable\getParameterByName('offline_time_pro') + $val3; $rowu = $conn->execQueryOne('SELECT daily_offline FROM user WHERE accountid=:accountid;', array( ':accountid' => $account_id )); $rand = Rand(0, 100); if ($rowu['daily_offline'] < metatable\getParameterByName('offline_time_boxtimes') && $jilv >= $rand) { $dropid = metatable\getParameterByName('offline_time_box'); $item_list = metatable\getDropListById($dropid); $ret = $conn->execScript('UPDATE user SET daily_offline=:daily_offline, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':modify_time' => phpcommon\getNowTime(), ':daily_offline' => $rowu['daily_offline'] + 1, )); $ret = $conn->execScript('UPDATE hang SET hang_time=:hang_time, reward_id=:reward_id, modify_time=:modify_time ' . ' WHERE accountid=:accountid;', array( ':accountid' => $account_id, ':hang_time' => phpcommon\getNowTime(), ':modify_time' => phpcommon\getNowTime(), ':reward_id' => $item_list[0]['item_id'], )); if (!$ret) { die(); return; } } array_push($item_list, array( 'item_id' => $item_id, 'item_num' => $num, 'time' => 0, )); foreach ($item_list as $i) { $items = $addreward->addReward($i['item_id'], $i['item_num'], $account_id, $i['time'], 0); foreach($items as $s) { array_push($all_item_list, array( 'item_id' => $s['item_id'], 'item_num' => $s['item_num'], 'time' => $s['time'], )); } } } $coin_num = $addreward->getCoinNum($account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'time' => phpcommon\getNowTime(), 'item_list' => $item_list, 'all_item_list' => $all_item_list, 'coin_nums' => $coin_num, )); } public function getHangDoubleReward() { $account_id = $_REQUEST['account_id']; //登录校验 $login = loginVerify($account_id, $_REQUEST['session_id']); if (!$login) { phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } $conn = $this->getMysql($account_id); $item_id = 0; $num = 0; if (!$conn) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } $row = $conn->execQueryOne('SELECT * FROM hang WHERE accountid=:accountid;', array( ':accountid' => $account_id )); if (!$row) { phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); return; } $item_list = array(); array_push($item_list, array( 'item_id' => $row['reward_id'], 'item_num' => 1, 'time' => 0, )); array_push($item_list, array( 'item_id' => 10001, 'item_num' => $row['reward_num'], 'time' => 0, )); $addreward = new classes\AddReward(); $all_item_list = array(); foreach ($item_list as $i) { $items = $addreward->addReward($i['item_id'], $i['item_num'], $account_id, $i['time'], 0); foreach($items as $s) { array_push($all_item_list, array( 'item_id' => $s['item_id'], 'item_num' => $s['item_num'], 'time' => $s['time'], )); } } $coin_num = $addreward->getCoinNum($account_id); echo json_encode(array( 'errcode' => 0, 'errmsg' => '', 'item_list' => $item_list, 'all_item_list' => $all_item_list, 'coin_nums' => $coin_num, )); } } ?>