Админка: создание предметов.

This commit is contained in:
Ivor Barhansky 2022-05-27 20:02:03 +03:00
parent 0f62ee20e7
commit 5b29d5b593
2 changed files with 144 additions and 138 deletions

View File

@ -1,143 +1,100 @@
<?php <?php
# Date: 31.01.2021 (20:21) # Date: 31.01.2021 (20:21)
?> require_once '../config.php';
<form method=post>
<div> use Battles\Admin\Item;
<table>
<caption>Добавление вещей в магазин</caption>
<tr>
<th id="main">Основное
<tr>
<td><input name="name" placeholder="Название">
<tr>
<td><input name="image" placeholder="Картинка">
<tr>
<td><select name="shop">
<option value="0" selected disabled>Тип магазина</option>
<option value="1">Обычный</option>
<option value="2">Цветной</option>
</select>
<tr>
<td><input name=count placeholder="Количество (шт.)">
<tr>
<td><select name="item_type">
<option value="0" selected disabled>Тип предмета</option>
<option value="1">Шлем</option>
<option value="2">Броня</option>
<option value="3">Поножи</option>
<option value="4">Сапоги</option>
<option value="5">Перчатки</option>
<option value="6">Оружие</option>
<option value="7">Щит</option>
<option value="8">Пояс</option>
<option value="9">Кольцо</option>
<option value="10">Амулет</option>
<option value="20">Расходник</option>
<option value="50">Всё остальное</option>
<option value="100">Хлам</option>
</select>
<tr>
<td><input name=weight placeholder="Масса">
<tr>
<td><input name=durability placeholder="Макс. износ">
<tr>
<td><input name=price placeholder="Цена (кр.)">
<tr>
<th id="needs">Требования
<tr>
<td><input name=need_level placeholder="Уровень">
<tr>
<td><input name=need_strength placeholder="Сила">
<tr>
<td><input name=need_dexterity placeholder="Ловкость">
<tr>
<td><input name=need_intuition placeholder="Интуиция">
<tr>
<td><input name=need_endurance placeholder="Выносливость">
<tr>
<td><input name=need_intelligence placeholder="Интеллект">
<tr>
<td><input name=need_wisdom placeholder="Мудрость">
<tr>
<th id="adds">Характеристики
<tr>
<td><input name=minu placeholder="Мин.урон">
<tr>
<td><input name=maxu placeholder="Макс.урон">
<tr>
<td><input name=gsila placeholder="Сила">
<tr>
<td><input name=glovk placeholder="Ловкость">
<tr>
<td><input name=ginta placeholder="Интуиция">
<tr>
<td><input name=gintel placeholder="Интеллект">
<tr>
<td><input name=ghp placeholder="НР">
<tr>
<td><input name=mfkrit placeholder="Мф.крит">
<tr>
<td><input name=mfakrit placeholder="Мф.антикрит">
<tr>
<td><input name=mfuvorot placeholder="Мф.уворот">
<tr>
<td><input name=mfauvorot placeholder="Мф.антиуворот">
<tr>
<td><input name=gnoj placeholder="Ум.ножи">
<tr>
<td><input name=gtopor placeholder="Ум.топоры">
<tr>
<td><input name=gdubina placeholder="Ум.дубины">
<tr>
<td><input name=gmech placeholder="Ум.мечи">
<tr>
<td><input name=bron1 placeholder="Броня головы">
<tr>
<td><input name=bron2 placeholder="Броня корпуса">
<tr>
<td><input name=bron3 placeholder="Броня пояса">
<tr>
<td><input name=bron4 placeholder="Броня ног">
<tr>
<td><input name=gfire placeholder="Мастерство огня">
<tr>
<td><input name=gwater placeholder="Мастерство воды">
<tr>
<td><input name=gair placeholder="Мастерство воздуха">
<tr>
<td><input name=gearth placeholder="Мастерство земли">
<tr>
<td><input name=glight placeholder="Светлая магия">
<tr>
<td><input name=ggray placeholder="Серая магия">
<tr>
<td><input name=gdark placeholder="Темная магия">
<tr>
<td><input name=encicl placeholder="В энциклопедию">
<tr>
<td><input name=magic placeholder="Наложенно заклятие">
</table>
<INPUT TYPE="submit" value="Добавить">
</div>
</form>
<?php
if (isset($_POST)) { if (isset($_POST)) {
echo "Ждём лучших времён!"; Item::add($_POST);
//if($_POST['razdel'] !=7) $goden_tmp=0; else */
// $goden_tmp = $_POST['goden'];
//
// if ($_POST['shop'] == 1) if (mysql_query("INSERT INTO shop(name,duration,maxdur,cost,ecost,nlevel,nsila,nlovk,ninta,nvinos,nintel,nmudra,nnoj,ntopor,ndubina,nmech,nalign,minu,maxu,goden,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,gnoj,gtopor,gdubina,gmech,img,count,bron1,bron2,bron3,bron4,magic,type,massa,needident,nfire,nwater,nair,nearth,nlight,ngray,ndark,gfire,gwater,gair,gearth,glight,ggray,gdark,encicl,artefact,letter,isrep,razdel) VALUES ('" . $_POST['name'] . "','" . $_POST['duration'] . "','" . $_POST['maxdur'] . "','" . $_POST['cost'] . "','" . $_POST['ecost'] . "','" . $_POST['nlevel'] . "','" . $_POST['nsila'] . "','" . $_POST['nlovk'] . "','" . $_POST['ninta'] . "','" . $_POST['nvinos'] . "','" . $_POST['nintel'] . "','" . $_POST['nmudra'] . "','" . $_POST['nnoj'] . "','" . $_POST['ntopor'] . "','" . $_POST['ndubina'] . "','" . $_POST['nmech'] . "','" . $_POST['nalign'] . "','" . $_POST['minu'] . "','" . $_POST['maxu'] . "','" . $goden_tmp . "','" . $_POST['gsila'] . "','" . $_POST['glovk'] . "','" . $_POST['ginta'] . "','" . $_POST['gintel'] . "','" . $_POST['ghp'] . "','" . $_POST['mfkrit'] . "','" . $_POST['mfakrit'] . "','" . $_POST['mfuvorot'] . "','" . $_POST['mfauvorot'] . "','" . $_POST['gnoj'] . "','" . $_POST['gtopor'] . "','" . $_POST['gdubina'] . "','" . $_POST['gmech'] . "','" . $_POST['img'] . "','" . $_POST['count'] . "','" . $_POST['bron1'] . "','" . $_POST['bron2'] . "','" . $_POST['bron3'] . "','" . $_POST['bron4'] . "','" . $_POST['magic'] . "','" . $_POST['type'] . "','" . $_POST['massa'] . "','" . $_POST['needident'] . "','" . $_POST['nfire'] . "','" . $_POST['nwater'] . "','" . $_POST['nair'] . "','" . $_POST['nearth'] . "','" . $_POST['nlight'] . "','" . $_POST['ngray'] . "','" . $_POST['ndark'] . "','" . $_POST['gfire'] . "','" . $_POST['gwater'] . "','" . $_POST['gair'] . "','" . $_POST['gearth'] . "','" . $_POST['glight'] . "','" . $_POST['ggray'] . "','" . $_POST['gdark'] . "','" . $_POST['encicl'] . "','0','" . $_POST['letter'] . "','" . $_POST['isrep'] . "','" . $_POST['razdel'] . "');")) {
// echo "Предмет успешно добавлен";
// } else {
// echo "Предмет не был добавлен!-1";
// };
//
// if ($_POST['shop'] == 2) if (mysql_query("INSERT INTO fshop(name,duration,maxdur,cost,ecost,nlevel,nsila,nlovk,ninta,nvinos,nintel,nmudra,nnoj,ntopor,ndubina,nmech,nalign,minu,maxu,goden,gsila,glovk,ginta,gintel,ghp,mfkrit,mfakrit,mfuvorot,mfauvorot,gnoj,gtopor,gdubina,gmech,img,count,bron1,bron2,bron3,bron4,magic,type,massa,needident,nfire,nwater,nair,nearth,nlight,ngray,ndark,gfire,gwater,gair,gearth,glight,ggray,gdark,letter,isrep,razdel) VALUES ('" . $_POST['name'] . "','" . $_POST['duration'] . "','" . $_POST['maxdur'] . "','" . $_POST['cost'] . "','" . $_POST['ecost'] . "','" . $_POST['nlevel'] . "','" . $_POST['nsila'] . "','" . $_POST['nlovk'] . "','" . $_POST['ninta'] . "','" . $_POST['nvinos'] . "','" . $_POST['nintel'] . "','" . $_POST['nmudra'] . "','" . $_POST['nnoj'] . "','" . $_POST['ntopor'] . "','" . $_POST['ndubina'] . "','" . $_POST['nmech'] . "','" . $_POST['nalign'] . "','" . $_POST['minu'] . "','" . $_POST['maxu'] . "','" . $goden_tmp . "','" . $_POST['gsila'] . "','" . $_POST['glovk'] . "','" . $_POST['ginta'] . "','" . $_POST['gintel'] . "','" . $_POST['ghp'] . "','" . $_POST['mfkrit'] . "','" . $_POST['mfakrit'] . "','" . $_POST['mfuvorot'] . "','" . $_POST['mfauvorot'] . "','" . $_POST['gnoj'] . "','" . $_POST['gtopor'] . "','" . $_POST['gdubina'] . "','" . $_POST['gmech'] . "','" . $_POST['img'] . "','" . $_POST['count'] . "','" . $_POST['bron1'] . "','" . $_POST['bron2'] . "','" . $_POST['bron3'] . "','" . $_POST['bron4'] . "','" . $_POST['magic'] . "','" . $_POST['type'] . "','" . $_POST['massa'] . "','" . $_POST['needident'] . "','" . $_POST['nfire'] . "','" . $_POST['nwater'] . "','" . $_POST['nair'] . "','" . $_POST['nearth'] . "','" . $_POST['nlight'] . "','" . $_POST['ngray'] . "','" . $_POST['ndark'] . "','" . $_POST['gfire'] . "','" . $_POST['gwater'] . "','" . $_POST['gair'] . "','" . $_POST['gearth'] . "','" . $_POST['glight'] . "','" . $_POST['ggray'] . "','" . $_POST['gdark'] . "','" . $_POST['letter'] . "','" . $_POST['isrep'] . "','" . $_POST['razdel'] . "');")) {
// echo "Предмет успешно добавлен";
// } else {
// echo "Предмет не был добавлен!" . mysql_error();
// };
//
} }
//End item adder ?>
<form method=post>
<div>
<table>
<caption>Добавление вещей в игру</caption>
<tr>
<th id="main">Основное
<tr>
<td><input name="name" placeholder="Название">
<tr>
<td><input name="image" placeholder="Картинка">
<tr>
<td><select name="shop">
<option value="0" selected disabled>Тип магазина</option>
<option value="1">Обычный</option>
<option value="2">Цветной</option>
</select>
<tr>
<td><input name=count placeholder="Количество (шт.)" disabled>
<tr>
<td><select name="item_type">
<option value="0" selected disabled>Тип предмета</option>
<option value="1">Шлем</option>
<option value="2">Броня</option>
<option value="3">Поножи</option>
<option value="4">Сапоги</option>
<option value="5">Перчатки</option>
<option value="6">Оружие</option>
<option value="7">Щит</option>
<option value="8">Пояс</option>
<option value="9">Кольцо</option>
<option value="10">Амулет</option>
<option value="20">Расходник</option>
<option value="50">Всё остальное</option>
<option value="100">Хлам</option>
</select>
<tr>
<td><input name=weight placeholder="Масса">
<tr>
<td><input name=durability placeholder="Макс. износ">
<tr>
<td><input name=price placeholder="Цена (кр.)" disabled>
<tr>
<th id="needs">Требования
<tr>
<td><input name=need_level placeholder="Уровень">
<tr>
<td><input name=need_strength placeholder="Сила">
<tr>
<td><input name=need_dexterity placeholder="Ловкость">
<tr>
<td><input name=need_intuition placeholder="Интуиция">
<tr>
<td><input name=need_endurance placeholder="Выносливость">
<tr>
<td><input name=need_intelligence placeholder="Интеллект">
<tr>
<td><input name=need_wisdom placeholder="Мудрость">
<tr>
<th id="adds">Характеристики
<tr>
<td><input name=minu placeholder="Мин.урон">
<tr>
<td><input name=maxu placeholder="Макс.урон">
<tr>
<td><input name=add_strength placeholder="Сила">
<tr>
<td><input name=add_dexterity placeholder="Ловкость">
<tr>
<td><input name=add_intuition placeholder="Интуиция">
<tr>
<td><input name=add_endurance placeholder="Выносливость">
<tr>
<td><input name=add_intelligence placeholder="Интеллект">
<tr>
<td><input name=add_wisdom placeholder="Мудрость">
<tr>
<td><input name=add_accuracy placeholder="Точность">
<tr>
<td><input name=add_evasion placeholder="Уворот">
<tr>
<td><input name=add_criticals placeholder="Крит">
<tr>
<td><input name=add_min_physical_damage placeholder="Мин.удар">
<tr>
<td><input name=add_min_physical_damage placeholder="Макс.удар">
</table>
<INPUT TYPE="submit" value="Добавить">
</div>
</form>

View File

@ -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);
}
}