battles/clan.php

115 lines
4.1 KiB
PHP
Raw Permalink Normal View History

2018-01-28 16:40:49 +00:00
<?php
use Battles\Clan;
use Battles\GameConfigs;
use Battles\Nick;
use Battles\Rooms;
use Battles\Template;
use Battles\User;
require_once 'functions.php';
if (!User::getInstance()->getClan()) {
exit('Ошибка! Вы не состоите в клане!');
}
2019-06-20 21:48:46 +00:00
if (User::getInstance()->getClan() != Clan::getInstance()->getClanShortName()) {
exit('Ошибка! Клана ' . User::getInstance()->getClan() . ' не существует!');
2019-06-20 21:48:46 +00:00
}
Template::header('clan');
?>
<style>
.row {
cursor: default;
}
.column {
padding: 10px;
}
.left {
width: 60%;
float: left;
2019-06-20 23:37:39 +00:00
}
.right {
width: 30%;
float: right;
}
.row:after {
content: "";
display: table;
clear: both;
}
</style>
2019-06-22 12:49:35 +00:00
<div>
<button onclick="location.href='main.php'">Вернуться</button>
<?php if (!empty($_POST['login']) && !empty($_POST['action'])): ?>
<span class="error">
<?php if ($_POST['action'] == 'add_member'): ?>
<?= Clan::getInstance()->addMember($_POST['login']) ?>
<?php endif; ?>
<?php if ($_POST['action'] == 'remove_member'): ?>
<?= Clan::getInstance()->removeMember($_POST['login']) ?>
<?php endif; ?>
<?php if ($_POST['action'] == 'change_owner'): ?>
<?= Clan::getInstance()->changeOwner($_POST['login']) ?>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
<div class="row">
<div class="column left">
<h3><img src="./i/clan/<?= Clan::getInstance()->getClanShortName() ?>.png"
alt="<?= Clan::getInstance()->getClanShortName() ?>"><?= Clan::getInstance()->getClanName() ?></h3>
<?php if (Clan::getInstance()->getClanOwnerId() === User::getInstance()->getId()): ?>
<div>
<span id="add_member">
<input type="submit" onclick="use('add_member')" value="Принять в клан">
</span>
[стоимость: <?= GameConfigs::CLAN['add_member_cost'] ?>]
</div>
<div>
<span id="remove_member">
<input type="submit" onclick="use('remove_member')" value="Выгнать из клана">
</span>
[стоимость: <?= GameConfigs::CLAN['remove_member_cost'] ?>]
</div>
<div>
<span id="change_owner">
<input type="submit" onclick="use('change_owner')" value="Сменить главу клана">
</span>
(сложить с себя полномочия, назначив <strong style="color: teal;">Главой Клана</strong> другого
персонажа)
</div>
<?php endif; ?>
</div>
<div class="column right">
<table class='zebra' style='width: 100%;'>
<caption><h3>Соклановцы</h3></caption>
<tr>
<th id='c1'>Имя</th>
<th id='c2'>Местонахождение</th>
</tr>
<?php foreach (Clan::getInstance()->getMemberlist() as $member): ?>
2019-06-22 12:49:35 +00:00
<tr>
<td>
<?php if ($member->clan_owner): ?>
👑
<?php endif; ?>
<?= Nick::id($member->id)->full() ?>
</td>
<td>
<em style='font-size: smaller;'><?= $member->room ? Rooms::$roomNames[$member->room] : 'Персонаж не в игре' ?></em>
</td>
2019-06-22 12:49:35 +00:00
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
2019-06-20 21:48:46 +00:00
<script type="text/javascript">
function use(option) {
2019-06-20 23:57:48 +00:00
document.getElementById(option).innerHTML = "<form method='post'><input placeholder='Имя персонажа' name='login'><button name='action' value='" + option + "' type='submit'>Ок</button><button>×</button></form>";
2019-06-20 21:48:46 +00:00
}
</script>