1. finalize ekrshop

2. shop bying fixes
3. item class code clear
4. moved all gifts to separate file
5. removed artefact upgrade
This commit is contained in:
Igor Barkov [iwork]
2019-01-15 17:56:15 +02:00
parent a393f67ccd
commit 016e5a9ccd
7 changed files with 305 additions and 422 deletions

131
shop.php
View File

@@ -2,7 +2,7 @@
ob_start();
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
require_once("functions.php");
require_once 'functions.php';
if ($user['room'] != 22) {
header("Location: main.php");
@@ -101,7 +101,10 @@ FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `c
`magic`.`img` AS `magic_img`,
0 AS `maxdur`
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND `tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 AND `owner` = ?i ORDER BY `update` DESC', null, $_SESSION['uid']);
FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE
`dressed` = 0 AND `setsale` = 0 AND `cost` > 0 AND `present` = "?s" AND
`tradesale` = 0 AND `podzem` = 0 AND `goden` = 0 AND `artefact` = 0 AND `owner` = ?i
ORDER BY `update` DESC', null, $_SESSION['uid']);
$iteminfo = [];
while ($row = $inventoryItems->fetch_assoc()) {
@@ -113,14 +116,14 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0
$sellItemId = filter_input(INPUT_GET, 'sell');
if ($sellItemId) {
$dress = db::c()->query('SELECT `id`, `name`, `cost`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc();
$dress = db::c()->query('SELECT `id`, `name`, `cost`, `koll` FROM `inventory` WHERE `dressed` = 0 AND `artefact` = 0 AND `id` = ?i AND `owner` = ?i', $sellItemId, $user['id'])->fetch_assoc();
$kols = '';
if ($dress['koll']) {
$dress['cost'] *= $dress['koll'];
$kols = " (x{$dress['koll']}) ";
}
$allcost = mt_rand(0,$dress['cost']/2);
$allcost = mt_rand(0, $dress['cost'] / 2);
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $dress['id']);
db::c()->query('UPDATE `users` SET `money` = `money` + ?i WHERE `id` = ?i', $allcost, $_SESSION['uid']);
if ($allcost == 0) $status = "После длительных и изнурительных торгов вы плюнули на всё и просто подарили ваш «{$dress['name']}» торговцу.";
@@ -151,6 +154,7 @@ if (!empty($_GET['buy'])) {
'glovk' => $dress['glovk'],
'ginta' => $dress['ginta'],
'gintel' => $dress['gintel'],
'ghp' => $dress['ghp'],
'gnoj' => $dress['gnoj'],
'gtopor' => $dress['gtopor'],
@@ -163,6 +167,7 @@ if (!empty($_GET['buy'])) {
'glight' => $dress['glight'],
'ggray' => $dress['ggray'],
'gdark' => $dress['gdark'],
'needident' => $dress['needident'],
'nsila' => $dress['nsila'],
'nlovk' => $dress['nlovk'],
@@ -174,6 +179,19 @@ if (!empty($_GET['buy'])) {
'ntopor' => $dress['ntopor'],
'ndubina' => $dress['ndubina'],
'nmech' => $dress['nmech'],
'nfire' => $dress['nfire'],
'nwater' => $dress['nwater'],
'nair' => $dress['nair'],
'nearth' => $dress['nearth'],
'nlight' => $dress['nlight'],
'ngray' => $dress['ngray'],
'ndark' => $dress['ndark'],
'mfkrit' => $dress['mfkrit'],
'mfakrit' => $dress['mfakrit'],
'mfuvorot' => $dress['mfuvorot'],
'mfauvorot' => $dress['mfauvorot'],
'bron1' => $dress['bron1'],
'bron2' => $dress['bron2'],
'bron3' => $dress['bron3'],
@@ -187,10 +205,10 @@ if (!empty($_GET['buy'])) {
'goden' => $dress['goden'],
'gmp' => $dress['gmp'],
'artefact' => $dress['artefact'],
'koll' => $dress['koll']
'koll' => $dress['koll'],
];
db::c()->query('INSERT INTO `inventory` SET ?A[?i,?i,"?s",?i,?i,?i,"?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i]', $newItem);
db::c()->query('INSERT INTO `inventory` SET ?A[?i,?i,"?s",?i,?i,?i,"?s",?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i,?i]', $newItem);
$inventoryItemId = db::c()->getLastInsertId();
if ($dress['count'] != -1) db::c()->query('UPDATE `shop` SET `count` = `count` - 1 WHERE `id` = ?i', $_GET['buy']);
$status = "Вы купили «{$dress['name']}» за {$dress['cost']} кр.";
@@ -222,75 +240,66 @@ if (!empty($_GET['buy'])) {
<TABLE width=100% cellspacing="0" cellpadding="4">
<TR>
<TD valign=top align=left>
<h3><?= $shopCategoryType ?></h3>
<?php if ($saleItems): ?>
<div style="text-align: center;">Вы можете продать ваши предметы за сущие копейки.</div>
<?php endif; ?>
<!--Магазин-->
<TABLE border=0 width=100% cellspacing="0" cellpadding="0" bgcolor="#A5A5A5">
<TR>
<TD align=center>
<h3><?= $shopCategoryType ?></h3>
<?php if ($saleItems): ?>
Вы можете продать ваши предметы за сущие копейки.
<?php endif; ?>
</TD>
</TR>
<TR>
<TD>
<TABLE class="zebra" WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">
<?php
if ($saleItems == true) {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage();
$ii->printControls(true);
echo "</td>";
echo "<td style='vertical-align: top;'>";
$ii->printInfo();
echo "</td></tr>";
}
} else {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage();
$ii->printControls();
echo "</td>";
echo "<td style='vertical-align: top;'>";
$ii->printInfo();
echo "</td></tr>";
}
}
?>
</TABLE>
</TD>
</TR>
<TABLE class="zebra" WIDTH=100% CELLSPACING="1" CELLPADDING="2">
<?php
if ($saleItems == true) {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage();
$ii->printControls('sell');
echo "</td>";
echo "<td style='vertical-align: top;'>";
$ii->printInfo();
echo "</td></tr>";
}
} else {
foreach ($iteminfo as $ii) {
echo "<tr><td style='width: 150px; text-align: center;'>";
$ii->printImage();
$ii->printControls();
echo "</td>";
echo "<td style='vertical-align: top;'>";
$ii->printInfo();
echo "</td></tr>";
}
}
?>
</TABLE>
</TD>
<TD valign=top width=280>
<B>Масса всех ваших вещей: <?= getItemsMassaInfo() ?>
<BR>У вас в наличии: <span style="color: darkgreen;"><?= $user['money'] ?></span> кр.</B>
<hr>
<div style="text-align: center; font-weight: bold;">Отделы магазина</div>
<a href="shop.php?otdel=sale&rnd=<?= mt_rand() ?>">Продать вещи</a>
<dl>
<dt><b>Оружие:</b></dt>
<dd><a href="shop.php?otdel=1&rnd=<?= mt_rand() ?>">кинжалы</a></dd>
<dd><a href="shop.php?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="shop.php?otdel=12&rnd=<?= mt_rand() ?>">дубины</a></dd>
<dd><a href="shop.php?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dd><a href="?otdel=1&rnd=<?= mt_rand() ?>">кинжалы</a></dd>
<dd><a href="?otdel=11&rnd=<?= mt_rand() ?>">топоры</a></dd>
<dd><a href="?otdel=12&rnd=<?= mt_rand() ?>">дубины</a></dd>
<dd><a href="?otdel=13&rnd=<?= mt_rand() ?>">мечи</a></dd>
<dt><b>Одежда:</b></dt>
<dd><a href="shop.php?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="shop.php?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="shop.php?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="shop.php?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="shop.php?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="shop.php?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dd><a href="?otdel=24&rnd=<?= mt_rand() ?>">шлемы</a></dd>
<dd><a href="?otdel=23&rnd=<?= mt_rand() ?>">тяжелая броня</a></dd>
<dd><a href="?otdel=22&rnd=<?= mt_rand() ?>">легкая броня</a></dd>
<dd><a href="?otdel=3&rnd=<?= mt_rand() ?>">щиты</a></dd>
<dd><a href="?otdel=21&rnd=<?= mt_rand() ?>">перчатки</a></dd>
<dd><a href="?otdel=2&rnd=<?= mt_rand() ?>">сапоги</a></dd>
<dt><b>Ювелирные товары:</b></dt>
<dd><a href="shop.php?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="shop.php?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="shop.php?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dd><a href="?otdel=4&rnd=<?= mt_rand() ?>">серьги</a></dd>
<dd><a href="?otdel=41&rnd=<?= mt_rand() ?>">ожерелья</a></dd>
<dd><a href="?otdel=42&rnd=<?= mt_rand() ?>">кольца</a></dd>
<dt><b>Магия:</b></dt>
<dd><a href="shop.php?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="shop.php?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dd><a href="?otdel=51&rnd=<?= mt_rand() ?>">боевые</a></dd>
<dd><a href="?otdel=5&rnd=<?= mt_rand() ?>">разные</a></dd>
<dt><b>Разное:</b></dt>
<dd><a href="shop.php?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="shop.php?otdel=52&rnd=<?= mt_rand() ?>">руны</a></dd>
<dd><a href="?otdel=6&rnd=<?= mt_rand() ?>">амуниция</a></dd>
<dd><a href="?otdel=52&rnd=<?= mt_rand() ?>">руны</a></dd>
</dl>
<div id="hint3" class="ahint"></div>
</TD>