Изменил отображение приёмов
This commit is contained in:
parent
d9ec810f7f
commit
1fbd8d6de2
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DarksLight2\Battle\Techniques;
|
||||||
|
|
||||||
|
use DarksLight2\Entity;
|
||||||
|
use DarksLight2\Traits\Singleton;
|
||||||
|
|
||||||
|
class TechniqueCategoryEntity extends Entity
|
||||||
|
{
|
||||||
|
use Singleton;
|
||||||
|
|
||||||
|
public int $id;
|
||||||
|
public string $name;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DarksLight2\Battle\Techniques;
|
||||||
|
|
||||||
|
use DarksLight2\Entity;
|
||||||
|
use DarksLight2\Traits\Singleton;
|
||||||
|
|
||||||
|
class TechniquesEntity extends Entity
|
||||||
|
{
|
||||||
|
use Singleton;
|
||||||
|
|
||||||
|
public int $id;
|
||||||
|
public string $name;
|
||||||
|
public string $description;
|
||||||
|
public string $image;
|
||||||
|
public int $category_id;
|
||||||
|
public int $delay;
|
||||||
|
public float $spirit_points;
|
||||||
|
public int $critical_points;
|
||||||
|
public int $parry_points;
|
||||||
|
public int $defense_points;
|
||||||
|
public int $damage_points;
|
||||||
|
public ?int $skip;
|
||||||
|
public int $level;
|
||||||
|
}
|
122
_incl_data/class/DarksLight2/Entity.php
Normal file
122
_incl_data/class/DarksLight2/Entity.php
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DarksLight2;
|
||||||
|
|
||||||
|
use Core\Db;
|
||||||
|
use Exception;
|
||||||
|
use ReflectionClass;
|
||||||
|
use ReflectionException;
|
||||||
|
use ReflectionProperty;
|
||||||
|
|
||||||
|
abstract class Entity
|
||||||
|
{
|
||||||
|
protected string $table;
|
||||||
|
|
||||||
|
public function toSnakCase($string): string
|
||||||
|
{
|
||||||
|
return strtolower(preg_replace(['/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'], '$1_$2', $string));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTable(): string
|
||||||
|
{
|
||||||
|
if(!isset($this->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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2020,11 +2020,9 @@ class Priems
|
|||||||
public function uns($id)
|
public function uns($id)
|
||||||
{
|
{
|
||||||
global $u, $c, $code;
|
global $u, $c, $code;
|
||||||
$pl = mysql_fetch_assoc(
|
|
||||||
mysql_query(
|
$pl = $this->getTechniquesInfo($id);
|
||||||
'SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (!isset($pl['id']) || $this->testpriem($pl, 1) != 0) {
|
if (!isset($pl['id']) || $this->testpriem($pl, 1) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2129,13 +2127,13 @@ class Priems
|
|||||||
$cli2 = ' class="nopriemuse" ';
|
$cli2 = ' class="nopriemuse" ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$pr .= '<a onMouseOver="top.hi(this,\'<b>' . $pl['name'] . '</b><Br>' . $lvar . '\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" ' . $cl . '><img ' . $cli2 . ' style="margin-top:3px; ' . $cl2 . ' margin-left:4px;" src="https://img.new-combats.com/i/eff/' . $pl['img'] . '.gif" width="40" height="25" /></a>';
|
$pr .= '<a onMouseOver="top.hi(this,\'<b>' . $pl['name'] . '</b><Br>' . $lvar . '\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" ' . $cl . '><img ' . $cli2 . ' style="margin-top:3px; ' . $cl2 . ' margin-left:4px;" src="https://img.new-combats.com/i/eff/' . $pl['img'] . '.gif" width="55" height="35" /></a>';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (isset($_GET['inv'])) {
|
if (isset($_GET['inv'])) {
|
||||||
$pr .= '<a title="Перейти к настройкам приемов" href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&rz=4&p_raz=all\'"><img style="margin-top:4px; margin-left:4px;" src="https://img.new-combats.com/i/items/w/clearPriem.gif" width="40" height="25" /></a>';
|
$pr .= '<a title="Перейти к настройкам приемов" href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&rz=4&p_raz=all\'"><img style="margin-top:4px; margin-left:4px;" src="https://img.new-combats.com/i/items/w/clearPriem.gif" width="55" height="35" /></a>';
|
||||||
} else {
|
} else {
|
||||||
$pr .= '<img style="margin-top:4px; margin-left:4px;" src="https://img.new-combats.com/i/items/w/clearPriem.gif" width="40" height="25" />';
|
$pr .= '<img style="margin-top:4px; margin-left:4px;" src="https://img.new-combats.com/i/items/w/clearPriem.gif" width="55" height="35" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2516,50 +2514,38 @@ class Priems
|
|||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
//выводим все доступные приемы игроку на его уровне - 1, выводим все доступные приемы только игроку - 2
|
public function getTechniquesInfo(?int $id = null): array
|
||||||
public function seePriems($mt)
|
|
||||||
{
|
{
|
||||||
global $code;
|
if(isset($id)) {
|
||||||
$t = $this->u->items['tr'];
|
return Db::getRow('SELECT * FROM techniques_categories LEFT JOIN priems ON techniques_categories.technique_id = priems.id
|
||||||
$nm = [1 => 'hit', 2 => 'krit', 3 => 'counter', 4 => 'block', 5 => 'parry', 6 => 'hp', 7 => 'spirit'];
|
WHERE priems.level <= ? AND priems.activ > 0 AND priems.id = ? ORDER BY priems.img,priems.level', [User::start()->info['level'], $id]);
|
||||||
$lvlfe = $this->u->info['level'];
|
|
||||||
if (isset($_GET['all'])) {
|
|
||||||
$lvlfe = 21;
|
|
||||||
}
|
}
|
||||||
$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 = '<a href="javascript:void(0)" onclick="location.href=\'main.php?skills=1&all=' . ((int)$_GET['all']) . '&rz=4&use_priem=' . $pl['id'] . '&rnd=' . $code . '&p_raz=\' + p_raz;">';
|
|
||||||
$a2 = '</a>';
|
|
||||||
|
|
||||||
if ($this->pyes($pl['id']) || $this->testpriem($pl, 1) > 0) {
|
return Db::getRows('SELECT * FROM techniques_categories LEFT JOIN priems ON techniques_categories.technique_id = priems.id
|
||||||
if ((isset($_GET['all']) && $_GET['all'] == 1) || $this->pyes($pl['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;';
|
$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 . '<img class="pwq' . $mtnu . ' pwqall" onMouseOver="top.hi(this,\'(#' . $pl['id'] . ') <b>' . $pl['name'] . '</b><Br>' . $lvar . '\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" style="margin-top:2px; ' . $cl . ' margin-left:1px;" src="https://img.new-combats.com/i/eff/' . $pl['img'] . '.gif" width="40" height="25" />' . $a2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo
|
||||||
|
<<< HTML
|
||||||
|
<a href="javascript:void(0)" onclick="location.href='main.php?skills=1&rz=4&use_priem=$priem[id]';">
|
||||||
|
<img class="pwq$priem[category_id] pwqall" onMouseOver="top.popup(this, '(#$priem[id]) <b>$priem[name]</b><Br>{$this->priemInfo($priem, 1)[0]}');" onMouseOut="top.hic();" onMouseDown="top.hic();" style="display:none;margin-top:2px; $cl margin-left:1px;" src="https://img.new-combats.com/i/eff/$priem[img].gif" width="40" height="25" />
|
||||||
|
</a>
|
||||||
|
HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function zeromax($num, $max)
|
private function zeromax($num, $max)
|
||||||
|
14
js/title.js
14
js/title.js
@ -60,6 +60,20 @@ function himove(e) {
|
|||||||
$('#ttl').css({'top': `${y}px`, 'left': `${x}px`});
|
$('#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) {
|
function hi(el, txt, e, tp, st, sm, fm, css) {
|
||||||
if (!e) e = window.event;
|
if (!e) e = window.event;
|
||||||
top.xyfmn = [el, txt, e, tp, st, sm, fm, css];
|
top.xyfmn = [el, txt, e, tp, st, sm, fm, css];
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use DarksLight2\Battle\Techniques\TechniqueCategoryEntity;
|
||||||
|
|
||||||
if (!defined('GAME')) {
|
if (!defined('GAME')) {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
@ -1651,75 +1654,35 @@ $tma = '';
|
|||||||
echo !$re ?: "<br> <b style='color:red;'>$re</b><br><br>";
|
echo !$re ?: "<br> <b style='color:red;'>$re</b><br><br>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<B>Выбранные приемы:</B><BR>
|
<div style="display: flex; width: 100%;text-align: center;">
|
||||||
<?php $priem->seeMy(1); ?><br>
|
<fieldset style="width: 100%">
|
||||||
<B>Приёмы для выбора:</B>
|
<legend><b>Выбранные приемы</b></legend>
|
||||||
<div>
|
<input type="button" class="btn" value="Запомнить набор" onclick="top.savePriems(); return false;" >
|
||||||
<?php $priem->seePriems(1); ?>
|
<input type="button" class="btn" value="Очистить слоты" onclick="window.location.href = '/main.php?skills=1&rz=4&all=<?= $_GET[all] ?>&clear_abil=1'; return false;">
|
||||||
|
|
||||||
|
<?php $priem->seeMy(1); ?>
|
||||||
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
|
||||||
<td valign="top" align=right width=1>
|
<div style="display: flex; width: 100%">
|
||||||
<FIELDSET>
|
<fieldset style="width: 50%">
|
||||||
<LEGEND>Категории</LEGEND>
|
<legend><b>Категории</b></legend>
|
||||||
<SMALL>
|
|
||||||
<NOBR>
|
<div style="display: flex;
|
||||||
<A href="#" onclick='show_div("all"); return(false)'>Все</A>
|
flex-wrap: wrap;
|
||||||
<BR>
|
flex-direction: column;
|
||||||
<A href="#" onclick='show_div("hit"); return(false)'>Приемы атаки</A>
|
justify-content: center;">
|
||||||
<BR>
|
<?php
|
||||||
<A href="#" onclick='show_div("block"); return(false)'>Приемы защиты</A>
|
$categories = TechniqueCategoryEntity::getInstance()->findAll();
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("counter"); return(false)'>Приемы
|
foreach ($categories as $category) {
|
||||||
контрударов</A>
|
?>
|
||||||
<BR>
|
<div style='margin-right: 10px;height: 20px'><a onclick='show_div("<?=$category->id?>")' href='#'><?=$category->name?></a></div>
|
||||||
<A href="#" onclick='show_div("krit"); return(false)'>Приемы критических
|
<?php
|
||||||
ударов</A>
|
}
|
||||||
<BR>
|
?>
|
||||||
<A href="#" onclick='show_div("parry"); return(false)'>Приемы
|
</div>
|
||||||
парирования</A>
|
</fieldset>
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("multi"); return(false)'>Комбо-приемы</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("hp"); return(false)'>Приемы крови</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("blood"); return(false)'>Приемы жертвы</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("spirit"); return(false)'>Приемы силы духа</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_fire"); return(false)'>Заклинания
|
|
||||||
Огня</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_water"); return(false)'>Заклинания
|
|
||||||
Воды</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_air"); return(false)'>Заклинания
|
|
||||||
Воздуха</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_earth"); return(false)'>Заклинания
|
|
||||||
Земли</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_light"); return(false)'>Заклинания магии
|
|
||||||
Света</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_gray"); return(false)'>Заклинания Серой
|
|
||||||
магии</A>
|
|
||||||
<BR>
|
|
||||||
<A href="#" onclick='show_div("wis_dark"); return(false)'>Заклинания магии
|
|
||||||
Тьмы</A><BR>
|
|
||||||
</NOBR>
|
|
||||||
</SMALL>
|
|
||||||
</FIELDSET>
|
|
||||||
<SCRIPT>show_div(p_raz);</SCRIPT>
|
|
||||||
</td>
|
|
||||||
<td valign="top" align="right">
|
|
||||||
<table width="200" align=right cellpadding=0 cellspacing=0>
|
|
||||||
<tr>
|
|
||||||
<form name=F1 action="?skills=1&rz=4" method="GET">
|
|
||||||
<input type="hidden" name="skills" value="1">
|
|
||||||
<input type="hidden" name="rz" value="4">
|
|
||||||
<td>
|
|
||||||
<FIELDSET>
|
|
||||||
<LEGEND>Показывать приёмы</LEGEND>
|
|
||||||
|
|
||||||
<INPUT TYPE=radio ID=A1 NAME=all value=0 <?php
|
<INPUT TYPE=radio ID=A1 NAME=all value=0 <?php
|
||||||
if ($_GET['all'] == 0) {
|
if ($_GET['all'] == 0) {
|
||||||
@ -1754,7 +1717,6 @@ $tma = '';
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<td> </td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user