Рефакторинг, очистка, работа над ошибками, связанными с базой, отказ от глобальной переменной $user во многих файлах.
Singleton в некоторых местах вместо решения #42. Новые шаги для решения #16 и #52. Closes #42. Closes #32. Closes #31.
This commit is contained in:
+7
-6
@@ -3,6 +3,7 @@
|
||||
use Battles\Bank;
|
||||
use Battles\GameLogs;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
|
||||
require_once 'functions.php';
|
||||
const SMITH = 'оружейник';
|
||||
@@ -42,9 +43,9 @@ function setProfession($name, $type, $needMoney, $needLevel)
|
||||
$profId = 22;
|
||||
}
|
||||
if (!empty($profId)) {
|
||||
$user->setMoney($user->getMoney() - $needMoney);
|
||||
Bank::setWalletMoney($user->getMoney(), $user->getId());
|
||||
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->getId());
|
||||
User::getInstance()->setMoney(User::getInstance()->getMoney() - $needMoney);
|
||||
Bank::setWalletMoney(User::getInstance()->getMoney(), User::getInstance()->getId());
|
||||
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, User::getInstance()->getId());
|
||||
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
|
||||
GameLogs::addUserLog($_SESSION['uid'], $deloText);
|
||||
$user['prof' . $type] = true;
|
||||
@@ -66,7 +67,7 @@ if ($get == 'medic') {
|
||||
}
|
||||
|
||||
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->getId(), $user->getId());
|
||||
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', User::getInstance()->getId(), User::getInstance()->getId());
|
||||
header('Location: city.php');
|
||||
}
|
||||
Template::header('Академия');
|
||||
@@ -79,8 +80,8 @@ Template::header('Академия');
|
||||
<div><?= $status ?></div>
|
||||
<div class="appblock appblock-main">
|
||||
<span class="legend">Информация</span>
|
||||
<span class="wrap">Кредиты<span class="num"><?= $user->getMoney() ?></span></span>
|
||||
<span class="wrap">Уровень персонажа<span class="num"><?= $user->getLevel() ?></span></span>
|
||||
<span class="wrap">Кредиты<span class="num"><?= User::getInstance()->getMoney() ?></span></span>
|
||||
<span class="wrap">Уровень персонажа<span class="num"><?= User::getInstance()->getLevel() ?></span></span>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
<span class="legend">Наёмник</span>
|
||||
|
||||
Reference in New Issue
Block a user