Compare commits
3 Commits
4f8140a6c6
...
1cfdabce70
Author | SHA1 | Date | |
---|---|---|---|
1cfdabce70 | |||
|
4701e4b542 | ||
|
a1c052f585 |
12
akadem.php
12
akadem.php
@ -1,7 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\GameLogs;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
session_start();
|
||||
require_once 'functions.php';
|
||||
$user = $user ?? new \Battles\User($_SESSION['uid']);
|
||||
$user = $user ?? new User($_SESSION['uid']);
|
||||
const SMITH = 'оружейник';
|
||||
const MERCENARY = 'наёмник';
|
||||
const MEDIC = 'лекарь';
|
||||
@ -43,7 +49,7 @@ function setProfession($name, $type, $needMoney, $needLevel)
|
||||
Bank::setWalletMoney($user->money, $user->id);
|
||||
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->id);
|
||||
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
|
||||
addToDelo($deloText);
|
||||
GameLogs::addUserLog($_SESSION['uid'], $deloText);
|
||||
$user['prof' . $type] = true;
|
||||
$status = 'Вы получили профессию!';
|
||||
} else {
|
||||
@ -66,7 +72,7 @@ if ($get == 'exit') {
|
||||
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->id, $user->id);
|
||||
header('Location: city.php');
|
||||
}
|
||||
\Battles\Template::header('Академия');
|
||||
Template::header('Академия');
|
||||
?>
|
||||
<link href="css/secondary.css" rel="stylesheet"/>
|
||||
<div style="float: right;">
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Battles;
|
||||
|
||||
use Exceptions\GameException;
|
||||
use db;
|
||||
|
||||
class User
|
||||
{
|
||||
@ -53,7 +56,7 @@ class User
|
||||
|
||||
public function __construct($user)
|
||||
{
|
||||
$user_query = \db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
|
||||
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
|
||||
foreach ($this as $key => $value) {
|
||||
if (isset($user_query[$key])) {
|
||||
$this->$key = $user_query[$key];
|
||||
@ -80,7 +83,7 @@ class User
|
||||
return $this->$stat_name;
|
||||
}
|
||||
} else {
|
||||
throw new \Exceptions\GameException(self::ERROR_STAT_UNKNOWN);
|
||||
throw new GameException(self::ERROR_STAT_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,12 +98,12 @@ class User
|
||||
if (in_array($stat_name, $allowed)) {
|
||||
if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) {
|
||||
$query = 'UPDATE users SET ?f = ?f + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i';
|
||||
\db::c()->query($query, $stat_name, $stat_name, $this->id);
|
||||
db::c()->query($query, $stat_name, $stat_name, $this->id);
|
||||
} else {
|
||||
throw new \Exceptions\GameException(self::ERROR_STAT_IS_MAXIMUM);
|
||||
throw new GameException(self::ERROR_STAT_IS_MAXIMUM);
|
||||
}
|
||||
} else {
|
||||
throw new \Exceptions\GameException(self::ERROR_STAT_UNKNOWN);
|
||||
throw new GameException(self::ERROR_STAT_UNKNOWN);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Battles\GameLogs;
|
||||
use Battles\ShopItem;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
session_start();
|
||||
require_once 'functions.php';
|
||||
$user = $user ?? new \Battles\User($_SESSION['uid']);
|
||||
$user = $user ?? new User($_SESSION['uid']);
|
||||
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
||||
$putItemCost = (int)filter_input(INPUT_POST, 'cost', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
|
||||
$putItemId = (int)filter_input(INPUT_POST, 'putId', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
|
||||
@ -14,11 +20,11 @@ if ($putItemId) {
|
||||
$putItemCost = $dress['cost'];
|
||||
}
|
||||
$commission = ceil($putItemCost / 10); # 10% от суммы с округлением вверх.
|
||||
if ($user['money'] > $commission) {
|
||||
if ($user->money > $commission) {
|
||||
|
||||
if (db::c()->getAffectedRows()) {
|
||||
$deloText = "{$user['login']} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. ";
|
||||
addToDelo($deloText);
|
||||
$deloText = "{$user->login} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. ";
|
||||
GameLogs::addUserLog($user->id, $deloText);
|
||||
db::c()->query('UPDATE `inventory` SET `setsale` = ?i WHERE `id` = ?i', $putItemCost, $putItemId);
|
||||
db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $commission, $_SESSION['uid']);
|
||||
$status = "Вы сдали в магазин «{$dress['name']}» за {$putItemCost} кр. Вычтено за услуги магазина: {$commission} кр.";
|
||||
@ -26,15 +32,15 @@ if ($putItemId) {
|
||||
$status = "Предмет не найден в инвентаре!";
|
||||
}
|
||||
} else {
|
||||
$status = "У вас не хватает " . $commission - $user['money'] . " кр. чтобы оплатить комиссию!";
|
||||
$status = "У вас не хватает " . $commission - $user->money . " кр. чтобы оплатить комиссию!";
|
||||
}
|
||||
}
|
||||
|
||||
if ($returningItemId) {
|
||||
$dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i AND `owner` = ?i', $returningItemId, $_SESSION['uid'])->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) {
|
||||
$deloText = "{$user['login']} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки.";
|
||||
addToDelo($deloText);
|
||||
$deloText = "{$user->login} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки.";
|
||||
GameLogs::addUserLog($user->id, $deloText);
|
||||
db::c()->query('UPDATE `inventory` SET `setsale` = 0 WHERE `id` = ?i', $returningItemId);
|
||||
$status = "Вы забрали из магазина ваш «{$dress['name']}».";
|
||||
} else {
|
||||
@ -47,16 +53,16 @@ if ($byingItemId) {
|
||||
$seller = db::c()->query('SELECT `login` FROM `users` WHERE `id` =?i', $dress['owner'])->fetch_assoc();
|
||||
|
||||
if ($dress['setsale']) {
|
||||
if ($user['money'] >= $dress['setsale']) {
|
||||
db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $_SESSION['uid'], $byingItemId);
|
||||
db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $_SESSION['uid']);
|
||||
if ($user->money >= $dress['setsale']) {
|
||||
db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $user->id, $byingItemId);
|
||||
db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $user->id);
|
||||
db::c()->query('UPDATE `users` set `money` = `money` + ?i WHERE `id` = ?i', $dress['setsale'], $dress['owner']);
|
||||
$status = "Вы купили «{$dress['name']}» за {$dress['setsale']} кр.";
|
||||
$deloText = "{$user['login']} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр.";
|
||||
addToDelo($deloText);
|
||||
$deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user['login']} за {$dress['setsale']} кр.";
|
||||
addToDelo($deloText, $dress['owner']);
|
||||
$user['money'] = $user['money'] - $dress['setsale'];
|
||||
$deloText = "{$user->login} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр.";
|
||||
GameLogs::addUserLog($user->id, $deloText);
|
||||
$deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user->login} за {$dress['setsale']} кр.";
|
||||
GameLogs::addUserLog($dress['owner'], $deloText);
|
||||
$user->money -= $dress['setsale'];
|
||||
telegraph($dress['owner'], "Предмет «{$dress['name']}» продан на рынке за {$dress['setsale']} кр.");
|
||||
} else {
|
||||
$status = "Недостаточно средств!";
|
||||
@ -122,10 +128,10 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0
|
||||
|
||||
$iteminfo = [];
|
||||
while ($row = $data->fetch_assoc()) {
|
||||
$iteminfo[] = new \Battles\ShopItem($row);
|
||||
$iteminfo[] = new ShopItem($row);
|
||||
}
|
||||
|
||||
\Battles\Template::header('Рынок');
|
||||
Template::header('Рынок');
|
||||
?>
|
||||
<script src="js/main.js"></script>
|
||||
<h1>Рынок</h1>
|
||||
@ -148,8 +154,6 @@ while ($row = $data->fetch_assoc()) {
|
||||
<input name="search"> <input type="submit" value="Искать товар">
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><!--Рюкзак-->
|
||||
<TABLE WIDTH=100%>
|
||||
@ -165,10 +169,7 @@ while ($row = $data->fetch_assoc()) {
|
||||
}
|
||||
?>
|
||||
</TABLE>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD valign=top width=280>
|
||||
<div style="margin-left:15px; margin-top: 10px;">
|
||||
<b>Масса всех ваших вещей: <?= getItemsMassaInfo() ?>
|
||||
@ -183,6 +184,4 @@ while ($row = $data->fetch_assoc()) {
|
||||
<br>
|
||||
<button onclick="hrefToFrame('city.php?cp=1')">Вернуться</button>
|
||||
</div>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
@ -4,9 +4,13 @@
|
||||
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
use Battles\Travel;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'config.php';
|
||||
|
||||
$user = new \Battles\User($_SESSION['uid']);
|
||||
$user = new User($_SESSION['uid']);
|
||||
if ($user->id && $user->block) {
|
||||
exit('user blocked!');
|
||||
}
|
||||
@ -58,8 +62,8 @@ $roomsCheck = [22, 23, 25, 27, 29, 30, 31, 37, 38, 39, 40, 41, 45, 53, 61, 401,
|
||||
// [И] Имя файла который инклюдит файл с проверкой не совпадает с именем файла локации в которой я нахожусь
|
||||
// [И] Номер комнаты который я пытаюсь открыть есть в списке проверяемых
|
||||
if (in_array($user->room, $roomsCheck)
|
||||
&& pathinfo(debug_backtrace()[0]['file'])['basename'] != \Battles\Travel::$roomFileName[$user->room]
|
||||
&& in_array(array_search(pathinfo(debug_backtrace()[0]['file'])['basename'], \Battles\Travel::$roomFileName), $roomsCheck)) {
|
||||
&& pathinfo(debug_backtrace()[0]['file'])['basename'] != Travel::$roomFileName[$user->room]
|
||||
&& in_array(array_search(pathinfo(debug_backtrace()[0]['file'])['basename'], Travel::$roomFileName), $roomsCheck)) {
|
||||
header('location: main.php');
|
||||
exit;
|
||||
}
|
||||
@ -1132,25 +1136,6 @@ function SolveExp($at_id, $def_id, $damage)
|
||||
return round((($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2) / 3, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Функция записи в личное дело.
|
||||
*
|
||||
* @param string $message - текст записи.
|
||||
* @param int $user_id - ID пользователя которому добавляется запись.
|
||||
* @param int $type - тип записи: (1)обычная, (2)модераторская.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function addToDelo($message, $user_id = 0, $type = 1)
|
||||
{
|
||||
if (empty($user_id)) {
|
||||
$user_id = $_SESSION['uid'];
|
||||
}
|
||||
db::c()->query('INSERT INTO `delo` (pers, text, type, date) VALUES (?i,"?s",?i,?i)', $user_id, $message, $type, time());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Апаем стат или мастерство на единицу.
|
||||
*
|
||||
|
24
main.php
24
main.php
@ -1,4 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Battles\DressedItems;
|
||||
use Battles\GameLogs;
|
||||
use Battles\InventoryItem;
|
||||
use Battles\Template;
|
||||
use Battles\Travel;
|
||||
use Battles\UserInfo;
|
||||
|
||||
ob_start("ob_gzhandler");
|
||||
session_start();
|
||||
$get = filter_input(INPUT_SERVER, 'QUERY_STRING');
|
||||
@ -26,13 +34,13 @@ $ids = $_GET['ids'] ?? null;
|
||||
$setShadow = $_POST['setshadow'] ?? null;
|
||||
$edit = $_GET['edit'] ?? null;
|
||||
// Подготавливаем отображение инфы и предметов.
|
||||
$userInfo = new \Battles\UserInfo($user->id);
|
||||
$getItemsBonuses = new \Battles\DressedItems($_SESSION['uid']);
|
||||
$userInfo = new UserInfo($user->id);
|
||||
$getItemsBonuses = new DressedItems($_SESSION['uid']);
|
||||
$data_query = 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot = 0 AND on_sale = 0';
|
||||
$data = db::c()->query($data_query, $_SESSION['uid']);
|
||||
$iteminfo = [];
|
||||
while ($row = $data->fetch_assoc()) {
|
||||
$iteminfo[] = new \Battles\InventoryItem($row);
|
||||
$iteminfo[] = new InventoryItem($row);
|
||||
}
|
||||
|
||||
//Обработчики нажатий на кнопки.
|
||||
@ -64,7 +72,7 @@ if ($edit === null) {
|
||||
exit();
|
||||
}
|
||||
if (in_array($user->room, [22, 23, 25, 27, 29, 30, 31, 34, 45, 53, 61, 402, 403, 600, 601, 602, 603, 620, 621, 650, 660, 661, 662, 666, 760, 1051, 1052, 1055])) {
|
||||
header('location: ' . \Battles\Travel::$roomFileName[$user->room]);
|
||||
header('location: ' . Travel::$roomFileName[$user->room]);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@ -247,7 +255,7 @@ if ($mfs && $ids) {
|
||||
}
|
||||
}
|
||||
if ($setShadow) {
|
||||
\Battles\Template::header('Образ персонажа');
|
||||
Template::header('Образ персонажа');
|
||||
?>
|
||||
<div style="text-align: right;">
|
||||
<input type=button value="Вернуться" onClick="location.href='main.php?edit=<?= mt_rand() ?>';" class="button">
|
||||
@ -298,7 +306,7 @@ if ($edit) {
|
||||
addOnePoint($upm, 'mastery');
|
||||
}
|
||||
if ($drop) {
|
||||
$items = new \Battles\DressedItems($_SESSION['uid']);
|
||||
$items = new DressedItems($_SESSION['uid']);
|
||||
$items->undressItem($drop);
|
||||
}
|
||||
//Пока что одеваем предмет отсюда.
|
||||
@ -311,7 +319,7 @@ if ($edit) {
|
||||
$q = $q->fetch_assoc();
|
||||
if (empty($q['dressed'])) {
|
||||
destructitem($q['id']);
|
||||
addToDelo($user->login . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
|
||||
GameLogs::addUserLog($user->id, $user->login . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
|
||||
err('Предмет ' . $q['name'] . ' выброшен.');
|
||||
} else {
|
||||
err('Ошибка: нельзя выбросить одетый предмет!');
|
||||
@ -327,7 +335,7 @@ if ($edit) {
|
||||
undressall($_SESSION['uid']);
|
||||
}
|
||||
}
|
||||
\Battles\Template::header('Игра');
|
||||
Template::header('Игра');
|
||||
?>
|
||||
<script src="js/funcs.js"></script>
|
||||
<script>
|
||||
|
33
register.php
33
register.php
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Battles\Template;
|
||||
|
||||
session_start();
|
||||
require_once "config.php";
|
||||
if ($_COOKIE[GAMEDOMAIN] ?? null) {
|
||||
@ -15,25 +18,29 @@ if ($_COOKIE[GAMEDOMAIN] ?? null) {
|
||||
$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
|
||||
|
||||
if ($login && $password && $email && $birthday && $law && $law2) {
|
||||
$check = db::c()->query('SELECT 1 FROM `users` WHERE `login` = "?s" OR `email` = "?s"', $login, $email)->getNumRows();
|
||||
if ($check > 0) {
|
||||
$error = "В системе уже есть такие данные!";
|
||||
} else {
|
||||
db::c()->query('INSERT INTO users (login,pass,email,borndate,ip,session_id)
|
||||
VALUES ("?s", "?s", "?s", "?s", "?s", "?s")', $login, $password, $email, $birthday, $ip, session_id());
|
||||
$nid = db::c()->getLastInsertId();
|
||||
db::c()->query('INSERT INTO `online` (user_id, date, room, real_time) VALUES (?i, ?i, ?i, ?i)', $nid, time(), 1, time());
|
||||
db::c()->query('INSERT INTO `bank` (`user_id`) VALUES (?i)', $nid, 5);
|
||||
setcookie(GAMEDOMAIN, $nid, time() + 3600);
|
||||
$newUser = new class {
|
||||
public static function addUser(string $login, string $password, string $email, string $birthday): bool
|
||||
{
|
||||
if (db::c()->query('SELECT 1 FROM `users` WHERE `login` = "?s" OR `email` = "?s"', $login, $email)->getNumRows()) {
|
||||
return false;
|
||||
}
|
||||
db::c()->query('INSERT INTO users (login,pass,email,borndate,ip,session_id,shadow)
|
||||
VALUES ("?s", "?s", "?s", "?s", "?s", "?s", "?s")', $login, $password, $email, $birthday, $_SERVER['REMOTE_ADDR'], session_id(), '0.gif');
|
||||
db::c()->query('INSERT INTO `online` (user_id, date, room, real_time) VALUES (?i, ?i, ?i, ?i)', db::c()->getLastInsertId(), time(), 1, time());
|
||||
db::c()->query('INSERT INTO `bank` (user_id) VALUES (?i)', db::c()->getLastInsertId());
|
||||
setcookie(GAMEDOMAIN, db::c()->getLastInsertId(), time() + 3600);
|
||||
setcookie("battle", time());
|
||||
$_SESSION['uid'] = $nid;
|
||||
$_SESSION['uid'] = db::c()->getLastInsertId();
|
||||
$_SESSION['sid'] = session_id();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
$newUser::addUser($login, $password, $email, $birthday);
|
||||
header('Location: fight.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
\Battles\Template::header('Регистрация персонажа');
|
||||
Template::header('Регистрация персонажа');
|
||||
?>
|
||||
<a href="/"> ← на главную</a>
|
||||
<?php if ($error ?? null): ?>
|
||||
|
17
repair.php
17
repair.php
@ -1,4 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\GameLogs;
|
||||
use Battles\Template;
|
||||
|
||||
session_start();
|
||||
require_once("functions.php");
|
||||
$d = db::c()->query('SELECT SUM(`massa`) FROM `inventory` WHERE `dressed` = 0 AND `owner` = ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
@ -50,7 +55,7 @@ if ($action == 'repair' && $itemId) {
|
||||
db::c()->query('UPDATE `inventory` SET `maxdur` = `maxdur` - 1, `duration` = 0 WHERE `dressed` = 0 AND `setsale` = 0 AND `id` = ?i AND `owner` = ?i', $itemId, $_SESSION['uid']);
|
||||
$user->money -= ceil($q['duration'] / 2);
|
||||
Bank::setWalletMoney($user->money, $user->id);
|
||||
addToDelo('Отремонтирован предмет «' . $q['name'] . '» id:(' . $itemId . ') за ' . ceil($q['duration'] / 2) . ' кр.');
|
||||
GameLogs::addUserLog($user->id, 'Отремонтирован предмет «' . $q['name'] . '» id:(' . $itemId . ') за ' . ceil($q['duration'] / 2) . ' кр.');
|
||||
$status = REPAIR_STATUS['OK_REPAIRED'];
|
||||
} else {
|
||||
$status = REPAIR_STATUS['ERROR_NO_MONEY'];
|
||||
@ -62,7 +67,7 @@ if ($goto == 'remont') {
|
||||
if ($goto == 'gravirovka') {
|
||||
$gravirovka_query = db::c()->query('SELECT `id`,`name`,`img`,`text` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `type` = 3 AND `name` NOT LIKE "?S" AND `setsale` = 0 OR `text` <> "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0 ORDER by `update` DESC', $_SESSION['uid'], '%Букет%', '', $_SESSION['uid']);
|
||||
}
|
||||
\Battles\Template::header('Кузня');
|
||||
Template::header('Кузня');
|
||||
?>
|
||||
<link href="css/secondary.css" rel="stylesheet"/>
|
||||
<script src="js/main.js"></script>
|
||||
@ -151,9 +156,7 @@ if ($goto == 'modding') {
|
||||
onClick="if(!confirm('Вы действительно хотите модифицировать эту вещь?')){ return false;}">Модифицировать
|
||||
за <?= $row['cost'] ?> кр.</A><BR>
|
||||
</small>
|
||||
</TD>
|
||||
<TD valign=top><?php #showitem($row) ?></TD>
|
||||
</TR>
|
||||
<TD valign=top><?php #showitem($row) ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -179,9 +182,7 @@ if ($goto == 'podgon') {
|
||||
onclick="if(!confirm('Вы действительно хотите подогнать эту вещь?')){ return false;}">Подогнать
|
||||
за <?= $babki ?> <?= $cost_t ?>.</A><BR>
|
||||
</small>
|
||||
</TD>
|
||||
<TD valign=top><?php #showitem($row) ?></TD>
|
||||
</TR>
|
||||
<TD valign=top><?php #showitem($row) ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
22
shop.php
22
shop.php
@ -1,8 +1,14 @@
|
||||
<?php
|
||||
|
||||
use Battles\GameLogs;
|
||||
use Battles\ShopItem;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
ob_start();
|
||||
session_start();
|
||||
require_once 'functions.php';
|
||||
$user = $user ?? new \Battles\User($_SESSION['uid']);
|
||||
$user = $user ?? new User($_SESSION['uid']);
|
||||
/*
|
||||
* aheroshop.php
|
||||
* $data = db::c()->query('SELECT * FROM `ahero_shop` WHERE `count` > 0 AND `razdel` = ?i ORDER by `point` ASC', $_GET['otdel']);
|
||||
@ -90,7 +96,7 @@ FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `c
|
||||
|
||||
$iteminfo = [];
|
||||
while ($row = $shopItems->fetch_assoc()) {
|
||||
$iteminfo[] = new \Battles\ShopItem($row);
|
||||
$iteminfo[] = new ShopItem($row);
|
||||
}
|
||||
} else {
|
||||
$inventoryItems = db::c()->query('SELECT `inventory`.*,
|
||||
@ -110,7 +116,7 @@ ORDER BY `update` DESC', null, $_SESSION['uid']);
|
||||
|
||||
$iteminfo = [];
|
||||
while ($row = $inventoryItems->fetch_assoc()) {
|
||||
$iteminfo[] = new \Battles\ShopItem($row);
|
||||
$iteminfo[] = new ShopItem($row);
|
||||
}
|
||||
|
||||
}
|
||||
@ -134,8 +140,8 @@ if ($sellItemId) {
|
||||
$status = "Вы продали «{$dress['name']}» $kols за " . $allcost . " кр.";
|
||||
}
|
||||
|
||||
$deloText = "{$user['login']} продал товар «{$dress['name']}» {$kols}id:({$dress['id']}) в магазине за {$allcost} кр.";
|
||||
addToDelo($deloText);
|
||||
$deloText = "{$user->login} продал товар «{$dress['name']}» {$kols}id:({$dress['id']}) в магазине за {$allcost} кр.";
|
||||
GameLogs::addUserLog($user->id, $deloText);
|
||||
// Для обновления данных о деньгах на странице
|
||||
$user['money'] += $allcost;
|
||||
}
|
||||
@ -223,8 +229,8 @@ if (!empty($_GET['buy'])) {
|
||||
}
|
||||
$status = "Вы купили «{$dress['name']}» за {$dress['cost']} кр.";
|
||||
db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['cost'], $_SESSION['uid']);
|
||||
$deloText = "{$user['login']} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине за {$dress['cost']} кр.";
|
||||
addToDelo($deloText);
|
||||
$deloText = "{$user->login} купил товар «{$dress['name']}» id:({$inventoryItemId}) в магазине за {$dress['cost']} кр.";
|
||||
GameLogs::addUserLog($user->id, $deloText);
|
||||
// Для обновления данных о деньгах на странице
|
||||
$user['money'] -= $dress['cost'];
|
||||
|
||||
@ -232,7 +238,7 @@ if (!empty($_GET['buy'])) {
|
||||
$status = "Недостаточно денег или нет вещей в наличии.";
|
||||
}
|
||||
}
|
||||
\Battles\Template::header('Магазин');
|
||||
Template::header('Магазин');
|
||||
?>
|
||||
<script src="js/main.js"></script>
|
||||
<h1>Государственный магазин</h1>
|
||||
|
Loading…
Reference in New Issue
Block a user