This commit is contained in:
aozhiwei 2020-03-25 19:20:46 +08:00
parent 68e2f9d769
commit 1fa87e437b

View File

@ -31,6 +31,18 @@ class AddReward {
return $it;
}
protected function getBag($bag_id)
{
$g_conf_bag_cluster = require('../res/bag@bag.php');
$bag_conf = getBagConfig($g_conf_bag_cluster, $bag_id);
$b = array(
'id' => $bag_conf['id'],
'name' => $bag_conf['name'],
'fuction' => $bag_conf['fuction'],
);
return $b;
}
protected function getExplode($string)
{
$delim = "|";
@ -170,16 +182,17 @@ class AddReward {
}
$status = 2;
$active_time = $time * 3600 + time();
if ($time == 0) {
$active_time = 0;
$status = 1;
}
$row = $conn->execQueryOne('SELECT * FROM bag WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $accountid,
'id' => $item_id
));
if (!$row && $item_id != 0) {
if ($time == 0) {
$status = 1;
$active_time = 0;
}
$status = $this->getStatus($item_id, $status, $accountid);
$ret = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, active_time, create_time, modify_time) ' .
' VALUES(:account_id, :id, 0, :status, :active_time, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, active_time=:active_time, modify_time=:modify_time;',
@ -203,14 +216,18 @@ class AddReward {
$this->addDiamond($item_id, $item_num, $accountid);
} else {
$nowTime = $row['active_time'];
$status = $row['status'];
if ($time == 0) {
$nowTime = 0;
$status = 1;
if ($row['status'] == 2) {
$status = 1;
}
} else {
if ($row['active_time'] < time() + $time * 3600) {
$nowTime = time() + $time * 3600;
}
}
$status = $this->getStatus($item_id, $status,$accountid);
$ret = $conn->execScript('UPDATE bag SET active_time=:active_time, status=:status, modify_time=:modify_time ' .
' WHERE accountid=:account_id AND id=:id;',
array(
@ -232,5 +249,46 @@ class AddReward {
));
return $item_list;
}
public function getStatus($item_id, $status, $accountid)
{
$s = $status;
$b = $this->getBag($item_id);
$bag_meta_table = require('../res/bag@bag.php');
//正在装备的道具
$flag = 0;
$conn = $this->getMysql($accountid);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
if ($b['fuction'] != 5) {
foreach ($bag_meta_table as $bag_info) {
$id = $bag_info['id'];
$bag = $this->getBag($id);
if ($bag['fuction'] != $b['fuction']) {
continue;
}
$row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $accountid,
':id' => $id,
));
if ($row['status'] != 0 || !$row) {
continue;
}
$flag = 1;
break;
}
if ($flag == 1) {
$s = $status;
} else {
$s = 0;
}
} else {
$s = 0;
}
return $s;
}
}
?>