1
This commit is contained in:
parent
9853cf7c39
commit
a8dcea4dba
@ -203,7 +203,8 @@ DROP TABLE IF EXISTS `history_record`;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `history_record`(
|
||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`accountid` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`room_uuid` VARCHAR(60) NOT NULL DEFAULT '' COMMENT '战斗id',
|
||||
`map_name` varchar(50) DEFAULT '' COMMENT '地图名字',
|
||||
`game_time` int(11) NOT NULL COMMENT '游戏完成时间',
|
||||
`rank` int(11) NOT NULL COMMENT '游戏排名',
|
||||
@ -211,6 +212,8 @@ CREATE TABLE `history_record`(
|
||||
`harms` int(11) NOT NULL COMMENT '游戏伤害',
|
||||
`hurts` int(11) NOT NULL COMMENT '承受伤害',
|
||||
`alive_time` int(11) NOT NULL COMMENT '游戏生存时间',
|
||||
`coin` bigint NOT NULL COMMENT '战斗结算金币',
|
||||
`status` int(11) NOT NULL COMMENT '结算金币领取状态',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
@ -63,6 +63,9 @@ define('GOLD', 101); //每5秒产出
|
||||
define('TIME_LIMIT', 102); //时间上限
|
||||
define('SKIN_TRIAL_TIME', 20); //皮肤试用时间
|
||||
define('SKIN_SKILL_TIME', 21); //皮肤满级体验时间
|
||||
define('DOUBLE_GOLD', 22); //免费金币翻倍率
|
||||
define('DOUBLE_SIGN_IN', 23); //每日签到翻倍率
|
||||
define('DOUBLE_END_WAR', 24); //战斗结束翻倍率
|
||||
|
||||
require 'config_loader.php';
|
||||
|
||||
|
@ -67,7 +67,8 @@ class HangController{
|
||||
$num = $p_time_limit['param_value'] / 5 * $p_num['param_value'];
|
||||
}
|
||||
if ($weight != 0) {
|
||||
$num = $num * 3;
|
||||
$p_gold = $this->getParameter(DOUBLE_GOLD);
|
||||
$num = $num * $p_gold['param_value'];
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
|
@ -49,6 +49,19 @@ class RoleController{
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
protected function getParameter($para_id)
|
||||
{
|
||||
$g_conf_para_cluster = require('../config/game2001api.parameter.cluster.php');
|
||||
$para_conf = getParameterConfig($g_conf_para_cluster, $para_id);
|
||||
$p = array(
|
||||
'id' => $para_conf['id'],
|
||||
'param_name' => $para_conf['param_name'],
|
||||
'param_value' => $para_conf['param_value'],
|
||||
);
|
||||
return $p;
|
||||
}
|
||||
|
||||
public function roleInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
@ -130,6 +143,7 @@ class RoleController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$room_uuid = $_REQUEST['room_uuid']; //战斗id
|
||||
$map_name = $_REQUEST['map_name']; //地图名
|
||||
$game_time = $_REQUEST['game_time']; //游戏结束时间
|
||||
$hurt = $_REQUEST['hurt']; //承受伤害
|
||||
@ -194,10 +208,11 @@ class RoleController{
|
||||
}
|
||||
}
|
||||
//插入历史记录
|
||||
$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);',
|
||||
$ret = $conn->execScript('INSERT INTO history_record(accountid, room_uuid, map_name, game_time, rank, kills, harms, hurts, alive_time, coin, status) ' .
|
||||
' VALUES(:accountid, :room_uuid, :map_name, :game_time, :rank, :kills, :harms, :hurts, :alive_time, :coin, 0);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':room_uuid' => $room_uuid,
|
||||
':map_name' => $map_name,
|
||||
':game_time' => $game_time,
|
||||
':rank' => $rank,
|
||||
@ -205,6 +220,7 @@ class RoleController{
|
||||
':harms' => $harm,
|
||||
':hurts' => $hurt,
|
||||
':alive_time' => $alive_time,
|
||||
':coin' => $coin_num
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
@ -272,7 +288,7 @@ class RoleController{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$record_list = array();
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_BASE_USER + 1, '没有这个玩家');
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$rowCount = $conn->execQueryRowCount('SELECT * FROM history_record WHERE accountid=:accountid;',
|
||||
@ -314,7 +330,7 @@ class RoleController{
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_BASE_USER + 1, '没有这个玩家');
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$quest = new classes\Quest();
|
||||
@ -333,7 +349,7 @@ class RoleController{
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_BASE_USER + 1, '没有这个玩家');
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
@ -353,6 +369,55 @@ class RoleController{
|
||||
'add_HP_his' => $row['add_HP_his']
|
||||
));
|
||||
}
|
||||
|
||||
public function fightReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$room_uuid = $_REQUEST['room_uuid'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
$record_list = array();
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT * FROM history_record WHERE accountid=:accountid AND room_uuid=:room_uuid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':room_uuid' => $room_uuid
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这场战斗记录');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($row['status'] == 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '战斗奖励已领取');
|
||||
return;
|
||||
}
|
||||
$coin_num = $row['coin'];
|
||||
$p_gold = $this->getParameter(DOUBLE_END_WAR);
|
||||
$coin_num = $row['coin'] * ($p_gold['param_value'] - 1);
|
||||
$rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $coin_num + $rowUser['coin_num']
|
||||
));
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,6 +60,18 @@ class SignController{
|
||||
return $arr;
|
||||
}
|
||||
|
||||
protected function getParameter($para_id)
|
||||
{
|
||||
$g_conf_para_cluster = require('../config/game2001api.parameter.cluster.php');
|
||||
$para_conf = getParameterConfig($g_conf_para_cluster, $para_id);
|
||||
$p = array(
|
||||
'id' => $para_conf['id'],
|
||||
'param_name' => $para_conf['param_name'],
|
||||
'param_value' => $para_conf['param_value'],
|
||||
);
|
||||
return $p;
|
||||
}
|
||||
|
||||
public function signInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
@ -105,25 +117,6 @@ class SignController{
|
||||
return;
|
||||
}
|
||||
$sign_days = 1;
|
||||
$signable = 0;
|
||||
//获得奖励
|
||||
$s = $this->getSign($sign_days + 90000);
|
||||
$g_conf_sign_cluster = require('../config/game2001api.signDaily.cluster.php');
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
$row2 = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $num + $row2['coin_num']
|
||||
));
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
||||
if (time() >= $start_time && time() < $end_time) {
|
||||
$quest->triggerQuest(QUEST_ACTIVITY_LOGIN, 3, 1, $account_id);
|
||||
}
|
||||
@ -131,34 +124,17 @@ class SignController{
|
||||
if ($nowTime - phpcommon\getdayseconds($row['sign_time']) > 0) {
|
||||
$sign_days = $row['sign_days'] + 1;
|
||||
$signable = 0;
|
||||
$ret = $conn->execScript('UPDATE sign SET sign_days=:sign_days, sign_time=:sign_time, signable=:signable ' .
|
||||
$ret = $conn->execScript('UPDATE sign SET sign_days=:sign_days, signable=:signable ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_days' => $sign_days,
|
||||
':sign_time' => time(),
|
||||
':signable' => $signable
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//获得奖励
|
||||
$g_conf_sign_cluster = require('../config/game2001api.signDaily.cluster.php');
|
||||
$s = $this->getSign($sign_days % count($g_conf_sign_cluster) + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
$row2 = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $num + $row2['coin_num']
|
||||
));
|
||||
|
||||
//刷新每日任务和活动任务
|
||||
$rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;',
|
||||
array(
|
||||
@ -207,21 +183,11 @@ class SignController{
|
||||
}
|
||||
} else {
|
||||
$sign_days = $row['sign_days'];
|
||||
$signable = 1;
|
||||
$ret = $conn->execScript('UPDATE sign SET signable=:signable ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':signable' => $signable
|
||||
));
|
||||
$signable = $row['signable'];
|
||||
if (time() >= $start_time && time() < $end_time) {
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_ACTIVITY_LOGIN, 3, 1, $account_id);
|
||||
}
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
@ -231,5 +197,89 @@ class SignController{
|
||||
'signable' => $signable
|
||||
));
|
||||
}
|
||||
|
||||
public function addReward($item_id, $item_num, $account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$rowSkin = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_id' => $item_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num ' .
|
||||
' WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_id' => $item_id,
|
||||
':fragment_num' => $item_num + $rowSkin['fragment_num']
|
||||
));
|
||||
}
|
||||
|
||||
public function signReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$double = $_REQUEST['double'];
|
||||
//登录校验
|
||||
$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;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT * FROM sign WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row || $row['signable'] == 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '今日已签到');
|
||||
return;
|
||||
}
|
||||
|
||||
$ret = $conn->execScript('UPDATE sign SET sign_time=:sign_time, signable=1 ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_time' => time(),
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//获得奖励
|
||||
$g_conf_sign_cluster = require('../config/game2001api.signDaily.cluster.php');
|
||||
$s = $this->getSign($row['sign_days'] % count($g_conf_sign_cluster) + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
$num = $s['num'];
|
||||
if ($double == 1) {
|
||||
$p_gold = $this->getParameter(DOUBLE_SIGN_IN);
|
||||
$num = $num * $p_gold['param_value'];
|
||||
}
|
||||
if ($item_id == 10001) {
|
||||
$row2 = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $num + $row2['coin_num']
|
||||
));
|
||||
} else if($item_id > 13000 && $item_id < 14000){
|
||||
$this->addReward($item_id, $num, $account_id);
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -152,9 +152,20 @@ class SupplyBoxController{
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id
|
||||
));
|
||||
if (!$row) {
|
||||
if (!$row && $free_open == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个宝箱');
|
||||
return;
|
||||
} else if (!$row && $free_open == 1) {
|
||||
$ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time) ' .
|
||||
' VALUES(:accountid, :box_id, 0, 0, 0);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($free_open == 0) {
|
||||
if ($row['box_num'] <= 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user