1
This commit is contained in:
parent
4ff5ebeb76
commit
b8e8982832
@ -36,6 +36,35 @@ class EquipController{
|
|||||||
return $e;
|
return $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function subCoin($account_id, $equip_id)
|
||||||
|
{
|
||||||
|
$e = $this->getEquip($equip_id);
|
||||||
|
if (!$e) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$conn = $this->getMysql($account_id);
|
||||||
|
if (!$conn) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$rowCoin = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id
|
||||||
|
));
|
||||||
|
if ($rowCoin['coin_num'] < $e['equip_cost']) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' .
|
||||||
|
' WHERE accountid=:accountid;',
|
||||||
|
array(
|
||||||
|
':accountid' => $account_id,
|
||||||
|
':coin_num' => $rowCoin['coin_num'] - $e['equip_cost']
|
||||||
|
));
|
||||||
|
return $e;
|
||||||
|
}
|
||||||
|
|
||||||
public function equipInfo()
|
public function equipInfo()
|
||||||
{
|
{
|
||||||
$account_id = $_REQUEST['account_id'];
|
$account_id = $_REQUEST['account_id'];
|
||||||
@ -105,36 +134,15 @@ class EquipController{
|
|||||||
$equip_id = $_REQUEST['equip_id'];
|
$equip_id = $_REQUEST['equip_id'];
|
||||||
$coin_num = $_REQUEST['coin_num'];
|
$coin_num = $_REQUEST['coin_num'];
|
||||||
$equip_level = $_REQUEST['equip_level'];
|
$equip_level = $_REQUEST['equip_level'];
|
||||||
if ($equip_level >= 10) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 4, '装备已到满级');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$e = $this->getEquip($equip_id * 10 + $equip_level);
|
|
||||||
if (!$e) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个装备');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id
|
|
||||||
));
|
|
||||||
if ($row['coin_num'] < $e['equip_cost']) {
|
|
||||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num ' .
|
|
||||||
' WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $account_id,
|
|
||||||
':coin_num' => $row['coin_num'] - $e['equip_cost']
|
|
||||||
));
|
|
||||||
|
|
||||||
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND equip_id=:equip_id;',
|
$row = $conn->execQueryOne('SELECT * FROM equip WHERE accountid=:account_id AND equip_id=:equip_id;',
|
||||||
array(
|
array(
|
||||||
':account_id' => $account_id,
|
':account_id' => $account_id,
|
||||||
':equip_id' => $equip_id
|
':equip_id' => $equip_id
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
|
$e = $this->subCoin($account_id, $equip_id * 10 + 1);
|
||||||
$ret = $conn->execScript('INSERT INTO equip(accountid, equip_id, equip_level, equip_experience_level, active_time) ' .
|
$ret = $conn->execScript('INSERT INTO equip(accountid, equip_id, equip_level, equip_experience_level, active_time) ' .
|
||||||
' VALUES(:accountid, :equip_id, :equip_level, :equip_experience_level, :active_time);',
|
' VALUES(:accountid, :equip_id, :equip_level, :equip_experience_level, :active_time);',
|
||||||
array(
|
array(
|
||||||
@ -149,6 +157,11 @@ class EquipController{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if ($row['equip_level'] >= 10) {
|
||||||
|
phpcommon\sendError(ERR_USER_BASE + 4, '装备已到满级');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$e = $this->subCoin($account_id, $equip_id * 10 + $row['equip_level']);
|
||||||
$ret = $conn->execScript('UPDATE equip SET equip_level=:equip_level ' .
|
$ret = $conn->execScript('UPDATE equip SET equip_level=:equip_level ' .
|
||||||
' WHERE accountid=:account_id AND equip_id=:equip_id;',
|
' WHERE accountid=:account_id AND equip_id=:equip_id;',
|
||||||
array(
|
array(
|
||||||
|
@ -278,10 +278,7 @@ class SupplyBoxController{
|
|||||||
array(
|
array(
|
||||||
':accountid' => $account_id
|
':accountid' => $account_id
|
||||||
));
|
));
|
||||||
var_dump($s['price']);
|
|
||||||
var_dump($s['parameter']);
|
|
||||||
var_dump($row['buy_times']);
|
|
||||||
var_dump($s['price'] * pow($s['parameter'], ($row['buy_times'])));
|
|
||||||
if ($row1['coin_num'] < $s['price'] * pow($s['parameter'], ($row['buy_times']))) {
|
if ($row1['coin_num'] < $s['price'] * pow($s['parameter'], ($row['buy_times']))) {
|
||||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user