This commit is contained in:
aozhiwei 2020-06-04 16:22:56 +08:00
parent 604fb32de4
commit b405645f2e
8 changed files with 377 additions and 119 deletions

View File

@ -257,8 +257,10 @@ CREATE TABLE `equip` (
`sub_time` int(11) NOT NULL DEFAULT '0' COMMENT '缩短时间', `sub_time` int(11) NOT NULL DEFAULT '0' COMMENT '缩短时间',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
`using_id` int(11) NOT NULL DEFAULT '0' COMMENT '上阵id',
PRIMARY KEY (`idx`), PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`) UNIQUE KEY `accountid_id` (`accountid`, id)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -0,0 +1,25 @@
begin;
UPDATE user set season_time=1591459199 WHERE season_time=0;
DROP TABLE IF EXISTS `equip`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `equip` (
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
`id` int(11) NOT NULL DEFAULT '0' COMMENT '装备id',
`lv` int(11) NOT NULL DEFAULT '0' COMMENT '装备等级',
`active_time` int(11) NOT NULL DEFAULT '0' COMMENT '进阶时间',
`sub_time` int(11) NOT NULL DEFAULT '0' COMMENT '缩短时间',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
`using_id` int(11) NOT NULL DEFAULT '0' COMMENT '上阵id',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid_id` (`accountid`, id)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into version (version) values(20200604);
commit;

View File

@ -62,6 +62,7 @@ function getSkinConfig($skin_table ,$item_id)
function getEquipConfig($equip_table, $item_id) function getEquipConfig($equip_table, $item_id)
{ {
$item_id = (int)$item_id;
return array_key_exists($item_id, $equip_table) ? $equip_table[$item_id] : null; return array_key_exists($item_id, $equip_table) ? $equip_table[$item_id] : null;
} }

View File

@ -91,6 +91,7 @@ class EquipController{
return; return;
} }
$equip_list = array(); $equip_list = array();
$time_flag = 0;
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id;', $row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id;',
array( array(
':account_id' => $account_id ':account_id' => $account_id
@ -108,9 +109,9 @@ class EquipController{
break; break;
} }
} }
$ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time) ' . $ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id) ' .
' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time) ' . ' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time;', ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id;',
array( array(
':account_id' => $account_id, ':account_id' => $account_id,
':id' => $id, ':id' => $id,
@ -118,41 +119,60 @@ class EquipController{
':create_time' => time(), ':create_time' => time(),
':modify_time' => time(), ':modify_time' => time(),
':sub_time' => 0, ':sub_time' => 0,
':using_id' => $id,
)); ));
if(!$ret){ if(!$ret){
die(); die();
return; return;
} }
$ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' .
' VALUES(:account_id, :id, 0, :status, 1, :active_time, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=1, active_time=:active_time, modify_time=:modify_time;',
array(
':account_id' => $account_id,
':id' => 18004,
':active_time' => 0,
':status' => 0,
':create_time' => time(),
':modify_time' => time()
));
array_push($equip_list, array( array_push($equip_list, array(
'id' => $id, 'id' => $id,
'lv' => 0, 'lv' => 0,
'active_time' => 0, 'active_time' => 0,
'using_id' => $id,
)); ));
} else { } else {
$time = $row['active_time'] + $row['sub_time']; $time = $row['active_time'] + $row['sub_time'];
if (time() >= $row['active_time'] + $row['sub_time']) { $using_id = $row['using_id'];
$ret1 = $conn->execScript('UPDATE equip SET active_time=0, sub_time=0, modify_time=:modify_time ' . if (time() >= $row['active_time'] + $row['sub_time'] && $row['sub_time'] != 0) {
$ret1 = $conn->execScript('UPDATE equip SET active_time=0, sub_time=0, using_id=:using_id, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
':modify_time' => time() ':modify_time' => time(),
':using_id' => $row['id'],
)); ));
if (!$ret1) { if (!$ret1) {
die(); die();
return; return;
} }
$time = 0; $time = 0;
$time_flag = 1;
$using_id = $row['id'];
} }
array_push($equip_list, array( array_push($equip_list, array(
'id' => $row['id'], 'id' => $row['id'],
'lv' => $row['lv'], 'lv' => $row['lv'],
'active_time' => $time, 'active_time' => $time,
'using_id' => $using_id,
)); ));
} }
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'equip_list' => $equip_list 'equip_list' => $equip_list,
'time_flag' => $time_flag,
)); ));
} }
@ -189,6 +209,7 @@ class EquipController{
return; return;
} }
$flag = 0; $flag = 0;
$id = $row['id'];
if ($row['lv'] < $e['max_level']) { if ($row['lv'] < $e['max_level']) {
//金币升级 //金币升级
$coin_array = $this->getExplode($e['level_gold_cost']); $coin_array = $this->getExplode($e['level_gold_cost']);
@ -222,7 +243,6 @@ class EquipController{
':account_id' => $account_id ':account_id' => $account_id
)); ));
$max_p = $e['upgrade_priority']; $max_p = $e['upgrade_priority'];
$id = 0;
$g_conf_lot_cluster = require('../res/equip@equip.php'); $g_conf_lot_cluster = require('../res/equip@equip.php');
for ($i = 0; $i < count($g_conf_lot_cluster); $i++) { for ($i = 0; $i < count($g_conf_lot_cluster); $i++) {
$ec = $this->getEquip(12100 + $i); $ec = $this->getEquip(12100 + $i);
@ -234,7 +254,7 @@ class EquipController{
break; break;
} }
} }
if ($id == 0) { if ($id == $row['id']) {
phpcommon\sendError(ERR_USER_BASE + 4, '装备已达满级'); phpcommon\sendError(ERR_USER_BASE + 4, '装备已达满级');
return; return;
} }
@ -276,18 +296,21 @@ class EquipController{
} }
$active_time = time(); $active_time = time();
$sub_time = $e['equip_upgradetime']; $sub_time = $e['equip_upgradetime'];
$using_id = $row['using_id'];
if ($e['equip_upgradetime'] == 0) { if ($e['equip_upgradetime'] == 0) {
$active_time = 0; $active_time = 0;
$flag = 1; $flag = 1;
$using_id = $id;
} }
$retEquip = $conn->execScript('UPDATE equip SET id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time ' . $retEquip = $conn->execScript('UPDATE equip SET id=:id, lv=0, active_time=:active_time, using_id=:using_id, sub_time=:sub_time, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
':id' => $id, ':id' => $id,
':modify_time' => time(), ':modify_time' => time(),
':active_time' => $active_time, ':active_time' => $active_time,
':sub_time' => $sub_time ':sub_time' => $sub_time,
':using_id' => $using_id,
)); ));
if (!$retEquip) { if (!$retEquip) {
die(); die();
@ -301,6 +324,7 @@ class EquipController{
'errmsg' => '', 'errmsg' => '',
'coin_nums' => $coin_num, 'coin_nums' => $coin_num,
'flag' => $flag, 'flag' => $flag,
'id' => $id,
)); ));
} }
@ -327,13 +351,28 @@ class EquipController{
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return; return;
} }
$e = $this->getEquip($row['id']); $e1 = $this->getEquip($row['id']);
$last_id = $e1['upgrade_priority'];
$id = 0;
$g_conf_lot_cluster = require('../res/equip@equip.php');
for ($i = 0; $i < count($g_conf_lot_cluster); $i++) {
$ec = $this->getEquip(12100 + $i);
if (!$ec || empty($ec['upgrade_priority'])) {
continue;
}
if ($ec['upgrade_priority'] == (int)$last_id - 1) {
$id = $ec['id'];
break;
}
}
$e = $this->getEquip($id);
if (!$e) { if (!$e) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备'); phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
return; return;
} }
$sub_time = $row['sub_time'] - $row['sub_time'] * $e['reduce_time'] * 0.01; $flag = 0;
//error_log($sub_time); //error_log($e['reduce_time']);
$sub_time = $row['sub_time'] - floor($row['sub_time'] * $e['reduce_time'] * 0.01);
if ($type == 1) { if ($type == 1) {
$rowUser = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:account_id;', $rowUser = $conn->execQueryOne('SELECT diamond_num FROM user WHERE accountid=:account_id;',
array( array(
@ -347,7 +386,7 @@ class EquipController{
phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足'); phpcommon\sendError(ERR_USER_BASE + 3, '钻石不足');
return; return;
} }
$sub_time = $row['sub_time'] - $row['sub_time'] * $e['diamond_time'] * 0.01; $sub_time = $row['sub_time'] - floor($row['sub_time'] * $e['diamond_time'] * 0.01);
$retUser = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' . $retUser = $conn->execScript('UPDATE user SET diamond_num=:diamond_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(
@ -361,16 +400,22 @@ class EquipController{
} }
} }
$active_time = $row['active_time']; $active_time = $row['active_time'];
if ($sub_time == 0) { $using_id = $row['using_id'];
if ($active_time + $sub_time <= time()) {
$active_time = 0; $active_time = 0;
} }
$retEquip = $conn->execScript('UPDATE equip SET active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time ' . if ($sub_time == 0) {
$flag = 1;
$using_id = $row['id'];
}
$retEquip = $conn->execScript('UPDATE equip SET active_time=:active_time, using_id=:using_id, sub_time=:sub_time, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
':active_time' => $active_time, ':active_time' => $active_time,
':sub_time' => $sub_time, ':sub_time' => $sub_time,
':modify_time' => time(), ':modify_time' => time(),
':using_id' => $using_id,
)); ));
if (!$retEquip) { if (!$retEquip) {
die(); die();
@ -382,8 +427,56 @@ class EquipController{
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
'diamond_nums' => $num, 'diamond_nums' => $num,
'active_time' => $active_time,
'flag' => $flag,
'id' => $row['id'],
)); ));
} }
public function exchangeEquip()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$equip_id = $_REQUEST['id'];
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT id, using_id FROM equip WHERE accountid=:account_id;',
array(
':account_id' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
return;
}
if ($equip_id > $row['id']) {
phpcommon\sendError(ERR_USER_BASE + 3, '武器未获得');
return;
}
$ret = $conn->execScript('UPDATE equip SET using_id=:using_id, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':using_id' => $equip_id,
':modify_time' => time(),
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'using_id' => $equip_id,
));
}
} }
?> ?>

