From 1fbd8d6de29800c01b3ba2d8dc48d0516863badd Mon Sep 17 00:00:00 2001 From: Maksym Date: Mon, 23 Jan 2023 07:33:19 +0100 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=B8=D1=91=D0=BC=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Techniques/TechniqueCategoryEntity.php | 14 ++ .../Battle/Techniques/TechniquesEntity.php | 25 ++++ _incl_data/class/DarksLight2/Entity.php | 122 ++++++++++++++++++ _incl_data/class/Priems.php | 80 +++++------- js/title.js | 14 ++ modules_data/_umenie.php | 100 +++++--------- 6 files changed, 239 insertions(+), 116 deletions(-) create mode 100644 _incl_data/class/DarksLight2/Battle/Techniques/TechniqueCategoryEntity.php create mode 100644 _incl_data/class/DarksLight2/Battle/Techniques/TechniquesEntity.php create mode 100644 _incl_data/class/DarksLight2/Entity.php diff --git a/_incl_data/class/DarksLight2/Battle/Techniques/TechniqueCategoryEntity.php b/_incl_data/class/DarksLight2/Battle/Techniques/TechniqueCategoryEntity.php new file mode 100644 index 00000000..12169e3b --- /dev/null +++ b/_incl_data/class/DarksLight2/Battle/Techniques/TechniqueCategoryEntity.php @@ -0,0 +1,14 @@ +table)) { + try { + $class = new ReflectionClass($this); + $table_name = preg_replace( + '/_entity/', + '', + $this->toSnakCase($class->getShortName()) + ); + + if (!Db::getRow("SHOW TABLES LIKE '$table_name'")) { + throw new Exception( + 'Undefined table ' . $table_name . ' in database' + ); + } + + $this->table = $table_name; + } catch (Exception $e) { + die; + } + } + + return $this->table; + } + + public function morph(array $object) { + + $class = new ReflectionClass(get_called_class()); + + try { + $entity = $class->newInstance(); + } catch (ReflectionException $e) { + die($e->getMessage()); + } + + foreach($class->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) { + if (isset($object[$prop->getName()])) { + $prop->setValue($entity,$object[$prop->getName()]); + } + } + + return $entity; + } + + public function find(array $condition): ?Entity + { + $query = "SELECT * FROM {$this->getTable()} WHERE "; + $values = []; + + foreach ($condition as $field => $value) { + $values[] = $value; + $query .= "$field = ?"; + } + + $request = Db::prepare("$query LIMIT 1"); + $request->execute($values); + + if($result = $request->fetch()) { + return self::morph($result); + } + + return null; + } + + /** + * @param array|null $condition + * + * @return Entity[]|null + */ + public function findAll(?array $condition = null): ?array + { + if(!isset($condition)) { + $query = "SELECT * FROM {$this->getTable()}"; + } else { + $query = "SELECT * FROM {$this->getTable()} WHERE "; + $values = []; + + foreach ($condition as $field => $value) { + $values[] = $value; + $query .= "$field = ?"; + } + } + + $request = Db::prepare("$query"); + $request->execute($values ?? null); + + if($rows = $request->fetchAll()) { + $result = []; + foreach ($rows as $row) { + $result[] = self::morph($row); + } + return $result; + } + + return null; + } + + public function save(): void + { + + } +} \ No newline at end of file diff --git a/_incl_data/class/Priems.php b/_incl_data/class/Priems.php index 7af8851b..9e4a4465 100644 --- a/_incl_data/class/Priems.php +++ b/_incl_data/class/Priems.php @@ -2020,11 +2020,9 @@ class Priems public function uns($id) { global $u, $c, $code; - $pl = mysql_fetch_assoc( - mysql_query( - 'SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1' - ) - ); + + $pl = $this->getTechniquesInfo($id); + if (!isset($pl['id']) || $this->testpriem($pl, 1) != 0) { return; } @@ -2129,13 +2127,13 @@ class Priems $cli2 = ' class="nopriemuse" '; } - $pr .= ''; + $pr .= ''; } else { if (isset($_GET['inv'])) { - $pr .= ''; + $pr .= ''; } else { - $pr .= ''; + $pr .= ''; } } @@ -2516,50 +2514,38 @@ class Priems return $r; } - //выводим все доступные приемы игроку на его уровне - 1, выводим все доступные приемы только игроку - 2 - public function seePriems($mt) + public function getTechniquesInfo(?int $id = null): array { - global $code; - $t = $this->u->items['tr']; - $nm = [1 => 'hit', 2 => 'krit', 3 => 'counter', 4 => 'block', 5 => 'parry', 6 => 'hp', 7 => 'spirit']; - $lvlfe = $this->u->info['level']; - if (isset($_GET['all'])) { - $lvlfe = 21; + if(isset($id)) { + return Db::getRow('SELECT * FROM techniques_categories LEFT JOIN priems ON techniques_categories.technique_id = priems.id + WHERE priems.level <= ? AND priems.activ > 0 AND priems.id = ? ORDER BY priems.img,priems.level', [User::start()->info['level'], $id]); } - $sp = mysql_query( - 'SELECT * FROM `priems` WHERE `level`<="' . $lvlfe . '" AND `activ` > "0" ORDER BY `img`,`level` ASC' - ); - $this->u->info['lvl'] = $this->u->info['level']; - $lvar = ''; - while ($pl = mysql_fetch_assoc($sp)) { - $noaki = 0; - if ($pl['activ'] == 1 || $this->testActiv($pl['activ']) == 1) { - $lvar = $this->priemInfo($pl, 1); - $lvar = $lvar[0]; - $cl = ''; - $a1 = ''; - $a2 = ''; - if ($this->pyes($pl['id']) || $this->testpriem($pl, 1) > 0) { - if ((isset($_GET['all']) && $_GET['all'] == 1) || $this->pyes($pl['id'])) { - $cl = 'filter: alpha(opacity=35); -moz-opacity: 0.35; -khtml-opacity: 0.35; opacity: 0.35;'; - $a1 = ''; - $a2 = ''; - } else { - $noaki = 1; - } - } - if ($noaki == 0) { - $mtnu = explode('_', $pl['img']); - if ($mtnu[0] != 'wis') { - $mtnu = $mtnu[0]; - } else { - $mtnu = 'wis_' . $mtnu[1]; - } - echo $a1 . '' . $a2; - } + return Db::getRows('SELECT * FROM techniques_categories LEFT JOIN priems ON techniques_categories.technique_id = priems.id + WHERE priems.level <= ? AND priems.activ > 0 ORDER BY priems.img,priems.level', [User::start()->info['level']]); + } + + public function getByCategory(?int $category_id = null) + { + + $priems = $this->getTechniquesInfo(); + + $cl = ''; + + foreach ($priems as $priem) { + + if ($this->pyes($priem['id']) || $this->testpriem($priem, 1) > 0) { + $cl = 'filter: alpha(opacity=35); -moz-opacity: 0.35; -khtml-opacity: 0.35; opacity: 0.35;'; } + + echo + <<< HTML + + + + HTML; } + } private function zeromax($num, $max) diff --git a/js/title.js b/js/title.js index 2fe1ebf5..b883329f 100644 --- a/js/title.js +++ b/js/title.js @@ -60,6 +60,20 @@ function himove(e) { $('#ttl').css({'top': `${y}px`, 'left': `${x}px`}); } +function popup(element, content, width = 230) { + + let el_offset = $(element).offset() + let popup = $('#ttl'); + + popup.html(content); + popup.css({ + 'display': 'block', + 'top': el_offset.top + 20 + 'px', + 'left': el_offset.left + 40 + 'px', + 'width': width + 'px' + }); +} + function hi(el, txt, e, tp, st, sm, fm, css) { if (!e) e = window.event; top.xyfmn = [el, txt, e, tp, st, sm, fm, css]; diff --git a/modules_data/_umenie.php b/modules_data/_umenie.php index ea1bba4f..370f50ef 100644 --- a/modules_data/_umenie.php +++ b/modules_data/_umenie.php @@ -1,4 +1,7 @@ $re

"; } ?> - Выбранные приемы:
- seeMy(1); ?>
- Приёмы для выбора: -
- seePriems(1); ?> +
+
+ Выбранные приемы + + + + seeMy(1); ?> +
- - -
- Категории - - - Все -
- Приемы атаки -
- Приемы защиты -
- Приемы - контрударов -
- Приемы критических - ударов -
- Приемы - парирования -
- Комбо-приемы -
- Приемы крови -
- Приемы жертвы -
- Приемы силы духа -
- Заклинания - Огня -
- Заклинания - Воды -
- Заклинания - Воздуха -
- Заклинания - Земли -
- Заклинания магии - Света -
- Заклинания Серой - магии -
- Заклинания магии - Тьмы
-
-
-
- - - - - - - - -
-
- Показывать приёмы + +
+
+ Категории + +
+ findAll(); + + foreach ($categories as $category) { + ?> + + +
+
 
-