1
This commit is contained in:
parent
3b3c1cae09
commit
b6333464d5
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@
|
||||
*.*#
|
||||
~*.*
|
||||
\#*.*
|
||||
*.out
|
||||
*.tar
|
||||
*.tar.gz
|
||||
target
|
||||
|
@ -48,12 +48,14 @@ CREATE TABLE `user` (
|
||||
`harm` int(11) NOT NULL COMMENT '所有伤害',
|
||||
`add_HP` int(11) NOT NULL COMMENT '所有治疗量',
|
||||
`alive_time` int(11) NOT NULL COMMENT '所有生存时间',
|
||||
`coin_num` int(11) NOT NULL COMMENT '角色金币',
|
||||
`integral` int(11) NOT NULL COMMENT '角色积分',
|
||||
`coin_num` bigint NOT NULL COMMENT '角色金币',
|
||||
`integral` bigint NOT NULL COMMENT '角色积分',
|
||||
`kill_his` int(11) NOT NULL COMMENT '最高击杀',
|
||||
`alive_time_his` int(11) NOT NULL COMMENT '最长生存时间',
|
||||
`harm_his` int(11) NOT NULL COMMENT '最高伤害',
|
||||
`add_HP_his` int(11) NOT NULL COMMENT '最多治疗量',
|
||||
`act_share_status` int(11) NOT NULL COMMENT '分享好礼活动状态',
|
||||
`act_share_time` int(11) NOT NULL COMMENT '分享好礼活动时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
@ -73,6 +75,11 @@ CREATE TABLE `skin` (
|
||||
`fragment_id` int(11) NOT NULL COMMENT '碎片id',
|
||||
`fragment_num` int(11) NOT NULL COMMENT '碎片数量',
|
||||
`active_time` varchar(50) NOT NULL DEFAULT '有效时间',
|
||||
`fragment_status` int(11) NOT NULL COMMENT '碎片收集状态',
|
||||
`skin_type` int(11) NOT NULL COMMENT '皮肤类型',
|
||||
`skin_level` int(11) NOT NULL COMMENT '皮肤等级',
|
||||
`skin_experience_level` int(11) NOT NULL COMMENT '皮肤体验等级',
|
||||
`skin_experience_type` int(11) NOT NULL COMMENT '皮肤试用类型(0:没试用,1:皮肤体验,2:满级体验)',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
||||
Subproject commit 914355e0f3d6ca491b299489adf475f93d211389
|
||||
Subproject commit 5ea3bbc8db78d38dfc32b2dc1e4f35d368f1154c
|
@ -92,5 +92,28 @@ function getTaskRewardConfig($taskReward_table, $taskReward_id)
|
||||
$taskReward_id = (int)$taskReward_id;
|
||||
return array_key_exists($taskReward_id, $taskReward_table) ? $taskReward_table[$taskReward_id] : null;
|
||||
}
|
||||
|
||||
function getActivityConfig($activity_table, $activity_id)
|
||||
{
|
||||
$activity_id = (int)$activity_id;
|
||||
return array_key_exists($activity_id, $activity_table) ? $activity_table[$activity_id] : null;
|
||||
}
|
||||
|
||||
function getActivityRewardConfig($activityReward_table, $activityReward_id)
|
||||
{
|
||||
$activityReward_id = (int)$activityReward_id;
|
||||
return array_key_exists($activityReward_id, $activityReward_table) ? $activityReward_table[$activityReward_id] : null;
|
||||
}
|
||||
|
||||
function getParameterConfig($p_table, $p_id)
|
||||
{
|
||||
$p_id = (int)$p_id;
|
||||
return array_key_exists($p_id, $p_table) ? $p_table[$p_id] : null;
|
||||
}
|
||||
|
||||
function getDressUpgradeConfig($dressUp_table, $dressUp_id)
|
||||
{
|
||||
return array_key_exists($dressUp_id, $dressUp_table) ? $dressUp_table[$dressUp_id] : null;
|
||||
}
|
||||
checkMysqlConfig();
|
||||
checkRedisConfig();
|
||||
|
@ -36,6 +36,34 @@ define('QUEST_SUM_PISTOLKILL', 72014);
|
||||
define('QUEST_SUM_SUBMACKILL', 72015);
|
||||
define('QUEST_SUM_GAME', 72016);
|
||||
define('QUEST_SUM_HELP', 72017);
|
||||
//活动
|
||||
define('QUEST_ACTIVITY_LOGIN', 83001);
|
||||
define('QUEST_ACTIVITY_GAME', 83002);
|
||||
|
||||
//常量定义
|
||||
define('ANODYNE_MAX_TIME', 1); //止痛药最大时间(秒)
|
||||
define('DESCEND_CD_TIME', 2); //降落伞下降时间
|
||||
define('MAX_ENERGY_SHIERLD', 3); //能量护盾最大值
|
||||
define('DOWNED_RECOVER_HP', 4); //倒地回血
|
||||
define('DOWNED_RELIVE_RECOVER_HP', 5); //倒地救活后回血
|
||||
define('DOWNED_DEC_HP', 6); //倒地后每秒掉血
|
||||
define('DOWNED_RELIVE_TIME', 7); //复活队友时间
|
||||
define('GAS_INACTIVE_TIME', 8); //战前准备时间
|
||||
define('JAMP_TIME', 10); //跳伞降落时间
|
||||
define('K', 11); //伤害公式里的K值
|
||||
define('KILL_PARAMETER', 12); //击杀金币系数
|
||||
define('RANK_PARAMETER', 13); //排名参数
|
||||
define('RESCUE_TIME', 14); //救援时间
|
||||
define('AUTO_JUMP_INTERVAL', 15); //自动跳伞间隔
|
||||
define('AUTO_JUMP_MIN_NUM', 16); //最少自动跳人数
|
||||
define('AUTO_JUMP_MAX_NUM', 17); //最大自动跳人数
|
||||
define('FIGHTING_MODE', 18); //是否乱斗模式
|
||||
define('WEAPON_TRIAL', 19); //武器满级体验时间
|
||||
define('GOLD', 101); //每5秒产出
|
||||
define('TIME_LIMIT', 102); //时间上限
|
||||
define('SKIN_TRIAL_TIME', 20); //皮肤试用时间
|
||||
define('SKIN_SKILL_TIME', 21); //皮肤满级体验时间
|
||||
|
||||
require 'config_loader.php';
|
||||
|
||||
|
||||
|
@ -71,7 +71,9 @@ class Quest{
|
||||
if ($row['quest_num'] + $quest_num >= $q['value']) {
|
||||
$quest_num = $q['value'];
|
||||
$quest_state = 1;
|
||||
$this->triggerQuest(QUEST_DAY_COMPLETE, 1, 1, $account_id);
|
||||
if ($quest_type == 1) {
|
||||
$this->triggerQuest(QUEST_DAY_COMPLETE, 1, 1, $account_id);
|
||||
}
|
||||
} else {
|
||||
$quest_num = $row['quest_num'] + $quest_num;
|
||||
$quest_state = 0;
|
||||
@ -108,7 +110,9 @@ class Quest{
|
||||
if ($quest_num >= $q['value']) {
|
||||
$quest_num = $q['value'];
|
||||
$quest_state = 1;
|
||||
$this->triggerQuest(QUEST_DAY_COMPLETE, 1, 1, $account_id);
|
||||
if ($quest_type == 1) {
|
||||
$this->triggerQuest(QUEST_DAY_COMPLETE, 1, 1, $account_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret = $conn->execScript('INSERT INTO quest(accountid, quest_id, quest_num, quest_type, quest_state) ' .
|
||||
|
352
webapp/controller/ActivityController.class.php
Normal file
352
webapp/controller/ActivityController.class.php
Normal file
@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
require 'classes/Quest.php';
|
||||
|
||||
class ActivityController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'gamedb2001_' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
|
||||
protected function getActivityConfig($activity_id)
|
||||
{
|
||||
$g_conf_activity_cluster = require('../config/game2001api.activity.cluster.php');
|
||||
$activity_conf = getActivityConfig($g_conf_activity_cluster, $activity_id);
|
||||
$a = array(
|
||||
'id' => $activity_conf['id'],
|
||||
'name' => $activity_conf['name'],
|
||||
'des' => $activity_conf['des'],
|
||||
'start_date' => $activity_conf['start_date'],
|
||||
'end_date' => $activity_conf['end_date'],
|
||||
);
|
||||
return $a;
|
||||
}
|
||||
|
||||
protected function getActivityRewardConfig($activityReward_id)
|
||||
{
|
||||
$g_conf_activityReward_cluster = require('../config/game2001api.activityReward.cluster.php');
|
||||
$activityReward_conf = getActivityRewardConfig($g_conf_activityReward_cluster, $activityReward_id);
|
||||
$act = array(
|
||||
'id' => $activityReward_conf['id'],
|
||||
'activity_id' => $activityReward_conf['activity_id'],
|
||||
'condition' => $activityReward_conf['condition'],
|
||||
'parameter' => $activityReward_conf['parameter'],
|
||||
'start_end_time' => $activityReward_conf['start_end_time'],
|
||||
'activity_reward' => $activityReward_conf['activity_reward'],
|
||||
'exchange_num' => $activityReward_conf['exchange_num'],
|
||||
'exchange_item' => $activityReward_conf['exchange_item']
|
||||
);
|
||||
return $act;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function activityInfo()
|
||||
{
|
||||
$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);
|
||||
$activity_list = array();
|
||||
$activity_skin_list = array();
|
||||
$activity_quest_list = array();
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
//活动列表
|
||||
$g_conf_activity_cluster = require('../config/game2001api.activity.cluster.php');
|
||||
for ($i = 1; $i <= count($g_conf_activity_cluster); $i++) {
|
||||
$start_status = 0;
|
||||
$a = $this->getActivityConfig($i);
|
||||
if (time() >= $a['start_date'] && time() < $a['end_date']) {
|
||||
$start_status = 1;
|
||||
} else {
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num ' .
|
||||
' WHERE accountid=:accountid AND skin_type=2;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_num' => 0
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
array_push($activity_list, array(
|
||||
'activity_id' => $a['id'],
|
||||
'start_time' => $a['start_date'],
|
||||
'end_time' => $a['end_date'],
|
||||
'status' => $start_status
|
||||
));
|
||||
}
|
||||
//求生庆典活动
|
||||
$rowSkin = $conn->execQuery('SELECT * FROM skin WHERE accountid=:accountid AND skin_type=:skin_type;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':skin_type' => 2
|
||||
));
|
||||
foreach ($rowSkin as $skin) {
|
||||
array_push($activity_skin_list, array(
|
||||
'id' => $skin['skin_id'],
|
||||
'num' => $skin['fragment_num'],
|
||||
'exchange_status' => $skin['skin_status'],
|
||||
'collect_status' => $skin['fragment_status']
|
||||
));
|
||||
}
|
||||
//分享好礼活动
|
||||
$row = $conn->execQueryOne('SELECT act_share_status, act_share_time FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$receive_status = $row['act_share_status'];
|
||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['act_share_time']) > 0
|
||||
&& $row['act_share_status'] == 1)
|
||||
{
|
||||
$receive_status = 0;
|
||||
$ret = $conn->execScript('UPDATE user SET act_share_status=:act_share_status ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':act_share_status' => $receive_status
|
||||
));
|
||||
}
|
||||
//任务活动
|
||||
$rows = $conn->execQuery('SELECT * FROM quest WHERE accountid=:accountid AND quest_type=:quest_type;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_type' => 3
|
||||
));
|
||||
foreach ($rows as $r) {
|
||||
array_push($activity_quest_list, array(
|
||||
'id' => $r['quest_id'],
|
||||
'num' => $r['quest_num'],
|
||||
'status' => $r['quest_state']
|
||||
));
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'activity_list' => $activity_list,
|
||||
'activity_id1' => 1,
|
||||
'activity_skin_list' => $activity_skin_list,
|
||||
'activity_id2' => 2,
|
||||
'receive_status' => $receive_status,
|
||||
'activity_id3' => 3,
|
||||
'activity_quest_list' => $activity_quest_list
|
||||
));
|
||||
}
|
||||
|
||||
public function triggerActivity()
|
||||
{
|
||||
$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);
|
||||
$activity_id = $_REQUEST['activity_id'];
|
||||
$type = $_REQUEST['type'];
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
|
||||
$act = $this->getActivityRewardConfig($activity_id);
|
||||
$array = $this->getExplode($act['activity_reward']);
|
||||
switch ($type)
|
||||
{
|
||||
case 1: //活动皮肤碎片收集
|
||||
{
|
||||
$item_id = $array[0][0];
|
||||
$item_num = $array[0][1];
|
||||
$rowSkin = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_id' => $item_id
|
||||
));
|
||||
if ($rowSkin['fragment_status'] != 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '今天已收集');
|
||||
return;
|
||||
}
|
||||
if ($rowSkin['fragment_num'] + $item_num >= $act['exchange_num']) {
|
||||
$skin_status = 2;
|
||||
} else {
|
||||
$skin_status = 3;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, skin_status=:skin_status, fragment_status=1 ' .
|
||||
' WHERE accountid=:accountid AND fragment_id=:fragment_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':skin_status' => $skin_status,
|
||||
':fragment_id' => $item_id,
|
||||
':fragment_num' => $item_num + $rowSkin['fragment_num']
|
||||
));
|
||||
break;
|
||||
}
|
||||
case 2: //活动皮肤兑换
|
||||
{
|
||||
var_dump(time());
|
||||
$arr = $this->getExplode($act['exchange_item']);
|
||||
$row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $arr[0][0]
|
||||
));
|
||||
if(!$row){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个皮肤');
|
||||
return;
|
||||
}
|
||||
if ($row['skin_status'] == 2) {
|
||||
$fragment_num = $row['fragment_num'] - $act['exchange_num'];
|
||||
$time = time();
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num, skin_status=1, active_time=:active_time ' .
|
||||
' WHERE accountid=:account_id AND skin_id=:skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $arr[0][0],
|
||||
':active_time' => $time,
|
||||
':fragment_num' => $fragment_num,
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: //活动补给箱领取
|
||||
{
|
||||
$ret = $conn->execScript('UPDATE user SET act_share_status=1, act_share_time=:act_share_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':act_share_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
for ($i = 0; $i < count($array); $i++) {
|
||||
$item_id = $array[$i][0];
|
||||
$item_num = $array[$i][1];
|
||||
$row = $conn->execQueryOne('SELECT * FROM supplybox WHERE accountid=:account_id AND box_id=:box_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':box_id' => $item_id
|
||||
));
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time) ' .
|
||||
' VALUES(:accountid, :box_id, :box_num, 0, 0);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $item_id,
|
||||
':box_num' => 1,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num ' .
|
||||
' WHERE accountid=:accountid AND box_id=:box_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $item_id,
|
||||
':box_num' => $row['box_num'] + $item_num,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: //活动任务奖励
|
||||
{
|
||||
$row = $conn->execQueryOne('SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id AND quest_type=:quest_type;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_id' => $activity_id,
|
||||
':quest_type' => 3
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个任务');
|
||||
return;
|
||||
}
|
||||
if ($row['quest_state'] == 1) {
|
||||
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state ' .
|
||||
' WHERE accountid=:accountid AND quest_id =:quest_id AND quest_type=:quest_type;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_id' => $activity_id,
|
||||
':quest_type' => 3,
|
||||
':quest_state' => 2
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$item_id = $array[0][0];
|
||||
$item_num = $array[0][1];
|
||||
$row1 = $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' => $item_num + $row1['coin_num']
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
@ -34,25 +34,37 @@ class EquipController{
|
||||
return $e;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
protected function subCoin($account_id, $equip_id)
|
||||
{
|
||||
$e = $this->getEquip($equip_id);
|
||||
if (!$e) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
|
||||
return;
|
||||
die();
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
die();
|
||||
}
|
||||
$rowCoin = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if ($rowCoin['coin_num'] < $e['equip_cost']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
die();
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
@ -84,7 +96,7 @@ class EquipController{
|
||||
':account_id' => $account_id
|
||||
));
|
||||
foreach ($rows as $row) {
|
||||
if (time() - $row['active_time'] >= 7200 && $row['active_time'] != 0) {
|
||||
if (time() >= $row['active_time'] && $row['active_time'] != 0) {
|
||||
$ret = $conn->execScript('UPDATE equip SET active_time=0 ' .
|
||||
' WHERE accountid=:account_id AND equip_id=:equip_id;',
|
||||
array(
|
||||
@ -96,10 +108,11 @@ class EquipController{
|
||||
return;
|
||||
}
|
||||
$equip_level = $row['equip_level'];
|
||||
$active_time = 0;
|
||||
} else {
|
||||
if ($row['active_time'] != 0) {
|
||||
$active_time = 2;
|
||||
$equip_level = 9;
|
||||
$active_time = $row['active_time'];
|
||||
$equip_level = $row['equip_experience_level'];
|
||||
} else {
|
||||
$active_time = 0;
|
||||
$equip_level = $row['equip_level'];
|
||||
@ -147,7 +160,7 @@ class EquipController{
|
||||
':accountid' => $account_id,
|
||||
':equip_id' => $equip_id,
|
||||
':equip_level' => $e['equip_nextlevel'],
|
||||
':equip_experience_level' => 9,
|
||||
':equip_experience_level' => 0,
|
||||
':active_time' => 0,
|
||||
));
|
||||
if (!$ret) {
|
||||
@ -199,16 +212,14 @@ class EquipController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
|
||||
return;
|
||||
}
|
||||
/*if ($e['equip_experience'] == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '装备不可以体验');
|
||||
return;
|
||||
}*/
|
||||
$p = $this->getParameter(WEAPON_TRIAL);
|
||||
$time = $p['param_value'];
|
||||
$ret = $conn->execScript('UPDATE equip SET active_time=:active_time, equip_experience_level=8 ' .
|
||||
' WHERE accountid=:account_id AND equip_id=:equip_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':equip_id' => $equip_id,
|
||||
':active_time' => time()
|
||||
':active_time' => time() + $time
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
|
@ -15,9 +15,27 @@ class HangController{
|
||||
return $conn;
|
||||
}
|
||||
|
||||
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 getHangReward()
|
||||
{
|
||||
$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;
|
||||
@ -42,9 +60,11 @@ class HangController{
|
||||
return;
|
||||
}
|
||||
$item_id = 10001;
|
||||
$num = time() - $row['hang_time'];
|
||||
if ($num >= 4 * 3600) {
|
||||
$num = 4 * 3600;
|
||||
$p_num = $this->getParameter(GOLD);
|
||||
$p_time_limit = $this->getParameter(TIME_LIMIT);
|
||||
$num = time() - $row['hang_time'] / 5 * $p_num['param_value'];
|
||||
if ($num >= $p_time_limit['param_value']) {
|
||||
$num = $p_time_limit['param_value'] / 5 * $p_num['param_value'];
|
||||
}
|
||||
if ($weight != 0) {
|
||||
$num = $num * 3;
|
||||
@ -72,6 +92,12 @@ class HangController{
|
||||
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, '没有这个玩家');
|
||||
|
@ -160,7 +160,7 @@ class QuestController{
|
||||
));
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state ' .
|
||||
' WHERE accountid=:accountid AND quest_type=:quest_type AND quest_id<:quest_id;',
|
||||
' WHERE accountid=:accountid AND quest_type=:quest_type AND quest_id<:quest_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_type' => 0,
|
||||
@ -172,6 +172,12 @@ class QuestController{
|
||||
public function questInfo()
|
||||
{
|
||||
$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);
|
||||
$quest_list = array();
|
||||
$active_list = array();
|
||||
@ -270,6 +276,12 @@ class QuestController{
|
||||
public function submitQuest()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$quest_id = $_REQUEST['quest_id'];
|
||||
$quest_type = $_REQUEST['type'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
@ -29,6 +29,12 @@ class RankController{
|
||||
public function rankInfo()
|
||||
{
|
||||
$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, '没有这个玩家');
|
||||
@ -44,15 +50,33 @@ class RankController{
|
||||
$rate_rank = 0;
|
||||
$win_list = array();
|
||||
$win_rank = 0;
|
||||
$user_list = array();
|
||||
//个人信息
|
||||
$row = $conn->execQueryOne('SELECT user_name, avatar_url, kills, alive_time, harm, win_times, game_times FROM user ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if ($row) {
|
||||
array_push($user_list, array(
|
||||
'account_id' => $account_id,
|
||||
'name' => $row['user_name'],
|
||||
'avatar_url' => $row['avatar_url'],
|
||||
'kill' => phpcommon\safediv($row['kills'], $row['game_times']),
|
||||
'alive'=> phpcommon\safediv($row['alive_time'], $row['game_times']),
|
||||
'harm' => phpcommon\safediv($row['harm'], $row['game_times']),
|
||||
'win_rate' => phpcommon\safediv($row['win_times'], $row['game_times']),
|
||||
'win_game' => $row['win_times']
|
||||
));
|
||||
}
|
||||
|
||||
//击杀榜
|
||||
|
||||
$r = $this->getRedis();
|
||||
$kill_rank_db = $r->get("game2001api: kill_rank");
|
||||
$kill_db = json_decode($kill_rank_db);
|
||||
$i = 0;
|
||||
foreach ($kill_db as $kill) {
|
||||
if ($i > 99) {
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
if ($kill_db[$i][0] == $account_id) {
|
||||
@ -76,7 +100,7 @@ class RankController{
|
||||
$alive_db = json_decode($alive_rank_db);
|
||||
$i = 0;
|
||||
foreach ($alive_db as $alive) {
|
||||
if ($i > 99) {
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
if ($alive_db[$i][0] == $account_id) {
|
||||
@ -100,7 +124,7 @@ class RankController{
|
||||
$harm_db = json_decode($harm_rank_db);
|
||||
$i = 0;
|
||||
foreach ($harm_db as $harm) {
|
||||
if ($i > 99) {
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
if ($harm_db[$i][0] == $account_id) {
|
||||
@ -124,7 +148,7 @@ class RankController{
|
||||
$rate_db = json_decode($rate_rank_db);
|
||||
$i = 0;
|
||||
foreach ($rate_db as $rate) {
|
||||
if ($i > 99) {
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
if ($rate_db[$i][0] == $account_id) {
|
||||
@ -148,7 +172,7 @@ class RankController{
|
||||
$win_db = json_decode($win_rank_db);
|
||||
$i = 0;
|
||||
foreach ($win_db as $win) {
|
||||
if ($i > 99) {
|
||||
if ($i > 49) {
|
||||
break;
|
||||
}
|
||||
if ($win_db[$i][0] == $account_id) {
|
||||
@ -170,6 +194,7 @@ class RankController{
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => "",
|
||||
'user_list' => $user_list,
|
||||
'kill_rank' => $kill_rank,
|
||||
'kill_list' => $kill_list,
|
||||
'alive_rank' => $alive_rank,
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
require 'classes/Quest.php';
|
||||
|
||||
|
||||
class RoleController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
@ -17,11 +18,49 @@ class RoleController{
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getActivityRewardConfig($activityReward_id)
|
||||
{
|
||||
$g_conf_activityReward_cluster = require('../config/game2001api.activityReward.cluster.php');
|
||||
$activityReward_conf = getActivityRewardConfig($g_conf_activityReward_cluster, $activityReward_id);
|
||||
$act = array(
|
||||
'id' => $activityReward_conf['id'],
|
||||
'activity_id' => $activityReward_conf['activity_id'],
|
||||
'condition' => $activityReward_conf['condition'],
|
||||
'parameter' => $activityReward_conf['parameter'],
|
||||
'start_end_time' => $activityReward_conf['start_end_time'],
|
||||
'activity_reward' => $activityReward_conf['activity_reward'],
|
||||
'exchange_num' => $activityReward_conf['exchange_num'],
|
||||
'exchange_item' => $activityReward_conf['exchange_item']
|
||||
);
|
||||
return $act;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function roleInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$user_name = $_REQUEST['name'];
|
||||
$avatar_url = $_REQUEST['avatar_url'];
|
||||
$login = loginVerify($account_id, $_REQUEST['session_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, '没有这个玩家');
|
||||
@ -36,14 +75,13 @@ class RoleController{
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, rank, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 100000, 0, 0, 0, 0, 0);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
':avatar_url' => $avatar_url
|
||||
));
|
||||
var_dump($ret);
|
||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, rank, 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) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 0, 100000, 0, 0, 0, 0, 0, 0, 0);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
':avatar_url' => $avatar_url
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
@ -81,6 +119,17 @@ class RoleController{
|
||||
public function battleReport()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$map_name = $_REQUEST['map_name']; //地图名
|
||||
$game_time = $_REQUEST['game_time']; //游戏结束时间
|
||||
$hurt = $_REQUEST['hurt']; //承受伤害
|
||||
@ -95,50 +144,18 @@ class RoleController{
|
||||
$pistol_kill = $_REQUEST['pistol_kill']; //手枪击杀数
|
||||
$submachine_kill = $_REQUEST['submachine_kill'];//冲锋枪击杀数
|
||||
$rescue_member = $_REQUEST['rescue_member']; //救起队友次数
|
||||
$conn = $this->getMysql($account_id);
|
||||
$kill_his = $kills;
|
||||
$harm_his = $harm;
|
||||
$alive_time_his = $alive_time;
|
||||
$add_HP_his = $add_HP;
|
||||
$coin_num = $_REQUEST['coin_num']; //金币
|
||||
$integral = $_REQUEST['score']; //积分
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
|
||||
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
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 ($row) {
|
||||
if ($kill_his < $row['kill_his']) {
|
||||
$kill_his = $row['kill_his'];
|
||||
}
|
||||
@ -224,6 +241,15 @@ class RoleController{
|
||||
$quest->triggerQuest(QUEST_SUM_TEAMWIN, 2, 1, $account_id);
|
||||
}
|
||||
}
|
||||
//触发活动任务
|
||||
$act = $this->getActivityRewardConfig(QUEST_ACTIVITY_LOGIN);
|
||||
$array = $this->getExplode($act['start_end_time']);
|
||||
$nowTime = phpcommon\getdayseconds(time());
|
||||
$start_time = $array[0][0] * 3600 + $array[0][1] * 60 + $nowTime;
|
||||
$end_time = $array[1][0] * 3600 + $array[1][1] * 60 + $nowTime;
|
||||
if (time() >= $start_time && time() < $start_time) {
|
||||
$quest->triggerQuest(QUEST_ACTIVITY_GAME, 3, 1, $account_id);
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -237,6 +263,12 @@ class RoleController{
|
||||
public function historyRecord()
|
||||
{
|
||||
$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);
|
||||
$record_list = array();
|
||||
if (!$conn) {
|
||||
@ -274,6 +306,12 @@ class RoleController{
|
||||
public function shareGame()
|
||||
{
|
||||
$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_BASE_USER + 1, '没有这个玩家');
|
||||
@ -287,6 +325,12 @@ class RoleController{
|
||||
public function historyInfo()
|
||||
{
|
||||
$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_BASE_USER + 1, '没有这个玩家');
|
||||
|
@ -30,9 +30,45 @@ class SignController{
|
||||
return $s;
|
||||
}
|
||||
|
||||
protected function getActivityRewardConfig($activityReward_id)
|
||||
{
|
||||
$g_conf_activityReward_cluster = require('../config/game2001api.activityReward.cluster.php');
|
||||
$activityReward_conf = getActivityRewardConfig($g_conf_activityReward_cluster, $activityReward_id);
|
||||
$act = array(
|
||||
'id' => $activityReward_conf['id'],
|
||||
'activity_id' => $activityReward_conf['activity_id'],
|
||||
'condition' => $activityReward_conf['condition'],
|
||||
'parameter' => $activityReward_conf['parameter'],
|
||||
'start_end_time' => $activityReward_conf['start_end_time'],
|
||||
'activity_reward' => $activityReward_conf['activity_reward'],
|
||||
'exchange_num' => $activityReward_conf['exchange_num'],
|
||||
'exchange_item' => $activityReward_conf['exchange_item']
|
||||
);
|
||||
return $act;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function signInfo()
|
||||
{
|
||||
$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);
|
||||
$sign_days = 0;
|
||||
$signable = 0;
|
||||
@ -49,6 +85,12 @@ class SignController{
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
//触发活动任务
|
||||
$act = $this->getActivityRewardConfig(QUEST_ACTIVITY_LOGIN);
|
||||
$array = $this->getExplode($act['start_end_time']);
|
||||
$nowTime = phpcommon\getdayseconds(time());
|
||||
$start_time = $array[0][0] * 3600 + $array[0][1] * 60 + $nowTime;
|
||||
$end_time = $array[1][0] * 3600 + $array[1][1] * 60 + $nowTime;
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO sign(accountid, sign_days, signable, sign_time) ' .
|
||||
' VALUES(:accountid, :sign_days, :signable, :sign_time);',
|
||||
@ -66,6 +108,7 @@ class SignController{
|
||||
$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;',
|
||||
@ -81,8 +124,11 @@ class SignController{
|
||||
$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);
|
||||
}
|
||||
} else {
|
||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['sign_time']) > 0) {
|
||||
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 ' .
|
||||
@ -98,7 +144,8 @@ class SignController{
|
||||
return;
|
||||
}
|
||||
//获得奖励
|
||||
$s = $this->getSign($sign_days % 7 + 90000);
|
||||
$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;',
|
||||
@ -112,21 +159,22 @@ class SignController{
|
||||
':coin_num' => $num + $row2['coin_num']
|
||||
));
|
||||
|
||||
//刷新每日任务
|
||||
//刷新每日任务和活动任务
|
||||
$rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if ($rowCount != 0) {
|
||||
for ($i = 0; $i < $rowCount; $i++) {
|
||||
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state, quest_num=:quest_num ' .
|
||||
' WHERE accountid=:accountid AND quest_type=:quest_type;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_num' => 0,
|
||||
':quest_type' => 1,
|
||||
':quest_state' => 0
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE quest SET quest_state=:quest_state, quest_num=:quest_num ' .
|
||||
' WHERE accountid=:accountid AND quest_type=:quest_type1 OR quest_type=:quest_type2;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':quest_num' => 0,
|
||||
':quest_type1' => 1,
|
||||
':quest_type2' => 3,
|
||||
':quest_state' => 0
|
||||
));
|
||||
}
|
||||
if (!$ret) {
|
||||
die();
|
||||
@ -136,6 +184,27 @@ class SignController{
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
||||
//刷新活动皮肤碎片收集状态
|
||||
$rowSkinCount = $conn->execQueryRowCount('SELECT * FROM skin ' .
|
||||
' WHERE accountid=:accountid AND skin_type=:skin_type;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':skin_type' => 2
|
||||
));
|
||||
if ($rowSkinCount != 0) {
|
||||
for ($i = 0; $i < $rowSkinCount; $i++) {
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_status=:fragment_status ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_status' => 0
|
||||
));
|
||||
}
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sign_days = $row['sign_days'];
|
||||
$signable = 1;
|
||||
@ -145,6 +214,10 @@ class SignController{
|
||||
':accountid' => $account_id,
|
||||
':signable' => $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;
|
||||
|
@ -18,7 +18,6 @@ class SkinController{
|
||||
protected function getSkin($skin_id)
|
||||
{
|
||||
$g_conf_skin_cluster = require('../config/game2001api.dress.cluster.php');
|
||||
|
||||
$skin_conf = getSkinConfig($g_conf_skin_cluster, $skin_id);
|
||||
$s = array(
|
||||
'skin_id' => $skin_conf['id'],
|
||||
@ -26,92 +25,175 @@ class SkinController{
|
||||
'skin_skillid' => $skin_conf['skill_id'],
|
||||
'skin_compose' => $skin_conf['compose'],
|
||||
'skin_experience' => $skin_conf['is_experience'],
|
||||
'skin_price' => $skin_conf['price']
|
||||
'skin_price' => $skin_conf['price'],
|
||||
'skin_type' => $skin_conf['type'],
|
||||
'duration' => $skin_conf['duration']
|
||||
);
|
||||
return $s;
|
||||
}
|
||||
|
||||
protected function getDressUpgrade($skin_id)
|
||||
{
|
||||
$g_conf_skin_cluster = require('../config/game2001api.dressUpgrade.cluster.php');
|
||||
$skin_conf = getDressUpgradeConfig($g_conf_skin_cluster, $skin_id);
|
||||
$d = array(
|
||||
'id' => $skin_conf['id'],
|
||||
'name' => $skin_conf['name'],
|
||||
'level' => $skin_conf['level'],
|
||||
'next_level' => $skin_conf['next_level'],
|
||||
'debris_id' => $skin_conf['debris'],
|
||||
'debris_num' => $skin_conf['debris_number'],
|
||||
);
|
||||
return $d;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
protected function updateActiveTime($row, $conn)
|
||||
{
|
||||
$skin_status = 0;
|
||||
if ($row['skin_type'] == 1) {
|
||||
$skin_status = 2;
|
||||
} else if ($row['skin_type'] == 2) {
|
||||
$skin_status = 3;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET active_time=0, skin_experience_level=0, skin_experience_type=0 ' .
|
||||
' WHERE accountid=:account_id AND skin_id=:skin_id;',
|
||||
array(
|
||||
':account_id' => $row['accountid'],
|
||||
':skin_id' => $row['skin_id'],
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
if ($row['skin_status'] == 0 && $row['skin_experience_type'] == 1) {
|
||||
$ret = $conn->execScript('UPDATE skin SET skin_status=:skin_status ' .
|
||||
' WHERE accountid=:account_id AND skin_id=:skin_id;',
|
||||
array(
|
||||
':account_id' => $row['accountid'],
|
||||
':skin_id' => $row['skin_id'],
|
||||
':skin_status' => $skin_status
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET skin_status=0 ' .
|
||||
' WHERE accountid = :account_id AND skin_id = 14001;',
|
||||
array(
|
||||
':account_id' => $row['accountid'],
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public function skinInfo()
|
||||
{
|
||||
$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);
|
||||
$skin_list = array();
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$g_conf_skin_cluster = require('../config/game2001api.dress.cluster.php');
|
||||
$s = $this->getSkin(14001);
|
||||
if(!$s){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个皮肤');
|
||||
return;
|
||||
}
|
||||
$rowCount = $conn->execQueryRowCount('SELECT * FROM skin WHERE accountid = :account_id;',
|
||||
array(
|
||||
':account_id' => $account_id
|
||||
));
|
||||
if ($rowCount == 0) {
|
||||
for ($i = 14001; $i < 14010; $i++) {
|
||||
for ($i = 14001; $i <= count($g_conf_skin_cluster) + 14000; $i++) {
|
||||
$s = $this->getSkin($i);
|
||||
if(!$s){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个皮肤');
|
||||
return;
|
||||
}
|
||||
if ($i == 14001) {
|
||||
$skin_status = 0;
|
||||
} else if ($s['skin_type'] == 2){
|
||||
$skin_status = 3;
|
||||
} else {
|
||||
$skin_status = 2;
|
||||
}
|
||||
$ret = $conn->execScript('INSERT INTO skin(accountid, skin_id, skin_status, fragment_id, fragment_num, active_time) ' .
|
||||
' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, :fragment_num, :active_time);',
|
||||
$ret = $conn->execScript('INSERT INTO skin(accountid, skin_id, skin_status, fragment_id, fragment_num, active_time, fragment_status, skin_type, skin_level, skin_experience_level, skin_experience_type) ' .
|
||||
' VALUES(:account_id, :skin_id, :skin_status, :fragment_id, 0, 0, 0, :skin_type, 1, 0, 0);',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $i,
|
||||
':skin_status' => $skin_status,
|
||||
':fragment_id' => $i - 1000,
|
||||
':fragment_num' => 0,
|
||||
':active_time' => 0,
|
||||
':skin_type' => $s['skin_type'],
|
||||
));
|
||||
}
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
$time = 0;
|
||||
$skin_level = 0;
|
||||
$skin_experience_type = 0;
|
||||
$skin_status = 0;
|
||||
$rows = $conn->execQuery('SELECT * FROM skin WHERE accountid = :account_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
));
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if(time() - $row['active_time'] >= 7200 && $row['active_time'] != 0){
|
||||
if($row['skin_status'] == 0){
|
||||
$ret = $conn->execScript('UPDATE skin SET active_time=0, skin_status=:skin_status ' .
|
||||
' WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $row['skin_id'],
|
||||
':skin_status' => 2
|
||||
));
|
||||
$ret = $conn->execScript('UPDATE skin SET skin_status=0 ' .
|
||||
' WHERE accountid = :account_id AND skin_id = 14001;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
));
|
||||
}else{
|
||||
$ret = $conn->execScript('UPDATE skin SET active_time=0, skin_status=:skin_status ' .
|
||||
' WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $row['skin_id'],
|
||||
':skin_status' => 2
|
||||
));
|
||||
}
|
||||
if(!$ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if($row['active_time'] != 0){
|
||||
$time = 2;
|
||||
}else{
|
||||
$time = 0;
|
||||
$s = $this->getSkin($row['skin_id']);
|
||||
if(time() >= $row['active_time'] && $row['active_time'] != 0){
|
||||
$this->updateActiveTime($row, $conn);
|
||||
}
|
||||
}
|
||||
$rowsSkin = $conn->execQuery('SELECT * FROM skin WHERE accountid = :account_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
));
|
||||
foreach ($rowsSkin as $rowSkin) {
|
||||
array_push($skin_list, array(
|
||||
'skin_id' => $row['skin_id'],
|
||||
'skin_status' => $row['skin_status'],
|
||||
'fragment_num' => $row['fragment_num'],
|
||||
'active_time' => $time,
|
||||
'skin_id' => $rowSkin['skin_id'],
|
||||
'skin_status' => $rowSkin['skin_status'],
|
||||
'fragment_num' => $rowSkin['fragment_num'],
|
||||
'active_time' => $rowSkin['active_time'],
|
||||
'skin_level' => $rowSkin['skin_level'],
|
||||
'skin_experience_type' => $rowSkin['skin_experience_type']
|
||||
));
|
||||
}
|
||||
echo json_encode(array(
|
||||
@ -125,6 +207,12 @@ class SkinController{
|
||||
public function unlockSkin()
|
||||
{
|
||||
$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);
|
||||
$skin_id = $_REQUEST['skin_id'];
|
||||
$coin_num = $_REQUEST['coin_num'];
|
||||
@ -137,8 +225,7 @@ class SkinController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个皮肤1');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT accountid, skin_id, skin_status, fragment_num, active_time ' .
|
||||
' FROM skin WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
$row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $skin_id
|
||||
@ -147,16 +234,21 @@ class SkinController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个皮肤');
|
||||
return;
|
||||
}
|
||||
if ($row['skin_type'] != 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2,'皮肤无法解锁');
|
||||
return;
|
||||
}
|
||||
$fragment_num = 0;
|
||||
if($row['fragment_num'] >= $s['skin_compose']){
|
||||
$fragment_num = $row['fragment_num'] - $s['skin_compose'];
|
||||
}else{
|
||||
$coin = $s['skin_price'] * 1.0 / $s['skin_compose'] * ($s['skin_compose'] - $row['fragment_num']);
|
||||
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if ($row['coin_num'] < $coin) {
|
||||
$array = $this->getExplode($s['skin_compose']);
|
||||
if ($row['fragment_num'] >= $array[0][1]) {
|
||||
$fragment_num = $row['fragment_num'] - $array[0][1];
|
||||
} else {
|
||||
$coin = $s['skin_price'] * 1.0 / $array[0][1] * ($array[0][1] - $row['fragment_num']);
|
||||
$rowUser = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if ($rowUser['coin_num'] < $coin) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
}
|
||||
@ -164,19 +256,24 @@ class SkinController{
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':coin_num' => $row['coin_num'] - $coin
|
||||
':coin_num' => $rowUser['coin_num'] - $coin
|
||||
));
|
||||
|
||||
$fragment_num = 0;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num ,skin_status=1 ' .
|
||||
$skin_status = 1;
|
||||
if ($row['skin_status'] == 0) {
|
||||
$skin_status = 0;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET fragment_num=:fragment_num ,skin_status=:skin_status, active_time=0, skin_experience_type=0 ' .
|
||||
' WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $skin_id,
|
||||
':fragment_num' => $fragment_num
|
||||
));
|
||||
if(!$ret){
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $skin_id,
|
||||
':fragment_num' => $fragment_num,
|
||||
':skin_status' => $skin_status
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
@ -189,6 +286,12 @@ class SkinController{
|
||||
public function exchangeSkin()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$usingskin_id = $_REQUEST['usingskin_id'];
|
||||
$exchangeskin_id = $_REQUEST['exchangeskin_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
@ -196,25 +299,45 @@ class SkinController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$using_ret = $conn->execScript('UPDATE skin SET skin_status=1 ' .
|
||||
$skin_status = 0;
|
||||
$row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND skin_id=:skin_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':skin_id' => $usingskin_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个皮肤');
|
||||
return;
|
||||
}
|
||||
if ($row['skin_experience_type'] == 0 || $row['skin_experience_type'] == 2) {
|
||||
$skin_status = 1;
|
||||
} else if ($row['skin_experience_type'] == 1) {
|
||||
if ($row['skin_type'] == 1) {
|
||||
$skin_status = 2;
|
||||
} else if ($row['skin_type'] == 2) {
|
||||
$skin_status = 3;
|
||||
}
|
||||
}
|
||||
$using_ret = $conn->execScript('UPDATE skin SET skin_status=:skin_status ' .
|
||||
' WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $usingskin_id
|
||||
));
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $usingskin_id,
|
||||
':skin_status' => $skin_status
|
||||
));
|
||||
|
||||
if(!$using_ret){
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有皮肤');
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$exchange_ret = $conn->execScript('UPDATE skin SET skin_status=0 ' .
|
||||
' WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $exchangeskin_id
|
||||
));
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $exchangeskin_id
|
||||
));
|
||||
if(!$exchange_ret){
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有皮肤');
|
||||
die();
|
||||
return;
|
||||
}
|
||||
echo json_encode(array(
|
||||
@ -226,8 +349,23 @@ class SkinController{
|
||||
public function freetryskin()
|
||||
{
|
||||
$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);
|
||||
$skin_id = $_REQUEST['skin_id'];
|
||||
$row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:accountid AND skin_id=:skin_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':skin_id' => $skin_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个角色');
|
||||
return;
|
||||
}
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1,'没有这个角色');
|
||||
return;
|
||||
@ -241,12 +379,31 @@ class SkinController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 3,'皮肤不可以体验');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET active_time=:active_time, skin_status=1 ' .
|
||||
$time = 0;
|
||||
$ex_level = 0;
|
||||
$ex_type = 0;
|
||||
if ($s['skin_type'] == 2) {
|
||||
$time = $s['duration'];
|
||||
}
|
||||
if ($row['skin_status'] <= 1) {
|
||||
$ex_level = 9;
|
||||
$p = $this->getParameter(SKIN_SKILL_TIME);
|
||||
$time = $p['param_value'];
|
||||
$ex_type = 2;
|
||||
} else {
|
||||
$ex_level = 1;
|
||||
$p = $this->getParameter(SKIN_TRIAL_TIME);
|
||||
$time = $p['param_value'];
|
||||
$ex_type = 1;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET active_time=:active_time, skin_experience_level=:skin_experience_level, skin_experience_type=:skin_experience_type ' .
|
||||
' WHERE accountid = :account_id AND skin_id = :skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $skin_id,
|
||||
':active_time' => time()
|
||||
':active_time' => time() + $time,
|
||||
':skin_experience_level' => $ex_level,
|
||||
':skin_experience_type' => $ex_type
|
||||
));
|
||||
if(!$ret){
|
||||
die();
|
||||
@ -257,5 +414,61 @@ class SkinController{
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
|
||||
public function updateSkin()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
$skin_id = $_REQUEST['skin_id'];
|
||||
|
||||
$row = $conn->execQueryOne('SELECT * FROM skin WHERE accountid=:account_id AND skin_id=:skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $skin_id
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '皮肤不存在');
|
||||
return;
|
||||
}
|
||||
$d = $this->getDressUpgrade($skin_id . '-' . $row['skin_level']);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个皮肤');
|
||||
return;
|
||||
}
|
||||
if ($d['next_level'] == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '皮肤已到满级');
|
||||
return;
|
||||
}
|
||||
if ($d['debris_num'] > $row['fragment_num']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 4, '皮肤碎片数量不足');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE skin SET skin_level=:skin_level, fragment_num=:fragment_num ' .
|
||||
' WHERE accountid=:account_id AND skin_id=:skin_id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':skin_id' => $skin_id,
|
||||
':skin_level' => $d['next_level'],
|
||||
':fragment_num' => $row['fragment_num'] - $d['debris_num']
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -63,6 +63,12 @@ class SupplyBoxController{
|
||||
public function supplyBoxInfo()
|
||||
{
|
||||
$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);
|
||||
$box_list = array();
|
||||
if (!$conn) {
|
||||
@ -111,6 +117,12 @@ class SupplyBoxController{
|
||||
public function openSupplyBox()
|
||||
{
|
||||
$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, '没有这个玩家');
|
||||
@ -144,21 +156,23 @@ class SupplyBoxController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个宝箱');
|
||||
return;
|
||||
}
|
||||
if ($row['box_num'] <= 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '宝箱数量不足');
|
||||
return;
|
||||
}
|
||||
$box_num = $row['box_num'] - 1;
|
||||
$ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num ' .
|
||||
' WHERE accountid=:accountid AND box_id=:box_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id,
|
||||
':box_num' => $box_num
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
if ($free_open == 0) {
|
||||
if ($row['box_num'] <= 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '宝箱数量不足');
|
||||
return;
|
||||
}
|
||||
$box_num = $row['box_num'] - 1;
|
||||
$ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num ' .
|
||||
' WHERE accountid=:accountid AND box_id=:box_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id,
|
||||
':box_num' => $box_num
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//确定奖励倍数
|
||||
$sum = 0;
|
||||
@ -228,6 +242,12 @@ class SupplyBoxController{
|
||||
public function buySupplyBox()
|
||||
{
|
||||
$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, '没有这个玩家');
|
||||
@ -275,9 +295,9 @@ class SupplyBoxController{
|
||||
}
|
||||
} else {
|
||||
$row1 = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
|
||||
if ($row1['coin_num'] < $s['price'] * pow($s['parameter'], ($row['buy_times']))) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
@ -328,7 +348,7 @@ class SupplyBoxController{
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':fragment_id' => $item_id,
|
||||
':fragment_num' => $item_num + $rowSkin['fragment_num']
|
||||
':fragment_num' => 99 + $rowSkin['fragment_num']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,11 @@ function autoload_controller__($classname)
|
||||
}
|
||||
spl_autoload_register('autoload_controller__');
|
||||
|
||||
function loginVerify($accountid, $sessionid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
try{
|
||||
$c = $_REQUEST['c'];
|
||||
$a = $_REQUEST['a'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user