Великое объединение магазинов. #54.

This commit is contained in:
2023-07-29 00:18:04 +03:00
parent ad182a21fe
commit 9de7415f08
19 changed files with 1865 additions and 3125 deletions
+187
View File
@@ -0,0 +1,187 @@
<style>
.wares {
display: grid;
grid-template-columns: 100px auto;
background-color: #d4d4d4;
}
.wares > div:nth-child(odd of .left), .wares > div:nth-child(odd of .left) + div {
background-color: #c8c8c8;
}
table.zerowide {
width: 100%;
border-spacing: 0;
border-collapse: collapse;
}
table.zerowide td {
padding: 0;
}
</style>
<form id="F1" name="F1" method="post"></form>
<table class="zerowide">
<tr>
<td style="vertical-align: top;">
<h3><?= $shopName ?></h3>
<div style="text-align: center; font-weight: bold;"><span style="color: crimson;">&nbsp;<?= $status ?></span></div>
<table class="zerowide">
<tr>
<td style="text-align: left; vertical-align: top; padding: 4px;">
<!--Магазин-->
<div id="hint3" style="visibility:hidden"></div>
<table class="zerowide" style="background-color: darkgrey;">
<tr>
<td style="text-align: center; height: 21px;">
<?php if ($actionSale): ?>
<strong>Отдел «Скупка»</strong><br>
Здесь вы можете продать свои вещи, за жалкие гроши...<br>
У вас в наличии:
<?php elseif ($actionGifts): ?>
<strong>Отдел «Сделать подарки»</strong>
<?php elseif (isset($shop::OTDEL_NAME[$otdel])): ?>
<strong>Отдел «<?= $shop::OTDEL_NAME[$otdel] ?>»</strong>
<?php endif; ?>
</td>
</tr>
<tr>
<td>
<!--Рюкзак / Прилавок-->
<table class="zerowide" style="background-color: dimgrey;">
<?php if ($actionGifts): ?>
<tr>
<td style="background-color: #d5d5d5;">
Вы можете сделать подарок дорогому человеку. Ваш подарок будет отображаться в информации о персонаже.
<input name="itemgift" id="itemgift" type="hidden" value="0" form="F1">
<ol>
<li>
Укажите имя персонажа, которому хотите сделать подарок.
<label>Имя <input name="to_login" form="F1"></label>
</li>
<?php if ($u->info['exp'] >= Present::EXP_NEEDED_FOR_ADD_PRESENT_TEXT): ?>
<li>
Поздравление. Будет отображаться в информации о персонаже (не более 60 символов).
<label><input name="podarok2" size="50" maxlength="60" form="F1"></label>
</li>
<li>
Приватное поздравление (в информации о персонаже не отображается).
<label><textarea name="txt" cols="80" rows="6" form="F1"></textarea></label>
</li>
<?php endif; ?>
<li>
Выберите, от чьего имени подарок:<br>
<label style="font-weight: bold;"><input type="radio" name="from" value="0" checked form="F1"> <?= $u->info['login'] ?></label><br>
<label><input type="radio" name="from" value="1" form="F1">анонимно</label><br>
<?php if ($uc->isRegistered()): ?>
<label><input type="radio" name="from" value="2" form="F1">от имени клана <?= $uc->getName() ?></label>
<?php endif; ?>
</li>
<li>
Нажмите кнопку <strong>Подарить</strong> под предметом, который хотите преподнести в подарок:<br>
</li>
</ol>
</td>
</tr>
<?php if ($giftsvars): ?>
<?php foreach ($giftsvars as $k => $v): ?>
<tr>
<td style="text-align: center; background-color: lightgrey;">
<?php if ($k === 0): ?>
<h3>Уникальные подарки</h3>
<?php endif; ?>
<table class="zerowide">
<tr>
<td style="width: 160px; text-align: center; border-right: 1px solid #a5a5a5; padding: 5px;">
<img style="padding-bottom: 5px;" src="<?= $v['img'] ?>" alt=""><br>
<button onclick="document.getElementById('itemgift').value=<?= $v['jsvalue'] ?>;document.getElementById('F1').submit();">
Подарить за <?= $v['money'] ?> кр.
</button>
</td>
<td style="vertical-align: top; border-right: 1px solid #a5a5a5; padding: 5px;">
<a href="/item/0"><?= $v['linkname'] ?></a><br><small>Это именной подарок, его можете подарить только вы.</small>
</td>
</tr>
</table>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td style="text-align: center; background-color: lightgrey;"><h3>Стандартные подарки</h3></td>
</tr>
<?php endif; ?>
<?= $itmAllSee ?>
<?php elseif ($actionSale): ?>
<?= $itmAllSee ?>
<?php else: ?>
<div class="wares">
<?php $shop->printWares(); ?>
</div>
<?php endif; ?>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<td style="width: 280px; vertical-align: top;">
<div style="display: flex; align-items: flex-end; font-size: smaller; flex-direction: column; gap: 2px;">
<?= $goLis; ?>
<?php if ($shopId === $shop::MAIN): ?>
<button onclick="location.href='main.php?loc=1.180.0.9&rnd=<?= $code; ?>'">Центральная Площадь</button>
<button onclick="location.href='main.php?loc=1.180.0.368&rnd=<?= $code; ?>'">Подпольная лавка</button>
<button onclick="location.href='main.php?loc=1.180.0.13&rnd=<?= $code; ?>'">Магазин «Берёзка»</button>
<?php else: ?>
<button onclick="location.href='main.php?loc=1.180.0.10&rnd=<?= $code; ?>'">Государственный магазин</button>
<?php endif; ?>
</div>
<div>
<div style="display: grid; grid-template-columns: max-content max-content; font-size: smaller; justify-content: end; margin: 10px 0;">
<div style="text-align: right; margin-right: 5px;">Масса:</div>
<div style="font-weight: bold;"><?= $u->aves['now'] ?>/<?= $u->aves['max'] ?></div>
<div style="text-align: right; margin-right: 5px;">У вас в наличии:</div>
<div style="font-weight: bold; color: green"><?= $shop->getUserWallet() ?></div>
</div>
<div style="text-align: center;">
<?php if (!$actionSale): ?>
<INPUT class="btn" TYPE="button" value="Продать вещи" onclick="location='?otdel=<?= $otdel ?>&sale=1'">
<?php else: ?>
<INPUT class="btn" TYPE="button" value="Купить вещи" onclick="location='?otdel=<?= $otdel ?>'">
<?php endif; ?>
&nbsp;
<INPUT class="btn" TYPE="button" value="Обновить" onclick="location = '<?= str_replace('item', '', str_replace('buy', '', $_SERVER['REQUEST_URI'])); ?>';">
</div>
<BR>
</div>
<div style="background-color:#A5A5A5; padding:1px; text-align: center; font-weight: bold;">Отделы магазина</div>
<div style="line-height:17px;">
<?php
/*названия разделов (справа)*/
//$otdels = $shop->getUsedOtdels();
$otdels[37] = "<span style='color: red'>$otdels[37]</span>";
$otdels[100] = 'Сделать подарки';
//$i = 1;
foreach ($otdels as $k => $v) {
$color = $otdel === $k ? '#C7C7C7' : '#e2e0e0';
if (in_array($k, array_keys($shop::OTDEL_GROUP_NAME))) {
if ($i !== 1) {
echo '<br>';
}
echo sprintf('<div style="background-color: #d5d5d5;"><img src="/i/shop_ico/%s.png" alt="%s"> <strong>%s</strong></div>',
$i, $shop::OTDEL_GROUP_NAME[$k], $shop::OTDEL_GROUP_NAME[$k]);
$i++;
}
if ($k === 100) {
echo '<br><div style="background-color: #d5d5d5;"><b>Возможности:</b></div>';
$k = '32&gifts=1';
}
echo '<a href="?otdel=' . $k . '"><div style="background-color: ' . $color . '">&nbsp;&nbsp;' . $v . '</a></div>';
}
?>
</div>
</td>
</table>
<br>
<div id="textgo" style="visibility:hidden;"></div>
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace Core;
class View
{
public static function render(string $view, array $arguments = [])
{
extract($arguments, EXTR_SKIP);
$file = $_SERVER['DOCUMENT_ROOT'] . "/_incl_data/Views/$view";
if (is_readable($file)) {
require $file;
} else {
trigger_error("File $file not found!", E_USER_ERROR);
}
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace DTO;
class Present
{
/** Логин отправителя
* @var string
*/
public string $sender;
/** Логин получателя
* @var string
*/
public string $receiver;
/** id подарка
* @var int
*/
public int $itemId;
/** Заголовок поздравления.
* Обычно отображается в инфе персонажа в тултипе.
* @var string
*/
public string $textTitle = '';
/** Текст поздравления
* Отображается только получателю подарка в инвентаре.
* @var string
*/
public string $text = '';
/** Флаг анонимности. Если true, в поле "отправитель" будет "невидимка".
* @var bool
*/
public bool $anonymousSender = false;
/** Флаг кланового подарка. Если true, в поле "отправитель" будет имя клана в котором состоит игрок.
* @var bool
*/
public bool $clanSender = false;
}
+26
View File
@@ -0,0 +1,26 @@
<?php
use Core\Db;
use User\UserIp;
class Delo
{
/**
* Запись в личное дело персонажа.
* @param int $uid
* @param string $dop
* @param string $text
* @param string $from
* @param float $moneyOut
* @param int $type
* @return void
*/
public static function add(int $type, string $from, int $uid, string $text, float $moneyOut = 0, string $dop = '')
{
$sql = 'insert into users_delo (uid, dop, time, city, text, login, `delete`, no_right, ip, moneyOut, type) values (?,?,unix_timestamp(),?,?,?,0,?,?,?,?)';
Db::sql($sql, [
$uid, $dop, 'capitalcity', $text, $from, '', UserIp::get(), $moneyOut, $type,
]);
}
}
+122
View File
@@ -0,0 +1,122 @@
<?php
namespace Item\Data;
class Bonuses
{
private static array $names = [
'hpAll' => 'Уровень жизни (HP)',
'mpAll' => 'Уровень маны',
's1' => 'Сила',
's2' => 'Ловкость',
's3' => 'Интуиция',
's4' => 'Выносливость',
's5' => 'Интелект',
's6' => 'Мудрость',
'm1' => 'Мф. критического удара (%)',
'm2' => 'Мф. против критического удара (%)',
'm3' => 'Мф. мощности критического удара (%)',
'm4' => 'Мф. увертывания (%)',
'm5' => 'Мф. против увертывания (%)',
'm6' => 'Мф. контрудара (%)',
'm7' => 'Мф. парирования (%)',
'm8' => 'Мф. блока щитом (%)',
'm9' => 'Мф. пробоя брони (%)',
'm10' => 'Мф. мощности урона',
'm11' => 'Мф. мощности магии стихий',
'm14' => 'Мф. абс. критического удара (%)',
'm15' => 'Мф. абс. увертывания (%)',
'm18' => 'Мф. абс. блока щитом (%)',
'a1' => 'Мастерство владения ножами, кинжалами',
'a2' => 'Мастерство владения топорами, секирами',
'a3' => 'Мастерство владения дубинами, молотами',
'a4' => 'Мастерство владения мечами',
'a5' => 'Мастерство владения магическими посохами',
'aall' => 'Мастерство владения оружием',
'mall' => 'Мастерство владения магией стихий',
'mg1' => 'Мастерство владения магией огня',
'mg2' => 'Мастерство владения магией воздуха',
'mg3' => 'Мастерство владения магией воды',
'mg4' => 'Мастерство владения магией земли',
'mg7' => 'Мастерство владения серой магией',
'pa1' => 'Мф. мощности колющего урона',
'pa2' => 'Мф. мощности рубящего урона',
'pa3' => 'Мф. мощности дробящий урона',
'pa4' => 'Мф. мощности режущий урона',
'pm1' => 'Мф. мощности магии огня',
'pm2' => 'Мф. мощности магии воздуха',
'pm3' => 'Мф. мощности магии воды',
'pm4' => 'Мф. мощности магии земли',
'za' => 'Защита от урона',
'zm' => 'Защита от магии стихий',
'speedhp' => 'Регенерация здоровья (НР)',
'speedmp' => 'Регенерация маны (МР)',
'zona' => 'Дополнительная зона атаки',
'zonb' => 'Дополнительная зона блока',
'speed_dungeon' => 'Скорость перемещения по пещерам',
'antm3' => 'Мф. против мощности крит. удара',
'spasenie' => 'Спасение после смерти',
'exp' => 'Получаемый опыт (%)',
'repair_z' => 'Бесплатное извлечение заточек',
'repair_r' => 'Бесплатное извлечение рун',
'repair_discount' => 'Скидка на ремонт вещей',
'gold' => 'Благодать Ангела',
'magic_cast' => 'Дополнительное заклинание за ход',
];
private array $result = [];
public function __construct(array $data)
{
foreach ($data as $bonusName => $value) {
if (!self::$names[$bonusName]) {
continue;
}
$this->result[self::$names[$bonusName]] = $value;
}
$this->armor($data);
}
private function armor(array $data): void
{
$min = 0;
$max = 0;
$type = [
1 => 'головы',
2 => 'корпуса',
3 => 'пояса',
4 => 'ног',
];
foreach ($type as $k => $v) {
if (!empty($data['mib' . $k])) {
$min = $data['mib' . $k];
$max = $data['mib' . $k];
}
if (!empty($data['mab' . $k])) {
if (empty($data['mib' . $k])) {
$min = $data['mab' . $k];
}
$max = $data['mab' . $k];
}
if (empty($min) && empty($max)) {
return;
}
$this->result['Броня ' . $v] = $min . ' - ' . $max;
}
}
public function get(): array
{
return $this->result;
}
public function addZonb()
{
if (isset($this->result[self::$names['zonb']])) {
$this->result[self::$names['zonb']]++;
} else {
$this->result[self::$names['zonb']] = 1;
}
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace Item\Data;
class Properties
{
private static array $names = [
'damage' => 'Урон',
];
private array $result = [];
public function __construct(array $data)
{
$this->damage($data);
}
private function damage(array $data): void
{
$min = 0;
$max = 0;
if (!empty($data['yron_min'])) {
$min = $data['yron_min'];
$max = $data['yron_min'];
}
if (!empty($data['yron_max'])) {
if (empty($data['yron_min'])) {
$min = $data['yron_max'];
}
$max = $data['yron_max'];
}
if (empty($min) && empty($max)) {
return;
}
$this->result[self::$names['damage']] = $min . ' - ' . $max;
}
public function get(): array
{
return $this->result;
}
}
@@ -0,0 +1,84 @@
<?php
namespace Item\Data;
class Requirements
{
private static array $names = [
'sex' => 'Пол',
'lvl' => 'Уровень',
's1' => 'Сила',
's2' => 'Ловкость',
's3' => 'Интуиция',
's4' => 'Выносливость',
's5' => 'Интелект',
's6' => 'Мудрость',
'a1' => 'Мастерство владения ножами, кинжалами',
'a2' => 'Мастерство владения топорами, секирами',
'a3' => 'Мастерство владения дубинами, молотами',
'a4' => 'Мастерство владения мечами',
'a5' => 'Мастерство владения магическими посохами',
'mg1' => 'Мастерство владения магией огня',
'mg2' => 'Мастерство владения магией воздуха',
'mg3' => 'Мастерство владения магией воды',
'mg4' => 'Мастерство владения магией земли',
'mg7' => 'Мастерство владения серой магией',
'align' => 'Склонность',
];
private static array $sex = [
0 => 'Мужской',
1 => 'Женский',
];
private static array $align = [
1 => 'Свет',
2 => 'Хаос',
3 => 'Тьма',
7 => 'Нейстралитет',
9 => 'Дитя подземелья',
];
private int $alignValue = 0;
private array $result = [];
public function __construct(array $data)
{
foreach ($data as $requirementName => $value) {
if (!self::$names[$requirementName]) {
continue;
}
if ($requirementName === 'sex') {
if (self::$sex[$value]) {
$value = self::$sex[$value];
} else {
continue;
}
}
if ($requirementName === 'align') {
if (self::$align[$value]) {
$this->alignValue = $value;
$value = self::$align[$value];
} else {
continue;
}
}
$this->result[$requirementName] = [
'name' => self::$names[$requirementName],
'value' => $value,
];
}
}
public function get(): array
{
return $this->result;
}
/** Число для отрисовки иконки.
* @return int
*/
public function getAlign(): int
{
return $this->alignValue;
}
}
+56
View File
@@ -0,0 +1,56 @@
<?php
namespace Item;
use Core\ConversionHelper;
use Core\Db;
class DataModel
{
private array $data = [];
public function __construct(int $itemId)
{
$datastring = Db::getValue('select data from items_main_data where items_id = ?', [$itemId]);
if (empty($datastring)) {
return;
}
$this->data = ConversionHelper::dataStringToArray($datastring);
}
public function getAll(): array
{
return $this->data;
}
public function getRequirements(): array
{
return $this->getPrefixed('tr_');
}
private function getPrefixed(string $prefix): array
{
$result = [];
foreach ($this->data as $k => $v) {
if ($this->searchByPrefix($prefix, $k)) {
$result[str_replace($prefix, '', $k)] = $v;
}
}
return $result;
}
private function searchByPrefix(string $prefix, string $string): bool
{
return substr($string, 0, strlen($prefix)) === $prefix;
}
public function getBonuses(): array
{
return $this->getPrefixed('add_');
}
public function getProperties(): array
{
return $this->getPrefixed('sv_');
}
}
File diff suppressed because it is too large Load Diff
+90
View File
@@ -0,0 +1,90 @@
<?php
use Core\Db;
use User\Clan;
class Present
{
const EXP_NEEDED_FOR_ADD_PRESENT_TEXT = 500000;
private array $sender;
private array $receiver;
private string $status;
private \DTO\Present $present;
private Clan $senderClan;
/**
* @param \DTO\Present $present
*/
public function __construct(\DTO\Present $present)
{
$check = Db::getValue('select count(id) from users where login in (?,?)', [$present->sender, $present->receiver]);
if ($check === 1) {
$this->status = 'Очень щедро дарить что-то самому себе 😉';
return;
}
if ($check === 0) {
$this->status = 'Ошибка: В городе нет такого персонажа!';
return;
}
$this->sender = User::getInfo($present->sender);
$this->receiver = User::getInfo($present->receiver);
$this->senderClan = new Clan($this->sender);
if ($present->anonymousSender) {
$this->sender['login'] = 'невидимки';
} elseif ($present->clanSender) {
$this->sender['login'] = 'клана ' . $this->senderClan->getName();
}
$this->present = $present;
if ($this->sender['exp'] < self::EXP_NEEDED_FOR_ADD_PRESENT_TEXT) {
$this->present->textTitle = '';
$this->present->text = '';
}
$this->send();
$this->sendResultToChat('Получен подарок от ' . $this->sender['login']);
$this->status = 'Подарок был успешно отправлен персонажу ' . $this->receiver['login'];
}
private function send()
{
$values = [
'textTitle' => strip_tags($this->present->textTitle),
'text' => strip_tags($this->present->text),
'sender' => $this->sender['login'],
'receiver' => $this->receiver['id'],
'presentId' => $this->present->itemId,
];
Db::sql('update items_users set gtxt1 = :textTitle, gtxt2 = :text, gift = :sender, time_create = unix_timestamp(), uid = :receiver where id = :presentId', $values);
$this->addDelo(['id' => $this->present->itemId, 'name' => (new ItemModel($this->present->itemId))->getName()]);
}
private function addDelo(array $item)
{
$from = 'present';
$senderLog = sprintf('Отправлен подарок к %s [id:%s]. Предмет %s [id:%s].', $this->receiver['login'], $this->receiver['id'], $item['name'], $item['id']);
$receiverLog = sprintf('Получен подарок от %s [id:%s]. Предмет %s [id:%s].', $this->sender['login'], $this->sender['id'], $item['name'], $item['id']);
Delo::add(1, $from, $this->receiver['id'], $receiverLog);
Delo::add(1, $from, $this->sender['id'], $senderLog);
}
private function sendResultToChat(string $text)
{
$msg = new ChatMessage();
$msg->setTo($this->receiver['login']);
$msg->setType(6);
$msg->setText($text);
(new Chat())->sendMsg($msg);
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
}
+396 -451
View File
@@ -3639,14 +3639,6 @@ class User
return $plid;
}
public function addKr($amount, $uid = 0)
{
if ($uid === 0) {
$uid = $this->info['id'];
}
Db::sql('update users set money = money + ? where id = ?', [$amount, $uid]);
}
public function addNewbot($id, $botDate, $clon, $logins_bot = null, $luser = null, $round = null)
{
if ($clon != null) {
@@ -3907,11 +3899,14 @@ class User
return ItemsModel::addItem($id, $uid, $md, $dn, $mxiznos, $nosudba, $plavka);
}
/*
* $iid Уникальный id прдемета и одновремено флаг что
* покупка из комка.
*/
/**
* @param $sid
* @param $itm
* @param mixed $x количество
* @param $mdata
* @param $vip
* @return string
*/
public function buyItem($sid, $itm, $x, $mdata = null, $vip = false)
{
global $c, $code, $sid;
@@ -3932,7 +3927,7 @@ class User
);
$r = '';
$vip = false;
if ($this->info['allLock'] > time()) {
$r = 'Вам запрещено совершать покупки до ' . date('d.m.y H:i', $this->info['allLock']) . '';
} elseif (isset($i['id'])) {
@@ -4540,13 +4535,11 @@ class User
$r = 'Для покупки доступно ' . $i['max_buy'] . ' шт.';
} elseif ($need_rep > 0) {
$r = 'Вы не заслужили нашего доверия, мы не продадим вам этот товар.';
} elseif ($i['price_1'] * $x > $this->info['money4'] && $zuby == 1) {
$r = 'У вас недостаточно денег.';
} elseif ($mxby == -1) {
$r = 'Максимальное количество покупок для данного предмета исчерпана<br>Возможно купить: ' . $i['max_buy'] . ' шт.';
} elseif ($trn == 0 && $this->info['admin'] == 0) {
$r = 'У вас недостаточно требуемых предметов (не хватает ' . $trnt . ')';
} elseif ($i['price_1'] * $x > $this->info['money'] && $zuby == 0) {
} elseif ($i['price_1'] * $x > $this->info['money']) {
$r = 'У вас недостаточно денег (не хватает ' . ($price - $this->info['money']) . ' кр.)';
} else {
$d = mysql_fetch_array(
@@ -4554,164 +4547,144 @@ class User
'SELECT `id`,`items_id`,`data` FROM `items_main_data` WHERE `items_id` = "' . $i['id'] . '" LIMIT 1'
)
);
if ($zuby == 0) {
$this->info['money'] -= $price;
$this->info['money'] -= $price;
$this->addKr(-$price);
//новая дата
$data = '';
$data .= $d['data'];
if ($mdata != null) {
$data .= '|' . $mdata;
}
$upd = mysql_query(
'UPDATE `users` SET `money` = "' . mysql_real_escape_string(
round($this->info['money'], 2)
) . '",`money4` = "' . mysql_real_escape_string(
round($this->info['money4'], 2)
) . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
if ($upd) {
//новая дата
$data = '';
$data .= $d['data'];
if ($mdata != null) {
$data .= '|' . $mdata;
$j = 0;
$c_itm = 0;
$c_itm_data_a = [];
while ($j < count($detrn)) {
$itm = mysql_fetch_array(
mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "' . ((int)$detrn[$j][0]) . '" AND `uid` = "' . $this->info['id'] . '" AND (`delete` = "0") AND `inShop` = "0" ORDER BY `inGroup` DESC LIMIT 1'
)
);
if (!empty($itm['data']) && $c_itm == 0) {
$po = ConversionHelper::dataStringToArray($itm['data']);
if (isset($po['sudba'])) {
$c_itm_data_a['sudba'] = $po['sudba'];
}
if (!empty($po['gravi'])) {
$c_itm_data_a['gravi'] = $po['gravi'];
if (isset($po['gravic'])) {
$c_itm_data_a['gravic'] = $po['gravic'];
}
$c_itm++;
}
if (!empty($po['imposed_id']) && $po['imposed_id'] > 0) {
$c_itm_data_a['imposed_id'] = $po['imposed_id'];
if (isset($po['imposed'])) {
$c_itm_data_a['imposed'] = $po['imposed'];
}
if (isset($po['imposed_name'])) {
$c_itm_data_a['imposed_name'] = $po['imposed_name'];
}
if (isset($po['imposed_level'])) {
$c_itm_data_a['imposed_level'] = $po['imposed_level'];
}
if (isset($po['bm_a1'])) {
$c_itm_data_a['bm_a1'] = $po['bm_a1'];
}
$c_itm++;
}
if (!empty($po['spell_id']) && $po['spell_id'] > 0) {
$c_itm_data_a['spell_id'] = $po['spell_id'];
if (isset($po['spell'])) {
$c_itm_data_a['spell'] = $po['spell'];
}
if (isset($po['spell_name'])) {
$c_itm_data_a['spell_name'] = $po['spell_name'];
}
if (isset($po['spell_lvl'])) {
$c_itm_data_a['spell_lvl'] = $po['spell_lvl'];
}
if (isset($po['spell_st_name'])) {
$c_itm_data_a['spell_st_name'] = $po['spell_st_name'];
}
if (isset($po['spell_st_val'])) {
$c_itm_data_a['spell_st_val'] = $po['spell_st_val'];
}
$c_itm++;
}
if (!empty($po['rune_id']) && $po['rune_id'] > 0) {
$c_itm_data_a['rune_id'] = $po['rune_id'];
if (isset($po['rune'])) {
$c_itm_data_a['rune'] = $po['rune'];
}
if (isset($po['rune_name'])) {
$c_itm_data_a['rune_name'] = $po['rune_name'];
}
if (isset($po['rune_lvl'])) {
$c_itm_data_a['rune_lvl'] = $po['rune_lvl'];
}
$c_itm++;
}
if (!empty($po['upatack_id']) && $po['upatack_id'] > 0) {
$c_itm_data_a['upatack_id'] = $po['upatack_id'];
if (isset($po['upatack'])) {
$c_itm_data_a['upatack'] = $po['upatack'];
}
if (isset($po['upatack_name'])) {
$c_itm_data_a['upatack_name'] = $po['upatack_name'];
}
if (isset($po['upatack_lvl'])) {
$c_itm_data_a['upatack_lvl'] = $po['upatack_lvl'];
}
$c_itm++;
}
}
$j = 0;
$c_itm = 0;
$c_itm_data_a = [];
while ($j < count($detrn)) {
$itm = mysql_fetch_array(
$j++;
}
if ($c_itm > 0) {
$data = ConversionHelper::dataStringToArray($data);
// Чарка
if (isset($c_itm_data_a['spell_st_name']) && isset($c_itm_data_a['spell_st_val']) && $c_itm_data_a['spell_st_name'] != '' && $c_itm_data_a['spell_st_val'] != '') {
$data['add_' . $c_itm_data_a['spell_st_name']] = (int)(isset($data['add_' . $c_itm_data_a['spell_st_name']]) ? (int)$data['add_' . $c_itm_data_a['spell_st_name']] : 0) + (int)$c_itm_data_a['spell_st_val'];
}
// Руна
if (isset($c_itm_data_a['rune']) && $c_itm_data_a['rune'] > 0) {
$ritm = mysql_fetch_array(
mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "' . ((int)$detrn[$j][0]) . '" AND `uid` = "' . $this->info['id'] . '" AND (`delete` = "0") AND `inShop` = "0" ORDER BY `inGroup` DESC LIMIT 1'
'SELECT * FROM `items_main_data` WHERE `items_id` = "' . $c_itm_data_a['rune_id'] . '" LIMIT 1'
)
);
if (isset($itm['data']) && $itm['data'] != '' && $c_itm == 0) {
$po = ConversionHelper::dataStringToArray($itm['data']);
if (isset($po['sudba'])) {
if (isset($po['sudba'])) {
$c_itm_data_a['sudba'] = $po['sudba'];
}
}
if (isset($po['gravi']) && $po['gravi'] != '') {
if (isset($po['gravi'])) {
$c_itm_data_a['gravi'] = $po['gravi'];
}
if (isset($po['gravic'])) {
$c_itm_data_a['gravic'] = $po['gravic'];
}
$c_itm++;
}
if (isset($po['imposed_id']) && $po['imposed_id'] > 0) {
if (isset($po['imposed'])) {
$c_itm_data_a['imposed'] = $po['imposed'];
}
if (isset($po['imposed_id'])) {
$c_itm_data_a['imposed_id'] = $po['imposed_id'];
}
if (isset($po['imposed_name'])) {
$c_itm_data_a['imposed_name'] = $po['imposed_name'];
}
if (isset($po['imposed_level'])) {
$c_itm_data_a['imposed_level'] = $po['imposed_level'];
}
if (isset($po['bm_a1'])) {
$c_itm_data_a['bm_a1'] = $po['bm_a1'];
}
$c_itm++;
}
if (isset($po['spell_id']) && $po['spell_id'] > 0) {
if (isset($po['spell'])) {
$c_itm_data_a['spell'] = $po['spell'];
}
if (isset($po['spell_id'])) {
$c_itm_data_a['spell_id'] = $po['spell_id'];
}
if (isset($po['spell_name'])) {
$c_itm_data_a['spell_name'] = $po['spell_name'];
}
if (isset($po['spell_lvl'])) {
$c_itm_data_a['spell_lvl'] = $po['spell_lvl'];
}
if (isset($po['spell_st_name'])) {
$c_itm_data_a['spell_st_name'] = $po['spell_st_name'];
}
if (isset($po['spell_st_val'])) {
$c_itm_data_a['spell_st_val'] = $po['spell_st_val'];
}
$c_itm++;
}
if (isset($po['rune_id']) && $po['rune_id'] > 0) {
if (isset($po['rune'])) {
$c_itm_data_a['rune'] = $po['rune'];
}
if (isset($po['rune_id'])) {
$c_itm_data_a['rune_id'] = $po['rune_id'];
}
if (isset($po['rune_name'])) {
$c_itm_data_a['rune_name'] = $po['rune_name'];
}
if (isset($po['rune_lvl'])) {
$c_itm_data_a['rune_lvl'] = $po['rune_lvl'];
}
$c_itm++;
}
if (isset($po['upatack_id']) && $po['upatack_id'] > 0) {
if (isset($po['upatack'])) {
$c_itm_data_a['upatack'] = $po['upatack'];
}
if (isset($po['upatack_id'])) {
$c_itm_data_a['upatack_id'] = $po['upatack_id'];
}
if (isset($po['upatack_name'])) {
$c_itm_data_a['upatack_name'] = $po['upatack_name'];
}
if (isset($po['upatack_lvl'])) {
$c_itm_data_a['upatack_lvl'] = $po['upatack_lvl'];
}
$c_itm++;
$j = 0;
$data_r = ConversionHelper::dataStringToArray($ritm['data']);
while ($j < count($this->items['add'])) {
if (isset($data_r['add_' . $this->items['add'][$j]])) {
$data['add_' . $this->items['add'][$j]] += $data_r['add_' . $this->items['add'][$j]];
}
$j++;
}
$j++;
}
if ($c_itm > 0) {
$data = ConversionHelper::dataStringToArray($data);
// Чарка
if (isset($c_itm_data_a['spell_st_name']) && isset($c_itm_data_a['spell_st_val']) && $c_itm_data_a['spell_st_name'] != '' && $c_itm_data_a['spell_st_val'] != '') {
$data['add_' . $c_itm_data_a['spell_st_name']] = (int)(isset($data['add_' . $c_itm_data_a['spell_st_name']]) ? (int)$data['add_' . $c_itm_data_a['spell_st_name']] : 0) + (int)$c_itm_data_a['spell_st_val'];
}
// Руна
if (isset($c_itm_data_a['rune']) && $c_itm_data_a['rune'] > 0) {
$ritm = mysql_fetch_array(
mysql_query(
'SELECT * FROM `items_main_data` WHERE `items_id` = "' . $c_itm_data_a['rune_id'] . '" LIMIT 1'
)
);
$j = 0;
$data_r = ConversionHelper::dataStringToArray($ritm['data']);
while ($j < count($this->items['add'])) {
if (isset($data_r['add_' . $this->items['add'][$j]])) {
$data['add_' . $this->items['add'][$j]] += $data_r['add_' . $this->items['add'][$j]];
}
$j++;
}
}
$data = ConversionHelper::arrayToDataString($data);
$c_itm_data = ConversionHelper::arrayToDataString($c_itm_data_a);
$data .= '|' . $c_itm_data;
}
$i['gift'] = '';
$data = ConversionHelper::arrayToDataString($data);
$c_itm_data = ConversionHelper::arrayToDataString($c_itm_data_a);
$data .= '|' . $c_itm_data;
}
$ix = 1;
$gix = 0;
while ($ix <= $x) {
if ($i['type'] != 71) {
if ($i['iznos'] > 0) {
$i['iznosMAXi'] = $i['iznos'];
}
//
$i['price_2'] = 0;
//
$ins = mysql_query(
'INSERT INTO `items_users` (`1price`,`2price`,`gift`,`overType`,`item_id`,`uid`,`data`,`iznosMAX`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`time_create`) VALUES (
$i['gift'] = '';
$ix = 1;
$gix = 0;
while ($ix <= $x) {
if ($i['type'] != 71) {
if ($i['iznos'] > 0) {
$i['iznosMAXi'] = $i['iznos'];
}
//
$i['price_2'] = 0;
//
$ins = mysql_query(
'INSERT INTO `items_users` (`1price`,`2price`,`gift`,`overType`,`item_id`,`uid`,`data`,`iznosMAX`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`time_create`) VALUES (
"' . $i['price_1'] . '",
"' . $i['price_2'] . '",
"' . $i['gift'] . '",
@@ -4725,76 +4698,68 @@ class User
"' . $this->info['city'] . '",
"' . time() . '",
"' . time() . '")'
);
} else {
mysql_query(
'DELETE FROM `obraz` WHERE `uid` = "' . $this->info['id'] . '" AND `sex` = "' . $i['sex'] . '" AND `img` = "' . str_replace(
'.png', '.gif', $i['img']
) . '" LIMIT 1'
);
$ins = mysql_query(
'INSERT INTO `obraz` (`sex`,`img`,`level`,`uid`,`usr_add`) VALUES ("' . $i['sex'] . '","' . str_replace(
'.png', '.gif', $i['img']
) . '","' . $i['level'] . '","' . $this->info['id'] . '","' . time() . '")'
);
}
if ($ins) {
$gix++;
}
$ix++;
}
if ($ins) {
//Записываем в личное дело что предмет получен
if ($trnt != '' && $i['tr_items'] != '') {
$trnt = ', ' . $trnt;
}
if ($zuby == 0) {
$r = 'Вы приобрели предмет &quot;' . $i['name'] . '&quot; (x' . $x . ' / ' . $gix . ') за ' . $price . ' кр. ' . $trnt . '<br>Предмет успешно добавлен в инвентарь.';
} else {
$r = 'Вы приобрели предмет &quot;' . $i['name'] . '&quot; (x' . $x . ' / ' . $gix . ') за ' . $this->zuby(
$price
) . '. ' . $trnt . '<br>Предмет успешно добавлен в инвентарь.';
}
$j = 0;
while ($j < count($detrn)) {
$ost = ((int)$detrn[$j][1]);
$s4 = mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "' . ((int)$detrn[$j][0]) . '" AND `uid` = "' . $this->info['id'] . '" AND (`delete` = "0" OR `delete` = "1000") AND `inShop` = "0" AND `inOdet` = "0" ORDER BY `inGroup` DESC LIMIT ' . ((int)$detrn[$j][1]) . ''
);
while ($itm = mysql_fetch_array($s4)) {
//удаляем предмет
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
$j++;
}
mysql_query(
'UPDATE `items_shop` SET `kolvo` = "' . ($i['kolvo'] - $x) . '" WHERE `iid` = "' . $i['iid'] . '" LIMIT 1'
);
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: Приобрел предмет &quot;<strong>' . $i['name'] . '</strong>&quot; (x' . $x . ') [#' . $i['iid'] . '] за <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
);
} else {
//Записываем в личное дело что предмет не получен
$r = 'Вам не удалось приобрести &quot;' . $i['name'] . '&quot;. Администрация магазина в &quot;' . $this->city_name[$this->info['city']] . '&quot; должна Вам ' . $price . ' кр.<br>Приносим свои извинения за неудобства.';
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: не удалось приобрести предмет #' . $i['iid'] . '. К возрату: <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
mysql_query(
'DELETE FROM `obraz` WHERE `uid` = "' . $this->info['id'] . '" AND `sex` = "' . $i['sex'] . '" AND `img` = "' . str_replace(
'.png', '.gif', $i['img']
) . '" LIMIT 1'
);
$ins = mysql_query(
'INSERT INTO `obraz` (`sex`,`img`,`level`,`uid`,`usr_add`) VALUES ("' . $i['sex'] . '","' . str_replace(
'.png', '.gif', $i['img']
) . '","' . $i['level'] . '","' . $this->info['id'] . '","' . time() . '")'
);
if (!$ld) {
echo '<div>Ошибка, невозможно добавить запись в /db/usersDelo/!</div>';
}
}
} else {
$r = 'Вам не удалось приобрести предмет...';
if ($ins) {
$gix++;
}
$ix++;
}
if ($ins) {
//Записываем в личное дело что предмет получен
if ($trnt != '' && $i['tr_items'] != '') {
$trnt = ', ' . $trnt;
}
$r = 'Вы приобрели предмет &quot;' . $i['name'] . '&quot; (x' . $x . ' / ' . $gix . ') за ' . $price . ' кр. ' . $trnt . '<br>Предмет успешно добавлен в инвентарь.';
$j = 0;
while ($j < count($detrn)) {
$ost = ((int)$detrn[$j][1]);
$s4 = mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "' . ((int)$detrn[$j][0]) . '" AND `uid` = "' . $this->info['id'] . '" AND (`delete` = "0" OR `delete` = "1000") AND `inShop` = "0" AND `inOdet` = "0" ORDER BY `inGroup` DESC LIMIT ' . ((int)$detrn[$j][1]) . ''
);
while ($itm = mysql_fetch_array($s4)) {
//удаляем предмет
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
$j++;
}
mysql_query(
'UPDATE `items_shop` SET `kolvo` = "' . ($i['kolvo'] - $x) . '" WHERE `iid` = "' . $i['iid'] . '" LIMIT 1'
);
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: Приобрел предмет &quot;<strong>' . $i['name'] . '</strong>&quot; (x' . $x . ') [#' . $i['iid'] . '] за <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
);
} else {
//Записываем в личное дело что предмет не получен
$r = 'Вам не удалось приобрести &quot;' . $i['name'] . '&quot;. Администрация магазина в &quot;' . $this->city_name[$this->info['city']] . '&quot; должна Вам ' . $price . ' кр.<br>Приносим свои извинения за неудобства.';
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: не удалось приобрести предмет #' . $i['iid'] . '. К возрату: <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
);
if (!$ld) {
echo '<div>Ошибка, невозможно добавить запись в /db/usersDelo/!</div>';
}
}
}
} else { // Стандартная покупка предмета
if ($i['kolvo'] < $x) {
@@ -4886,83 +4851,57 @@ class User
}
}
$zuby = 0;
if (isset($_GET['zuby']) && $i['level'] < 8 && Config::get('zuby') == true) {
$zuby = 1;
}
$d = mysql_fetch_array(
mysql_query(
'SELECT `id`,`items_id`,`data` FROM `items_main_data` WHERE `items_id` = "' . $i['id'] . '" LIMIT 1'
)
);
$po = ConversionHelper::dataStringToArray($d['data']);
if (!empty($d['data'])) {
$po = ConversionHelper::dataStringToArray($d['data']);
}
if ($zuby == 1 && $po['tr_lvl'] > 7) {
$r = 'Данный предмет нельзя приобрести за зубы.';
} elseif (!isset($this->sid_zuby[$sid]) && $zuby == 1) {
$r = 'Данный предмет нельзя приобрести за зубы.';
} elseif ($zuby == 1 && $i['nozuby'] == 1) {
$r = 'Данный предмет нельзя приобрести за зубы.';
} elseif ($i['max_buy'] < $x && $i['max_buy'] > 0) {
if ($i['max_buy'] < $x && $i['max_buy'] > 0) {
$r = 'Для покупки доступно ' . $i['max_buy'] . ' шт.';
} elseif (isset($need_rep) && $need_rep == 0) {
$r = 'Вы не заслужили нашего доверия, мы не продадим вам этот товар.';
} elseif ($zuby == 1 && $this->info['money4'] < $i['price_1']) {
$r = 'У вас недостаточно зубов.';
} elseif ($i['price_1'] * $x > $this->info['money4'] && $zuby == 1) {
$r = 'У вас недостаточно денег.';
} elseif ($mxby == -1) {
$r = 'Максимальное количество покупок для данного предмета исчерпана<br>Возможно купить: ' . $i['max_buy'] . ' шт.';
} elseif ($trn == 0 && $this->info['admin'] == 0) {
$r = 'У вас недостаточно требуемых предметов (не хватает ' . $trnt . ')';
} elseif ($i['price_1'] * $x > $this->info['money'] && $zuby == 0) {
} elseif ($i['price_1'] * $x > $this->info['money']) {
$r = 'У вас недостаточно денег (не хватает ' . ($price - $this->info['money']) . ' кр.)';
} else {
if ($zuby == 0) {
$this->info['money'] -= $price;
} else {
$this->info['money4'] -= $price;
$this->info['money'] -= $price;
$this->addKr(-$price);
//новая дата
$data = '';
$data .= $d['data'];
$data = str_replace('sudba=1', 'sudba=' . $this->info['login'], $data);
if ($mdata != null) {
$data .= '|' . $mdata;
}
$upd = mysql_query(
'UPDATE `users` SET `money` = "' . mysql_real_escape_string(
round($this->info['money'], 2)
) . '",`money4` = "' . mysql_real_escape_string(
round($this->info['money4'], 2)
) . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
if ($upd) {
//новая дата
$data = '';
$data .= $d['data'];
$data = str_replace('sudba=1', 'sudba=' . $this->info['login'], $data);
if ($mdata != null) {
$data .= '|' . $mdata;
}
$i['gift'] = '';
$i['gift'] = '';
if ($zuby == 1) {
$i['gift'] = '1';
$data .= '|nosale=1|zazuby=' . round($price / $x, 2) . '';
}
if ($sid == 404) {
$data .= '|nosale=1|notransfer=1|fromshop=404|sudba=1';
}
if ($sid == 404) {
$data .= '|nosale=1|notransfer=1|fromshop=404|sudba=1';
}
$ix = 1;
$gix = 0;
while ($ix <= $x) {
if ($i['type'] != 71) {
if ($i['iznos'] > 0) {
$i['iznosMAXi'] = $i['iznos'];
}
//
$i['price_2'] = 0;
//
$ins = mysql_query(
'INSERT INTO `items_users` (`1price`,`2price`,`gift`,`overType`,`item_id`,`uid`,`data`,`iznosMAX`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`time_create`) VALUES (
$ix = 1;
$gix = 0;
while ($ix <= $x) {
if ($i['type'] != 71) {
if ($i['iznos'] > 0) {
$i['iznosMAXi'] = $i['iznos'];
}
//
$i['price_2'] = 0;
//
$ins = mysql_query(
'INSERT INTO `items_users` (`1price`,`2price`,`gift`,`overType`,`item_id`,`uid`,`data`,`iznosMAX`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`time_create`) VALUES (
"' . $i['price_1'] . '",
"' . $i['price_2'] . '",
"' . $i['gift'] . '",
@@ -4976,127 +4915,112 @@ class User
"' . $this->info['city'] . '",
"' . time() . '",
"' . time() . '")'
);
} else {
mysql_query(
'DELETE FROM `obraz` WHERE `uid` = "' . $this->info['id'] . '" AND `sex` = "' . $i['sex'] . '" AND `img` = "' . str_replace(
'.png', '.gif', $i['img']
) . '" LIMIT 1'
);
$ins = mysql_query(
'INSERT INTO `obraz` (`sex`,`img`,`level`,`uid`,`usr_add`) VALUES ("' . $i['sex'] . '","' . str_replace(
'.png', '.gif', $i['img']
) . '","' . $i['level'] . '","' . $this->info['id'] . '","' . time() . '")'
);
}
if ($ins) {
$gix++;
}
$ix++;
}
if ($ins) {
//Записываем в личное дело что предмет получен
if ($trnt != '' && $i['tr_items'] != '') {
$trnt = ', ' . $trnt;
}
if ($zuby == 0) {
$r = 'Вы приобрели предмет &quot;' . $i['name'] . '&quot; (x' . $x . ' / ' . $gix . ') за ' . $price . ' кр. ' . $trnt . '<br>Предмет успешно добавлен в инвентарь.';
} else {
$r = 'Вы приобрели предмет &quot;' . $i['name'] . '&quot; (x' . $x . ' / ' . $gix . ') за ' . $this->zuby(
$price
) . '. ' . $trnt . '<br>Предмет успешно добавлен в инвентарь.';
}
$zx = 0;
$rs = 0;
while ($zx < $x) {
if (($sid == 1 || $sid == 5) && $i['level'] >= 4 && round($price / $x) > 25) {
if ($this->stats['shopSale'] == 0 && !Config::get('nosanich')) {
//Выдаем странички Саныча в гос магазине и канаве
$prmn = 0; //дополнительный бонус
$prmn = (1 - (pow(0.5, ($price / $x / 200)))) * 100;
$prmn = round(20 / 100 * $prmn);
if (rand(0, 100) < 20 + $prmn && rand(0, 100) > 80 - $prmn) {
//3143 - 3192
if (rand(0, 100) < 20 + $prmn && rand(0, 100) > 80 - $prmn) {
//обложка
$gitm = rand(3193, 3195);
} else {
$gitm = rand(3143, 3192);
}
if ($gitm == 3193) {
$gitm = 3194;
}
$this->addItem($gitm, $this->info['id']);
$rs++;
}
}
}
$zx++;
}
if ($rs > 1) {
if (rand(0, 1) == 1) {
$r .= ' Предмет был завернут в какую-то бумажку. (x' . $rs . ')';
} elseif (rand(0, 1)) {
$r .= ' Предмет был завернут в странный свиток. (x' . $rs . ')';
} else {
$r .= ' К предмету была прикреплена какая-та бумажка. (x' . $rs . ')';
}
} elseif ($rs > 0) {
if (rand(0, 1) == 1) {
$r .= ' Предмет был завернут в какую-то бумажку.';
} elseif (rand(0, 1)) {
$r .= ' Предмет был завернут в странный свиток.';
} else {
$r .= ' К предмету была прикреплена какая-та бумажка.';
}
}
$j = 0;
while ($j < count($detrn)) {
$ost = ((int)$detrn[$j][1]);
$s4 = mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "' . ((int)$detrn[$j][0]) . '" AND `uid` = "' . $this->info['id'] . '" AND (`delete` = "0" OR `delete` = "1000") AND `inShop` = "0" AND `inOdet` = "0" ORDER BY `inGroup` DESC LIMIT ' . ((int)$detrn[$j][1]) . ''
);
while ($itm = mysql_fetch_array($s4)) {
//удаляем предмет
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
$j++;
}
mysql_query(
'UPDATE `items_shop` SET `kolvo` = "' . ($i['kolvo'] - $x) . '" WHERE `iid` = "' . $i['iid'] . '" LIMIT 1'
);
$zuby_inf = '';
if ($zuby == 1) {
$zuby_inf = ' <font color=red><small>(За зубы)</small></font>';
}
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: Приобрел предмет &quot;<strong>' . $i['name'] . '</strong>&quot; (x' . $x . ') [#' . $i['iid'] . '] за <strong>' . $price . '</strong> кр.' . $zuby_inf . '',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
);
} else {
//Записываем в личное дело что предмет не получен
$r = 'Вам не удалось приобрести &quot;' . $i['name'] . '&quot;. Администрация магазина в &quot;' . $this->city_name[$this->info['city']] . '&quot; должна Вам ' . $price . ' кр.<br>Приносим свои извинения за неудобства.';
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: не удалось приобрести предмет #' . $i['iid'] . '. К возрату: <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
mysql_query(
'DELETE FROM `obraz` WHERE `uid` = "' . $this->info['id'] . '" AND `sex` = "' . $i['sex'] . '" AND `img` = "' . str_replace(
'.png', '.gif', $i['img']
) . '" LIMIT 1'
);
if (!$ld) {
echo '<div>Ошибка, невозможно добавить запись в /db/usersDelo/!</div>';
$ins = mysql_query(
'INSERT INTO `obraz` (`sex`,`img`,`level`,`uid`,`usr_add`) VALUES ("' . $i['sex'] . '","' . str_replace(
'.png', '.gif', $i['img']
) . '","' . $i['level'] . '","' . $this->info['id'] . '","' . time() . '")'
);
}
if ($ins) {
$gix++;
}
$ix++;
}
if ($ins) {
//Записываем в личное дело что предмет получен
if ($trnt != '' && $i['tr_items'] != '') {
$trnt = ', ' . $trnt;
}
$r = 'Вы приобрели предмет &quot;' . $i['name'] . '&quot; (x' . $x . ' / ' . $gix . ') за ' . $price . ' кр. ' . $trnt . '<br>Предмет успешно добавлен в инвентарь.';
$zx = 0;
$rs = 0;
while ($zx < $x) {
if (($sid == 1 || $sid == 5) && $i['level'] >= 4 && round($price / $x) > 25 && $this->stats['shopSale'] == 0 && !Config::get('nosanich')) {
//Выдаем странички Саныча в гос магазине и канаве
$prmn = 0; //дополнительный бонус
$prmn = (1 - (pow(0.5, ($price / $x / 200)))) * 100;
$prmn = round(20 / 100 * $prmn);
if (rand(0, 100) < 20 + $prmn && rand(0, 100) > 80 - $prmn) {
//3143 - 3192
if (rand(0, 100) < 20 + $prmn && rand(0, 100) > 80 - $prmn) {
//обложка
$gitm = rand(3193, 3195);
} else {
$gitm = rand(3143, 3192);
}
if ($gitm == 3193) {
$gitm = 3194;
}
$this->addItem($gitm, $this->info['id']);
$rs++;
}
}
$zx++;
}
if ($rs > 1) {
if (rand(0, 1) == 1) {
$r .= ' Предмет был завернут в какую-то бумажку. (x' . $rs . ')';
} elseif (rand(0, 1)) {
$r .= ' Предмет был завернут в странный свиток. (x' . $rs . ')';
} else {
$r .= ' К предмету была прикреплена какая-та бумажка. (x' . $rs . ')';
}
} elseif ($rs > 0) {
if (rand(0, 1) == 1) {
$r .= ' Предмет был завернут в какую-то бумажку.';
} elseif (rand(0, 1)) {
$r .= ' Предмет был завернут в странный свиток.';
} else {
$r .= ' К предмету была прикреплена какая-та бумажка.';
}
}
$j = 0;
while ($j < count($detrn)) {
$ost = ((int)$detrn[$j][1]);
$s4 = mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "' . ((int)$detrn[$j][0]) . '" AND `uid` = "' . $this->info['id'] . '" AND (`delete` = "0" OR `delete` = "1000") AND `inShop` = "0" AND `inOdet` = "0" ORDER BY `inGroup` DESC LIMIT ' . ((int)$detrn[$j][1]) . ''
);
while ($itm = mysql_fetch_array($s4)) {
//удаляем предмет
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
$j++;
}
mysql_query(
'UPDATE `items_shop` SET `kolvo` = "' . ($i['kolvo'] - $x) . '" WHERE `iid` = "' . $i['iid'] . '" LIMIT 1'
);
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: Приобрел предмет &quot;<strong>' . $i['name'] . '</strong>&quot; (x' . $x . ') [#' . $i['iid'] . '] за <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
);
} else {
$r = 'Вам не удалось приобрести предмет...';
//Записываем в личное дело что предмет не получен
$r = 'Вам не удалось приобрести &quot;' . $i['name'] . '&quot;. Администрация магазина в &quot;' . $this->city_name[$this->info['city']] . '&quot; должна Вам ' . $price . ' кр.<br>Приносим свои извинения за неудобства.';
$ld = $this->addDelo(
1, $this->info['id'],
'&quot;<font color=green>Shop.' . $this->info['city'] . '</font>&quot;: не удалось приобрести предмет #' . $i['iid'] . '. К возрату: <strong>' . $price . '</strong> кр.',
time(), $this->info['city'], 'Shop.' . $this->info['city'] . '', (int)$price, 0
);
if (!$ld) {
echo '<div>Ошибка, невозможно добавить запись в /db/usersDelo/!</div>';
}
}
}
}
@@ -5106,59 +5030,37 @@ class User
return '<div align="left">' . $r . '</div>';
}
public function addDelo($type, $uid, $txt, $tm, $ct, $frm, $mo, $mi, $vvv = false)
/*
* $iid Уникальный id прдемета и одновремено флаг что
* покупка из комка.
*/
/**
* @param $type
* @param $uid
* @param $txt
* @param @deprecated $tm
* @param @deprecated $ct
* @param $frm
* @param $mo
* @param @deprecated $mi
* @param $vvv
* @return bool
* @deprecated использовать Delo::add().
*/
public function addDelo($type, $uid, $txt, $tm, $ct, $frm, $mo, $mi, $vvv = false): bool
{
return Db::sql(
'insert into users_delo (uid, dop, time, city, text, login, `delete`, ip, moneyOut, type, no_right) values (?,?,?,?,?,?,?,?,?,?,?)',
[
$uid,
$vvv,
$tm,
$ct,
$txt,
$frm,
0,
$_SERVER['HTTP_X_REAL_IP'],
$mo,
$type,
'',
]
);
$dop = $vvv ?: '';
Delo::add($type, $frm, $uid, $txt, $mo, $dop);
return true;
}
public function zuby($v, $t = 0): string
public function addKr($amount, $uid = 0)
{
$r = '';
if ($v < 0) {
$v = 0;
if ($uid === 0) {
$uid = $this->info['id'];
}
if ($t == 0) {
$names[] = ' <img height=7 title=Гнилой&nbsp;Зуб src=' . Config::img() . '/zub_low1.gif />';
$names[] = ' <img height=7 title=Нормальный&nbsp;Зуб src=' . Config::img() . '/zub_low2.gif />';
$names[] = ' <img height=7 title=Белый&nbsp;Зуб src=' . Config::img() . '/zub_low3.gif />';
$names[] = ' <img height=7 title=Золотой&nbsp;Зуб src=' . Config::img() . '/zub_low4.gif />';
} else {
$names[] = ' <img style=vertical-align:baseline height=7 title=Гнилой&nbsp;Зуб src=' . Config::img() . '/zub_low1.gif />';
$names[] = ' <img style=vertical-align:baseline height=7 title=Нормальный&nbsp;Зуб src=' . Config::img() . '/zub_low2.gif />';
$names[] = ' <img style=vertical-align:baseline height=7 title=Белый&nbsp;Зуб src=' . Config::img() . '/zub_low3.gif />';
$names[] = ' <img style=vertical-align:baseline height=7 title=Золотой&nbsp;Зуб src=' . Config::img() . '/zub_low4.gif />';
}
$int = $v;
do {
$mod = $int % 10;
$int = floor($int / 10);//или быстрее $int = ($int-$mod)/10;
$r = array_shift($names) . "" . $mod . $r;
} while ($int);
$ost = explode('.', $v);
$ost = $ost[1];
if (empty($ost)) {
$ost = '00';
}
$r .= '.' . $ost;
return $r;
Db::sql('update users set money = money + ? where id = ?', [$amount, $uid]);
}
public function newAct($test): bool
@@ -5973,6 +5875,41 @@ class User
}
}
public function zuby($v, $t = 0): string
{
$r = '';
if ($v < 0) {
$v = 0;
}
if ($t == 0) {
$names[] = ' <img height=7 title=Гнилой&nbsp;Зуб src=' . Config::img() . '/zub_low1.gif />';
$names[] = ' <img height=7 title=Нормальный&nbsp;Зуб src=' . Config::img() . '/zub_low2.gif />';
$names[] = ' <img height=7 title=Белый&nbsp;Зуб src=' . Config::img() . '/zub_low3.gif />';
$names[] = ' <img height=7 title=Золотой&nbsp;Зуб src=' . Config::img() . '/zub_low4.gif />';
} else {
$names[] = ' <img style=vertical-align:baseline height=7 title=Гнилой&nbsp;Зуб src=' . Config::img() . '/zub_low1.gif />';
$names[] = ' <img style=vertical-align:baseline height=7 title=Нормальный&nbsp;Зуб src=' . Config::img() . '/zub_low2.gif />';
$names[] = ' <img style=vertical-align:baseline height=7 title=Белый&nbsp;Зуб src=' . Config::img() . '/zub_low3.gif />';
$names[] = ' <img style=vertical-align:baseline height=7 title=Золотой&nbsp;Зуб src=' . Config::img() . '/zub_low4.gif />';
}
$int = $v;
do {
$mod = $int % 10;
$int = floor($int / 10);//или быстрее $int = ($int-$mod)/10;
$r = array_shift($names) . "" . $mod . $r;
} while ($int);
$ost = explode('.', $v);
$ost = $ost[1];
if (empty($ost)) {
$ost = '00';
}
$r .= '.' . $ost;
return $r;
}
public function price($vl)
{
if ($vl == round($vl)) {
@@ -10925,6 +10862,14 @@ LIMIT 1'
return number_format($v, 2, '.', ' ');
}
public function addVoinstvennost($amount, $uid = 0)
{
if ($uid === 0) {
$uid = $this->info['id'];
}
Db::sql('update rep set rep3 = rep3 + ? where id = ?', [$amount, $uid]);
}
/**
* Эта функция сломана! Формулы hp и mp в любых условиях выдают числа около 1000 за раз, в результате
* любое восстановление - практически моментальное. 12.07.2022 Инс.
+4 -18
View File
@@ -4,6 +4,7 @@ namespace User;
use Core\ConversionHelper;
use Core\Db;
use Delo;
use User;
class ItemsModel
@@ -101,24 +102,18 @@ class ItemsModel
if ($mxiznos > 0) {
$i['iznosMAXi'] = $mxiznos;
}
if ($user->info['dnow'] > 0) {
$room = $user->room['city'];
} else {
$room = $user->info['city'];
}
$args = [
$i['overTypei'] ?? 0,
$i['id'],
$uid,
$data,
$i['iznosMAXi'],
$i['geni'],
$i['magic_inci'],
$room,
$i['dn_delete'] ?? 0,
];
Db::sql(
'insert into items_users (overType, item_id, uid, data, iznosMAX, geniration, magic_inc, maidin, lastUPD, time_create, dn_delete) values (?,?,?,?,?,?,?,?,unix_timestamp(),unix_timestamp(),?)',
'insert into items_users (overType, item_id, uid, data, iznosMAX, magic_inc, lastUPD, time_create, dn_delete) values (?,?,?,?,?,?,unix_timestamp(),unix_timestamp(),?)',
$args
);
$rt = Db::lastInsertId() ?? 0;
@@ -132,16 +127,7 @@ class ItemsModel
$ads = 'Расплавлен предмет : [' . $plavka . ']';
}
//Записываем в личное дело что предмет получен
$user->addDelo(
1,
$uid,
'&quot;AddItems.' . $user->info['city'] . '&quot;: Получен предмет &quot;<strong>' . $i['name'] . '</strong>&quot; (x1) [#' . $i['iid'] . ']. ' . $ads,
time(),
$user->info['city'],
'AddItems.' . $user->info['city'],
0,
0
);
Delo::add(1, 'additems', $uid, 'Получен предмет «' . $i['name'] . '» [id:' . $i['iid'] . ']' . $ads);
}
}
return $rt;