Зачем-то инкапсуляция...
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Rooms;
|
||||
use Battles\Template;
|
||||
use Battles\User;
|
||||
use Exceptions\GameException;
|
||||
|
||||
ob_start("ob_gzhandler");
|
||||
session_start();
|
||||
require_once "functions.php";
|
||||
$user = $user ?? new \Battles\User($_SESSION['uid']);
|
||||
$user = $user ?? new User($_SESSION['uid']);
|
||||
const SUCCESS = "Успешная операция!";
|
||||
|
||||
$bank = new \Battles\Bank($user->id);
|
||||
$bank = new Bank($user->getId());
|
||||
$status = '';
|
||||
|
||||
$toid = $_POST['to_id'] ?? 0;
|
||||
@@ -15,37 +22,37 @@ try {
|
||||
// Зачисление кредитов на счёт.
|
||||
if ($submit === 'depositMoney' && $summa) {
|
||||
$operation = $bank->depositMoney($summa);
|
||||
$user->money = $operation['walletMoney'];
|
||||
$user->setMoney($operation['walletMoney']);
|
||||
$bank->setMoney($operation['bankMoney']);
|
||||
$status = SUCCESS;
|
||||
}
|
||||
// Снятие кредитов со счёта.
|
||||
if ($submit === 'withdrawMoney' && $summa) {
|
||||
$operation = $bank->withdrawMoney($summa);
|
||||
$user->money = $operation['walletMoney'];
|
||||
$user->setMoney($operation['walletMoney']);
|
||||
$bank->setMoney($operation['bankMoney']);
|
||||
$status = SUCCESS;
|
||||
}
|
||||
// Перевод кредитов на другой счёт.
|
||||
if ($submit === 'sendMoney' && $summa && $toid) {
|
||||
$user->money = $bank->sendMoney($toid, $summa);
|
||||
$user->setMoney($bank->sendMoney($toid, $summa));
|
||||
$status = SUCCESS;
|
||||
}
|
||||
} catch (\Exceptions\GameException $e) {
|
||||
} catch (GameException $e) {
|
||||
echo 'Банковская ошибка!';
|
||||
} finally {
|
||||
unset($submit, $summa, $toid);
|
||||
}
|
||||
\Battles\Template::header('Банк');
|
||||
Template::header('Банк');
|
||||
?>
|
||||
<link href="css/secondary.css" rel="stylesheet"/>
|
||||
<script src="js/main.js"></script>
|
||||
<?php \Battles\Template::buildingTop(\Battles\Rooms::$roomNames[29], 'strah') ?>
|
||||
<?php Template::buildingTop(Rooms::$roomNames[29], 'strah') ?>
|
||||
<div><?= $status ?></div>
|
||||
<div class="appblock appblock-main">
|
||||
<span class="wrap">На счету: <span class="num"><?= $bank->getMoney() ?></span></span>
|
||||
<hr>
|
||||
<span class="wrap">На руках: <span class="num"><?= $user->money ?></span></span>
|
||||
<span class="wrap">На руках: <span class="num"><?= $user->getMoney() ?></span></span>
|
||||
</div>
|
||||
<div class="appblock">
|
||||
<span class="legend">Работа со счётом</span>
|
||||
|
||||
Reference in New Issue
Block a user