This commit is contained in:
wangwei01 2019-07-19 15:04:47 +08:00
parent 6ed554e74c
commit 5543b7074e

View File

@ -29,6 +29,8 @@ class TankController{
'max_lv' => $tank_meta['max_lv'],
'compose' => $tank_meta['compose'],
'debris' => $tank_meta['debris'],
'gold_cost_int' => $tank_meta['costgold_int'],
'gold_cost' => $tank_meta['costgold'],
);
return $t;
}
@ -424,7 +426,15 @@ class TankController{
':tank_id' => $tank_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '坦克不存在');
phpcommon\sendError(ERR_USER_BASE + 2, '坦克不存在');
return;
}
$rowCoin = $conn->execQueryOne('SELECT coin_num FROM user WHERE accountid=:account_id;',
array(
':account_id' => $account_id,
));
if (!$rowCoin) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个角色');
return;
}
$t = $this->getTank($tank_id);
@ -436,21 +446,38 @@ class TankController{
phpcommon\sendError(ERR_USER_BASE + 3, '坦克已到满级');
return;
}
$coin_num = $t['cost'] * ceil($row['tank_level'] / 5) + $t['cost_int'];
$fragment_num = $t['cost'] * ceil($row['tank_level'] / 5) + $t['cost_int'];
$coin_num = $c['gold_cost'] * ceil($row['tank_level'] / 5) + $c['gold_cost_int'];
if ($free == 1) {
$coin_num = 0;
$fragment_num = 0;
}
if ($coin_num > $row['fragment_num'] ){
if ($coin_num > $rowCoin['coin_num']) {
phpcommon\sendError(ERR_USER_BASE + 6, '金币不足');
return;
}
if ($fragment_num > $row['fragment_num'] ){
phpcommon\sendError(ERR_USER_BASE + 4, '坦克碎片数量不足');
return;
}
$retCoin = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time ' .
' WHERE accountid=:account_id;',
array(
':account_id' => $account_id,
':coin_num' => $rowCoin['coin_num'] - $coin_num,
':modify_time' => time()
));
if (!$retCoin) {
die();
return;
}
$ret = $conn->execScript('UPDATE tank SET tank_level=:tank_level, fragment_num=:fragment_num, modify_time=:modify_time ' .
' WHERE accountid=:account_id AND tank_id=:tank_id;',
array(
':account_id' => $account_id,
':tank_id' => $tank_id,
':tank_level' => $row['tank_level'] + 1,
':fragment_num' => $row['fragment_num'] - $coin_num,
':fragment_num' => $row['fragment_num'] - $fragment_num,
':modify_time' => time()
));
if (!$ret) {