Зачатки MVC

This commit is contained in:
lopar
2020-07-04 13:49:43 +03:00
parent 25a6f17d7e
commit c6316820a0
6 changed files with 146 additions and 3 deletions

56
classes/ItemTypes.php Normal file
View File

@@ -0,0 +1,56 @@
<?php
/**
* Author: lopiu
* Date: 04.07.2020
* Time: 12:33
*/
trait ItemTypes
{
public function getItemName($item_type_id) {
switch ($item_type_id) {
case 1:
$this->typename = 'Серьги';
break;
case 2:
$this->typename = 'Ожерелье';
break;
case 3:
$this->typename = 'Оружие';
break;
case 4:
$this->typename = 'Броня';
break;
case 5:
$this->typename = 'Кольцо';
break;
case 8:
$this->typename = 'Шлем';
break;
case 9:
$this->typename = 'Перчатки';
break;
case 10:
$this->typename = 'Щит';
break;
case 11:
$this->typename = 'Обувь';
break;
case 12:
$this->typename = 'Магический свиток';
break;
case 22:
$this->typename = 'Рубашка';
break;
case 50:
$this->typename = 'Волшебное зелье';
break;
case 200:
$this->typename = 'Сувенир';
break;
default:
$this->typename = 'Хлам';
}
}
}

59
classes/Rooms.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
/**
* Author: lopiu
* Date: 04.07.2020
* Time: 11:10
*/
trait Rooms
{
/**
* Возвращает имя комнаты по её ID.
* @param $room_id - ID комнаты.
* @return string
*/
public function getRoomName($room_id)
{
switch ($room_id) {
default:
$this->roomname = "Неизвестная локация";
break;
case 1:
$this->roomname = "Дом поединков";
break;
case 20:
$this->roomname = "Центральная площадь";
break;
case 21:
$this->roomname = "Страшилкина улица";
break;
case 22:
$this->roomname = "Магазин";
break;
case 23:
$this->roomname = "Ремонтная мастерская";
break;
case 24:
$this->roomname = "Памятник Архангелу";
break;
case 25:
$this->roomname = "Комиссионный магазин";
break;
case 26:
$this->roomname = "Большая парковая улица";
break;
case 27:
$this->roomname = "Почта";
break;
case 28:
$this->roomname = "Регистратура кланов";
break;
case 29:
$this->roomname = "Банк";
break;
}
return $this->roomname;
}
}

View File

@@ -31,6 +31,8 @@ class User
public $exp;
public $stats;
use Rooms;
public function __construct($user)
{
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
@@ -62,4 +64,11 @@ PRESENT_AFTER;
}
}
public function showUserInfo() {
$dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i' AND dressed_slot > 0, $this->id);
foreach ($dressed_items->fetch_assoc() as $item) {
}
}
}