game/AI.php

193 lines
6.6 KiB
PHP
Raw Normal View History

2023-11-09 17:24:47 +00:00
<?php
use Core\Db;
use Helper\Conversion;
use Item\Data\Bonuses;
use Item\Data\Properties;
use Item\Data\Requirements;
use Model\Constant\ShopOtdel;
ini_set('xdebug.var_display_max_depth', 10);
ini_set('xdebug.var_display_max_children', 256);
ini_set('xdebug.var_display_max_data', 1024);
if (!defined('GAME_VERSION')) {
require_once '_incl_data/autoload.php';
}
//const GAME = true;
$user = User::start();
//var_dump($user->info['testStats'], $user->info['testStats2']);
//exit();
$im = Db::getColumn("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'items_main'");
$iu = Db::getColumn("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'items_users'");
$u = Db::getColumn("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'users'");
$s = Db::getColumn("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'stats'");
$p = Db::getRows('select * from const_stats');
var_dump((new ShopOtdel())->getGroups());
?>
<div style="display: grid; grid-template-columns: 50% 50%; word-wrap: break-word;">
<div>
<b><u>$user->[info]</u></b><br>
<?php
$rr = 1;
foreach ($user->info as $k => $v) {
if (isset($user->is[$k])) {
$k .= " <span style='background-color: lightcyan;'>[{$user->is[$k]}]</span>";
}
if ($k == 'stats') {
echo 'stats = ARRAY<br>';
foreach (Conversion::dataStringToArray($v) as $dk => $dv) {
if (isset($user->is[$dk])) {
$dk .= " <span style='background-color: lightcyan;'>[{$user->is[$dk]}]</span>";
}
echo "<span style='background-color: #99FFCC; margin-left: 5px;'>$dk = $dv</span><br>";
}
$k = '';
$v = '';
}
echo "$rr. $k = $v<br>";
$rr++;
}
?>
</div>
<div>
<b><u>$user->[stats]</u></b><br>
<?php
$rr = 1;
foreach ($user->stats as $k => $v) {
if (isset($user->is[$k])) {
$k .= " <span style='background-color: lightcyan;'>[{$user->is[$k]}]";
} else {
$k = "<span>$k";
}
echo "$rr. $k</span> = $v<br>";
$rr++;
if (is_array($v)) {
foreach ($v as $k2 => $v2) {
echo "<span style='background-color: #99FFCC; margin-left: 5px;'>$k2 = $v2</span><br>";
if (is_array($v2)) {
foreach ($v2 as $k3 => $v3) {
echo "<span style='background-color: aliceblue; margin-left: 10px;'>$k3 = $v3</span><br>";
if ($k3 === 'data' && $v3 !== '[]') {
$v3 .= '|add_mib2=43';
$itemData = Conversion::dataStringToArray($v3);
echo 'DATA TR_<br>';
foreach ((new Requirements($itemData))->get() as $k => $v) {
echo "$k = $v<br>";
}
echo 'DATA ADD_<br>';
foreach ((new Bonuses($itemData))->get() as $k => $v) {
echo "$k = $v<br>";
}
}
}
}
}
}
}
?>
</div>
</div>
<br>
<div style="display: grid; grid-template-columns: auto auto;">
<div> Поля в базе users
<?php var_dump($u); ?>
</div>
<div> Поля в базе stats
<?php var_dump($s); ?>
</div>
</div>
<div style="margin-top: 10px; background-color: aliceblue">Отдельно, уже согласованные параметры предметов, которые могут находиться исключительно в поле data</div>
<div style="display: grid; grid-template-columns: auto auto auto; background-color: aliceblue">
<div> sv_* (хотим убрать)
<?php var_dump(Properties::$names); ?>
</div>
</div>
<div style="display: grid; grid-template-columns: auto auto;">
<div> Поля в базе items_main
<?php var_dump($im); ?>
</div>
<div> Поля в базе items_users
<?php var_dump($iu); ?>
</div>
</div>
<hr>
<hr> Параметры игрока.<br><br>
<div style="display: grid; grid-template-columns: auto auto auto;">
<div> Заскриптованные
<?php var_dump($user->is); ?>
</div>
<div> Хотим оставить
</div>
<div> Хотим убрать
</div>
</div>
<?php
2023-11-09 17:24:47 +00:00
echo "<h5>Текущая таблица параметров</h5>";
foreach ($p as $prow) {
echo "{$prow['sys_name']}{$prow['name']}";
if ($prow['is_percentage']) {
echo " (%)";
}
if ($prow['is_requirement']) {
echo " <span style='background-color: lightpink;'>[требуется]</span> ";
}
if ($prow['is_bonus']) {
echo " <span style='background-color: lightgreen;'>[даёт]</span> ";
}
echo "<br>";
}
$stats = Db::getRows('select id, stats from stats');
$sarr = [];
foreach ($stats as $stat) {
$data = Conversion::dataStringToArray($stat['stats']);
$arr = [
'uid' => $stat['id'],
's1' => $data['s1'] ?? 0,
's2' => $data['s2'] ?? 0,
's3' => $data['s3'] ?? 0,
's4' => $data['s4'] ?? 0,
's5' => $data['s5'] ?? 0,
's6' => $data['s6'] ?? 0,
's7' => $data['s7'] ?? 0,
'a1' => $data['a1'] ?? 0,
'a2' => $data['a2'] ?? 0,
'a3' => $data['a3'] ?? 0,
'a4' => $data['a4'] ?? 0,
'mg1' => $data['mg1'] ?? 0,
'mg2' => $data['mg2'] ?? 0,
'mg3' => $data['mg3'] ?? 0,
'mg4' => $data['mg4'] ?? 0,
];
unset($data['s1'], $data['s2'], $data['s3'], $data['s4'], $data['s5'], $data['s6'], $data['s7'],
$data['a1'], $data['a2'], $data['a3'], $data['a4'],
$data['mg1'], $data['mg2'], $data['mg3'], $data['mg4']);
$arr['tails'] = Conversion::arrayToDataString($data);
$arr['tails_json'] = json_encode($data);
$sarr[] = $arr;
}
var_dump($sarr);