talent
This commit is contained in:
parent
d71b656ca2
commit
1920b2ec8d
@ -119,13 +119,14 @@ class SoloController
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
$talent = array(0, 0, 0);
|
||||||
$offlinehours = 0;
|
$offlinehours = 0;
|
||||||
if (!$solorow) {
|
if (!$solorow) {
|
||||||
$medals = $medalsgrowlimit;
|
$medals = $medalsgrowlimit;
|
||||||
$ret = $conn->execScript(
|
$ret = $conn->execScript(
|
||||||
'INSERT INTO solo(accountid, level, exp, medals, lastredeem, lastoffline, gamelevel, funds, create_time, modify_time) ' .
|
'INSERT INTO solo(accountid, level, exp, medals, lastredeem, lastoffline, gamelevel, funds, talent, create_time, modify_time) ' .
|
||||||
' VALUES(:account_id, 1, 0, :medals, :lastredeem, :lastoffline, :gamelevel, :funds, :create_time, :modify_time) ' .
|
' VALUES(:account_id, 1, 0, :medals, :lastredeem, :lastoffline, :gamelevel, :funds, :talent, :create_time, :modify_time) ' .
|
||||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, level=1, exp=0, medals=:medals, lastredeem=:lastredeem, lastoffline=:lastoffline, gamelevel=:gamelevel, funds=:funds, modify_time=:modify_time;',
|
' ON DUPLICATE KEY UPDATE accountid=:account_id, level=1, exp=0, medals=:medals, lastredeem=:lastredeem, lastoffline=:lastoffline, gamelevel=:gamelevel, funds=:funds, talent=:talent, modify_time=:modify_time;',
|
||||||
array(
|
array(
|
||||||
':account_id' => $account_id,
|
':account_id' => $account_id,
|
||||||
':medals' => $medals,
|
':medals' => $medals,
|
||||||
@ -133,6 +134,7 @@ class SoloController
|
|||||||
':lastoffline' => $nowtime,
|
':lastoffline' => $nowtime,
|
||||||
':gamelevel' => json_encode($gamelevel),
|
':gamelevel' => json_encode($gamelevel),
|
||||||
':funds' => json_encode($funds),
|
':funds' => json_encode($funds),
|
||||||
|
':talent' => json_encode($talent),
|
||||||
':create_time' => $nowtime,
|
':create_time' => $nowtime,
|
||||||
':modify_time' => $nowtime
|
':modify_time' => $nowtime
|
||||||
)
|
)
|
||||||
@ -193,6 +195,10 @@ class SoloController
|
|||||||
if (!is_null($solorow['funds']) && !empty($solorow['funds'])) {
|
if (!is_null($solorow['funds']) && !empty($solorow['funds'])) {
|
||||||
$funds = json_decode($solorow['funds']);
|
$funds = json_decode($solorow['funds']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_null($solorow['talent']) && !empty($solorow['talent'])) {
|
||||||
|
$talent = json_decode($solorow['talent'], true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$upexp = 0;
|
$upexp = 0;
|
||||||
@ -213,6 +219,11 @@ class SoloController
|
|||||||
'offlinehours' => $offlinehours,
|
'offlinehours' => $offlinehours,
|
||||||
'gamelevel' => $gamelevel,
|
'gamelevel' => $gamelevel,
|
||||||
'funds' => $funds,
|
'funds' => $funds,
|
||||||
|
'talent' => array(
|
||||||
|
'norm' => $talent[0],
|
||||||
|
'unlockadv' => $talent[1],
|
||||||
|
'adv' => $talent[2],
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,6 +819,180 @@ class SoloController
|
|||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function activeTalent()
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $_REQUEST['type'];
|
||||||
|
if ($type < 1 || $type > 2) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家 1');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$solorow = $conn->execQueryOne(
|
||||||
|
'SELECT talent FROM solo WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$solorow) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家 2');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$talent = array(0, 0, 0);
|
||||||
|
if (!is_null($solorow['talent']) && !empty($solorow['talent'])) {
|
||||||
|
$talent = json_decode($solorow['talent'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemnumstr = '';
|
||||||
|
if ($type == 1) {
|
||||||
|
//norm
|
||||||
|
$conf = require('../res/talent@talent.php');
|
||||||
|
$next = $talent[0] + 1;
|
||||||
|
if (!array_key_exists($next, $conf)) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '已最高天赋');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$talent[0] = $next;
|
||||||
|
$itemnumstr = $conf[$next]['item_num'];
|
||||||
|
if ($conf[$next]['sptalent_id'] != '' && $conf[$next]['sptalent_id'] > $talent[1]) {
|
||||||
|
$talent[1] = intval($conf[$next]['sptalent_id']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//adv
|
||||||
|
if ($talent[1] <= $talent[2]) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '无可激活');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$conf = require('../res/talent2@talent.php');
|
||||||
|
$found = false;
|
||||||
|
foreach ($conf as $key => $itemconf) {
|
||||||
|
if ($key > $talent[2] && $key <= $talent[1]) {
|
||||||
|
$itemnumstr = $itemconf['item_num'];
|
||||||
|
$talent[2] = $key;
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$found) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '无可激活 1');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemstrs = explode(';', $itemnumstr);
|
||||||
|
$costitem_list = array();
|
||||||
|
foreach ($itemstrs as $stritem) {
|
||||||
|
$strs = explode(':', $stritem);
|
||||||
|
if (count($strs) < 2) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '材料不足');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($strs[0] == 10001 || $strs[0] == 10003) {
|
||||||
|
$row = $conn->execQueryOne(
|
||||||
|
'SELECT coin_num, diamond_num FROM user WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $accountid
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (($strs[0] == 10001 && $strs[1] > $row['coin_num']) ||
|
||||||
|
($strs[0] == 10003 && $strs[1] > $row['diamond_num'])
|
||||||
|
) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '材料不足 1');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$row = $conn->execQueryOne(
|
||||||
|
'SELECT num FROM bag WHERE accountid=:accountid AND id=:id;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
'id' => $strs[0]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$row || $row['num'] < $strs[1]) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '材料不足 2');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$costitem_list[] = array(
|
||||||
|
'item_id' => $strs[0],
|
||||||
|
'item_num' => $strs[1],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($costitem_list as $costitem) {
|
||||||
|
if ($costitem['item_id'] == 10001) {
|
||||||
|
$conn->execScript(
|
||||||
|
'UPDATE user SET coin_num=coin_num-:subcoin, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':subcoin' => $costitem['item_num'],
|
||||||
|
':modify_time' => time()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if ($costitem['item_id'] == 10003) {
|
||||||
|
$conn->execScript(
|
||||||
|
'UPDATE user SET diamond_num=diamond_num-:subdiamond, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':subdiamond' => $costitem['item_num'],
|
||||||
|
':modify_time' => time()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$conn->execScript('UPDATE bag SET num=num-:subnum, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid AND id =:id;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':id' => $costitem['item_id'],
|
||||||
|
':subnum' => $costitem['item_num'],
|
||||||
|
':modify_time' => time()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->execScript(
|
||||||
|
'UPDATE solo SET talent=:talent, modify_time=:modify_time ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':talent' => json_encode($talent),
|
||||||
|
':modify_time' => time()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo json_encode(array(
|
||||||
|
'errcode' => 0,
|
||||||
|
'errmsg' => '',
|
||||||
|
'type' => $type,
|
||||||
|
'talent' => array(
|
||||||
|
'norm' => $talent[0],
|
||||||
|
'unlockadv' => $talent[1],
|
||||||
|
'adv' => $talent[2],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
protected function levelaward($isbattle)
|
protected function levelaward($isbattle)
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user