patch-admin (#56)
5b29d5b593Админка: создание предметов.197e489e0eАдминка: класс регистрации кланов.
This commit was merged in pull request #56.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Battles\Admin;
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Database\Db;
|
||||
use Battles\GameConfigs;
|
||||
use Battles\User;
|
||||
|
||||
class Clan
|
||||
{
|
||||
public static function getUnapprovedList(): string
|
||||
{
|
||||
$list = '';
|
||||
$rows = Db::getInstance()->ofetchAll('select * from clans where status = 0');
|
||||
foreach ($rows as $row) {
|
||||
$id = $row->owner_id;
|
||||
$login = User::getInstance($id)->getLogin();
|
||||
$full = $row->full_name;
|
||||
$short = $row->short_name;
|
||||
$info = nl2br($row->info);
|
||||
$list .= <<<UNREGCLANLIST
|
||||
<div>
|
||||
<fieldset style="display: inline;">
|
||||
<legend>$full [$short]</legend>
|
||||
Глава клана: <span class="abils">$login</span><br>
|
||||
Описание:<div class="abils">$info</div>
|
||||
<BR>
|
||||
<button onclick="location.href='?regclan=$id'">Зарегистрировать</button>
|
||||
<button onclick="location.href='?remclan=$id'">Отказать</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
UNREGCLANLIST;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function allowRegister($id)
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
|
||||
}
|
||||
|
||||
public static function disallowRegister($id)
|
||||
{
|
||||
$bank = new Bank($id);
|
||||
Db::getInstance()->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
|
||||
$bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Battles\Admin;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Item
|
||||
{
|
||||
public static function add(array $params): void
|
||||
{
|
||||
$query = 'insert into items (
|
||||
name, item_type, durability,
|
||||
need_strength, need_dexterity, need_intuition, need_endurance, need_intelligence, need_wisdom,
|
||||
add_strength, add_dexterity, add_intuition, add_endurance, add_intelligence, add_wisdom,
|
||||
add_accuracy, add_evasion, add_criticals, add_min_physical_damage, add_max_physical_damage,
|
||||
image, weight)
|
||||
values (
|
||||
:name, :item_type, :durability,
|
||||
:need_strength, :need_dexterity, :need_intuition, :need_endurance, :need_intelligence, :need_wisdom,
|
||||
:add_strength, :add_dexterity, :add_intuition, :add_endurance, :add_intelligence, :add_wisdom,
|
||||
:add_accuracy, :add_evasion, :add_criticals, :add_min_physical_damage, :add_max_physical_damage,
|
||||
:image, :weight)';
|
||||
$values = [
|
||||
'name' => $params['name'] ?? uniqid(),
|
||||
'item_type' => $params['item_type'],
|
||||
'durability' => $params['durability'] ?? 1,
|
||||
'need_strength' => $params['need_strength'] ?? 0,
|
||||
'need_dexterity' => $params['need_dexterity'] ?? 0,
|
||||
'need_intuition' => $params['need_intuition'] ?? 0,
|
||||
'need_endurance' => $params['need_endurance'] ?? 0,
|
||||
'need_intelligence' => $params['need_intelligence'] ?? 0,
|
||||
'need_wisdom' => $params['need_wisdom'] ?? 0,
|
||||
'add_strength' => $params['add_strength'] ?? 0,
|
||||
'add_dexterity' => $params['add_dexterity'] ?? 0,
|
||||
'add_intuition' => $params['add_intuition'] ?? 0,
|
||||
'add_endurance' => $params['add_endurance'] ?? 0,
|
||||
'add_intelligence' => $params['add_intelligence'] ?? 0,
|
||||
'add_wisdom' => $params['add_wisdom'] ?? 0,
|
||||
'add_accuracy' => $params['add_accuracy'] ?? 0,
|
||||
'add_evasion' => $params['add_evasion'] ?? 0,
|
||||
'add_criticals' => $params['add_criticals'] ?? 0,
|
||||
'add_min_physical_damage' => $params['add_min_physical_damage'] ?? 0,
|
||||
'add_max_physical_damage' => $params['add_max_physical_damage'] ?? 0,
|
||||
'image' => $params['image'] ?? 'noitem.png',
|
||||
'weight' => $params['weight'] ?? 1,
|
||||
];
|
||||
Db::getInstance()->execute($query, $values);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user