View File

@ -109,11 +109,12 @@ class GameOverController{
die(); die();
return; return;
} }
$id = 12121; $id = 12120;
$conn = $this->getMysql($account_id); $conn = $this->getMysql($account_id);
if (!$conn) { if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
die(); die();
return;
} }
$row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:account_id;', $row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:account_id;',
array( array(
@ -122,10 +123,20 @@ class GameOverController{
if ($row) { if ($row) {
$id = $row['id']; $id = $row['id'];
} }
$e = $this->getEquip($id);
if (!$e) {
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具');
die();
return;
}
$count = 3;
if ($e['upgrade_priority'] == 1) {
$count = 1;
}
//道具物品 //道具物品
$first_list = array(); $first_list = array();
$first_list = $this->fixReward($first_list); $first_list = $this->fixReward($first_list);
$first_list = $this->randomReward($first_list, $id); $first_list = $this->randomReward($first_list, $id, $count);
$first_db = array( $first_db = array(
'first_uuid' => $first_uuid, 'first_uuid' => $first_uuid,
'first_list' => $first_list, 'first_list' => $first_list,
@ -221,19 +232,19 @@ class GameOverController{
return $item_list; return $item_list;
} }
protected function randomReward($item_list, $id) protected function randomReward($item_list, $id, $count)
{ {
//随机奖励 //随机奖励
//$e = $this->getEquip($id); $e = $this->getEquip($id);
//$d = $this->getDrop($e['drop_id']); $b = $this->getDrop($e['drop_id']);
$b = $this->getbox(6); //$b = $this->getbox(6);
$count = 3; //$count = 3;
$item_id_array = $this->getExplode($b['item_id']); $item_id_array = $this->getExplode($b['item_id']);
$item_num_array = $this->getExplode($b['num']); $item_num_array = $this->getExplode($b['num']);
$weight_array = $this->getExplode($b['weight']); $weight_array = $this->getExplode($b['weight']);
$time_array = $this->getExplode($b['time']); //$time_array = $this->getExplode($b['time']);
$reward_array = array(); $reward_array = array();
for ($c = 0; $c < $count; $c++) { for ($c = 0; $c < $count; $c++) {
$weight_sum = 0; $weight_sum = 0;
@ -263,7 +274,7 @@ class GameOverController{
} }
$item_id = $item_id_array[$keys][0]; $item_id = $item_id_array[$keys][0];
$item_num = $item_num_array[$keys][0]; $item_num = $item_num_array[$keys][0];
$time = $time_array[$keys][0]; $time = 0;
array_push($reward_array, array( array_push($reward_array, array(
'id' => $item_id 'id' => $item_id
)); ));

View File

@ -41,6 +41,7 @@ class PassController{
'end_time' => $season_meta['time2'], 'end_time' => $season_meta['time2'],
'reward' => $season_meta['season_reward'], 'reward' => $season_meta['season_reward'],
'weekreward' => $season_meta['week_reward'], 'weekreward' => $season_meta['week_reward'],
'season_overreward' => $season_meta['season_overreward'],
); );
return $season; return $season;
} }
@ -86,17 +87,6 @@ class PassController{
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) { if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
$open_time = strtotime($season['open_time']); $open_time = strtotime($season['open_time']);
$end_time = strtotime($season['end_time']); $end_time = strtotime($season['end_time']);
/*$ret = $conn->execScript('UPDATE user SET season_time=:season_time, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':season_time' => $end_time,
':modify_time' => time()
));
if (!$ret) {
die();
return;
}*/
$number = $i; $number = $i;
$item_multiply = $this->getExplode($season['reward']); $item_multiply = $this->getExplode($season['reward']);
//$ii = 0; //$ii = 0;
@ -444,7 +434,7 @@ class PassController{
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
)); ));
/* if (!$row) { if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return; return;
} }
@ -452,30 +442,69 @@ class PassController{
if ($row['season_status'] == 1) { if ($row['season_status'] == 1) {
phpcommon\sendError(ERR_USER_BASE + 2, '赛季未结束'); phpcommon\sendError(ERR_USER_BASE + 2, '赛季未结束');
return; return;
}*/ }
$reward = array(); $reward = array();
$level = 0; $level = 0;
//积分结算
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php'); $seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) { for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
$seaPoint = $this->getSeasonPoint($ii); $seaPoint = $this->getSeasonPoint($ii);
if ($row['season_end_score'] >= $seaPoint['min'] && $row['season_end_score'] <= $seaPoint['max'] if ($row['season_end_score'] >= $seaPoint['min'] && $row['season_end_score'] <= $seaPoint['max']
|| $row['season_end_score'] >= $seaPoint['min'] && $seaPoint['max'] == -1) || $row['season_end_score'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
{ {
$delim = ':';
$drop_multiply = explode($delim, $seaPoint['reward']);
array_push($reward, array(
'item_id' => $drop_multiply[0],
'item_num' => $drop_multiply[1],
'time' => $drop_multiply[2]
));
$level = $ii; $level = $ii;
break;
} }
} }
//奖励结算
$season_meta_table = require('../res/season@season.php');
$id = 0;
for ($i = 1; $i <= count($season_meta_table); $i++) {
$season = $this->getSeason($i);
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
$open_time = strtotime($season['open_time']);
$end_time = strtotime($season['end_time']);
$id = $i - 1;
break;
}
}
$s = $this->getSeason($id);
if ($s) {
$delim1 = '|';
$item_multiply = explode($delim1, $s['season_overreward']);
$delim2 = ';';
$mul = explode($delim2, $item_multiply[$level - 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($reward, array(
'item_id' => $week_array[$s][0],
'item_num' => $week_array[$s][1],
'time' => $week_array[$s][2],
));
}
}
$all_item_list = array();
$addreward = new classes\AddReward(); $addreward = new classes\AddReward();
foreach ($reward as $r) { foreach ($reward as $r) {
$addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time'], 0); $items = $addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time'], 0);
foreach($items as $j) {
array_push($all_item_list, array(
'item_id' => $j['item_id'],
'item_num' => $j['item_num'],
'time' => $j['time'],
));
}
} }
$ret = $conn->execScript('UPDATE user SET pass_status=1, modify_time=:modify_time ' . $ret = $conn->execScript('UPDATE user SET season_status=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', ' WHERE accountid=:accountid;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
@ -486,12 +515,15 @@ class PassController{
return; return;
} }
$diamond_num = $addreward->getDiamondNum($account_id); $diamond_num = $addreward->getDiamondNum($account_id);
$coin_num = $addreward->getCoinNum($account_id);
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg'=> '', 'errmsg'=> '',
'item_list' => $reward, 'item_list' => $reward,
'level' => $level, 'level' => $level,
'diamond_nums' => $diamond_num 'all_item_list' => $all_item_list,
'diamond_nums' => $diamond_num,
'coin_nums' => $coin_num
)); ));
} }
} }

