This commit is contained in:
wangwei01 2019-04-29 19:56:06 +08:00
parent f877f70e65
commit 377e2683d5
2 changed files with 76 additions and 51 deletions

View File

@ -55,7 +55,7 @@ CREATE TABLE `user` (
`harm_his` int(11) NOT NULL COMMENT '最高伤害',
`add_HP_his` int(11) NOT NULL COMMENT '最多治疗量',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`)
KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
--
@ -204,7 +204,7 @@ CREATE TABLE `history_record`(
`hurts` int(11) NOT NULL COMMENT '承受伤害',
`alive_time` int(11) NOT NULL COMMENT '游戏生存时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `accountid` (`accountid`)
KEY `accountid` (`accountid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

View File

@ -102,63 +102,88 @@ class RoleController{
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
if ($rank == 1) {
$win_times = 1;
} else {
$win_times = 0;
}
$ret = $conn->execScript('INSERT INTO user(accountid, game_times, win_times, kills, harm, add_HP, alive_time, kill_his, alive_time_his, harm_his, add_HP_his, coin_num, integral) ' .
' VALUES(:accountid, :game_times, :win_times, :kills, :harm, :add_HP, :alive_time, :kill_his, :alive_time_his, :harm_his, :add_HP_his, :coin_num, :integral);',
array(
':accountid' => $account_id,
':game_times' => 1,
':win_times' => $win_times,
':kills' => $kills,
':harm' => $harm,
':add_HP' => $add_HP,
':alive_time' => $alive_time,
':kill_his' => $kill_his,
':alive_time_his' => $alive_time_his,
':harm_his' => $harm_his,
':add_HP_his' => $add_HP_his,
':coin_num' => $coin_num,
':integral' => $integral
));
if (!$ret) {
die();
return;
}
} else {
if ($kills < $row['kill_his']) {
$high_kill = $row['kill_his'];
}
if ($harm < $row['harm_his']) {
$high_harm = $row['harm_his'];
}
if ($rank == 1) {
$row['win_times']++;
}
if ($alive_time_his < $row['alive_time_his']) {
$alive_time_his = $row['alive_time_his'];
}
if ($add_HP_his < $row['add_HP_his']) {
$add_HP_his = $row['add_HP_his'];
}
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, integral=:integral ' .
' WHERE accountid=:accountid;',
array(
':game_times' => $row['game_times']++,
':win_times' => $row['win_times'],
':kill_his' => $kill_his,
':kills' => $row['kills'] + $kills,
':harm_his' => $harm_his,
':harm' => $row['harm'] + $harm,
':add_HP' => $row['add_HP'] + $add_HP,
':alive_time' => $row['alive_time'] + $alive_time,
':alive_time_his' => $alive_time_his,
':add_HP_his' => $add_HP_his,
':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num,
':integral' => $row['integral'] + $integral
));
if (!$ret) {
die();
return;
}
}
if ($kills < $row['kill_his']) {
$high_kill = $row['kill_his'];
}
if ($harm < $row['harm_his']) {
$high_harm = $row['harm_his'];
}
if ($rank == 1) {
$row['win_times']++;
}
if ($alive_time_his < $row['alive_time_his']) {
$alive_time_his = $row['alive_time_his'];
}
if ($add_HP_his < $row['add_HP_his']) {
$add_HP_his = $row['add_HP_his'];
}
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, win_times=:win_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, integral=:integral ' .
' WHERE accountid=:accountid;',
//插入历史记录
$ret = $conn->execScript('INSERT INTO history_record(accountid, map_name, game_time, rank, kills, harms, hurts, alive_time) ' .
' VALUES(:accountid, :map_name, :game_time, :rank, :kills, :harms, :hurts, :alive_time);',
array(
':game_times' => $row['game_times']++,
':win_times' => $row['win_times'],
':kill_his' => $kill_his,
':kills' => $row['kills'] + $kills,
':harm_his' => $harm_his,
':harm' => $row['harm'] + $harm,
':add_HP' => $row['add_HP'] + $add_HP,
':alive_time' => $row['alive_time'] + $alive_time,
':alive_time_his' => $alive_time_his,
':add_HP_his' => $add_HP_his,
':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num,
':integral' => $row['integral'] + $integral
':map_name' => $map_name,
':game_time' => $game_time,
':rank' => $rank,
':kills' => $kills,
':harms' => $harm,
':hurts' => $hurt,
':alive_time' => $alive_time,
));
if (!$ret) {
die();
return;
}
$ret = $conn->execScript('INSERT INTO history_record(accountid, map_name, game_time, rank, kills, harm, hurt, alive_time, coin_num, integral) ' .
' VALUES(:accountid, :map_name, :game_time, :rank, :kills, :harm, :hurt, :alive_time, :coin_num, integral);',
array(
':accountid' => $account_id,
':game_time' => $game_time,
':rank' => $rank,
':kills' => $kills,
':harm' => $harm,
':hurt' => $hurt,
':alive_time' => $alive_time,
':coin_num' => $coin_num,
':integral' => $integral
));
if (!$ret) {
die();
return;
}
//刷新任务
$quest = new classes\Quest();
$quest->triggerQuest(QUEST_DAY_FIGHT, 1, 1, $account_id);