Перенос и унификация функции снятия всех предметов в класс DressedItems.

This commit is contained in:
lopar 2021-03-11 20:58:38 +02:00
parent 3f22c6664a
commit c54b97681b
12 changed files with 24 additions and 25 deletions

View File

@ -25,7 +25,7 @@ if ($player) {
unset($row);
}
if ($undress_char) {
undressall($_SESSION['player_id']);
\Battles\DressedItems::undressAllItems($_SESSION['player_id']);
}
if ($end) {
unset($_SESSION['player_id']);

View File

@ -98,4 +98,8 @@ SQL;
self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]);
}
}
public static function undressAllItems($user_id)
{
return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id);
}
}

View File

@ -17,7 +17,7 @@ if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) {
while ($row = mysql_fetch_array($data)) {
$pers = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $row[0] . '" LIMIT 1'));
undressall($pers['id']);
\Battles\DressedItems::undressAllItems($pers['id']);
###
mysql_query('UPDATE `inventory` SET `owner` = "' . ($pers['id'] + _BOTSEPARATOR_) . '" WHERE `owner` = "' . $pers['id'] . '"');
###
@ -88,9 +88,9 @@ if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) {
}
// Боты: Архивариус и два помощника.
undressall(233);
undressall(234);
undressall(235);
\Battles\DressedItems::undressAllItems(233);
\Battles\DressedItems::undressAllItems(234);
\Battles\DressedItems::undressAllItems(235);
mysql_query("DELETE FROM `inventory` WHERE `owner` = 233");
mysql_query("DELETE FROM `inventory` WHERE `owner` = 234");
@ -158,7 +158,7 @@ if ($tur_data['endtime'] < time() && $tur_data['id']) {
$list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1");
while ($u = mysql_fetch_array($list)) {
undressall($u['id']);
\Battles\DressedItems::undressAllItems($u['id']);
$rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
while ($r = mysql_fetch_array($rep)) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')");

View File

@ -109,7 +109,7 @@ $var_map = [
function get_out($u)
{
$pers = db::c()->query('SELECT * FROM users WHERE id = ?i', $u)->fetch_assoc_array();
undressall($pers['id']);
\Battles\DressedItems::undressAllItems($pers['id']);
db::c()->query('UPDATE inventory SET owner = ?i WHERE owner = ?i', $pers['id'], $pers['id'] + _BOTSEPARATOR_);
###
$row = db::c()->query('SELECT * FROM `effects` WHERE `owner` = ?i', $pers['id'] + _BOTSEPARATOR_);
@ -449,11 +449,6 @@ function addActions($time, $vars, $vls, $uid)
return $ins;
}
function undressall($user_id)
{
db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $user_id);
}
#15
function ref_drop()
{

View File

@ -117,8 +117,8 @@ if ($user['battle'] > 0) {
mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('Архивариус','83','','" . $jert['hp'] . "');");
$jert['id'] = mysql_insert_id();
}
undressall($jert['id']);
undressall($user['id']);
\Battles\DressedItems::undressAllItems($jert['id']);
\Battles\DressedItems::undressAllItems($user['id']);
$teams = [];
$teams[$user['id']][$jert['id']] = [0, 0, time()];
$teams[$jert['id']][$user['id']] = [0, 0, time()];

View File

@ -104,8 +104,8 @@ elseif (!$us['online']) {
}
if(rand(0,100)<80)
undressall($jert['id']);
undressall($user['id']);
\Battles\DressedItems::undressAllItems($jert['id']);
\Battles\DressedItems::undressAllItems($user['id']);
$teams = array();
$teams[$user['id']][$jert['id']] = array(0,0,time());
$teams[$jert['id']][$user['id']] = array(0,0,time());

View File

@ -104,8 +104,8 @@ if ($user['battle'] > 0) {
}
if(rand(0,100)<80)
undressall($jert['id']);
undressall($user['id']);
\Battles\DressedItems::undressAllItems($jert['id']);
\Battles\DressedItems::undressAllItems($user['id']);
$teams = array();
$teams[$user['id']][$jert['id']] = array(0,0,time());
$teams[$jert['id']][$user['id']] = array(0,0,time());

View File

@ -3,7 +3,7 @@
if ($user['battle'] > 0) {
echo "Не в бою...";
} elseif (rand(1, 100) != 1) {
undressall($user['id']);
\Battles\DressedItems::undressAllItems($user['id']);
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
if (empty($_SESSION['uid'])) {
header("Location: index.php");

View File

@ -74,7 +74,7 @@ if ($edit) {
usemagic($use, $useTarget);
}
if ($undress) {
undressall($_SESSION['uid']);
\Battles\DressedItems::undressAllItems($_SESSION['uid']);
}
}

View File

@ -192,7 +192,7 @@ if ($rhar[$user->getRoom()][$_GET['path']] > 0 && $_GET['path'] < 5 && $_GET['pa
$list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1 AND `battle` = 0");
while ($u = mysql_fetch_array($list)) {
if ($u['hp'] <= 0) {
undressall($u['id']);
\Battles\DressedItems::undressAllItems($u['id']);
$rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1");
while ($r = mysql_fetch_array($rep)) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')");
@ -226,7 +226,7 @@ while ($u = mysql_fetch_array($list)) {
if (($kol_pl + $ls) < 2 && ($tur_data['start_time'] + 60) <= time()) {
$tur = mysql_fetch_array(mysql_query("SELECT * FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1"));
undressall($user['id']);
\Battles\DressedItems::undressAllItems($user['id']);
$rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $user['id'] . "' AND `bs` = 1");
while ($r = mysql_fetch_array($rep)) {
mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $user->getRoom() . "');");

View File

@ -8,7 +8,7 @@ if ($user->getRoom() != 31) {
if (isset($effect['id'])) {
exit('Для распределения статов на Вас не дожно быть никаких эффектов');
}
undressall($user['id']);
\Battles\DressedItems::undressAllItems($user['id']);
if ((int)$_GET['delsn'] > 0) {
mysql_query("DELETE FROM `deztow_charstams` WHERE `id` = '" . (int)$_GET['delsn'] . "' AND `name` = '" . $_GET['ddname'] . "' AND `owner` = '" . (int)$user['id'] . "' LIMIT 1");

View File

@ -421,11 +421,11 @@ class Zayavka
if ($z['type'] == 4 || $z['type'] == 5) {
foreach ($z['team1'] as $k => $v) {
undressall($v);
\Battles\DressedItems::undressAllItems($v);
}
foreach ($z['team2'] as $k => $v) {
undressall($v);
\Battles\DressedItems::undressAllItems($v);
}
}