View File

@ -86,6 +86,35 @@ class RoleController{
return $arr; return $arr;
} }
protected function getSeason($season_id)
{
$season_meta_table = require('../res/season@season.php');
$season_meta = getSeasonConfig($season_meta_table, $season_id);
$season = array(
'number' => $season_meta['season_number'],
'open_time' => $season_meta['time1'],
'end_time' => $season_meta['time2'],
'reward' => $season_meta['season_reward'],
'weekreward' => $season_meta['week_reward'],
);
return $season;
}
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'],
'topoint' => $seaPoint_meta['topoint'],
//'weekreward' => $seaPoint_meta['week_reward'],
);
return $seaPoint;
}
public function roleInfo() public function roleInfo()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
@ -117,9 +146,18 @@ class RoleController{
)); ));
//$newInfo = array(); //$newInfo = array();
if (!$row) { if (!$row) {
$season_time = 0;
$season_meta_table = require('../res/season@season.php');
for ($i = 1; $i <= count($season_meta_table); $i++) {
$season = $this->getSeason($i);
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
$season_time = strtotime($season['end_time']);
break;
}
}
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo) ' . $ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo) ' . ' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=0, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo;', ' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo;',
array( array(
':accountid' => $account_id, ':accountid' => $account_id,
':user_name' => $user_name, ':user_name' => $user_name,
@ -128,7 +166,8 @@ class RoleController{
':modify_time' => time(), ':modify_time' => time(),
':daily_time' => 0, ':daily_time' => 0,
':update_time' => time(), ':update_time' => time(),
':newInfo' => '' ':newInfo' => '',
':season_time' => $season_time
)); ));
if (!$ret) { if (!$ret) {
die(); die();
@ -145,7 +184,7 @@ class RoleController{
'harm' => 0, 'harm' => 0,
'add_HP' => 0, 'add_HP' => 0,
'alive_time' => 0, 'alive_time' => 0,
'coin_num' => 0, 'coin_num' => 200,
'first_fight' => 0, 'first_fight' => 0,
'collect_status' => 0, 'collect_status' => 0,
'keys_num' => 0, 'keys_num' => 0,
@ -174,15 +213,6 @@ class RoleController{
'newInfo' => '' 'newInfo' => ''
)); ));
} else { } else {
/*$ret = $conn->execScript('UPDATE user SET first_login=1 ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$ret) {
die();
return;
}*/
if ($avatar_url != '') { if ($avatar_url != '') {
if ($user_name != $row['user_name']) { if ($user_name != $row['user_name']) {
$ret = $conn->execScript('UPDATE user SET user_name=:user_name, modify_time=:modify_time ' . $ret = $conn->execScript('UPDATE user SET user_name=:user_name, modify_time=:modify_time ' .
@ -221,7 +251,14 @@ class RoleController{
$daily_first_login = 0; $daily_first_login = 0;
$kefu_status = 0; $kefu_status = 0;
$coin_times = 0; $coin_times = 0;
if (time() > $row['season_time'] && $row['season_time'] != 0) {
$this->updateSeasonStatus($account_id);
}
} }
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
echo json_encode(array( echo json_encode(array(
'errcode' => 0, 'errcode' => 0,
'errmsg' => '', 'errmsg' => '',
@ -266,6 +303,63 @@ class RoleController{
} }
} }
protected function updateSeasonStatus($account_id)
{
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
//刷新赛季奖励状态
$rowUser = $conn->execQueryOne('SELECT season_time, pass_status, integral ' .
' FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (time() > $rowUser['season_time'] && $rowUser['season_time'] != 0) {
$season_meta_table = require('../res/season@season.php');
$end_time = 0;
for ($i = 1; $i <= count($season_meta_table); $i++) {
$season = $this->getSeason($i);
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
$end_time = strtotime($season['end_time']);
break;
}
}
$season_point_table = require('../res/seasomPoint@seasomPoint.php');
$integral = 0;
for ($j = 1; $j <= count($season_point_table); $j++) {
$seasonpoint = $this->getSeasonPoint($j);
if ($rowUser['integral'] <= $seasonpoint['max'] ||
$seasonpoint['max'] == -1) {
$integral = $seasonpoint['topoint'];
break;
}
}
$user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, integral=:integral, season_end_score=:season_end_score, modify_time=:modify_time, season_games=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, season_win=0, season_time=:season_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':season_end_score' => $rowUser['integral'],
':modify_time' => time(),
':season_time' => $end_time,
':integral' => $integral
));
if (!$user_ret) {
die();
}
$pass_ret = $conn->execScript('UPDATE passinfo SET active_status=0, honor_status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => time()
));
if (!$pass_ret) {
die();
}
}
}
protected function updateDaily($account_id, $daily_time) protected function updateDaily($account_id, $daily_time)
{ {
$nowTime = phpcommon\getdayseconds(time()); $nowTime = phpcommon\getdayseconds(time());

View File

@ -172,7 +172,7 @@ class SignController{
if ($nowTime - phpcommon\getdayseconds($rowuser['update_time']) > 0) { if ($nowTime - phpcommon\getdayseconds($rowuser['update_time']) > 0) {
//每日刷新 //每日刷新
$this->updateDaily($account_id); $this->updateDaily($account_id);
$this->updateSeasonStatus($account_id); //$this->updateSeasonStatus($account_id);
if (phpcommon\getMondayseconds(time()) - phpcommon\getMondayseconds($rowuser['update_time']) > 0) { if (phpcommon\getMondayseconds(time()) - phpcommon\getMondayseconds($rowuser['update_time']) > 0) {
$this->updateWeekReward($account_id); $this->updateWeekReward($account_id);
} }
@ -490,61 +490,61 @@ class SignController{
die(); die();
} }
} }
protected function updateSeasonStatus($account_id) // protected function updateSeasonStatus($account_id)
{ // {
$conn = $this->getMysql($account_id); // $conn = $this->getMysql($account_id);
if (!$conn) { // if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家'); // phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die(); // die();
} // }
//刷新赛季奖励状态 // //刷新赛季奖励状态
$rowUser = $conn->execQueryOne('SELECT season_time, pass_status, integral ' . // $rowUser = $conn->execQueryOne('SELECT season_time, pass_status, integral ' .
' FROM user WHERE accountid=:accountid;', // ' FROM user WHERE accountid=:accountid;',
array( // array(
':accountid' => $account_id, // ':accountid' => $account_id,
)); // ));
if (time() > $rowUser['season_time'] && $rowUser['season_time'] != 0) { // if (time() > $rowUser['season_time']) {
$season_meta_table = require('../res/season@season.php'); // $season_meta_table = require('../res/season@season.php');
$end_time = 0; // $end_time = 0;
for ($i = 1; $i <= count($season_meta_table); $i++) { // for ($i = 1; $i <= count($season_meta_table); $i++) {
$season = $this->getSeason($i); // $season = $this->getSeason($i);
if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) { // if (time() >= strtotime($season['open_time']) && time() <= strtotime($season['end_time'])) {
$end_time = strtotime($season['end_time']); // $end_time = strtotime($season['end_time']);
break; // break;
} // }
} // }
$season_point_table = require('../res/seasomPoint@seasomPoint.php'); // $season_point_table = require('../res/seasomPoint@seasomPoint.php');
$integral = 0; // $integral = 0;
for ($j = 1; $j <= count($season_point_table); $j++) { // for ($j = 1; $j <= count($season_point_table); $j++) {
$seasonpoint = $this->getSeasonPoint($j); // $seasonpoint = $this->getSeasonPoint($j);
if ($rowUser['integral'] <= $seasonpoint['max']) { // if ($rowUser['integral'] <= $seasonpoint['max']) {
$integral = $seasonpoint['topoint']; // $integral = $seasonpoint['topoint'];
break; // break;
} // }
} // }
$user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, integral=:integral, season_end_score=:season_end_score, modify_time=:modify_time, season_games=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, season_win=0, season_time=:season_time ' . // $user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, integral=:integral, season_end_score=:season_end_score, modify_time=:modify_time, season_games=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, season_win=0, season_time=:season_time ' .
' WHERE accountid=:accountid;', // ' WHERE accountid=:accountid;',
array( // array(
':accountid' => $account_id, // ':accountid' => $account_id,
':season_end_score' => $rowUser['integral'], // ':season_end_score' => $rowUser['integral'],
':modify_time' => time(), // ':modify_time' => time(),
':season_time' => $end_time, // ':season_time' => $end_time,
':integral' => $integral // ':integral' => $integral
)); // ));
if (!$user_ret) { // if (!$user_ret) {
die(); // die();
} // }
$pass_ret = $conn->execScript('UPDATE passinfo SET active_status=0, honor_status=0, modify_time=:modify_time ' . // $pass_ret = $conn->execScript('UPDATE passinfo SET active_status=0, honor_status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid;', // ' WHERE accountid=:accountid;',
array( // array(
':accountid' => $account_id, // ':accountid' => $account_id,
':modify_time' => time() // ':modify_time' => time()
)); // ));
if (!$pass_ret) { // if (!$pass_ret) {
die(); // die();
} // }
} // }
} // }
protected function updateWeekReward($account_id) protected function updateWeekReward($account_id)
{ {