Compare commits
186 Commits
037d43857d
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c85c61d0c | |||
| 8efb371909 | |||
| 655987979f | |||
| bfd9e0c5a3 | |||
| f614e5ef83 | |||
| c7be3e57f8 | |||
| bf17b19309 | |||
| acd9c98d38 | |||
| 69641b49c3 | |||
| 1f6626ea33 | |||
| 26f28a9be8 | |||
| 8be1c6cd7e | |||
| c51dbaeae3 | |||
| 0abc1bb2f5 | |||
| faa472f2a1 | |||
| c9d6565b09 | |||
| c8d3bc83f8 | |||
| bbf409b3d2 | |||
| af827a262a | |||
| 9623695242 | |||
| 268d7463ee | |||
| c3591977b8 | |||
| 47e90c261b | |||
| d7d8db2198 | |||
| 9c8b6bd89c | |||
| 70f6e3252d | |||
| 8b83ef3ba8 | |||
| 9b243ec729 | |||
| a2775be423 | |||
| 490b9bc901 | |||
| f761c22950 | |||
| 4c6a5d055b | |||
| ad80a30a5f | |||
| 44856fa9c1 | |||
| 5f25fcd7e5 | |||
| 774bc82556 | |||
| cf614b5fd2 | |||
| ea46cd7f35 | |||
| fc17eada24 | |||
| 1645f58a63 | |||
| ce2691971b | |||
| 3e753c8b93 | |||
| def933dca4 | |||
| a14232a899 | |||
| 2abd435798 | |||
| 4113c4a1da | |||
| 53f0e1108f | |||
| bdbb359e20 | |||
| e0b08e0b1a | |||
| 707d6c5c99 | |||
| 82e48d473b | |||
| 7535cc657a | |||
| eb971fbc65 | |||
| 3b4bbf3a6a | |||
| be5779ff27 | |||
| 0e832dbbc2 | |||
| 5f48c6f67d | |||
| 6f006ed790 | |||
| 045803087d | |||
| 294575021a | |||
| 0ab73fe5e2 | |||
| c4aeb53f57 | |||
| d1663a34cf | |||
| 5c01742890 | |||
| fc663a8c42 | |||
| 80ef052c6e | |||
| 0f30620f61 | |||
| 0d2b4aba63 | |||
| 81a8161d32 | |||
| 63be6c94b3 | |||
| f557dbcd1a | |||
| e5c7ff4a33 | |||
| e359eb6f40 | |||
| e5e614d1d7 | |||
| afde0b1380 | |||
| 351cc5c6a2 | |||
| e4bf3fd342 | |||
| deac9203bd | |||
| f4a66a1147 | |||
| d36d5361f2 | |||
| 7266569f69 | |||
| 08b43f096e | |||
| c4f0485960 | |||
| fff3de0a98 | |||
| a412d334ae | |||
| 77f3135f7a | |||
| 77f8a0056e | |||
| 12e75d2c34 | |||
| 9de7415f08 | |||
| cffcf57031 | |||
| 74b644fe59 | |||
| b378e8e117 | |||
| ad182a21fe | |||
| 2d3f23f81b | |||
| 83ec9d12f9 | |||
| 01b00cc392 | |||
| 4d4743e888 | |||
| b7dd8d2d2e | |||
| 0796da3c53 | |||
| 9001974e2f | |||
| 059b8e9579 | |||
| 89a8c47471 | |||
| 5df55f8623 | |||
| 92772463e6 | |||
| 1500eb9364 | |||
| 6185c43e00 | |||
| b064cb349c | |||
| be1b631a18 | |||
| 22c2348ed4 | |||
| 8b2accf246 | |||
| c6c6e32ac4 | |||
| 6eca7863ce | |||
| 49a7f3a273 | |||
| d2cf95ef55 | |||
| 48ca7b4109 | |||
| b76f096196 | |||
| c2eae44401 | |||
| b055071e2e | |||
| bff6e87ab8 | |||
| adc1f81007 | |||
| 802f0a2ad0 | |||
| 7270ec2004 | |||
| 5e06f5e136 | |||
| f49f8cd08d | |||
| 0668d3de5f | |||
| 2440ad3cc1 | |||
| a073a02176 | |||
| 0163cb5be6 | |||
| 72c502d94a | |||
| cf2aea847a | |||
| 02c76e76ad | |||
| 2bc67ce543 | |||
| 3dc4cf7284 | |||
| 2d63efd915 | |||
| ec11709a86 | |||
| 6afdb1a1be | |||
| bdda3d24a0 | |||
| f92aa003ac | |||
| 92318be837 | |||
| 4e9d2deed4 | |||
| e2daf51a5f | |||
| 3893a1c734 | |||
| c77107c3bf | |||
| f8e02fd793 | |||
| cfaf82f73a | |||
| 3f3ffc2114 | |||
| 0a8662c591 | |||
| 4c4136577c | |||
| d82a2e3103 | |||
| c41f36644c | |||
| 01b504e677 | |||
| 1b5bf26294 | |||
| fdf063d527 | |||
| c3d7f0c649 | |||
| 6344d11dc3 | |||
| 22b9b7097c | |||
| c97071a642 | |||
| 00ecc3a862 | |||
| 075165d37d | |||
| b7003d0c63 | |||
| d9bf4b0bdc | |||
| 656e3549eb | |||
| 395153f291 | |||
| 253a8dca63 | |||
| a9dc9af61e | |||
| 00c76de9d5 | |||
| acf6a2d167 | |||
| ea01cd0a56 | |||
| 99b90a198b | |||
| a9ab7257e8 | |||
| 6095358496 | |||
| b619cd302b | |||
| 72fe6139c6 | |||
| 2d3bd006c0 | |||
| 1fbd8d6de2 | |||
| 571ba4dffb | |||
| f0a9a3e8a1 | |||
| 46c1e38ea8 | |||
| dcc6a1337c | |||
| d1be4995e2 | |||
| 5518b335a8 | |||
| 95604fc4b1 | |||
| 5df2447d34 | |||
| 328e7483cd | |||
| 3f579afaed | |||
| bae941e155 |
+79
-1
@@ -1 +1,79 @@
|
||||
/.idea/
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
DefaultLanguage ru
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
#Options +FollowSymLinks -MultiViews
|
||||
|
||||
Options -Indexes
|
||||
Options -MultiViews
|
||||
RewriteEngine On
|
||||
@@ -14,10 +14,7 @@ RewriteCond %{HTTP:PROXY_CONNECTION} !^$ [OR]
|
||||
RewriteCond %{HTTP:XPROXY_CONNECTION} !^$ [OR]
|
||||
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
|
||||
RewriteCond %{HTTP:HTTP_CLIENT_IP} !^$
|
||||
RewriteRule (.+) https://new-combats.com/proxy/
|
||||
|
||||
RewriteCond %{SERVER_PORT} 80
|
||||
RewriteRule ^(.*)$ https://new-combats.com/$1 [R,L]
|
||||
RewriteRule (.+) https://new-combats.tech/proxy/
|
||||
|
||||
RewriteBase /
|
||||
RewriteCond %{ENV:REDIRECT} !^yes$
|
||||
@@ -79,7 +76,7 @@ RewriteRule ^repass/?$ /repass.php [L]
|
||||
RewriteRule ^mail/(.*)/?$ /mailconf.php?$1 [L]
|
||||
|
||||
RewriteRule ^register/?$ /register.php [L]
|
||||
#RewriteRule ^register1/?$ /register1.php [L]
|
||||
|
||||
RewriteRule ^reg/?$ /register.php [L]
|
||||
|
||||
RewriteRule ^enter/?$ /enter.php [L]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
open_basedir=/home/newcom1/public_html/:/usr/local/lib/php/:/tmp
|
||||
@@ -1,222 +1,486 @@
|
||||
<?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 (isset($_GET['m1'])) {
|
||||
define('GAME', true);
|
||||
|
||||
|
||||
|
||||
include_once '_incl_data/__config.php';
|
||||
include_once '_incl_data/class/__db_connect.php';
|
||||
|
||||
$sp = mysql_query('SELECT * FROM `users_recombats` WHERE `email` != "" ORDER BY `name` DESC LIMIT 7000');
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
echo "<br>" . $pl['email'];
|
||||
}
|
||||
} elseif (isset($_GET['bk1'])) {
|
||||
define('GAME', true);
|
||||
|
||||
|
||||
|
||||
include('_incl_data/__config.php');
|
||||
include('_incl_data/class/__db_connect.php');
|
||||
$u = User::start();
|
||||
|
||||
$ins = 'Вещи БК-1:<hr>';
|
||||
$sp = mysql_query('SELECT * FROM `items_main` WHERE `geni` = 1');
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
|
||||
$po = mysql_fetch_array(
|
||||
mysql_query('SELECT * FROM `items_main_data` WHERE `items_id` = "' . $pl['id'] . '" LIMIT 1')
|
||||
);
|
||||
$po = $u->lookStats($po['data']);
|
||||
|
||||
if (!isset($po['add_minAtack']) && isset($po['sv_minAtack'])) {
|
||||
$po['add_minAtack'] = $po['sv_minAtack'];
|
||||
$po['add_maxAtack'] = $po['sv_maxAtack'];
|
||||
}
|
||||
|
||||
$ins .= 'INSERT INTO `items_main` (
|
||||
`id`, `name`, `img`, `art`, `type`, `inslot`, `use_magic`, `price`, `price2`, `iznosMAXi`, `massa`, `tr_level`, `tr_s1`, `tr_s2`, `tr_s3`, `tr_s4`, `tr_s5`, `tr_s6`, `add_s1`, `add_s2`, `add_s3`, `add_s4`, `add_s5`, `add_s6`, `add_hp`, `add_mp`, `add_m1`, `add_m2`, `add_m3`, `add_m4`, `add_b1`, `add_b2`, `add_b3`, `add_b4`, `add_attack_min`, `add_attack_max`
|
||||
,`tr_a1`,`tr_a2`,`tr_a3`,`tr_a4`,`tr_mg1`,`tr_mg2`,`tr_mg3`,`tr_mg4`,`tr_mg5`,`tr_mg6`,`tr_mg7`
|
||||
,`add_a1`,`add_a2`,`add_a3`,`add_a4`,`add_mg1`,`add_mg2`,`add_mg3`,`add_mg4`,`add_mg5`,`add_mg6`,`add_mg7`
|
||||
) VALUES ';
|
||||
$ins .= '(
|
||||
NULL,
|
||||
"' . $pl['name'] . '",
|
||||
"' . $pl['img'] . '",
|
||||
"' . (0 + round($po['art'])) . '",
|
||||
"' . $pl['type'] . '",
|
||||
"' . $pl['inslot'] . '",
|
||||
"",
|
||||
"' . $pl['price1'] . '",
|
||||
"' . $pl['price2'] . '",
|
||||
"' . $pl['iznosMAXi'] . '",
|
||||
"' . $pl['massa'] . '",
|
||||
"' . (0 + round($po['tr_lvl'])) . '",
|
||||
"' . (0 + round($po['tr_s1'])) . '",
|
||||
"' . (0 + round($po['tr_s2'])) . '",
|
||||
"' . (0 + round($po['tr_s3'])) . '",
|
||||
"' . (0 + round($po['tr_s4'])) . '",
|
||||
"' . (0 + round($po['tr_s5'])) . '",
|
||||
"' . (0 + round($po['tr_s6'])) . '",
|
||||
"' . (0 + round($po['add_s1'])) . '",
|
||||
"' . (0 + round($po['add_s2'])) . '",
|
||||
"' . (0 + round($po['add_s3'])) . '",
|
||||
"' . (0 + round($po['add_s4'])) . '",
|
||||
"' . (0 + round($po['add_s5'])) . '",
|
||||
"' . (0 + round($po['add_s6'])) . '",
|
||||
"' . (0 + round($po['add_hpAll'])) . '",
|
||||
"' . (0 + round($po['add_mpAll'])) . '",
|
||||
"' . (0 + round($po['add_m1'])) . '",
|
||||
"' . (0 + round($po['add_m2'])) . '",
|
||||
"' . (0 + round($po['add_m3'])) . '",
|
||||
"' . (0 + round($po['add_m4'])) . '",
|
||||
"' . (0 + round($po['add_mib1'])) . '",
|
||||
"' . (0 + round($po['add_mib2'])) . '",
|
||||
"' . (0 + round($po['add_mib3'])) . '",
|
||||
"' . (0 + round($po['add_mib4'])) . '",
|
||||
"' . (0 + round($po['add_minAtack'])) . '",
|
||||
"' . (0 + round($po['add_maxAtack'])) . '",
|
||||
"' . (0 + round($po['tr_a1'])) . '",
|
||||
"' . (0 + round($po['tr_a2'])) . '",
|
||||
"' . (0 + round($po['tr_a3'])) . '",
|
||||
"' . (0 + round($po['tr_a4'])) . '",
|
||||
"' . (0 + round($po['tr_mg1'])) . '",
|
||||
"' . (0 + round($po['tr_mg2'])) . '",
|
||||
"' . (0 + round($po['tr_mg3'])) . '",
|
||||
"' . (0 + round($po['tr_mg4'])) . '",
|
||||
"' . (0 + round($po['tr_mg5'])) . '",
|
||||
"' . (0 + round($po['tr_mg6'])) . '",
|
||||
"' . (0 + round($po['tr_mg7'])) . '",
|
||||
"' . (0 + round($po['add_a1'])) . '",
|
||||
"' . (0 + round($po['add_a2'])) . '",
|
||||
"' . (0 + round($po['add_a3'])) . '",
|
||||
"' . (0 + round($po['add_a4'])) . '",
|
||||
"' . (0 + round($po['add_mg1'])) . '",
|
||||
"' . (0 + round($po['add_mg2'])) . '",
|
||||
"' . (0 + round($po['add_mg3'])) . '",
|
||||
"' . (0 + round($po['add_mg4'])) . '",
|
||||
"' . (0 + round($po['add_mg5'])) . '",
|
||||
"' . (0 + round($po['add_mg6'])) . '",
|
||||
"' . (0 + round($po['add_mg7'])) . '"
|
||||
);';
|
||||
$ins .= "\n" . '<br>';
|
||||
}
|
||||
|
||||
echo $ins;
|
||||
|
||||
die();
|
||||
if (!defined('GAME_VERSION')) {
|
||||
require_once '_incl_data/autoload.php';
|
||||
}
|
||||
|
||||
if (isset($_GET['test'])) {
|
||||
$i = 3;
|
||||
//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());
|
||||
?>
|
||||
|
||||
|
||||
function yrn($sila)
|
||||
{
|
||||
return 2 + $_GET['test'] + $sila - round($sila / 5);
|
||||
}
|
||||
<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>";
|
||||
|
||||
while ($i <= 100) {
|
||||
echo '<div';
|
||||
if ($i == 8 || $i == 13 || $i == 18 || $i == 23) {
|
||||
echo ' style="background-color:green;color:#fff;"';
|
||||
} elseif ($i == 7 || $i == 12 || $i == 17 || $i == 22) {
|
||||
echo ' style="background-color:grey;color:#fff;"';
|
||||
}
|
||||
echo '> ';
|
||||
echo $i . ' = ' . yrn($i);
|
||||
echo '</div>';
|
||||
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>
|
||||
<hr>
|
||||
Совпадения по параметрам $user->info и $user->stats. Возможно, это ничего не значит, а может и дублирование.<br><br>
|
||||
|
||||
<?php
|
||||
$i = 1;
|
||||
$i2 = 1;
|
||||
foreach ($user->info as $a => $b) {
|
||||
if (isset($user->stats[$a])) {
|
||||
echo "$i. info = stats: $a = $b<br>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
if (!isset($_GET['robot']) && UserIp::get() != $_SERVER['SERVER_ADDR'] && UserIp::get() != '127.0.0.1' && UserIp::get(
|
||||
) != '' && UserIp::get() != '31.131.116.166') {
|
||||
die(UserIp::get() . '<br>' . $_SERVER['SERVER_ADDR']);
|
||||
}
|
||||
|
||||
|
||||
const GAME = true;
|
||||
|
||||
|
||||
|
||||
include('_incl_data/__config.php');
|
||||
include('_incl_data/class/__db_connect.php');
|
||||
|
||||
$count = [0, 0, 0, 0, 0, 0];
|
||||
|
||||
function inuser_go_btl($id)
|
||||
{
|
||||
if (isset($id['id'])) {
|
||||
file_get_contents(
|
||||
'https://new-combats.com/jx/battle/refresh.php?uid=' . $id['id'] . '&cron_core=' . md5(
|
||||
$id['id'] . '_brfCOreW@!_' . $id['pass']
|
||||
) . '&pass=' . $id['pass']
|
||||
);
|
||||
echo '<br>';
|
||||
foreach ($user->stats as $a2 => $b2) {
|
||||
if (isset($user->info[$a2])) {
|
||||
echo "$i2. stats = info: $a2 = $b2<br>";
|
||||
$i2++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
|
||||
$sp = mysql_query(
|
||||
'SELECT `u`.* , `s`.* FROM `stats` AS `s` LEFT JOIN `users` AS `u` ON `u`.`id` = `s`.`id` WHERE `u`.`pass` = "botforpeople" ORDER BY `s`.`nextAct` ASC LIMIT 200'
|
||||
);
|
||||
|
||||
$btltest = [];
|
||||
<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>
|
||||
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
<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>
|
||||
|
||||
$i++;
|
||||
<hr>
|
||||
<hr> Параметры игрока.<br><br>
|
||||
<div style="display: grid; grid-template-columns: auto auto auto;">
|
||||
<div> Заскриптованные
|
||||
<?php var_dump($user->is); ?>
|
||||
</div>
|
||||
<div> Хотим оставить
|
||||
|
||||
if ($pl['zv'] == 0 && ($pl['battle'] == 0 || !isset($btltest[$pl['battle']]) || $btltest[$pl['battle']] < 10)) {
|
||||
</div>
|
||||
<div> Хотим убрать
|
||||
|
||||
$btltest[$pl['battle']]++;
|
||||
</div>
|
||||
</div>
|
||||
<hr> Все возможные поля в $user->stats. Некоторые имена полей генерируются динамически на лету, поэтому соответствия имени нет. А каких-то, возможно просто не существует.<br><br>
|
||||
<?php
|
||||
|
||||
if ($pl['timereg'] == 0) {
|
||||
mysql_query('UPDATE `users` SET `timereg` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
|
||||
} else {
|
||||
User::setOnline($pl['id']);
|
||||
}
|
||||
$st['clanpos'] = 0;
|
||||
$st['levels'] = 0;
|
||||
$st['levels'] = 0;
|
||||
$st['id'] = 0;
|
||||
$st['login'] = 0;
|
||||
$st['lvl'] = 0;
|
||||
$st['hpNow'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['mpNow'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['zona'] = 0;
|
||||
$st['zonb'] = 0;
|
||||
$st['items'] = 0;
|
||||
$st['effects'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['vip'] = 0;
|
||||
$st['items_img'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['wp'] = 0;
|
||||
$st['items'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['art'] = 0;
|
||||
$st['maks_itm'] = 0;
|
||||
$st['zonb'] = 0;
|
||||
$st['zona'] = 0;
|
||||
$st['a'] = 0;
|
||||
$st['mg'] = 0;
|
||||
$st['s'] = 0;
|
||||
$st['effects'] = 0;
|
||||
$st['puti'] = 0;
|
||||
$st['slvtm'] = 0;
|
||||
$st['act'] = 0;
|
||||
$st['noeffectbattle1'] = 0;
|
||||
$st['items_img'] = 0;
|
||||
$st['set_pog'] = 0;
|
||||
$st['set_pog2'] = 0;
|
||||
$st['act'] = 0;
|
||||
$st['effects'] = 0;
|
||||
$st['raztac'] = 0;
|
||||
$st['set_natoe'] = 0;
|
||||
$st['act'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['s6'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['m5'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['zaproc'] = 0;
|
||||
$st['s5'] = 0;
|
||||
$st['m19'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['antm3'] = 0;
|
||||
$st['s5'] = 0;
|
||||
$st['m10'] = 0;
|
||||
$st['m11'] = 0;
|
||||
$st['m11a'] = 0;
|
||||
$st['m8'] = 0;
|
||||
$st['zona'] = 0;
|
||||
$st['zonb'] = 0;
|
||||
$st['pm'] = 0;
|
||||
$st['a'] = 0;
|
||||
$st['mg'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['s5'] = 0;
|
||||
$st['pm'] = 0;
|
||||
$st['s5'] = 0;
|
||||
$st['m11a'] = 0;
|
||||
$st['pm'] = 0;
|
||||
$st['a'] = 0;
|
||||
$st['aall'] = 0;
|
||||
$st['m2all'] = 0;
|
||||
$st['mg'] = 0;
|
||||
$st['m2all'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['zma'] = 0;
|
||||
$st['mib'] = 0;
|
||||
$st['mab'] = 0;
|
||||
$st['mg'] = 0;
|
||||
$st['pm'] = 0;
|
||||
$st['pa'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['mall'] = 0;
|
||||
$st['mg'] = 0;
|
||||
$st['mall'] = 0;
|
||||
$st['m11'] = 0;
|
||||
$st['pm'] = 0;
|
||||
$st['m11'] = 0;
|
||||
$st['m10'] = 0;
|
||||
$st['pa'] = 0;
|
||||
$st['m10'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['yzm'] = 0;
|
||||
$st['yzma'] = 0;
|
||||
$st['yza'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['hpVinos'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['mpVinos'] = 0;
|
||||
$st['s6'] = 0;
|
||||
$st['hpProc'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['mpProc'] = 0;
|
||||
$st['hpNow'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['hpNow'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['mpNow'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['mpNow'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['zona'] = 0;
|
||||
$st['zonb'] = 0;
|
||||
$st['ozash'] = 0;
|
||||
$st['ozmsh'] = 0;
|
||||
$st['weapon1'] = 0;
|
||||
$st['weapon2'] = 0;
|
||||
$st['sheld1'] = 0;
|
||||
$st['sv_'] = 0;
|
||||
$st['sv_i'] = 0;
|
||||
$st['dom'] = 0;
|
||||
$st['prsu'] = 0;
|
||||
$st['x'] = 0;
|
||||
$st['y'] = 0;
|
||||
$st['s'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['maxves'] = 0;
|
||||
$st['speed_dungeon'] = 0;
|
||||
$st['speedhp'] = 0;
|
||||
$st['exp'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['reting'] = 0;
|
||||
$st['btl_cof'] = 0;
|
||||
$st['prckr'] = 0;
|
||||
$st['btl_cof'] = 0;
|
||||
$st['prckr'] = 0;
|
||||
$st['btl_cof'] = 0;
|
||||
$st['prckr'] = 0;
|
||||
$st['prckr'] = 0;
|
||||
$st['id'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['this_animal'] = 0;
|
||||
$st['this_animal'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['add_'] = 0;
|
||||
$st['add_'] = 0;
|
||||
$st['add_'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['pa2'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['pa2'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['pa2'] = 0;
|
||||
$st['m7'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['pa2'] = 0;
|
||||
$st['m7'] = 0;
|
||||
$st['s1'] = 0;
|
||||
$st['pa2'] = 0;
|
||||
$st['m7'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['pa1'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['pa1'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['pa1'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['m15'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['pa1'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['m15'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['pa1'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['m15'] = 0;
|
||||
$st['s2'] = 0;
|
||||
$st['pa1'] = 0;
|
||||
$st['m2'] = 0;
|
||||
$st['m4'] = 0;
|
||||
$st['m15'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['pa4'] = 0;
|
||||
$st['m3'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['pa4'] = 0;
|
||||
$st['m3'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['pa4'] = 0;
|
||||
$st['m3'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['m5'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['pa4'] = 0;
|
||||
$st['m3'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['m5'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['s3'] = 0;
|
||||
$st['pa4'] = 0;
|
||||
$st['m3'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['m5'] = 0;
|
||||
$st['m14'] = 0;
|
||||
$st['m3'] = 0;
|
||||
$st['m1'] = 0;
|
||||
$st['m5'] = 0;
|
||||
$st['m14'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['m19'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['m19'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['s4'] = 0;
|
||||
$st['hpAll'] = 0;
|
||||
$st['za'] = 0;
|
||||
$st['zm'] = 0;
|
||||
$st['s5'] = 0;
|
||||
$st['m11'] = 0;
|
||||
$st['pzm'] = 0;
|
||||
$st['s6'] = 0;
|
||||
$st['mpAll'] = 0;
|
||||
$st['speedmp'] = 0;
|
||||
$st['s6'] = 0;
|
||||
$st['pzm'] = 0;
|
||||
$st['m10'] = 0;
|
||||
|
||||
if ($pl['bot'] == 0) {
|
||||
mysql_query('UPDATE `stats` SET `bot` = "2" WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
|
||||
}
|
||||
|
||||
User::setOnline($pl['id']);
|
||||
|
||||
BotLogic::start($pl['id']);
|
||||
|
||||
} else {
|
||||
|
||||
if ($pl['zv'] > 0) {
|
||||
BotLogic::start($pl['id']);
|
||||
}
|
||||
|
||||
if ($pl['timereg'] == 0) {
|
||||
mysql_query('UPDATE `users` SET `timereg` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
|
||||
} else {
|
||||
User::setOnline($pl['id']);
|
||||
}
|
||||
|
||||
if ($pl['bot'] == 0) {
|
||||
mysql_query('UPDATE `stats` SET `bot` = "2" WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
|
||||
}
|
||||
mysql_query('UPDATE `stats` SET `nextAct` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
|
||||
User::setOnline($pl['id']);
|
||||
|
||||
echo '*';
|
||||
$stnames = [];
|
||||
foreach ($st as $k => $v) {
|
||||
if (isset($user->is[$k])) {
|
||||
$v = $user->is[$k];
|
||||
}
|
||||
echo '+';
|
||||
echo '[' . $pl['login'] . '] -> Действие: ' . $pl['ipreg'] . ' , ожидаем: ' . ($pl['timeMain'] - time(
|
||||
)) . ' сек., заявка: ' . $pl['zv'] . ', поединок: ' . $pl['battle'] . '';
|
||||
echo '<hr>';
|
||||
$stnames[$k] = $v;
|
||||
}
|
||||
var_dump($stnames);
|
||||
|
||||
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>";
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
use Enum\ShopId;
|
||||
|
||||
?>
|
||||
<style>
|
||||
.wares {
|
||||
display: grid;
|
||||
grid-template-columns: 100px auto;
|
||||
background-color: #d4d4d4;
|
||||
}
|
||||
|
||||
.wares > div:nth-child(odd of .left), .wares > div:nth-child(odd of .left) + div {
|
||||
background-color: #c8c8c8;
|
||||
}
|
||||
|
||||
table.zerowide {
|
||||
width: 100%;
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table.zerowide td {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<form id="F1" name="F1" method="post"></form>
|
||||
<table class="zerowide">
|
||||
<tr>
|
||||
<td style="vertical-align: top;">
|
||||
<h3><?= $shopName ?></h3>
|
||||
<div style="text-align: center; font-weight: bold;"><span style="color: crimson;"> <?= $status ?></span></div>
|
||||
<table class="zerowide">
|
||||
<tr>
|
||||
<td style="text-align: left; vertical-align: top; padding: 4px;">
|
||||
<!--Магазин-->
|
||||
<div id="hint3" style="visibility:hidden"></div>
|
||||
<table class="zerowide" style="background-color: darkgrey;">
|
||||
<tr>
|
||||
<td style="text-align: center; height: 21px;">
|
||||
<?php if ($actionSale): ?>
|
||||
<strong>Отдел «Скупка»</strong><br>
|
||||
Здесь вы можете продать свои вещи, за жалкие гроши...<br>
|
||||
У вас в наличии:
|
||||
<?php elseif ($actionGifts): ?>
|
||||
<strong>Отдел «Сделать подарки»</strong>
|
||||
<?php elseif ($shop->shopOtdel->getName($otdel)): ?>
|
||||
<strong>Отдел «<?= $shop->shopOtdel->getName($otdel) ?>»</strong>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<!--Рюкзак / Прилавок-->
|
||||
<table class="zerowide" style="background-color: dimgrey;">
|
||||
<?php if ($actionGifts): ?>
|
||||
<tr>
|
||||
<td style="background-color: #d5d5d5;">
|
||||
Вы можете сделать подарок дорогому человеку. Ваш подарок будет отображаться в информации о персонаже.
|
||||
<input name="itemgift" id="itemgift" type="hidden" value="0" form="F1">
|
||||
<ol>
|
||||
<li>
|
||||
Укажите имя персонажа, которому хотите сделать подарок.
|
||||
<label>Имя <input name="to_login" form="F1"></label>
|
||||
</li>
|
||||
<?php if ($u->info['exp'] >= Present::EXP_NEEDED_FOR_ADD_PRESENT_TEXT): ?>
|
||||
<li>
|
||||
Поздравление. Будет отображаться в информации о персонаже (не более 60 символов).
|
||||
<label><input name="podarok2" size="50" maxlength="60" form="F1"></label>
|
||||
</li>
|
||||
<li>
|
||||
Приватное поздравление (в информации о персонаже не отображается).
|
||||
<label><textarea name="txt" cols="80" rows="6" form="F1"></textarea></label>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<li>
|
||||
Выберите, от чьего имени подарок:<br>
|
||||
<label style="font-weight: bold;"><input type="radio" name="from" value="0" checked form="F1"> <?= $u->info['login'] ?></label><br>
|
||||
<label><input type="radio" name="from" value="1" form="F1">анонимно</label><br>
|
||||
<?php if ($uc->isRegistered()): ?>
|
||||
<label><input type="radio" name="from" value="2" form="F1">от имени клана <?= $uc->getName() ?></label>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<li>
|
||||
Нажмите кнопку <strong>Подарить</strong> под предметом, который хотите преподнести в подарок:<br>
|
||||
</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($giftsvars): ?>
|
||||
<?php foreach ($giftsvars as $k => $v): ?>
|
||||
<tr>
|
||||
<td style="text-align: center; background-color: lightgrey;">
|
||||
<?php if ($k === 0): ?>
|
||||
<h3>Уникальные подарки</h3>
|
||||
<?php endif; ?>
|
||||
<table class="zerowide">
|
||||
<tr>
|
||||
<td style="width: 160px; text-align: center; border-right: 1px solid #a5a5a5; padding: 5px;">
|
||||
<img style="padding-bottom: 5px;" src="<?= $v['img'] ?>" alt=""><br>
|
||||
<button onclick="document.getElementById('itemgift').value=<?= $v['jsvalue'] ?>;document.getElementById('F1').submit();">
|
||||
Подарить за <?= $v['money'] ?> кр.
|
||||
</button>
|
||||
</td>
|
||||
<td style="vertical-align: top; border-right: 1px solid #a5a5a5; padding: 5px;">
|
||||
<a href="/item/0"><?= $v['linkname'] ?></a><br><small>Это именной подарок, его можете подарить только вы.</small>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td style="text-align: center; background-color: lightgrey;"><h3>Стандартные подарки</h3></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?= $itmAllSee ?>
|
||||
<?php elseif ($actionSale): ?>
|
||||
<?= $itmAllSee ?>
|
||||
<?php else: ?>
|
||||
<div class="wares">
|
||||
<?php $shop->printWares(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<td style="width: 280px; vertical-align: top;">
|
||||
<div style="display: flex; align-items: flex-end; font-size: smaller; flex-direction: column; gap: 2px;">
|
||||
<?= $goLis; ?>
|
||||
<?php if ($shopId === ShopId::MAIN->value): ?>
|
||||
<button onclick="location.href='main.php?loc=1.180.0.9&rnd=<?= $code; ?>'">Центральная Площадь</button>
|
||||
<button onclick="location.href='main.php?loc=1.180.0.368&rnd=<?= $code; ?>'">Подпольная лавка</button>
|
||||
<button onclick="location.href='main.php?loc=1.180.0.13&rnd=<?= $code; ?>'">Магазин «Берёзка»</button>
|
||||
<?php else: ?>
|
||||
<button onclick="location.href='main.php?loc=1.180.0.10&rnd=<?= $code; ?>'">Государственный магазин</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: grid; grid-template-columns: max-content max-content; font-size: smaller; justify-content: end; margin: 10px 0;">
|
||||
<div style="text-align: right; margin-right: 5px;">Масса:</div>
|
||||
<div style="font-weight: bold;"><?= $u->aves['now'] ?>/<?= $u->aves['max'] ?></div>
|
||||
<div style="text-align: right; margin-right: 5px;">У вас в наличии:</div>
|
||||
<div style="font-weight: bold; color: green"><?= $shop->getUserWallet() ?></div>
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<?php if (!$actionSale): ?>
|
||||
<INPUT class="btn" TYPE="button" value="Продать вещи" onclick="location='?otdel=<?= $otdel ?>&sale=1'">
|
||||
<?php else: ?>
|
||||
<INPUT class="btn" TYPE="button" value="Купить вещи" onclick="location='?otdel=<?= $otdel ?>'">
|
||||
<?php endif; ?>
|
||||
|
||||
<INPUT class="btn" TYPE="button" value="Обновить" onclick="location = '<?= str_replace('item', '', str_replace('buy', '', $_SERVER['REQUEST_URI'])); ?>';">
|
||||
</div>
|
||||
<BR>
|
||||
</div>
|
||||
<div style="background-color:#A5A5A5; padding:1px; text-align: center; font-weight: bold;">Отделы магазина</div>
|
||||
<div style="line-height:17px;">
|
||||
<?php
|
||||
/*названия разделов (справа)*/
|
||||
//$otdels = $shop->getUsedOtdels();
|
||||
$otdels[37] = "<span style='color: red'>$otdels[37]</span>";
|
||||
$otdels[100] = 'Сделать подарки';
|
||||
|
||||
//$i = 1;
|
||||
foreach ($otdels as $k => $v) {
|
||||
$color = $otdel === $k ? '#C7C7C7' : '#e2e0e0';
|
||||
if (in_array($k, array_keys($shop->shopOtdel->getGroups()))) {
|
||||
if ($i !== 1) {
|
||||
echo '<br>';
|
||||
}
|
||||
echo sprintf('<div style="background-color: #d5d5d5;"><img src="/i/shop_ico/%s.png" alt="%s"> <strong>%s</strong></div>',
|
||||
$i, $shop->shopOtdel->getGroups()[$k], $shop->shopOtdel->getGroups()[$k]);
|
||||
$i++;
|
||||
}
|
||||
if ($k === 100) {
|
||||
echo '<br><div style="background-color: #d5d5d5;"><b>Возможности:</b></div>';
|
||||
$k = '32&gifts=1';
|
||||
}
|
||||
echo '<a href="?otdel=' . $k . '"><div style="background-color: ' . $color . '"> ' . $v . '</a></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
</table>
|
||||
<br>
|
||||
<div id="textgo" style="visibility:hidden;"></div>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Core\Config;
|
||||
use Insallah\Tournaments\Tournament;
|
||||
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
ini_set('display_errors', 'Off');
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
date_default_timezone_set('Europe/Moscow');
|
||||
|
||||
header('Cache-Control: no-cache, no-store, must-revalidate');
|
||||
@@ -13,9 +12,6 @@ header('Expires: 0');
|
||||
|
||||
require_once 'mysql_override.php';
|
||||
|
||||
// Для всех доработок, пока нет автозагрузки классов.
|
||||
require_once 'class/Insallah/Config.php';
|
||||
|
||||
// Попробуем в автозагрузку.
|
||||
// Никогда не заработает с такими названиями классов и файлов!
|
||||
// "На потом."
|
||||
@@ -24,8 +20,8 @@ spl_autoload_register(function ($className) {
|
||||
# 2 without
|
||||
$fileName = [
|
||||
__DIR__ . '/class/' . str_replace('\\', '/', $className . '.php'),
|
||||
__DIR__ . '/class/' . $className . '.php'
|
||||
];
|
||||
__DIR__ . '/class/' . $className . '.php',
|
||||
];
|
||||
foreach ($fileName as $file) {
|
||||
if (file_exists($file)) {
|
||||
require_once $file;
|
||||
|
||||
+11
-24
@@ -1,23 +1,22 @@
|
||||
<?php
|
||||
|
||||
use DarksLight2\Training\Steps\FirstStep;
|
||||
use DarksLight2\Training\TrainingException;
|
||||
use DarksLight2\Training\TrainingManager;
|
||||
|
||||
//error_reporting(E_ALL);
|
||||
const GAME = true; // Для совместимости с этой "защитой".
|
||||
const GAME_VERSION = 'alpha-7.4';
|
||||
// Новая автозагрузка.
|
||||
// ВНИМАНИЕ! Не введено в эксплуатацию!
|
||||
|
||||
require_once 'mysql_override.php';
|
||||
require_once 'class/Insallah/Config.php';
|
||||
|
||||
spl_autoload_register(function (string $className) {
|
||||
$rootdir = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '_incl_data' . DIRECTORY_SEPARATOR;
|
||||
# 1 with namespaces
|
||||
# 2 without
|
||||
$fileName = [
|
||||
__DIR__ . '/class/' . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
|
||||
__DIR__ . '/class/' . $className . '.php'
|
||||
$rootdir . 'class' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
|
||||
$rootdir . 'class' . DIRECTORY_SEPARATOR . $className . '.php',
|
||||
$rootdir . 'function' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $className . '.php'),
|
||||
$rootdir . 'vendor' . DIRECTORY_SEPARATOR . $className . '.php',
|
||||
];
|
||||
foreach ($fileName as $file) {
|
||||
if (file_exists($file)) {
|
||||
@@ -28,10 +27,11 @@ spl_autoload_register(function (string $className) {
|
||||
});
|
||||
|
||||
spl_autoload_register(function (string $classname) {
|
||||
$rootdir = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '_incl_data';
|
||||
$classMap = [
|
||||
'NewCombats' => __DIR__ . '/class/',
|
||||
'Insallah' => __DIR__ . '/class/Insallah/',
|
||||
'DarksLight2' => __DIR__ . '/class/DarksLight2/',
|
||||
'NewCombats' => $rootdir . '/class/',
|
||||
'Insallah' => $rootdir . '/class/Insallah/',
|
||||
'DarksLight2' => $rootdir . '/class/DarksLight2/',
|
||||
];
|
||||
$parts = explode('\\', $classname);
|
||||
$namespace = array_shift($parts);
|
||||
@@ -49,17 +49,4 @@ spl_autoload_register(function (string $classname) {
|
||||
}
|
||||
|
||||
require_once $file;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Нужно перенести в другое местечко, но пока так
|
||||
*/
|
||||
try {
|
||||
$training_manager = TrainingManager::getInstance(User::start()->info['id']);
|
||||
$training_manager->createDatabaseRecord();
|
||||
$training_manager->register([
|
||||
new FirstStep(),
|
||||
]);
|
||||
} catch (TrainingException $e) {
|
||||
}
|
||||
});
|
||||
@@ -1,126 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
use Core\Db;
|
||||
use User;
|
||||
use Helper\Math;
|
||||
use Helper\Table;
|
||||
use User\ItemsModel;
|
||||
|
||||
class Achievements
|
||||
{
|
||||
private User $user;
|
||||
private $info;
|
||||
private array $info;
|
||||
private array $data = [
|
||||
'zb' => [
|
||||
'questname' => 'Ежедн.Задания',
|
||||
'quest' => 'Выполнить задания бабки.',
|
||||
'check' => ['Заданий', 5, 25, 50, 100, 250],
|
||||
'prize' => ['Жетон <br>успеха <br>', 5, 20, 40, 60, 100],
|
||||
'startlink' => 11
|
||||
'startlink' => 11,
|
||||
],
|
||||
'vx' => [
|
||||
'questname' => 'Хаотические бои',
|
||||
'quest' => 'Победить в хаотических боях.',
|
||||
'check' => ['Побед', 50, 300, 400, 500, 1000],
|
||||
'prize' => ['екр.', 25, 50, 75, 100, 200],
|
||||
'startlink' => 21
|
||||
'startlink' => 21,
|
||||
],
|
||||
'snt' => [
|
||||
'questname' => 'Сундук трупожора',
|
||||
'quest' => 'Открыть сундук трупожора.',
|
||||
'check' => ['Открытий', 5, 25, 50, 100, 250],
|
||||
'prize' => ['екр.', 10, 25, 50, 75, 200],
|
||||
'startlink' => 31
|
||||
'startlink' => 31,
|
||||
],
|
||||
'rp' => [
|
||||
'questname' => 'Руны 8 лвл.',
|
||||
'quest' => 'Получить руну при плавке плохих заготовок. [S]',
|
||||
'check' => ['Рун', 5, 10, 25, 50, 100],
|
||||
'prize' => ['Плохие <br> заготовки <br>', 5, 7, 10, 12, 15],
|
||||
'startlink' => 41
|
||||
'startlink' => 41,
|
||||
],
|
||||
'rn' => [
|
||||
'questname' => 'Руны 9 лвл.',
|
||||
'quest' => 'Получить руну при плавке нормальных заготовок. [M]',
|
||||
'check' => ['Рун', 5, 10, 15, 25, 50],
|
||||
'prize' => ['Нормальные <br> заготовки <br>', 5, 7, 9, 12, 15],
|
||||
'startlink' => 51
|
||||
'startlink' => 51,
|
||||
],
|
||||
'rb' => [
|
||||
'questname' => 'Руны 10 лвл.',
|
||||
'quest' => 'Получить руну при плавке идеальных заготовок. [L]',
|
||||
'check' => ['Рун', 2, 5, 8, 11, 15],
|
||||
'prize' => ['Идеальные <br> заготовки <br>', 2, 4, 6, 10, 15],
|
||||
'startlink' => 61
|
||||
'startlink' => 61,
|
||||
],
|
||||
'pg' => [
|
||||
'questname' => 'Героич. Сражения',
|
||||
'quest' => 'Поучаствовать в героическом сражении.',
|
||||
'check' => ['Участий', 100, 200, 400, 600, 1000],
|
||||
'prize' => ['Жетон <br>успеха <br>', 10, 20, 40, 60, 80],
|
||||
'startlink' => 71
|
||||
'startlink' => 71,
|
||||
],
|
||||
'bv' => [
|
||||
'questname' => 'Продажи Бабушке',
|
||||
'quest' => 'Продать бабушке найденные вещи в пещере.',
|
||||
'check' => ['Продаж', 5, 25, 50, 100, 250],
|
||||
'prize' => ['кр.', 500, 1000, 2000, 4000, 5000],
|
||||
'startlink' => 81
|
||||
'startlink' => 81,
|
||||
],
|
||||
'kw' => [
|
||||
'questname' => 'Клан Поединки',
|
||||
'quest' => 'Победить в клановой войне.',
|
||||
'check' => ['Побед', 5, 10, 15, 20, 25],
|
||||
'prize' => ['Свиток <br> кланового<br> опыта ', 1, 2, 5, 10, 15],
|
||||
'startlink' => 91
|
||||
'startlink' => 91,
|
||||
],
|
||||
'pa' => [ # not implemented!
|
||||
'questname' => 'Покровительство',
|
||||
'quest' => 'Получить покровительство Ангела.',
|
||||
'check' => ['Получено', 5, 25, 50, 100, 250],
|
||||
'prize' => null,
|
||||
'startlink' => null
|
||||
'startlink' => null,
|
||||
],
|
||||
'bs' => [
|
||||
'questname' => 'Башня смерти',
|
||||
'quest' => 'Победы в башне смерти.',
|
||||
'check' => ['Побед', 1, 5, 10, 50, 500],
|
||||
'prize' => ['екр.', 1, 5, 10, 50, 200],
|
||||
'startlink' => 101
|
||||
'startlink' => 101,
|
||||
],
|
||||
'trn' => [ # not implemented!
|
||||
'questname' => 'Турниры',
|
||||
'quest' => 'Поучавствовать в турнирах.',
|
||||
'check' => ['Побед', 25, 50, 100, 200, 500],
|
||||
'prize' => ['екр.', 25, 25, 25, 25, 50],
|
||||
'startlink' => 111
|
||||
'startlink' => 111,
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->info = Db::getRow('select * from users_achiv where id = ?', [$user->info['id']]);
|
||||
$this->info = Db::getRow('select * from users_achiv where id = ?', [$user->info['id']]) ?: [];
|
||||
}
|
||||
|
||||
//fixme: сюда иногда приходит (NULL, NULL).
|
||||
private function prizeName(?int $int, ?string $string): string
|
||||
{
|
||||
return in_array($string, ['екр.', 'кр.']) ? $int . ' ' . $string : $string . ' ' . $int;
|
||||
}
|
||||
|
||||
private function drawSunduk($nagr, $whatInside, $tier): string
|
||||
{
|
||||
return vsprintf(
|
||||
'<img onclick="%s" onmouseover="%s" onmouseout="%s" onmousedown="%s" class="cp" src="%s" alt="Сундук">',
|
||||
[
|
||||
"location.href='\main.php?titul&nagr=$nagr'",
|
||||
"top.hi(this, '<b>Сундук $tier ранга<hr>Содержит:<hr> $whatInside</b>', event, 2, 0, 1, 1, 'max-width:307px')",
|
||||
"top.hic();",
|
||||
"top.hic();",
|
||||
"https://img.new-combats.com/i/titul/nagr$tier.gif"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function getList(): string
|
||||
{
|
||||
@@ -161,8 +143,8 @@ class Achievements
|
||||
$this->prizeName($value['prize'][2], $value['prize'][0]),
|
||||
$this->prizeName($value['prize'][3], $value['prize'][0]),
|
||||
$this->prizeName($value['prize'][4], $value['prize'][0]),
|
||||
$this->prizeName($value['prize'][5], $value['prize'][0])
|
||||
]
|
||||
$this->prizeName($value['prize'][5], $value['prize'][0]),
|
||||
],
|
||||
], 'prizelist', true);
|
||||
# If has new tier, AND only first 5 tiers AND prize is set.
|
||||
if (
|
||||
@@ -183,7 +165,7 @@ class Achievements
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function calculateCurrent($check = null)
|
||||
private function calculateCurrent($check = null): void
|
||||
{
|
||||
$this->info['bs'] = $this->user->info['win_bs'];
|
||||
foreach ($this->info as $k => $v) {
|
||||
@@ -205,26 +187,46 @@ class Achievements
|
||||
$this->info["klasP$k"] = Math::get100Percentage($this->data[$k]['check'][1], $this->info[$k]);
|
||||
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
if ($this->info[$k] >= $this->data[$k]['check'][$i]) {
|
||||
$this->info["klas$k"] = $i;
|
||||
if ($i === 5) {
|
||||
# На 5 ранге должно отдавать максимум.
|
||||
$this->info["klasP$k"] = 100;
|
||||
} else {
|
||||
$this->info["klasP$k"] = Math::get100Percentage(
|
||||
$this->data[$k]['check'][$i + 1] - $this->data[$k]['check'][$i],
|
||||
$this->info[$k] - $this->data[$k]['check'][$i]
|
||||
);
|
||||
}
|
||||
if ($this->info[$k] < $this->data[$k]['check'][$i]) {
|
||||
continue;
|
||||
}
|
||||
$this->info["klas$k"] = $i;
|
||||
if ($i === 5) {
|
||||
# На 5 ранге должно отдавать максимум.
|
||||
$this->info["klasP$k"] = 100;
|
||||
} else {
|
||||
$this->info["klasP$k"] = Math::get100Percentage(
|
||||
$this->data[$k]['check'][$i + 1] - $this->data[$k]['check'][$i],
|
||||
$this->info[$k] - $this->data[$k]['check'][$i]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function prizeName(?int $int, ?string $string): string
|
||||
{
|
||||
return in_array($string, ['екр.', 'кр.']) ? $int . ' ' . $string : $string . ' ' . $int;
|
||||
}
|
||||
|
||||
private function drawSunduk($nagr, $whatInside, $tier): string
|
||||
{
|
||||
return vsprintf(
|
||||
'<img onclick="%s" onmouseover="%s" onmouseout="%s" onmousedown="%s" class="cp" src="%s" alt="Сундук">',
|
||||
[
|
||||
"location.href='\main.php?titul&nagr=$nagr'",
|
||||
"top.hi(this, '<b>Сундук $tier ранга<hr>Содержит:<hr> $whatInside</b>', event, 2, 0, 1, 1, 'max-width:307px')",
|
||||
"top.hic();",
|
||||
"top.hic();",
|
||||
"//img.new-combats.tech/i/titul/nagr$tier.gif",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function getInfo(?int $uid = null)
|
||||
{
|
||||
if (!is_null($uid)) {
|
||||
$this->info = \Core\Db::getRow('select * from users_achiv where id = ?', [$uid]);
|
||||
$this->info = Db::getRow('select * from users_achiv where id = ?', [$uid]) ?: [];
|
||||
}
|
||||
$this->calculateCurrent();
|
||||
return $this->info;
|
||||
@@ -236,11 +238,6 @@ class Achievements
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
private function addOne($name)
|
||||
{
|
||||
\Core\Db::sql("update users_achiv set $name = $name + 1 where id = ?", [$this->user->info['id']]);
|
||||
}
|
||||
|
||||
public function updateTier($name)
|
||||
{
|
||||
if (in_array($name, array_keys($this->data))) {
|
||||
@@ -248,6 +245,11 @@ class Achievements
|
||||
}
|
||||
}
|
||||
|
||||
private function addOne($name)
|
||||
{
|
||||
Db::sql("update users_achiv set $name = $name + 1 where id = ?", [$this->user->info['id']]);
|
||||
}
|
||||
|
||||
public function updateCounter($name)
|
||||
{
|
||||
if (in_array($name, array_keys($this->data))) {
|
||||
@@ -271,7 +273,7 @@ class Achievements
|
||||
public function givePrizeItems($itemId, $aType)
|
||||
{
|
||||
for ($i = 1; $i <= $this->data[$aType]['prize'][$this->info[$aType . '_n'] + 1]; $i++) {
|
||||
$this->user->addItem($itemId, $this->user->info['id']);
|
||||
ItemsModel::addItem($itemId, $this->user->info['id']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,4 +281,4 @@ class Achievements
|
||||
{
|
||||
return array_keys($this->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace Admin;
|
||||
|
||||
use Core\Db;
|
||||
|
||||
readonly class Monster
|
||||
{
|
||||
public array $info;
|
||||
|
||||
public function __construct(int $monsterid)
|
||||
{
|
||||
$this->info = Db::getRow('select * from aaa_monsters where uid = ?', [$monsterid]);
|
||||
if ($_SERVER['REQUEST_METHOD'] === OAUTH_HTTP_METHOD_POST) {
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function save(): void
|
||||
{
|
||||
$params['uid'] = $this->info['uid'];
|
||||
$params['start_room'] = (int)$_POST['bot_sroom'];
|
||||
|
||||
$params['start_day'] = (int)$_POST['bot_sday'];
|
||||
$params['start_dd'] = (int)$_POST['bot_sdd'];
|
||||
$params['start_mm'] = (int)$_POST['bot_smm'];
|
||||
$params['start_hh'] = (int)$_POST['bot_shh'];
|
||||
$params['start_min'] = (int)$_POST['bot_smin'];
|
||||
|
||||
$params['back_day'] = (int)$_POST['bot_bday'];
|
||||
$params['back_dd'] = (int)$_POST['bot_bdd'];
|
||||
$params['back_mm'] = (int)$_POST['bot_bmm'];
|
||||
$params['back_hh'] = (int)$_POST['bot_bhh'];
|
||||
$params['back_min'] = (int)$_POST['bot_bmin'];
|
||||
|
||||
$params['start_text'] = $_POST['bot_stext'];
|
||||
$params['back_text'] = $_POST['bot_btext'];
|
||||
$params['win_text'] = $_POST['bot_wintext'];
|
||||
$params['lose_text'] = $_POST['bot_losetext'];
|
||||
$params['nich_text'] = $_POST['bot_nichtext'];
|
||||
|
||||
$params['win_back'] = $_POST['bot_winback'];
|
||||
$params['time_restart'] = $_POST['bot_trs'];
|
||||
|
||||
$params['win_itm'] = $_POST['bot_winitm'];
|
||||
$params['win_money1'] = $_POST['bot_winmoney1'];
|
||||
$params['win_money2'] = $_POST['bot_winmoney2'];
|
||||
$params['win_exp'] = $_POST['bot_winexp'];
|
||||
$params['win_eff'] = $_POST['bot_wineff'];
|
||||
$params['win_ico'] = $_POST['bot_winico'];
|
||||
|
||||
$params['lose_itm'] = $_POST['bot_loseitm'];
|
||||
$params['lose_money'] = $_POST['bot_losemoney1'];
|
||||
$params['lose_money2'] = $_POST['bot_losemoney2'];
|
||||
$params['lose_exp'] = $_POST['bot_loseexp'];
|
||||
$params['lose_eff'] = $_POST['bot_loseeff'];
|
||||
$params['lose_ico'] = $_POST['bot_loseico'];
|
||||
|
||||
if (!isset(
|
||||
$params['uid'],
|
||||
$params['start_room'],
|
||||
$params['start_day'],
|
||||
$params['back_day'],
|
||||
$params['start_dd'],
|
||||
$params['start_mm'],
|
||||
$params['start_hh'],
|
||||
$params['start_min'],
|
||||
$params['back_min'],
|
||||
$params['back_dd'],
|
||||
$params['back_mm'],
|
||||
$params['back_hh'],
|
||||
$params['start_text'],
|
||||
$params['back_text'],
|
||||
$params['win_text'],
|
||||
$params['lose_text'],
|
||||
$params['nich_text'],
|
||||
$params['win_money1'],
|
||||
$params['win_money2'],
|
||||
$params['lose_money'],
|
||||
$params['lose_money2'],
|
||||
$params['win_exp'],
|
||||
$params['lose_exp'],
|
||||
$params['win_itm'],
|
||||
$params['lose_itm'],
|
||||
$params['win_eff'],
|
||||
$params['lose_eff'],
|
||||
$params['win_ico'],
|
||||
$params['lose_ico'],
|
||||
$params['win_back'],
|
||||
$params['time_restart']
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
Db::sql('replace into aaa_monsters
|
||||
(uid, start_room, start_day, back_day, start_dd, start_mm, start_hh, start_min,
|
||||
back_min, back_dd, back_mm, back_hh, start_text, back_text, win_text, lose_text,
|
||||
nich_text, win_money1, win_money2, lose_money, lose_money2, win_exp, lose_exp,
|
||||
win_itm, lose_itm, win_eff, lose_eff, win_ico, lose_ico, win_back, time_restart)
|
||||
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [
|
||||
$params['uid'],
|
||||
$params['start_room'],
|
||||
$params['start_day'],
|
||||
$params['back_day'],
|
||||
$params['start_dd'],
|
||||
$params['start_mm'],
|
||||
$params['start_hh'],
|
||||
$params['start_min'],
|
||||
$params['back_min'],
|
||||
$params['back_dd'],
|
||||
$params['back_mm'],
|
||||
$params['back_hh'],
|
||||
$params['start_text'],
|
||||
$params['back_text'],
|
||||
$params['win_text'],
|
||||
$params['lose_text'],
|
||||
$params['nich_text'],
|
||||
$params['win_money1'],
|
||||
$params['win_money2'],
|
||||
$params['lose_money'],
|
||||
$params['lose_money2'],
|
||||
$params['win_exp'],
|
||||
$params['lose_exp'],
|
||||
$params['win_itm'],
|
||||
$params['lose_itm'],
|
||||
$params['win_eff'],
|
||||
$params['lose_eff'],
|
||||
$params['win_ico'],
|
||||
$params['lose_ico'],
|
||||
$params['win_back'],
|
||||
$params['time_restart'],
|
||||
]);
|
||||
|
||||
echo '<b style="color: red">Новые данные были успешно сохранены!</b>';
|
||||
}
|
||||
}
|
||||
+5364
-6213
File diff suppressed because it is too large
Load Diff
+556
-490
File diff suppressed because it is too large
Load Diff
+261
-237
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Helper\Conversion;
|
||||
|
||||
class BotPriemLogic
|
||||
{
|
||||
|
||||
@@ -100,247 +102,13 @@ class BotPriemLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function usePriem($id, $on = null)
|
||||
{
|
||||
$go_txt = '&usepriem=' . $id;
|
||||
if ($on != '') {
|
||||
$on = str_replace(' ', '%20', $on);
|
||||
$go_txt .= '&useon=' . $on;
|
||||
}
|
||||
BotLogic::inuser_go_btl(BotLogic::$bot, $go_txt);
|
||||
}
|
||||
|
||||
//Ставка на опережение
|
||||
private static function priem220($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Разгадать тактику
|
||||
private static function priem217($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Обреченность
|
||||
private static function priem204($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Выжить
|
||||
private static function priem232($i)
|
||||
{
|
||||
if (self::hp() <= 30 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Жажда крови
|
||||
private static function priem188($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Шок удар
|
||||
private static function priem235($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Хлебнуть крови
|
||||
private static function priem240($i)
|
||||
{
|
||||
if (self::hp() <= 70) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Силовое поле
|
||||
private static function priem175($i)
|
||||
{
|
||||
self::usePriem($i);
|
||||
}
|
||||
|
||||
//Прикрыться
|
||||
private static function priem1($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Вломить
|
||||
private static function priem2($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Собрать зубы
|
||||
private static function priem3($i)
|
||||
{
|
||||
if (self::hp() <= 70 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Воля к победе
|
||||
private static function priem6($i)
|
||||
{
|
||||
if (self::hp() <= 40 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Танец ветра
|
||||
private static function priem8($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Танец лезвий
|
||||
private static function priem48($i)
|
||||
{
|
||||
if (rand(0, 100) < 70) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Дикая удача
|
||||
private static function priem9($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Слепая удача
|
||||
private static function priem47($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Предвиденье
|
||||
private static function priem10($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Второе дыхание
|
||||
private static function priem49($i)
|
||||
{
|
||||
if (rand(0, 100) < 80 && self::hp() <= 60) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Рывок
|
||||
private static function priem223($i)
|
||||
{
|
||||
if (self::hp() <= 50 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Удачный удар
|
||||
private static function priem11($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Стойкость
|
||||
private static function priem13($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Ярость
|
||||
private static function priem14($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Сильный удар
|
||||
private static function priem4($i)
|
||||
{
|
||||
if (rand(0, 100) < 60) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Утереть пот
|
||||
private static function priem5($i)
|
||||
{
|
||||
if (self::hp() <= 95) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Агрессивная защита
|
||||
private static function priem211($i)
|
||||
{
|
||||
if (rand(0, 100) < 80) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Полная защита
|
||||
private static function priem45($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Активная защита
|
||||
private static function priem7($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static function hp()
|
||||
{
|
||||
return round((BotLogic::$st['hpNow'] / BotLogic::$st['hpAll'] * 100), 2);
|
||||
}
|
||||
|
||||
//Тест на возможность использования
|
||||
private static function testpriem($pl)
|
||||
private static function testpriem($pl): int
|
||||
{
|
||||
global $u;
|
||||
$notr = 0;
|
||||
|
||||
$tr = $u->lookStats($pl['tr']);
|
||||
$d2 = $u->lookStats($pl['date2']);
|
||||
$tr = Conversion::dataStringToArray($pl['tr']);
|
||||
$d2 = Conversion::dataStringToArray($pl['date2']);
|
||||
|
||||
$x = 1;
|
||||
while ($x <= 7) {
|
||||
@@ -396,4 +164,260 @@ class BotPriemLogic
|
||||
|
||||
return $notr;
|
||||
}
|
||||
|
||||
//Ставка на опережение
|
||||
|
||||
private static function priem1($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Разгадать тактику
|
||||
|
||||
private static function usePriem($id)
|
||||
{
|
||||
BotLogic::inuser_go_btl(BotLogic::$bot, '&usepriem=' . $id);
|
||||
}
|
||||
|
||||
//Обреченность
|
||||
|
||||
private static function priem2($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Выжить
|
||||
|
||||
private static function priem3($i)
|
||||
{
|
||||
if (self::hp() <= 70 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Жажда крови
|
||||
|
||||
private static function hp(): float
|
||||
{
|
||||
return round((BotLogic::$st['hpNow'] / BotLogic::$st['hpAll'] * 100), 2);
|
||||
}
|
||||
|
||||
//Шок удар
|
||||
|
||||
private static function priem4($i)
|
||||
{
|
||||
if (rand(0, 100) < 60) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Хлебнуть крови
|
||||
|
||||
private static function priem5($i)
|
||||
{
|
||||
if (self::hp() <= 95) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Силовое поле
|
||||
|
||||
private static function priem6($i)
|
||||
{
|
||||
if (self::hp() <= 40 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Прикрыться
|
||||
|
||||
private static function priem7($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Вломить
|
||||
|
||||
private static function priem8($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Собрать зубы
|
||||
|
||||
private static function priem9($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Воля к победе
|
||||
|
||||
private static function priem10($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Танец ветра
|
||||
|
||||
private static function priem11($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Танец лезвий
|
||||
|
||||
private static function priem13($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Дикая удача
|
||||
|
||||
private static function priem14($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Слепая удача
|
||||
|
||||
private static function priem45($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Предвиденье
|
||||
|
||||
private static function priem47($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Второе дыхание
|
||||
|
||||
private static function priem48($i)
|
||||
{
|
||||
if (rand(0, 100) < 70) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Рывок
|
||||
|
||||
private static function priem49($i)
|
||||
{
|
||||
if (rand(0, 100) < 80 && self::hp() <= 60) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Удачный удар
|
||||
|
||||
private static function priem188($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Стойкость
|
||||
|
||||
private static function priem204($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Ярость
|
||||
|
||||
private static function priem211($i)
|
||||
{
|
||||
if (rand(0, 100) < 80) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Сильный удар
|
||||
|
||||
private static function priem217($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Утереть пот
|
||||
|
||||
private static function priem220($i)
|
||||
{
|
||||
if (rand(0, 100) < 30) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Агрессивная защита
|
||||
|
||||
private static function priem223($i)
|
||||
{
|
||||
if (self::hp() <= 50 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Полная защита
|
||||
|
||||
private static function priem232($i)
|
||||
{
|
||||
if (self::hp() <= 30 && rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Активная защита
|
||||
|
||||
private static function priem235($i)
|
||||
{
|
||||
if (rand(0, 100) < 50) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
private static function priem240($i)
|
||||
{
|
||||
if (self::hp() <= 70) {
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
//Тест на возможность использования
|
||||
|
||||
private static function priem175($i)
|
||||
{
|
||||
self::usePriem($i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Captcha;
|
||||
|
||||
class Captcha
|
||||
{
|
||||
private int $width;
|
||||
private int $height;
|
||||
private string $sum;
|
||||
|
||||
public function width(int $width): Captcha
|
||||
{
|
||||
$this->width = max($width, 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function height(int $height): Captcha
|
||||
{
|
||||
$this->height = max($height, 1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function newImage()
|
||||
{
|
||||
if ($this->width < 1 || $this->height < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$img = imagecreatetruecolor($this->width, $this->height) or die('Cannot create image'); // создаем картинку
|
||||
imagefill($img, 0, 0, 0x616161); // заполняем фон картинки
|
||||
$x = -20;
|
||||
$i = 1;
|
||||
$sum = "";
|
||||
$colorRGB = rand(180, 200); //цвет текста
|
||||
while ($i++ <= 5000) {
|
||||
imageSetPixel($img, rand(0, 105), rand(0, 24), 0x515151);
|
||||
}
|
||||
|
||||
//рисуем 2 линии
|
||||
imageLine($img, rand(0, 10), rand(0, 50), rand(95, 105), rand(0, 26), 0x909090);
|
||||
imageLine($img, rand(0, 10), rand(0, 50), rand(95, 105), rand(0, 26), 0x909090);
|
||||
//рамка
|
||||
imageRectangle($img, 0, 0, 105, 24, 0x343434);
|
||||
|
||||
$fonts = [
|
||||
'fonts/FRSCRIPT.ttf',
|
||||
'fonts/CHILLER.ttf',
|
||||
'fonts/Bradley Hand ITC.ttf',
|
||||
'fonts/de_Manu_2_Regular.ttf',
|
||||
'fonts/Edgar_da_cool_Regular.ttf',
|
||||
'fonts/Hurryup_Hurryup.ttf',
|
||||
'fonts/Fh_Script_Regular.ttf',
|
||||
'fonts/Gabo4_Gabo4.ttf',
|
||||
'fonts/JAMI_Regular.ttf',
|
||||
'fonts/Justy1_Regular.ttf',
|
||||
];
|
||||
$font = '../' . $fonts[rand(0, sizeof($fonts) - 1)];
|
||||
|
||||
$i = 1;
|
||||
while ($i++ <= 4) { // выводим одну цифру за один проход цикла
|
||||
imagettftext($img, 15, 0, $x = $x + 25, 20, imagecolorallocate($img, $colorRGB, $colorRGB, $colorRGB), $font, $rnd = mt_rand(0, 9)); // выводим текст поверх картинки
|
||||
$sum = $sum . $rnd; // Собираем в одну строку все символы на картинке
|
||||
}
|
||||
|
||||
ob_start();
|
||||
imagepng($img); // выводим готовую картинку в формате PNG
|
||||
$imgData = ob_get_clean();
|
||||
imagedestroy($img); // освобождаем память, выделенную для картинки
|
||||
|
||||
echo '<img src="data:image/png;base64,' . base64_encode($imgData) . '" alt="captcha">';
|
||||
$this->sum = $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSum(): string
|
||||
{
|
||||
return $this->sum;
|
||||
}
|
||||
}
|
||||
+169
-33
File diff suppressed because one or more lines are too long
@@ -0,0 +1,334 @@
|
||||
<?php
|
||||
|
||||
#todo кажется часть полей вроде city, room, color, invis напрямик зависит от login (отправитель)
|
||||
#todo если это так, частью сеттеров можно будет пожертвовать.
|
||||
|
||||
class ChatMessage
|
||||
{
|
||||
private string $city = 'capitalcity';
|
||||
private int $room = 0;
|
||||
private string $login = '';
|
||||
private string $to = '';
|
||||
private string $text;
|
||||
private int $time = 0;
|
||||
private int $type = 0;
|
||||
private int $typeTime = 0;
|
||||
private string $color = '#000';
|
||||
private int $sound = 0;
|
||||
private int $spam = 0;
|
||||
private bool $isAlert = false;
|
||||
private int $invis = 0;
|
||||
private int $da = 0;
|
||||
private int $delete = 0;
|
||||
private int $molch = 0;
|
||||
private int $dn = 0;
|
||||
/**
|
||||
* Феерверки, чёрт подери!
|
||||
* _incl_data\class\magic\feerverks.php
|
||||
* @var string|null
|
||||
*/
|
||||
private ?string $fireworks = null;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDn(): int
|
||||
{
|
||||
return $this->dn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dn
|
||||
*/
|
||||
public function setDn(int $dn): void
|
||||
{
|
||||
$this->dn = $dn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDelete(): int
|
||||
{
|
||||
return $this->delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $delete
|
||||
*/
|
||||
public function setDelete(int $delete): void
|
||||
{
|
||||
$this->delete = $delete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMolch(): int
|
||||
{
|
||||
return $this->molch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $molch
|
||||
*/
|
||||
public function setMolch(int $molch): void
|
||||
{
|
||||
$this->molch = $molch;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getInvis(): int
|
||||
{
|
||||
return $this->invis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $invis
|
||||
*/
|
||||
public function setInvis(int $invis): void
|
||||
{
|
||||
$this->invis = $invis;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDa(): int
|
||||
{
|
||||
return $this->da;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $da
|
||||
*/
|
||||
public function setDa(int $da): void
|
||||
{
|
||||
$this->da = $da;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpam(): int
|
||||
{
|
||||
return $this->spam;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $spam
|
||||
*/
|
||||
public function setSpam(int $spam): void
|
||||
{
|
||||
$this->spam = $spam;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSound(): int
|
||||
{
|
||||
return $this->sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sound
|
||||
*/
|
||||
public function setSound(int $sound): void
|
||||
{
|
||||
$this->sound = $sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCity(): string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getRoom(): int
|
||||
{
|
||||
return $this->room;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogin(): string
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTo(): string
|
||||
{
|
||||
return $this->to;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getText(): string
|
||||
{
|
||||
if ($this->isAlert) {
|
||||
return '<span style="color: red">Внимание!</span> ' . $this->text;
|
||||
}
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTime(): int
|
||||
{
|
||||
if (!$this->time) {
|
||||
$this->time = time();
|
||||
}
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTypeTime(): int
|
||||
{
|
||||
return $this->typeTime;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getColor(): string
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $city
|
||||
*/
|
||||
public function setCity(string $city): void
|
||||
{
|
||||
$this->city = $city;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $room
|
||||
*/
|
||||
public function setRoom(int $room): void
|
||||
{
|
||||
$this->room = $room;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $login
|
||||
*/
|
||||
public function setLogin(string $login): void
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $to
|
||||
*/
|
||||
public function setTo(string $to): void
|
||||
{
|
||||
$this->to = $to;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
*/
|
||||
public function setText(string $text): void
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $time
|
||||
*/
|
||||
public function setTime(int $time): void
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
*/
|
||||
public function setType(int $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $typeTime
|
||||
*/
|
||||
public function setTypeTime(int $typeTime): void
|
||||
{
|
||||
$this->typeTime = $typeTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $color
|
||||
*/
|
||||
public function setColor(string $color): void
|
||||
{
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Добавляет к сообщению красный префикс "Внимание!".
|
||||
* @param bool $isAlert
|
||||
*/
|
||||
public function setIsAlert(bool $isAlert): void
|
||||
{
|
||||
$this->isAlert = $isAlert;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFireworks(): ?string
|
||||
{
|
||||
return $this->fireworks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $fireworks
|
||||
*/
|
||||
public function setFireworks(?string $fireworks): void
|
||||
{
|
||||
$this->fireworks = $fireworks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Заглушка для опциональной передачи параметров.
|
||||
* @param string $json
|
||||
* @return void
|
||||
*/
|
||||
public function setParamsFromJson(string $json): void
|
||||
{
|
||||
$params = json_decode($json, true);
|
||||
foreach ($params as $param => $value) {
|
||||
$method = 'set' . ucfirst($param);
|
||||
if (method_exists(self::class, $method)) {
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Clan;
|
||||
|
||||
use Core\Db;
|
||||
|
||||
class ClanInfo
|
||||
{
|
||||
public static function isJoinable(string $name): bool
|
||||
{
|
||||
return Db::getValue('select count(name) from clan where name = ? and status = 1', [$name]) > 0;
|
||||
}
|
||||
|
||||
public static function getNameById(int $id): string
|
||||
{
|
||||
$clan = self::getById($id);
|
||||
return !empty($clan['name']) ? $clan['name'] : '';
|
||||
}
|
||||
|
||||
public static function getById(int $id): array
|
||||
{
|
||||
return Db::getRow('select * from clan where id = ? and status = 1', [$id]) ?: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace Clan;
|
||||
|
||||
use Core\Db;
|
||||
use Delo;
|
||||
use Helper\Conversion;
|
||||
use User;
|
||||
use User\ItemsModel;
|
||||
|
||||
class ItemStorage
|
||||
{
|
||||
private string $error = '';
|
||||
|
||||
public function put(int $itemId, int $clanId): string
|
||||
{
|
||||
$user = User::start()->info;
|
||||
$item = ItemsModel::getOwnedItemById($itemId, $user['id']);
|
||||
$clanName = Db::getValue('select name from clan where id = ?', [$clanId]) ?? '';
|
||||
if (empty($clanName)) {
|
||||
return 'Клан не найден.';
|
||||
}
|
||||
if (!$this->isGoodForStorage($item, $user['clan'])) {
|
||||
return $this->error;
|
||||
}
|
||||
$col = User::start()->itemsX(($itemId));
|
||||
$idata = Conversion::dataStringToArray($item['data']);
|
||||
if (!isset($idata['toclan'])) {
|
||||
$idata['toclan'] = $user['clan'] . '#' . $user['id'];
|
||||
$item['data'] = Conversion::arrayToDataString($idata);
|
||||
Delo::add(
|
||||
2,
|
||||
'System.transfer.clan',
|
||||
$user['id'],
|
||||
'"System.transfer.MONEY": Предмет "' . $item['name'] . '" (#id : "' . $itemId . '") (x' . $col . ') был пожертвован клану "' . $clanName . '" (' . $clanId . ').',
|
||||
);
|
||||
$sendType = 4;
|
||||
} else {
|
||||
$sendType = 3;
|
||||
}
|
||||
Db::sql(
|
||||
'insert into clan_operations (clan, time, type, text, val, uid) values (?,unix_timestamp(),?,?,?,?)',
|
||||
[$clanId, $sendType, $user['login'], $item['name'] . ("x$col Ид: [$itemId]"), $user['id']]
|
||||
);
|
||||
Db::sql(
|
||||
'update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?',
|
||||
['-21' . $user['clan'], $item['data'], $itemId]
|
||||
);
|
||||
|
||||
return 'Вы передали предмет "' . $item['name'] . '" клану.';
|
||||
}
|
||||
|
||||
private function isGoodForStorage(array $item, $userClanId): bool
|
||||
{
|
||||
if (empty($item['inslot']) || !empty($item['gift'])) {
|
||||
$this->error = 'Предмет не найден.';
|
||||
}
|
||||
$idata = Conversion::dataStringToArray($item['data']);
|
||||
if (
|
||||
!empty($idata['frompisher']) ||
|
||||
!empty($idata['sudba']) ||
|
||||
!empty($idata['icos']) ||
|
||||
!empty($idata['fromlaba'])
|
||||
) {
|
||||
$this->error = 'Предмет не подходит.';
|
||||
}
|
||||
if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $userClanId) {
|
||||
$this->error = 'Предмет уже принадлежит клану.';
|
||||
}
|
||||
return empty($this->error);
|
||||
}
|
||||
|
||||
public function ungive_itm_cl($id, $user, $cl): string
|
||||
{
|
||||
$itm_ = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` >= 0 AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1'));
|
||||
$user_itm = mysql_fetch_array(
|
||||
mysql_query('SELECT `id`,`bot`,`clone` FROM `stats` WHERE `id` = "' . $itm_['uid'] . '" LIMIT 1')
|
||||
);
|
||||
if ($user_itm['bot'] > 0 || $user_itm['clone'] > 0 || !isset($user_itm['id'])) {
|
||||
$r = '<font color="#FF0000"><strong>Вы не можете изьять данный предмет, он не принадлежит клану</strong></font><br />';
|
||||
} elseif (isset($itm_['id'])) {
|
||||
|
||||
if ($itm_['inOdet'] != 0) {
|
||||
$o = ', `inOdet` = 0';
|
||||
} else {
|
||||
$o = '';
|
||||
}
|
||||
$r = '<font color="#FF0000"><strong>Вы успешно изъяли предмет "' . $itm_['name'] . '"</strong></font><br />';
|
||||
$col = $this->itemsX(((int)$id));
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1'
|
||||
);
|
||||
|
||||
} else {
|
||||
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function take_itm_cl($id, $user, $cl): string
|
||||
{
|
||||
$itm_ = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` = "-21' . $user['clan'] . '" AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1'));
|
||||
if (isset($itm_['id'])) {
|
||||
$po = Conversion::dataStringToArray($itm_['data']);
|
||||
if (isset($po['toclan'])) {
|
||||
$cls = explode('#', $po['toclan']);
|
||||
$cls = $cls[1];
|
||||
}
|
||||
|
||||
$col = $this->itemsX(((int)$id));
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1'
|
||||
);
|
||||
$r = '<font color="#FF0000"><strong>Вы успешно взяли предмет "' . $itm_['name'] . '" из хранилища</strong></font><br />';
|
||||
|
||||
} else {
|
||||
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />' . $id;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function rem_itm_cl($user, $cl, $type)
|
||||
{
|
||||
$itms = mysql_query(
|
||||
'SELECT * FROM `items_users` WHERE (`uid` = "-21' . $user['clan'] . '" OR `data` LIKE "%toclan=' . $user['clan'] . '#%")'
|
||||
);
|
||||
while ($pl = mysql_fetch_array($itms)) {
|
||||
$po = Conversion::dataStringToArray($pl['data']);
|
||||
if (isset($po['toclan'])) {
|
||||
$cls = explode('#', $po['toclan']);
|
||||
$cls = $cls[1];
|
||||
}
|
||||
if ($cls == $user['id']) {
|
||||
if ($pl['uid'] != $user['id']) {
|
||||
if ($pl['inOdet'] != 0) {
|
||||
mysql_query('UPDATE `items_users` SET `inOdet` = 0 WHERE `id` = "' . $pl['id'] . '"');
|
||||
}
|
||||
}
|
||||
unset($po['toclan']);
|
||||
$pl['data'] = Conversion::arrayToDataString($po);
|
||||
$col = $this->itemsX(((int)$pl['id']));
|
||||
$it_n = mysql_fetch_array(
|
||||
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
} elseif ($pl['uid'] == $user['id']) {
|
||||
$col = $this->itemsX(((int)$pl['id']));
|
||||
$it_n = mysql_fetch_array(
|
||||
mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"')
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Clan;
|
||||
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
use Uploader;
|
||||
|
||||
class Register
|
||||
{
|
||||
const REGISTER_COST_EKR = 50;
|
||||
private string $name;
|
||||
private int $align = 0;
|
||||
private Uploader $logo;
|
||||
private int $newClanId = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (!isset($_POST['newclanname'], $_POST['newclanalign'], $_FILES['newclanlogo'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setName($_POST['newclanname']);
|
||||
$this->setLogo();
|
||||
$this->setAlign(intval($_POST['newclanalign']));
|
||||
$this->new();
|
||||
}
|
||||
|
||||
private function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
private function setLogo()
|
||||
{
|
||||
$this->logo = new Uploader('newclanlogo');
|
||||
$this->logo->setMaxFileSize(.03);
|
||||
$this->logo->setDimensions(24, 15);
|
||||
$this->logo->setExtentions(['gif', 'png']);
|
||||
}
|
||||
|
||||
private function setAlign(int $align)
|
||||
{
|
||||
if (!in_array($align, [0, 1, 3, 7])) {
|
||||
$align = 0;
|
||||
}
|
||||
$this->align = $align;
|
||||
}
|
||||
|
||||
public function new()
|
||||
{
|
||||
if (!$this->hasGoodName()) {
|
||||
return;
|
||||
}
|
||||
$imageId = $this->logo->saveToDb();
|
||||
if (!$imageId) {
|
||||
echo $this->logo::$error;
|
||||
return;
|
||||
}
|
||||
Db::sql('insert into clan (name, align, logo) values (?,?,?)', [$this->name, $this->align, $imageId]);
|
||||
$this->newClanId = Db::lastInsertId();
|
||||
}
|
||||
|
||||
private function hasGoodName(): bool
|
||||
{
|
||||
return Db::getValue('select count(id) from clan where name = ?', [$this->name]) === 0;
|
||||
}
|
||||
|
||||
public static function approve(int $clanId)
|
||||
{
|
||||
Db::sql('update clan set status = 1, time_reg = unix_timestamp() where id = ?', [$clanId]);
|
||||
}
|
||||
|
||||
public static function reject(int $clanId)
|
||||
{
|
||||
Db::sql('delete from clan where id = ?', [$clanId]);
|
||||
}
|
||||
|
||||
public static function printForm(): string
|
||||
{
|
||||
$img = Config::img() . '/i/align';
|
||||
return <<<REGISTERFORM
|
||||
<style>
|
||||
div.regclangrid [type=radio] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* IMAGE STYLES */
|
||||
div.regclangrid [type=radio] + img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* CHECKED STYLES */
|
||||
div.regclangrid [type=radio]:checked + img {
|
||||
outline: 1px solid brown;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
div.regclangrid {
|
||||
display: grid;
|
||||
grid-template-columns: 100px auto;
|
||||
}
|
||||
</style>
|
||||
<form method="POST" enctype="multipart/form-data">
|
||||
<div class="regclangrid">
|
||||
<div><label for="clanname">Название:</label></div>
|
||||
<div><input name="newclanname" id="clanname"></div>
|
||||
<div><label for="clanlogo">Логотип:</label></div>
|
||||
<div><input type="file" name="newclanlogo" accept="image/*" id="newclanlogo"> размер: 24×15, формат: png или gif, до 30Кб</div>
|
||||
<div>Склонность:</div>
|
||||
<div>
|
||||
<label><input type="radio" name="newclanalign" value="0" checked><img src="$img/align0.gif" alt="none"></label>
|
||||
<label><input type="radio" name="newclanalign" value="1"><img src="$img/align1.gif" alt="light"></label>
|
||||
<label><input type="radio" name="newclanalign" value="3"><img src="$img/align3.gif" alt="dark"></label>
|
||||
<label><input type="radio" name="newclanalign" value="7"><img src="$img/align7.gif" alt="neutral"></label>
|
||||
</div>
|
||||
<div></div>
|
||||
<div><button type="submit">Подать заявку</button></div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
REGISTERFORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNewClanId(): int
|
||||
{
|
||||
return $this->newClanId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,77 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
use Helper\Conversion;
|
||||
|
||||
class ComissionShop
|
||||
{
|
||||
public function commisionShop($sid, $preview = "full")
|
||||
public function commisionShop($preview = 'full')
|
||||
{
|
||||
global $c, $code, $sid;
|
||||
switch ((int)$_GET['otdel']) {
|
||||
case 1:
|
||||
$typeOtdel = 18;
|
||||
break;
|
||||
case 2:
|
||||
$typeOtdel = 19;
|
||||
break;
|
||||
case 3:
|
||||
$typeOtdel = 20;
|
||||
break;
|
||||
case 4:
|
||||
$typeOtdel = 21;
|
||||
break;
|
||||
case 5:
|
||||
$typeOtdel = 22;
|
||||
break;
|
||||
case 6:
|
||||
$typeOtdel = 15;
|
||||
break;
|
||||
case 7:
|
||||
$typeOtdel = 12;
|
||||
break;
|
||||
case 8:
|
||||
$typeOtdel = 4;
|
||||
break;
|
||||
case 9:
|
||||
$typeOtdel = 5;
|
||||
break;
|
||||
case 10:
|
||||
$typeOtdel = 6;
|
||||
break;
|
||||
case 11:
|
||||
$typeOtdel = 1;
|
||||
break;
|
||||
case 12:
|
||||
$typeOtdel = 3;
|
||||
break;
|
||||
case 13:
|
||||
$typeOtdel = 8;
|
||||
break;
|
||||
case 14:
|
||||
$typeOtdel = 14;
|
||||
break;
|
||||
case 15:
|
||||
$typeOtdel = 13;
|
||||
break;
|
||||
case 16:
|
||||
$typeOtdel = 9;
|
||||
break;
|
||||
case 17:
|
||||
$typeOtdel = 10;
|
||||
break;
|
||||
case 18:
|
||||
$typeOtdel = 11;
|
||||
break;
|
||||
case 19:
|
||||
$typeOtdel = 29;
|
||||
break;
|
||||
case 20:
|
||||
$typeOtdel = 30;
|
||||
break;
|
||||
case 1050:
|
||||
$typeOtdel = 1050;
|
||||
break;
|
||||
default :
|
||||
$typeOtdel = 18;
|
||||
}
|
||||
global $code;
|
||||
$typeOtdel = match ((int)$_GET['otdel']) {
|
||||
2 => 19,
|
||||
3 => 20,
|
||||
4 => 21,
|
||||
5 => 22,
|
||||
6 => 15,
|
||||
7 => 12,
|
||||
8 => 4,
|
||||
9 => 5,
|
||||
10 => 6,
|
||||
11 => 1,
|
||||
12 => 3,
|
||||
13 => 8,
|
||||
14 => 14,
|
||||
15 => 13,
|
||||
16 => 9,
|
||||
17 => 10,
|
||||
18 => 11,
|
||||
19 => 29,
|
||||
20 => 30,
|
||||
1050 => 1050,
|
||||
default => 18,
|
||||
};
|
||||
if ($typeOtdel != 1050) {
|
||||
if ($preview == "full") {
|
||||
$cl = mysql_query(
|
||||
@@ -158,9 +117,9 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
)
|
||||
);
|
||||
if ($steck[0] > 1 && $preview == "preview") {
|
||||
$po = $this->lookStats($d['data']);
|
||||
$po = Helper\Conversion::dataStringToArray($d['data']);
|
||||
} else {
|
||||
$po = $this->lookStats($pl['data']);
|
||||
$po = Helper\Conversion::dataStringToArray($pl['data']);
|
||||
}
|
||||
if (($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) {
|
||||
//Зоны блока +
|
||||
@@ -169,7 +128,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
}
|
||||
}
|
||||
$is2 = '';
|
||||
$is1 = '<img src="https://img.new-combats.com/i/items/' . $pl['img'] . '"><br>';
|
||||
$is1 = '<img src="//img.new-combats.tech/i/items/' . $pl['img'] . '"><br>';
|
||||
if ($preview == "full") {
|
||||
$is1 .= '<a href="?otdel=' . ((int)$_GET['otdel']) . '&toRent=3&itemid=' . (int)$_GET['itemid'] . '&buy=' . $pl[0] . '&sd4=' . $this->info['nextAct'] . '&rnd=' . $code . ' " >купить</a> ';
|
||||
} elseif ($preview == "preview") {
|
||||
@@ -182,7 +141,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
$pl['kolvo'] = $col;
|
||||
$pl['name'] .= ' (x' . $col . ')';
|
||||
}
|
||||
$is2 .= '<a href="https://new-combats.com/item/' . $pl['item_id'] . '" target="_blank">' . $pl['name'] . '</a> ';
|
||||
$is2 .= '<a href="/item/' . $pl['item_id'] . '" target="_blank">' . $pl['name'] . '</a> ';
|
||||
if ($pl['massa'] > 0 && $preview == "full") {
|
||||
$is2 .= '(Масса: ' . round($pl['massa'], 2) . ')';
|
||||
if ($pl['gift'] != '') {
|
||||
@@ -192,18 +151,18 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
} else {
|
||||
$ttl = 'Этот предмет подарил ' . $pl['gift'] . '. Вы не сможете передать этот предмет кому-либо еще';
|
||||
}
|
||||
$is2 .= ' <img title="' . $ttl . '" src="https://img.new-combats.com/i/podarok.gif">';
|
||||
$is2 .= ' <img title="' . $ttl . '" src="//img.new-combats.tech/i/podarok.gif">';
|
||||
}
|
||||
if (isset($po['art'])) {
|
||||
$is2 .= ' <img title="Артефакт" src="https://img.new-combats.com/i/artefact.gif">';
|
||||
$is2 .= ' <img title="Артефакт" src="//img.new-combats.tech/i/artefact.gif">';
|
||||
}
|
||||
if (isset($po['sudba'])) {
|
||||
if ($po['sudba'] == '0') {
|
||||
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто наденет его. Никто другой не сможет его использовать." src="https://img.new-combats.com/i/destiny0.gif">';
|
||||
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто наденет его. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">';
|
||||
} elseif ($po['sudba'] == '1') {
|
||||
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто возьмет предмет. Никто другой не сможет его использовать." src="https://img.new-combats.com/i/destiny0.gif">';
|
||||
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто возьмет предмет. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/destiny0.gif">';
|
||||
} else {
|
||||
$is2 .= ' <img title="Этот предмет связан общей судьбой с ' . $po['sudba'] . '. Никто другой не сможет его использовать." src="https://img.new-combats.com/i/desteny.gif">';
|
||||
$is2 .= ' <img title="Этот предмет связан общей судьбой с ' . $po['sudba'] . '. Никто другой не сможет его использовать." src="//img.new-combats.tech/i/desteny.gif">';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -452,7 +411,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
//действие комплекта
|
||||
$i1c = 0;
|
||||
$i2c = 0;
|
||||
$i1e = $this->lookStats($plc['data']);
|
||||
$i1e = Helper\Conversion::dataStringToArray($plc['data']);
|
||||
while ($i1c < count($this->items['add'])) {
|
||||
if (isset($i1e[$this->items['add'][$i1c]])) {
|
||||
$i3c = $i1e[$this->items['add'][$i1c]];
|
||||
@@ -488,7 +447,7 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
//действие комплекта
|
||||
$i1c = 0;
|
||||
$i2c = 0;
|
||||
$i1e = $this->lookStats($plc['data']);
|
||||
$i1e = Helper\Conversion::dataStringToArray($plc['data']);
|
||||
while ($i1c < count($this->items['add'])) {
|
||||
if (isset($i1e[$this->items['add'][$i1c]])) {
|
||||
$i3c = $i1e[$this->items['add'][$i1c]];
|
||||
@@ -572,4 +531,96 @@ ORDER BY `1price`ASC , inGroupCount DESC'
|
||||
echo '<tr style="background-color:#' . $cr . ';"><td style="padding:7px;" align="center" valign="top">Прилавок магазина пуст</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
public function buyItem(int $iid, User $u): string
|
||||
{
|
||||
$irow = Db::getRow('select items_users.id, uid, 1price, inGroup, inShop, data, item_id, login, items_main.name, price1
|
||||
from items_users
|
||||
left join users on users.id = uid
|
||||
left join items_main on items_main.id = item_id
|
||||
where items_users.id = ? and inShop = 30', [$iid]);
|
||||
|
||||
$price = $irow['1price'];
|
||||
if (!isset($irow['id']) || !isset($iid) || $irow['inShop'] != 30) {
|
||||
$r = 'Предмет не найден на прилавке';
|
||||
} else {
|
||||
if ($price > $u->info['money']) {
|
||||
$r = 'У вас недостаточно денег (не хватает ' . ($price - $u->info['money']) . ' кр.)';
|
||||
} else {
|
||||
$u->addKr(-$price);
|
||||
$u->addKr($price, $irow['uid']);
|
||||
|
||||
$col = $u->itemsX($iid);
|
||||
if ($col > 1) {
|
||||
Db::sql('update items_users set uid = ?, inGroup = inGroup + 1000, 1price = ?, lastUPD = unix_timestamp(), inShop = 0
|
||||
where inShop = 30 and inOdet = 0 and item_id = ? and uid = ? and inGroup = ? limit ?',
|
||||
[$u->info['id'], $irow['price1'], $irow['item_id'], $irow['uid'], $irow['inGroup'], $col]);
|
||||
$irow['name'] .= "(x$col)";
|
||||
} else {
|
||||
Db::sql('update items_users set uid = ?, 1price = ?, lastUPD = unix_timestamp(), inShop = 0
|
||||
where id = ? and uid = ? and inOdet = 0',
|
||||
[$iid, $irow['uid']]);
|
||||
}
|
||||
|
||||
Delo::add(1, 'comShop', $u->info['id'], "Купил предмет «{$irow['name']}» у игрока {$irow['login']} за $price кр.", $price);
|
||||
Delo::add(1, 'comShop', $irow['uid'], "Продал предмет «{$irow['name']}» игроку {$irow['login']} за $price кр.");
|
||||
|
||||
$r = "Вы купили предмет «{$irow['name']}» у игрока {$irow['login']} за $price кр.<br>Предмет успешно добавлен в инвентарь.";
|
||||
}
|
||||
}
|
||||
return '<div>' . $r . '</div>';
|
||||
}
|
||||
|
||||
public function rent($action, int $iid, int $price, User $u)
|
||||
{
|
||||
if ($action == "Сдать в магазин" && $price > 0) {
|
||||
$ChImtem = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`, `item_id`, `data`, `inGroup`, `uid` FROM `items_users` WHERE `id` = ' . $iid . ' LIMIT 1'
|
||||
)
|
||||
);
|
||||
$ChSudba = Conversion::dataStringToArray($ChImtem['data']);
|
||||
if (!isset($ChSudba['sudba']) && $ChSudba['sudba'] == 0 && $ChSudba['sudba'] != 1 && !isset($ChSudba['toclan'])) {
|
||||
if (isset($ChImtem['inGroup']) && $ChImtem['inGroup'] > 0) {
|
||||
$col = $u->itemsX($ChImtem['id']);
|
||||
if ($col > 1) {
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `inShop` = 30, `1price` = ' . $price . ' WHERE `item_id`="' . $ChImtem['item_id'] . '" AND `uid`="' . $ChImtem['uid'] . '" AND `inGroup` = "' . $ChImtem['inGroup'] . '" LIMIT ' . $col . ''
|
||||
);
|
||||
} else {
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `inShop` = 30, `1price` = ' . $price . ' WHERE `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" '
|
||||
);
|
||||
}
|
||||
} else {
|
||||
mysql_query(
|
||||
'UPDATE `items_users` set `inShop` = 30, `1price` = ' . $price . ' where `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" '
|
||||
);
|
||||
}
|
||||
}
|
||||
} elseif ($action == "Забрать") {
|
||||
$i = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `im`.`price1`,
|
||||
`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`id` = "' . $iid . '" AND `iu`.`inShop` = "30" AND `iu`.`delete` = "0" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($i['inGroup']) and $i['inGroup'] > 0) {
|
||||
$col = $u->itemsX($i['id']);
|
||||
if ($col > 1) {
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `inShop` = 0, `1price` = ' . $i['price1'] . ' WHERE `item_id`="' . $i['item_id'] . '" AND `inShop` = "30" AND `uid`="' . $i['uid'] . '" AND `inGroup` = "' . $i['inGroup'] . '" LIMIT ' . $col . ''
|
||||
);
|
||||
} else {
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `inShop` = 0, `1price` = ' . $i['price1'] . ' WHERE `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" '
|
||||
);
|
||||
}
|
||||
} else {
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `inShop` = 0, `1price` = "' . $i['price1'] . '" WHERE `id` = "' . $iid . '" and `inShop` = "30" LIMIT 1'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,40 +4,55 @@ namespace Core;
|
||||
|
||||
class Config
|
||||
{
|
||||
const EKR_RUB_PRICE = 30;
|
||||
const KR_TO_EKR_EXCHANGE = 500;
|
||||
const EKR_TO_KR_EXCHANGE = 200;
|
||||
private static self $instance;
|
||||
private static string $hostname = 'new-combats.tech';
|
||||
private static string $gamename = 'Бойцовский Клуб';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
//singleton
|
||||
}
|
||||
|
||||
ini_set('display_errors', 'Off');
|
||||
ini_set('date.timezone', 'Europe/Moscow');
|
||||
/** Самый распространённый субдомен
|
||||
* //img.{siteName}.
|
||||
* @return string
|
||||
*/
|
||||
public static function img(): string
|
||||
{
|
||||
return self::subdomain('img');
|
||||
}
|
||||
|
||||
header('Cache-Control: no-cache, no-store, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
private static function subdomain(string $name): string
|
||||
{
|
||||
return DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $name . '.' . self::$hostname;
|
||||
}
|
||||
|
||||
public static function get(?string $key = null)
|
||||
{
|
||||
$c['ver'] = '1.8.3.7';
|
||||
/* Конфигурации игры */
|
||||
$c['name'] = 'Бойцовский Клуб';
|
||||
$c['title'] = 'Новый «' . $c['name'] . '» - Бесплатная,браузерная онлайн игра'; //Название игры
|
||||
$c['name'] = 'Новый «' . self::$gamename . '»';
|
||||
$c['title'] = $c['name'] . ' - Бесплатная,браузерная онлайн игра'; //Название игры
|
||||
$c['title2'] = ' - Бесплатная, онлайн игра посвященная сражениям и магии!';
|
||||
$c['title3'] = $c['name'];
|
||||
$c['keys'] = $c['name'] . ', combats.com, ' . $c['name'] . ' игра, ' . $c['name'] . ' играть, игра ' . $c['name'] . ', старый ' . $c['name'] . ', ' . $c['name'] . ' онлайн игра, ' . $c['name'] . ' браузерная игра, играть в ' . $c['name'] . ', игра бк, бк игра, старый бк, играть в бк, бк онлайн игра, новый бк, Легендарный ' . $c['name'] . ', легендарный бк, combats, комбатс, combats ru, combats com, OldBK, oldbk ru, oldbk com, олдбк, old bk, олд бк, mycombats, rebk, recombats, oldcombats, obk2'; //Ключевые слова META
|
||||
$c['desc'] = '«' . $c['name'] . '» – это бесплатная увлекательная браузерная онлайн игра 2004-2009г, в которой сконцентрировано все самое лучшее от современных онлайн игр. В этой браузерной игре заложены самые интересные традиции всем известной онлайн игры под названием «' . $c['name'] . ' 2004-2009», которая, кстати, стала первооткрывателем всех браузерных игр.'; //Описание META
|
||||
$c['keys'] = self::$gamename . ', combats.com, ' . self::$gamename . ' игра, ' . self::$gamename . ' играть, игра ' . self::$gamename . ', старый ' . self::$gamename . ', ' . self::$gamename . ' онлайн игра, ' . self::$gamename . ' браузерная игра, играть в ' . $c['name'] . ', игра бк, бк игра, старый бк, играть в бк, бк онлайн игра, новый бк, Легендарный ' . $c['name'] . ', легендарный бк, combats, комбатс, combats ru, combats com, OldBK, oldbk ru, oldbk com, олдбк, old bk, олд бк, mycombats, rebk, recombats, oldcombats, obk2'; //Ключевые слова META
|
||||
$c['desc'] = self::$gamename . ' – это бесплатная увлекательная браузерная онлайн игра 2004-2009г, в которой сконцентрировано все самое лучшее от современных онлайн игр. В этой браузерной игре заложены самые интересные традиции всем известной онлайн игры под названием «' . self::$gamename . ' 2004-2009», которая, кстати, стала первооткрывателем всех браузерных игр.'; //Описание META
|
||||
$c['footer'] = $c['name'] . ' © 2013-' . date('Y');
|
||||
|
||||
//Сервера
|
||||
$c['host'] = 'new-combats.com';
|
||||
$c['forum'] = 'forum.' . $c['host'];
|
||||
$c['img'] = 'img.' . $c['host'];
|
||||
$c['host'] = self::$hostname;
|
||||
$c['forum'] = self::subdomain('forum');
|
||||
$c['img'] = 'img.' . self::$hostname;
|
||||
$c['thiscity'] = 'capitalcity';
|
||||
$c['capitalcity'] = $c['host'];
|
||||
$c['abandonedplain'] = $c['host'];
|
||||
$c['https'] = 'https://' . $c['host'] . DIRECTORY_SEPARATOR;
|
||||
$c['exit'] = '<script>top.location.href="' . $c['https'] . '";</script>';
|
||||
$c['capitalcity'] = self::$hostname;
|
||||
$c['abandonedplain'] = self::$hostname;
|
||||
$c['https'] = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . self::$hostname;
|
||||
$c['img2'] = self::subdomain('img');
|
||||
$c['lib'] = self::subdomain('lib');
|
||||
$c['exit'] = "<script>window.location.replace('{$c['https']}');</script>";
|
||||
$c['support'] = 'support@' . $c['host'];
|
||||
|
||||
|
||||
@@ -64,9 +79,8 @@ class Config
|
||||
$c['expstop'] = 2999999; //9; //Опыт на котором останавливаемся 11 149999999
|
||||
$c['expstopu'] = 2999999; //Опыт на котором останавливаемся
|
||||
$c['noobgade'] = false; //нуб квест (пещера)
|
||||
$c['bonusonline'] = true; //бонус за онлайн
|
||||
$c['level_ransfer'] = 8; //С какого уровня разрешены передачи
|
||||
$c['znahar'] = true; //бесплатный знахарь
|
||||
|
||||
$c['nolevel'] = false; //лимитирование уровней
|
||||
$c['noitembuy'] = false; //Не требует ресурсы для покупки
|
||||
$c['effz'] = 0; //Скольким секундам равен заряд
|
||||
@@ -84,6 +98,7 @@ class Config
|
||||
$c['securetime'] = 0; //Время последнего возможного взлома персов (подбор пароля по базам данных других игр)
|
||||
|
||||
$c['copyright'] = 'Copyright © ' . date('Y') . ' « Новый Бойцовский Клуб »';
|
||||
$c['db_host'] = 'db';
|
||||
$c['db_user'] = 'prod1';
|
||||
$c['db_name'] = 'game_production';
|
||||
$c['db_password'] = 'Bz@fGaZjFU2206Ua';
|
||||
|
||||
@@ -13,7 +13,7 @@ class Database
|
||||
* Singleton.
|
||||
*/
|
||||
private function __construct() {
|
||||
mysql_select_db(Config::get('db_name'), mysql_connect('localhost', Config::get('db_user'), Config::get('db_password')));
|
||||
mysql_select_db(Config::get('db_name'), mysql_connect(Config::get('db_host'), Config::get('db_user'), Config::get('db_password')));
|
||||
mysql_query('SET NAMES utf8mb4');
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class Database
|
||||
public static function pdoinit(): PDO
|
||||
{
|
||||
return new PDO(
|
||||
'mysql:host=localhost;dbname=' . Config::get('db_name'),
|
||||
'mysql:host=' . Config::get('db_host') . ';dbname=' . Config::get('db_name'),
|
||||
Config::get('db_user'),
|
||||
Config::get('db_password'),
|
||||
[
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Core;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
@@ -15,67 +14,58 @@ class Db
|
||||
|
||||
/**
|
||||
* DB constructor.
|
||||
* @throws Exception
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
self::$db = Database::pdoinit();
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
throw new PDOException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return false|int
|
||||
*/
|
||||
public static function exec(string $query): false|int
|
||||
{
|
||||
self::init();
|
||||
return self::$db->exec($query);
|
||||
}
|
||||
|
||||
private static function init(): void
|
||||
{
|
||||
self::$instance ??= new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $stmt
|
||||
* @return PDOStatement
|
||||
* @param ?string $name [optional] Name of the sequence object from which the ID should be returned.
|
||||
* @return false|string
|
||||
*/
|
||||
private static function query(string $stmt): PDOStatement
|
||||
public static function lastInsertId(?string $name = null): false|string
|
||||
{
|
||||
self::init();
|
||||
return self::$db->query($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $stmt
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function prepare(string $stmt): PDOStatement
|
||||
{
|
||||
self::init();
|
||||
return self::$db->prepare($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return int
|
||||
*/
|
||||
static public function exec(string $query): int
|
||||
{
|
||||
self::init();
|
||||
return self::$db->exec($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function lastInsertId(): string
|
||||
{
|
||||
self::init();
|
||||
return self::$db->lastInsertId();
|
||||
return self::$db->lastInsertId($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return PDOStatement
|
||||
* @return false|array
|
||||
*/
|
||||
public static function run(string $query, array $args = []): PDOStatement
|
||||
public static function getRows(string $query, array $args = []): false|array
|
||||
{
|
||||
return self::run($query, $args)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return false|PDOStatement
|
||||
*/
|
||||
public static function run(string $query, array $args = []): false|PDOStatement
|
||||
{
|
||||
try {
|
||||
if (!$args) {
|
||||
@@ -90,23 +80,23 @@ class Db
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
* @param string $stmt
|
||||
* @return false|PDOStatement
|
||||
*/
|
||||
public static function getRow(string $query, array $args = [])
|
||||
private static function query(string $stmt): false|PDOStatement
|
||||
{
|
||||
return self::run($query, $args)->fetch();
|
||||
self::init();
|
||||
return self::$db->query($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
* @param string $stmt
|
||||
* @return false|PDOStatement
|
||||
*/
|
||||
public static function getRows(string $query, array $args = []): array
|
||||
public static function prepare(string $stmt): false|PDOStatement
|
||||
{
|
||||
return self::run($query, $args)->fetchAll();
|
||||
self::init();
|
||||
return self::$db->prepare($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +104,7 @@ class Db
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getValue(string $query, array $args = [])
|
||||
public static function getValue(string $query, array $args = []): mixed
|
||||
{
|
||||
$result = self::getRow($query, $args);
|
||||
if (!empty($result)) {
|
||||
@@ -123,6 +113,16 @@ class Db
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getRow(string $query, array $args = []): mixed
|
||||
{
|
||||
return self::run($query, $args)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
@@ -137,8 +137,8 @@ class Db
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
*/
|
||||
public static function sql(string $query, array $args = [])
|
||||
public static function sql(string $query, array $args = []): void
|
||||
{
|
||||
self::run($query, $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
use PHPMailer;
|
||||
|
||||
class Mail
|
||||
{
|
||||
public static function send($to, $message, $subject = 'Бойцовский клуб')
|
||||
{
|
||||
require dirname(__DIR__) . '/mail/class.phpmailer.php';
|
||||
$mail = new PHPMailer;
|
||||
|
||||
$mail->IsSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = 'smtp.mail.yahoo.com'; // Specify main and backup server
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = 'newcombats@yahoo.com'; // SMTP username
|
||||
$mail->Password = 'uqcdbnsoagxcyysh';
|
||||
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
|
||||
$mail->Port = 587;
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
$mail->From = 'newcombats@yahoo.com';
|
||||
$mail->FromName = 'Бойцовский Клуб';
|
||||
$mail->AddAddress($to); // Add a recipient
|
||||
|
||||
$mail->IsHTML(true); // Set email format to HTML
|
||||
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = '<div>' . $message . '</div>';
|
||||
$mail->AltBody = $message;
|
||||
|
||||
if (!$mail->Send()) {
|
||||
return 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
class View
|
||||
{
|
||||
public static function render(string $view, array $arguments = []): void
|
||||
{
|
||||
extract($arguments, EXTR_SKIP);
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . "/_incl_data/Views/$view";
|
||||
|
||||
if (is_readable($file)) {
|
||||
require $file;
|
||||
} else {
|
||||
trigger_error("File $file not found!", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace DTO;
|
||||
|
||||
class BattleSpell
|
||||
{
|
||||
public string $name;
|
||||
public string $elemental;
|
||||
public int $damage;
|
||||
public string $color;
|
||||
public string $colorCrit;
|
||||
public string $colorMiss;
|
||||
|
||||
public function __construct(string $elemental)
|
||||
{
|
||||
if (!in_array($elemental, ['fire', 'water', 'air', 'earth', 'light', 'dark'])) {
|
||||
$this->elemental = 'raw';
|
||||
}
|
||||
if ($elemental === 'fire') {
|
||||
$this->elemental = $elemental;
|
||||
$this->color = '#a00';
|
||||
$this->colorCrit = '#f00';
|
||||
$this->colorMiss = '#909090';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace DTO;
|
||||
|
||||
use Helper\Conversion;
|
||||
use ItemModel;
|
||||
|
||||
class KnowledgeTempleItem
|
||||
{
|
||||
public int $id;
|
||||
public int $type;
|
||||
public string $name;
|
||||
public int $level;
|
||||
|
||||
private int $rowId;
|
||||
|
||||
/**
|
||||
* @param array $item
|
||||
*/
|
||||
public function __construct(array $item)
|
||||
{
|
||||
$this->rowId = $item['id'];
|
||||
$this->id = intval($item['item_id']);
|
||||
$this->type = intval($item['type']);
|
||||
$this->name = $item['name'];
|
||||
|
||||
// Общий + конкретный.
|
||||
$itemData = array_merge(
|
||||
Conversion::dataStringToArray(ItemModel::getItemData($this->id)),
|
||||
Conversion::dataStringToArray($item['data']),
|
||||
);
|
||||
$this->level = intval($itemData['tr_lvl']);
|
||||
}
|
||||
|
||||
public function exists(): bool
|
||||
{
|
||||
return !empty($this->rowId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace DTO;
|
||||
|
||||
class Present
|
||||
{
|
||||
/** Логин отправителя
|
||||
* @var string
|
||||
*/
|
||||
public string $sender;
|
||||
/** Логин получателя
|
||||
* @var string
|
||||
*/
|
||||
public string $receiver;
|
||||
/** id подарка
|
||||
* @var int
|
||||
*/
|
||||
public int $itemId;
|
||||
/** Заголовок поздравления.
|
||||
* Обычно отображается в инфе персонажа в тултипе.
|
||||
* @var string
|
||||
*/
|
||||
public string $textTitle = '';
|
||||
/** Текст поздравления
|
||||
* Отображается только получателю подарка в инвентаре.
|
||||
* @var string
|
||||
*/
|
||||
public string $text = '';
|
||||
/** Флаг анонимности. Если true, в поле "отправитель" будет "невидимка".
|
||||
* @var bool
|
||||
*/
|
||||
public bool $anonymousSender = false;
|
||||
/** Флаг кланового подарка. Если true, в поле "отправитель" будет имя клана в котором состоит игрок.
|
||||
* @var bool
|
||||
*/
|
||||
public bool $clanSender = false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Helpers;
|
||||
|
||||
class Str
|
||||
{
|
||||
public static function snakeCase($string): string
|
||||
{
|
||||
return strtolower(preg_replace(['/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'], '$1_$2', $string));
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,47 @@
|
||||
|
||||
namespace DarksLight2\Training;
|
||||
|
||||
use DarksLight2\Helpers\Str;
|
||||
use User;
|
||||
|
||||
abstract class StepFactory
|
||||
{
|
||||
|
||||
abstract public function getTitle(): string;
|
||||
abstract public function getMessage(): string;
|
||||
abstract public function getShortName(): string;
|
||||
abstract public function getRewards(): array;
|
||||
public function onLocations(): array
|
||||
{
|
||||
return ['all'];
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return Str::snakeCase(get_class($this));
|
||||
}
|
||||
public function getAnswer()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function allowedToMove(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isInfo(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function databaseRecord()
|
||||
{
|
||||
return [
|
||||
'completed' => false,
|
||||
'progress' => [
|
||||
'current' => 0,
|
||||
'need' => 1,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class ChatFirstQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Начало.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Отправьте сообщение в общий чат.';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'chat_first_quest';
|
||||
}
|
||||
|
||||
public function isInfo(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class ChatFirstStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Начало.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Помните, оскорблять, унижать, обсуждать политику, подстёгивать других игроков, как в общем чате так и в приватном приведет к временному ограничению возможности отправки сообщений в любой из чатов.';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'chat_first_step';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class ChatSecondQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Начало.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Отправьте адресное сообщение в общий чат, нажав 1 раз по никнейму игрока либо в чате, либо со списка онлайна, который находится справа.';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'chat_second_quest';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isInfo(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class ChatThirdQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Начало.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Отправьте адресное личное сообщение в чат, нажав 2 раза по никнему игрока либо в чате, либо со списка онлайна, который находится справа.';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'chat_third_quest';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isInfo(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class FirstStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Добро пожаловать в игру!';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Мы поможем Вам адаптироваться в нашей браузерной онлайн игре.<br>
|
||||
Суть игры, заключается стремлении стать непобедимым бойцом в игре среди других персонажей!<br>
|
||||
Сделать это сможет каждый игрок, путём усиления своего персонажа, предметов улучшенного качества, интеграции рун и чарок в предметы и других, интересных усилений.<br>
|
||||
На общем фоне слева, Вы можете наблюдать своего персонажа ( слева ), на котором показаны пустые слоты под предметы, его параметры, ваши деньги, победы/поражения, а с права, общее окно разных локаций, таких как: Магазин, Ремонтная Мастерская, Здание лото, Здание Бойцовского Клуба где проходят поединки, Почта, Переход на Страшилкину Улицу и т.д.<br>
|
||||
Далее, мы подскажем Вам, для чего служит нижний фрейм.';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'first_step';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserFirstQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Сколько всего основных игровых Валют? Введите их число...';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_first_quest';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getAnswer(): string
|
||||
{
|
||||
return '2';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserFirstStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'В нашей игре, ваш персонаж расположен слева от экрана с игровыми локациями, там же, можно увидеть пустые слоты под предметы и параметры персонажа, ваш опыт, деньги, ежедневные задания...';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_first_step';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserFourthQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Войдите во вкладку " Умения ", в правой части экрана, сверху, а далее, перейдите во вкладку " Приёмы ", после чего, выберите нужные Вам приемы, но будьте внимательны, некоторые из приемов могут быть на разные классы, обязательно прочтите их описание или потестируйте в поединках.';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_fourth_quest';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isInfo(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserFourthStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return '"Параметры Персонажа"<br>
|
||||
Все игроки имеют свободные очки распределения параметров, что они дают игрокам конкретные модификаторы в зависимости от того, в какой из параметров распределяются очки распределения.<br>
|
||||
--- если можно, добавить скрин как выглядит эта кнопка ---
|
||||
Сила - Увеличивает мощность рубящего урона ( для Силачей )<br>
|
||||
Ловкость - Увеличивает мощность колющего урона ( для Критоуворотов и Уворотов )<br>
|
||||
Интуиция - Увеличивает мощность режущего урона ( для Критовиков )<br>
|
||||
Выносливость - Увеличивает защиту от урона и магии, а так же добавит немного жизней. ( для Танков )<br>
|
||||
Интелект - Увеличивает мощность магии. ( Для Любого Мага )<br>
|
||||
Мудрость - Увеличивает колличество маны. ( Для Любого Мага )<br>
|
||||
<br>
|
||||
Дополнительно, игроки имеют очки распределения Мастерства Оружия, это позволит воинам увеличить урон, а магам, открыть новые приемы.<br>
|
||||
Очки распределения Оружий распределяются точно так же, как и очки распределения параметров ( статов ).<br>
|
||||
<br>
|
||||
В случае, если вы распределили неверно любые доступные очки распределения, или хотите их изменить, вы можете это сделать, поднявшись на 2 этаж здания " Бойцовский Клуб ".';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_fourth_step';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getAnswer(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserSecondQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Кого убивает игровой класс "Танк"?';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_second_quest';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getAnswer(): string
|
||||
{
|
||||
return 'Уворотов и Силачей';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserSecondStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Опыт - Получение опыта происходит после сыгранных поединков, в зависимости от выбитого урона с противников, нажав по своему опыту, откроется таблица опыта, в которой можно посмотреть, когда вы получите дополнительное очко распределение параметров персонажа/оружий, награду за взятие " апа " или " Уровня "<br>
|
||||
Текущий уровень - Отображает ваш текущий уровень персонажа.<br>
|
||||
Победы - Отображает сумму всех ваших побед, в любых поединках.<br>
|
||||
Поражения - Отображает сумму всех ваших поражений, в любых поединках.<br>
|
||||
Ничьих - Отображает сумму всех поединков, которые завершились в ничью.<br>
|
||||
Кредиты - Обычная игровая валюта - кредиты ( креды ), которые можно потратить в обычном магазине.<br>
|
||||
Еврокредиты - Покупная игровая валюта - еврокредиты ( екры ) , которые можно потратить в магазине " Берёзка ". <br>
|
||||
Воинственность - Дополнительная игровая валюта, потратить её можно в Подпольной Лавке.<br>
|
||||
Ежедневное задание - Отображает текущее ежедневное задание либо предоставляет возможность его взятия.<br>
|
||||
Бонус - Позволяет получить немного кредитов или еврокредитов.';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_second_step';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserThirdQuest extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Распределите свободные параметры распределения ( статы ) и параметры оружий ( умения ) в зависимости от выбранного вами при регистрации "Класса" игрока нажав по кнопке " + Способности ", а далее, после распределения параметров " Сохранить ".';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_third_quest';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isInfo(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function allowedToMove(): array
|
||||
{
|
||||
return ['cp1'];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class MyUserThirdStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Персонаж.';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'В нашей игре, существует 5 Воинских и 4 Магических класса, такие как:<br>
|
||||
Критовик - Убивает Танков и Магов, основное оружие - Мечи<br>
|
||||
Уворот - Убивает Критовиков и Силачей, основное оружие - Кинжалы<br>
|
||||
Танк - Убивает Уворотов и Силачей, основное оружие - Дубина и щит.<br>
|
||||
Силач - Убивает Критовиков и Магов, основное оружие - Топоры<br>
|
||||
Критоуворот - Убивает Силачей и с небольшим шансом Критовиков и Уворотов, основное оружие - Кинжалы.<br>
|
||||
<br>
|
||||
Маг Огня - Атакующий маг, убивает Уворотов и Танков.<br>
|
||||
Маг Воздуха - Атакующий маг, убивает Уворотов и Танков.<br>
|
||||
Маг Земли - Защищающийся маг, слабый урон, хорошая защита.<br>
|
||||
Маг Воды - Защищающийся маг, слабый урон, хорошая защита.';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'my_user_third_step';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function allowedToMove(): array
|
||||
{
|
||||
return ['cp1'];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace DarksLight2\Training\Steps;
|
||||
|
||||
use DarksLight2\Training\StepFactory;
|
||||
|
||||
class SecondStep extends StepFactory
|
||||
{
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return 'Тест';
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return 'Тест';
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return 'second_step';
|
||||
}
|
||||
|
||||
public function getRewards(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,24 +3,125 @@
|
||||
namespace DarksLight2\Training;
|
||||
|
||||
use Core\Db;
|
||||
use DarksLight2\Training\Steps\ChatFirstStep;
|
||||
use DarksLight2\Training\Steps\MyUserFirstQuest;
|
||||
use DarksLight2\Training\Steps\MyUserFirstStep;
|
||||
use DarksLight2\Training\Steps\MyUserFourthQuest;
|
||||
use DarksLight2\Training\Steps\MyUserFourthStep;
|
||||
use DarksLight2\Training\Steps\MyUserSecondQuest;
|
||||
use DarksLight2\Training\Steps\MyUserSecondStep;
|
||||
use DarksLight2\Training\Steps\MyUserThirdQuest;
|
||||
use DarksLight2\Training\Steps\MyUserThirdStep;
|
||||
use DarksLight2\Traits\Singleton;
|
||||
use PDO;
|
||||
use stdClass;
|
||||
use PassGen;
|
||||
use User;
|
||||
|
||||
class TrainingManager
|
||||
{
|
||||
|
||||
use Singleton;
|
||||
|
||||
private $database_records = false;
|
||||
private array $steps_data;
|
||||
private int $user_id;
|
||||
private array $steps;
|
||||
public string $current_step = '';
|
||||
private array $registered_steps;
|
||||
private array $completed_steps;
|
||||
private array $active_steps;
|
||||
|
||||
public function __construct(int $user_id)
|
||||
private $database;
|
||||
|
||||
public function __construct(int $user_id, $refresh_token = true)
|
||||
{
|
||||
try {
|
||||
$this->register([
|
||||
new ChatFirstStep(),
|
||||
new MyUserFirstStep(),
|
||||
new MyUserFirstQuest(),
|
||||
new MyUserSecondStep(),
|
||||
new MyUserSecondQuest(),
|
||||
new MyUserThirdStep(),
|
||||
new MyUserThirdQuest(),
|
||||
new MyUserFourthStep(),
|
||||
new MyUserFourthQuest(),
|
||||
]);
|
||||
} catch (TrainingException $e) {
|
||||
}
|
||||
|
||||
$this->user_id = $user_id;
|
||||
$this->generateToken();
|
||||
|
||||
if($refresh_token) {
|
||||
$this->generateToken();
|
||||
}
|
||||
|
||||
$this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$user_id]);
|
||||
|
||||
$this->createDatabaseRecord();
|
||||
|
||||
$this->database['data'] = json_decode($this->database['data'], true);
|
||||
|
||||
$this->selectActiveSteps();
|
||||
}
|
||||
|
||||
public function getCurrentStepName(): string
|
||||
{
|
||||
if(empty($this->current_step)) {
|
||||
$this->current_step = array_key_first($this->active_steps) ?? '';
|
||||
}
|
||||
|
||||
return $this->current_step;
|
||||
}
|
||||
public function getRegistered(): array
|
||||
{
|
||||
return $this->registered_steps;
|
||||
}
|
||||
|
||||
public function getDatabaseData()
|
||||
{
|
||||
return $this->database;
|
||||
}
|
||||
|
||||
public function addPoint($short_name, $closure = null)
|
||||
{
|
||||
if($short_name === $this->getCurrentStepName()) {
|
||||
$this->database['data'][$short_name]['progress']['current']++;
|
||||
if(isset($closure)) {
|
||||
$closure($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function nextStep()
|
||||
{
|
||||
|
||||
if($this->database['data'][$this->getCurrentStepName()]['progress']['need'] <= $this->database['data'][$this->getCurrentStepName()]['progress']['current']) {
|
||||
$this->database['data'][$this->getCurrentStepName()]['progress']['current'] = 0;
|
||||
$this->database['data'][$this->getCurrentStepName()]['completed'] = true;
|
||||
unset($this->active_steps[$this->getCurrentStepName()]);
|
||||
$this->current_step = array_key_first($this->active_steps) ?? '';
|
||||
$this->database['current'] = $this->getCurrentStepName();
|
||||
}
|
||||
}
|
||||
|
||||
public function previousStep()
|
||||
{
|
||||
$this->current_step = end($this->completed_steps) ?? '';
|
||||
$this->database['current'] = $this->current_step;
|
||||
$this->database['data'][$this->getCurrentStepName()]['completed'] = false;
|
||||
}
|
||||
|
||||
public function selectActiveSteps()
|
||||
{
|
||||
foreach ($this->database['data'] as $step_name => $data) {
|
||||
if($data['completed'] === false) {
|
||||
$this->active_steps[$step_name] = $data;
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->completed_steps[] = $step_name;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
Db::sql('UPDATE user_training SET data = ?, current = ? WHERE user_id = ?', [json_encode($this->database['data']), $this->database['current'], $this->user_id]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,165 +138,55 @@ class TrainingManager
|
||||
|
||||
foreach ($steps as $step) {
|
||||
if($step instanceof StepFactory) {
|
||||
$this->steps[$step->getShortName()] = new class (
|
||||
$step->getMessage(),
|
||||
$step->getTitle(),
|
||||
$step->getRewards(),
|
||||
$this->stepData($step->getShortName())->complete,
|
||||
$step->getShortName(),
|
||||
$this->stepData($step->getShortName())->progress
|
||||
) {
|
||||
public string $message;
|
||||
public string $title;
|
||||
public string $short_name;
|
||||
public array $rewards;
|
||||
public bool $isComplete;
|
||||
|
||||
public stdClass $progress;
|
||||
|
||||
public function __construct(
|
||||
string $message,
|
||||
string $title,
|
||||
array $rewards,
|
||||
bool $isComplete,
|
||||
string $short_name,
|
||||
stdClass $progress
|
||||
) {
|
||||
$this->rewards = $rewards;
|
||||
$this->title = $title;
|
||||
$this->isComplete = $isComplete;
|
||||
$this->message = $message;
|
||||
$this->short_name = $short_name;
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if(!$this->isComplete) {
|
||||
$path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/' . $this->short_name . '.php';
|
||||
|
||||
if (file_exists($path)) {
|
||||
require $path;
|
||||
return;
|
||||
}
|
||||
|
||||
throw TrainingException::noRenderingFile();
|
||||
}
|
||||
}
|
||||
};
|
||||
$this->registered_steps[$step->getShortName()] = $step;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function stepData(string $short_name): object
|
||||
{
|
||||
$data = $this->getDatabaseRecords()->data;
|
||||
|
||||
if(!isset($data->$short_name)) {
|
||||
$this->updateDatabaseRecord($short_name);
|
||||
$data = $this->getDatabaseRecords()->data;
|
||||
}
|
||||
|
||||
return $data->$short_name;
|
||||
}
|
||||
|
||||
private function generateToken($length = 16)
|
||||
{
|
||||
$letters = 'abcdefgmikiHGJKLjkGASysj7603456';
|
||||
|
||||
$token = '';
|
||||
|
||||
for ($i = 0; $i <= $length; $i++) {
|
||||
$token .= $letters[rand(0, strlen($letters))];
|
||||
}
|
||||
|
||||
Db::run('UPDATE user_training SET api_token = ? WHERE user_id = ?', [
|
||||
$token,
|
||||
PassGen::new($length),
|
||||
$this->user_id
|
||||
]);
|
||||
}
|
||||
|
||||
public function getDatabaseRecords(): stdClass
|
||||
{
|
||||
if(!$this->database_records) {
|
||||
$data = Db::run('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id])
|
||||
->fetch(PDO::FETCH_OBJ);
|
||||
|
||||
$this->database_records = new stdClass();
|
||||
|
||||
$this->database_records->user_id = $data->user_id;
|
||||
$this->database_records->api_token = $data->api_token;
|
||||
$this->database_records->data = json_decode($data->data);
|
||||
}
|
||||
|
||||
return $this->database_records;
|
||||
}
|
||||
|
||||
public function updateDatabaseRecord(string $short_name)
|
||||
{
|
||||
if($this->getDatabaseRecords()) {
|
||||
|
||||
$this->database_records->data->$short_name = $this->firstRecordData()->$short_name;
|
||||
|
||||
Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [
|
||||
json_encode($this->database_records->data),
|
||||
$this->user_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function createDatabaseRecord()
|
||||
{
|
||||
if(!$this->getDatabaseRecords()) {
|
||||
Db::run('INSERT INTO user_training (user_id, data) VALUES (?, ?)', [
|
||||
$this->user_id,
|
||||
json_encode($this->firstRecordData())
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(!$this->database) {
|
||||
|
||||
private function firstRecordData(): stdClass
|
||||
{
|
||||
$data = new stdClass();
|
||||
$short_names = [
|
||||
'first_step',
|
||||
'second_step'
|
||||
];
|
||||
$data = [];
|
||||
|
||||
foreach ($short_names as $name) {
|
||||
$data->$name->complete = false;
|
||||
$data->$name->progress->current = 0;
|
||||
$data->$name->progress->need = 1;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
public function __get(string $name)
|
||||
{
|
||||
return $this->steps[$name];
|
||||
}
|
||||
|
||||
public function addPoint(string $short_name)
|
||||
{
|
||||
$this->database_records->data->$short_name->progress->current++;
|
||||
}
|
||||
|
||||
public function nextStep()
|
||||
{
|
||||
foreach ($this->database_records->data as $step) {
|
||||
if($step->complete === false && $step->progress->current >= $step->progress->need) {
|
||||
$step->complete = true;
|
||||
foreach ($this->registered_steps as $step) {
|
||||
$data[$step->getShortName()] = $step->databaseRecord();
|
||||
}
|
||||
|
||||
Db::sql('INSERT INTO user_training (user_id, data, current) VALUES (?, ?, ?)', [
|
||||
$this->user_id,
|
||||
json_encode($data, true),
|
||||
array_key_first($data)
|
||||
]);
|
||||
|
||||
$this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function store()
|
||||
/**
|
||||
* @throws \DarksLight2\Training\TrainingException
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->nextStep();
|
||||
if(in_array(User::start()->room['file'], $this->registered_steps[$this->getCurrentStepName()]->onLocations()) || in_array('all', $this->registered_steps[$this->getCurrentStepName()]->onLocations())) {
|
||||
$path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/step.php';
|
||||
|
||||
Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [
|
||||
json_encode($this->database_records->data),
|
||||
$this->user_id
|
||||
]);
|
||||
if (file_exists($path)) {
|
||||
$short_name = $this->getCurrentStepName();
|
||||
$answer = $this->registered_steps[$this->getCurrentStepName()]->getAnswer();
|
||||
require $path;
|
||||
return;
|
||||
}
|
||||
|
||||
throw TrainingException::noRenderingFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
use User\UserIp;
|
||||
|
||||
class Delo
|
||||
{
|
||||
/**
|
||||
* Запись в личное дело персонажа.
|
||||
* @param int $type цифровой тип лога (??)
|
||||
* @param string $from отправитель записи
|
||||
* @param int $uid кому пишется
|
||||
* @param string $text текст
|
||||
* @param float $moneyOut количество денег снятых с игрока
|
||||
* @param float $moneyIn количество денег полученных игроком
|
||||
* @return void
|
||||
*/
|
||||
public static function add(int $type, string $from, int $uid, string $text, float $moneyOut = 0, float $moneyIn = 0): void
|
||||
{
|
||||
$sql = 'insert into users_delo (uid, time, text, login, `delete`, no_right, ip, moneyOut, moneyIn, type) values (?,unix_timestamp(),?,?,0,?,?,?,?,?)';
|
||||
Db::sql($sql, [
|
||||
$uid, $text, $from, '', UserIp::get(), $moneyOut, $moneyIn, $type,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function printPublicModerationStatus(int $userid): void
|
||||
{
|
||||
$status = Db::getValue('select text from users_delo where uid = ? and hb != 0 order by id desc limit 1', [$userid]);
|
||||
if (!$status) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo <<<HTML
|
||||
<div style="padding-left: 5px; margin: 5px 0;">
|
||||
Сообщение от модераторов:<br>
|
||||
<span style="color: red; background-color: bisque; font-weight: bold;">$status</span>
|
||||
</div>
|
||||
HTML;
|
||||
}
|
||||
|
||||
public static function getAllByUserId(int $userid): array
|
||||
{
|
||||
return Db::getRows('select time, text from users_delo where uid = ? and type = 0 order by id desc', [$userid]);
|
||||
}
|
||||
}
|
||||
|
||||
+56
-48
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Helper\Conversion;
|
||||
use User\ItemsModel;
|
||||
|
||||
class Dialog
|
||||
{
|
||||
private $info;
|
||||
public $dText = '', $aText = '', $youInfo = '', $botInfo = '', $title = '', $p = 1, $pg = 1;
|
||||
private array $info;
|
||||
public string $dText = '';
|
||||
public string $aText = '';
|
||||
public string $youInfo = '';
|
||||
public string $botInfo = '';
|
||||
public string $title = '';
|
||||
public int $p = 1;
|
||||
public int $pg = 1;
|
||||
|
||||
public function trnObj($x, $j)
|
||||
public function trnObj($x, $j): array
|
||||
{
|
||||
$i = floor($x / $j);
|
||||
return [0 => $i, 1 => $x - ($i * $j)];
|
||||
@@ -202,7 +211,7 @@ class Dialog
|
||||
//Выдаем предмет для квеста
|
||||
$itmb = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "' . $act1[8] . '" LIMIT 1'));
|
||||
if (isset($itmb['id'])) {
|
||||
$u->addItem($act1[8], $u->info['id'], '|nodelete=1');
|
||||
ItemsModel::addItem($act1[8], $u->info['id'], '|nodelete=1');
|
||||
$txt .= '<br><b><font color=red>Вы получили предмет "' . $itmb['name'] . '"</font></b>';
|
||||
}
|
||||
}
|
||||
@@ -223,16 +232,16 @@ class Dialog
|
||||
$txt .= ' за ' . $act1[2] . ' екр.';
|
||||
}
|
||||
if ($act1[3] > 0) {
|
||||
$txt .= ' на срок ' . $u->timeOut($act1[3]) . '';
|
||||
$act1dt .= '|srok=' . $act1[3] . '';
|
||||
$txt .= ' на срок ' . Conversion::secondsToTimeout($act1[3]);
|
||||
$act1dt .= '|srok=' . $act1[3];
|
||||
}
|
||||
$txt .= '</font></b>';
|
||||
|
||||
$u->addItem($itmb['id'], $u->info['id'], $act1dt);
|
||||
ItemsModel::addItem($itmb['id'], $u->info['id'], $act1dt);
|
||||
$pg = $act1[4];
|
||||
}
|
||||
} else {
|
||||
$txt .= '<br><b><font color=red>Неудалось приобрести предмет...</font></b>';
|
||||
$txt .= '<br><b style="color: red">Неудалось приобрести предмет...</b>';
|
||||
$pg = 1;
|
||||
}
|
||||
} elseif ($act1[0] == 'quest') {
|
||||
@@ -257,7 +266,7 @@ class Dialog
|
||||
}
|
||||
$ic2 = 1;
|
||||
while ($ic2 <= $act3[2]) {
|
||||
$u->addItem($itmqs['id'], $u->info['id'], '|quest_item=1', ['del' => $act3[3]]);
|
||||
ItemsModel::addItem($itmqs['id'], $u->info['id'], '|quest_item=1', ['del' => $act3[3]]);
|
||||
$ic2++;
|
||||
}
|
||||
}
|
||||
@@ -387,7 +396,7 @@ class Dialog
|
||||
if ($upd) {
|
||||
if ($itik > 0) {
|
||||
//Выдаем предметы
|
||||
$u->addItem($itik, $u->info['id'], '|nosale=1|srok=' . (7 * 86400) . '', null, 1);
|
||||
ItemsModel::addItem($itik, $u->info['id'], '|nosale=1|srok=' . (7 * 86400) . '', null, 1);
|
||||
$itm_nm = mysql_fetch_array(mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $itik . '" LIMIT 1'));
|
||||
$txt = 'Вы получили предмет "' . $itm_nm['name'] . '"';
|
||||
} else {
|
||||
@@ -407,7 +416,7 @@ class Dialog
|
||||
}
|
||||
$arts_1 = $arts_1[rand(0, count($arts_1) - 1)];
|
||||
if ($arts_1 > 0) {
|
||||
$u->addItem($arts_1, $u->info['id'], '|sroknext=1|nosale=1|sleep_moroz=1|srok=' . (86400 / 2) . '', null, 100);
|
||||
ItemsModel::addItem($arts_1, $u->info['id'], '|sroknext=1|nosale=1|sleep_moroz=1|srok=' . (86400 / 2) . '', null, 100);
|
||||
}
|
||||
$itm_nm = mysql_fetch_array(mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $arts_1 . '" LIMIT 1'));
|
||||
|
||||
@@ -427,7 +436,7 @@ class Dialog
|
||||
}
|
||||
$arts_1 = $arts_1[rand(0, count($arts_1) - 1)];
|
||||
if ($arts_1 > 0) {
|
||||
$u->addItem($arts_1, $u->info['id'], '|sroknext=1|nosale=1|sleep_moroz=1|srok=' . (86400 / 2) . '', null, 100);
|
||||
ItemsModel::addItem($arts_1, $u->info['id'], '|sroknext=1|nosale=1|sleep_moroz=1|srok=' . (86400 / 2) . '', null, 100);
|
||||
}
|
||||
$itm_nm = mysql_fetch_array(mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $arts_1 . '" LIMIT 1'));
|
||||
|
||||
@@ -517,7 +526,7 @@ class Dialog
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$e = 1;
|
||||
while ($e <= $t[0]) {
|
||||
$u->addItem($cn[$i]['add'][0], $u->info['id'], $data);
|
||||
ItemsModel::addItem($cn[$i]['add'][0], $u->info['id'], $data);
|
||||
$e++;
|
||||
}
|
||||
$txt .= $cn[$i][$j]['n'] . ' x' . ($t[0] * $this->objLevel($cn[$i][$j], $u->info['level'])) . ' = ' . $cn[$i]['add'][1] . ' x' . $t[0] . '<br>';
|
||||
@@ -563,7 +572,7 @@ class Dialog
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$e = 1;
|
||||
while ($e <= $t[0]) {
|
||||
$u->addItem($cn[$i]['add'][0], $u->info['id'], $data);
|
||||
ItemsModel::addItem($cn[$i]['add'][0], $u->info['id'], $data);
|
||||
$e++;
|
||||
}
|
||||
$txt .= $cn[$i][$j]['n'] . ' x' . ($t[0] * $this->objLevel($cn[$i][$j], $u->info['level'])) . ' = ' . $cn[$i]['add'][1] . ' x' . $t[0] . '<br>';
|
||||
@@ -609,7 +618,7 @@ class Dialog
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$e = 1;
|
||||
while ($e <= $t[0]) {
|
||||
$u->addItem($cn[$i]['add'][0], $u->info['id'], $data);
|
||||
ItemsModel::addItem($cn[$i]['add'][0], $u->info['id'], $data);
|
||||
$e++;
|
||||
}
|
||||
$txt .= $cn[$i][$j]['n'] . ' x' . ($t[0] * $this->objLevel($cn[$i][$j], $u->info['level'])) . ' = ' . $cn[$i]['add'][1] . ' x' . $t[0] . '<br>';
|
||||
@@ -641,7 +650,7 @@ class Dialog
|
||||
if (isset($keypr1['id'], $keypr2['id'])) {
|
||||
mysql_query('DELETE FROM `items_users` WHERE `id` = "' . $keypr1['id'] . '" OR `id` = "' . $keypr2['id'] . '" LIMIT 2');
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$u->addItem(2555, $u->info['id'], $data);
|
||||
ItemsModel::addItem(2555, $u->info['id'], $data);
|
||||
$txt = 'Вы успешно получили "Пирамидальный ключ"';
|
||||
}
|
||||
|
||||
@@ -684,7 +693,7 @@ class Dialog
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$e = 1;
|
||||
while ($e <= $t[0]) {
|
||||
$u->addItem($cn[$i][$j]['add'][0], $u->info['id'], $data);
|
||||
ItemsModel::addItem($cn[$i][$j]['add'][0], $u->info['id'], $data);
|
||||
$e++;
|
||||
}
|
||||
mysql_query('DELETE FROM `items_users` WHERE `id` = "' . $keypr['id'] . '" LIMIT 1');
|
||||
@@ -740,7 +749,7 @@ class Dialog
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$e = 1;
|
||||
while ($e <= $t[0]) {
|
||||
$u->addItem($cn[$i][$j]['add'][0], $u->info['id'], $data);
|
||||
ItemsModel::addItem($cn[$i][$j]['add'][0], $u->info['id'], $data);
|
||||
$e++;
|
||||
}
|
||||
mysql_query('DELETE FROM `items_users` WHERE `id` = "' . $keypr['id'] . '" LIMIT 1');
|
||||
@@ -796,7 +805,7 @@ class Dialog
|
||||
$data = '|frompisher=' . $d->info['id2'];
|
||||
$e = 1;
|
||||
while ($e <= $t[0]) {
|
||||
$u->addItem($cn[$i][$j]['add'][0], $u->info['id'], $data);
|
||||
ItemsModel::addItem($cn[$i][$j]['add'][0], $u->info['id'], $data);
|
||||
$e++;
|
||||
}
|
||||
$txt .= $cn[$i][$j]['n'] . ' x' . ($t[0] * $this->objLevel($cn[$i][$j], $u->info['level'])) . ' = ' . $cn[$i][$j]['add'][1] . ' x' . $t[0] . '<br>';
|
||||
@@ -951,7 +960,7 @@ class Dialog
|
||||
$qsw = 0;
|
||||
while ($qsw < $item['colvo']) {
|
||||
$txt .= '<br/>Вы получили предмет';
|
||||
$u->addItem($item['item_id'], $u->info['id']);
|
||||
ItemsModel::addItem($item['item_id'], $u->info['id']);
|
||||
$qsw++;
|
||||
}
|
||||
}
|
||||
@@ -977,7 +986,7 @@ class Dialog
|
||||
if ($this->info['tr_dn'] != $d->info['id2']) {
|
||||
$go = 0;
|
||||
} elseif ($this->info['x'] != 0 || $this->info['y'] != 0) {
|
||||
if ($d->testLike($u->info['x'], $u->info['y'], $this->info['x'], $this->info['y']) != 1) {
|
||||
if (!$d->cellIsGoodforAction($u->info['x'], $u->info['y'], $this->info['x'], $this->info['y'])) {
|
||||
$go = 0;
|
||||
}
|
||||
//если бот погиб
|
||||
@@ -1015,8 +1024,7 @@ class Dialog
|
||||
}
|
||||
|
||||
$this->title = $this->info['text'];
|
||||
$this->youInfo = $u->getInfoPers($u->info['id'], 1);
|
||||
$this->youInfo = $this->youInfo[0];
|
||||
$this->youInfo = $u->getInfoPers($u->info['id'], 1)[0];
|
||||
$this->botInfo = $this->infoBot($this->info['bot_id']);
|
||||
//Диалог
|
||||
$qpl = mysql_fetch_array(mysql_query('SELECT * FROM `dungeon_dlg` WHERE `type` = "1" AND `qid` = "0" AND `id_dg` = "' . $this->info['id'] . '" AND `page` = "' . ((int)$pg) . '" LIMIT 1'));
|
||||
@@ -1135,7 +1143,7 @@ class Dialog
|
||||
}
|
||||
}
|
||||
if ($u->info['admin'] > 0) {
|
||||
$a .= '<small>(<a href="javascript:window.open(\'https://new-combats.com/quest_dlg_edit.php?pid=' . $pl['id'] . '\',\'winEdi1\',\'width=850,height=400,top=400,left=500,resizable=no,scrollbars=yes,status=no\');" title="Редактировать вариант ответа">ред.</a>)</small> ';
|
||||
$a .= '<small>(<a href="javascript:window.open(\'/quest_dlg_edit.php?pid=' . $pl['id'] . '\',\'winEdi1\',\'width=850,height=400,top=400,left=500,resizable=no,scrollbars=yes,status=no\');" title="Редактировать вариант ответа">ред.</a>)</small> ';
|
||||
}
|
||||
if ($go1 == '') {
|
||||
$a .= '• <a href="' . $pl['action'] . '">' . $pl['text'] . '</a><br>';
|
||||
@@ -1209,7 +1217,7 @@ class Dialog
|
||||
$val = 4799;
|
||||
}
|
||||
}
|
||||
$u->addItem($val, $u->info['id'], $data_itm);
|
||||
ItemsModel::addItem($val, $u->info['id'], $data_itm);
|
||||
$i1++;
|
||||
}
|
||||
} elseif ($var == 'up') {
|
||||
@@ -1274,41 +1282,41 @@ class Dialog
|
||||
if (isset($bot['id'])) {
|
||||
//Характеристики от предметов и их изображение
|
||||
$witm = [];
|
||||
$witm[1] = '<img width="60" height="60" style="display:block;" title="Пустой слот шлем" src="https://img.new-combats.com/i/items/w/w9.gif">';
|
||||
$witm[2] = '<img width="60" height="40" style="display:block;" title="Пустой слот наручи" src="https://img.new-combats.com/i/items/w/w13.gif">';
|
||||
$witm[3] = '<img width="60" height="60" style="display:block;" title="Пустой слот оружие" src="https://img.new-combats.com/i/items/w/w3.gif">';
|
||||
$witm[4] = '<img width="60" height="80" style="display:block;" title="Пустой слот броня" src="https://img.new-combats.com/i/items/w/w4.gif">';
|
||||
$witm[7] = '<img width="60" height="40" style="display:block;" title="Пустой слот пояс" src="https://img.new-combats.com/i/items/w/w5.gif">';
|
||||
$witm[8] = '<img width="60" height="20" style="display:block;" title="Пустой слот серьги" src="https://img.new-combats.com/i/items/w/w1.gif">';
|
||||
$witm[9] = '<img width="60" height="20" style="display:block;" title="Пустой слот ожерелье" src="https://img.new-combats.com/i/items/w/w2.gif">';
|
||||
$witm[10] = '<img width="20" height="20" style="display:block;" title="Пустой слот кольцо" src="https://img.new-combats.com/i/items/w/w6.gif">';
|
||||
$witm[11] = '<img width="20" height="20" style="display:block;" title="Пустой слот кольцо" src="https://img.new-combats.com/i/items/w/w6.gif">';
|
||||
$witm[12] = '<img width="20" height="20" style="display:block;" title="Пустой слот кольцо" src="https://img.new-combats.com/i/items/w/w6.gif">';
|
||||
$witm[13] = '<img width="60" height="40" style="display:block;" title="Пустой слот перчатки" src="https://img.new-combats.com/i/items/w/w11.gif">';
|
||||
$witm[14] = '<img width="60" height="60" style="display:block;" title="Пустой слот щит" src="https://img.new-combats.com/i/items/w/w10.gif">';
|
||||
$witm[16] = '<img width="60" height="80" style="display:block;" title="Пустой слот поножи" src="https://img.new-combats.com/i/items/w/w19.gif">';
|
||||
$witm[17] = '<img width="60" height="40" style="display:block;" title="Пустой слот обувь" src="https://img.new-combats.com/i/items/w/w12.gif">';
|
||||
$witm[1] = '<img width="60" height="60" style="display:block;" title="Пустой слот шлем" src="//img.new-combats.tech/i/items/w/w9.gif">';
|
||||
$witm[2] = '<img width="60" height="40" style="display:block;" title="Пустой слот наручи" src="//img.new-combats.tech/i/items/w/w13.gif">';
|
||||
$witm[3] = '<img width="60" height="60" style="display:block;" title="Пустой слот оружие" src="//img.new-combats.tech/i/items/w/w3.gif">';
|
||||
$witm[4] = '<img width="60" height="80" style="display:block;" title="Пустой слот броня" src="//img.new-combats.tech/i/items/w/w4.gif">';
|
||||
$witm[7] = '<img width="60" height="40" style="display:block;" title="Пустой слот пояс" src="//img.new-combats.tech/i/items/w/w5.gif">';
|
||||
$witm[8] = '<img width="60" height="20" style="display:block;" title="Пустой слот серьги" src="//img.new-combats.tech/i/items/w/w1.gif">';
|
||||
$witm[9] = '<img width="60" height="20" style="display:block;" title="Пустой слот ожерелье" src="//img.new-combats.tech/i/items/w/w2.gif">';
|
||||
$witm[10] = '<img width="20" height="20" style="display:block;" title="Пустой слот кольцо" src="//img.new-combats.tech/i/items/w/w6.gif">';
|
||||
$witm[11] = '<img width="20" height="20" style="display:block;" title="Пустой слот кольцо" src="//img.new-combats.tech/i/items/w/w6.gif">';
|
||||
$witm[12] = '<img width="20" height="20" style="display:block;" title="Пустой слот кольцо" src="//img.new-combats.tech/i/items/w/w6.gif">';
|
||||
$witm[13] = '<img width="60" height="40" style="display:block;" title="Пустой слот перчатки" src="//img.new-combats.tech/i/items/w/w11.gif">';
|
||||
$witm[14] = '<img width="60" height="60" style="display:block;" title="Пустой слот щит" src="//img.new-combats.tech/i/items/w/w10.gif">';
|
||||
$witm[16] = '<img width="60" height="80" style="display:block;" title="Пустой слот поножи" src="//img.new-combats.tech/i/items/w/w19.gif">';
|
||||
$witm[17] = '<img width="60" height="40" style="display:block;" title="Пустой слот обувь" src="//img.new-combats.tech/i/items/w/w12.gif">';
|
||||
//40-52 слот под магию
|
||||
$witm[53] = '<img style="display:block;" title="Пустой слот правый карман" src="https://img.new-combats.com/i/items/w/w15.gif">';
|
||||
$witm[54] = '<img style="display:block;" title="Пустой слот левый карман" src="https://img.new-combats.com/i/items/w/w15.gif">';
|
||||
$witm[55] = '<img style="display:block;" title="Пустой слот центральный карман" src="https://img.new-combats.com/i/items/w/w15.gif">';
|
||||
$witm[56] = '<img style="display:block;" title="Пустой слот смена" src="https://img.new-combats.com/i/items/w/w20.gif">';
|
||||
$witm[57] = '<img style="display:block;" title="Пустой слот смена" src="https://img.new-combats.com/i/items/w/w20.gif">';
|
||||
$witm[58] = '<img style="display:block;" title="Пустой слот смена" src="https://img.new-combats.com/i/items/w/w20.gif">';
|
||||
$witm[53] = '<img style="display:block;" title="Пустой слот правый карман" src="//img.new-combats.tech/i/items/w/w15.gif">';
|
||||
$witm[54] = '<img style="display:block;" title="Пустой слот левый карман" src="//img.new-combats.tech/i/items/w/w15.gif">';
|
||||
$witm[55] = '<img style="display:block;" title="Пустой слот центральный карман" src="//img.new-combats.tech/i/items/w/w15.gif">';
|
||||
$witm[56] = '<img style="display:block;" title="Пустой слот смена" src="//img.new-combats.tech/i/items/w/w20.gif">';
|
||||
$witm[57] = '<img style="display:block;" title="Пустой слот смена" src="//img.new-combats.tech/i/items/w/w20.gif">';
|
||||
$witm[58] = '<img style="display:block;" title="Пустой слот смена" src="//img.new-combats.tech/i/items/w/w20.gif">';
|
||||
|
||||
$pb = '';
|
||||
$hpmp = '?? ';
|
||||
$eff = '';
|
||||
$anml = '';
|
||||
$oi = '';
|
||||
$msl = '<img width="120" height="40" style="display:block" src="https://img.new-combats.com/i/slot_bottom.gif">';
|
||||
$msl = '<img width="120" height="40" style="display:block" src="//img.new-combats.tech/i/slot_bottom.gif">';
|
||||
$witmg = '';
|
||||
|
||||
if ($bot['level'] < 0) {
|
||||
$bot['level'] = '??';
|
||||
}
|
||||
|
||||
$r = '<div style="width:246px; padding:2px;" align="center"><b>' . $bot['login'] . '</b> [' . $bot['level'] . ']<img src="https://img.new-combats.com/i/inf_.gif"></div>
|
||||
$r = '<div style="width:246px; padding:2px;" align="center"><b>' . $bot['login'] . '</b> [' . $bot['level'] . ']<img src="//img.new-combats.tech/i/inf_.gif"></div>
|
||||
<div style="width:240px; padding:2px; border-bottom:1px solid #666666; border-right:1px solid #666666; border-left:1px solid #FFFFFF; border-top:1px solid #FFFFFF;">
|
||||
<div align="center"><!-- blocked -->' . $pb . '</div>
|
||||
<table width="240" border="0" cellspacing="0" cellpadding="0">
|
||||
@@ -1345,7 +1353,7 @@ class Dialog
|
||||
<td valign="top">
|
||||
<div style="position:relative;height:220px;">
|
||||
<!-- образ -->
|
||||
<div style="position:absolute; width:120px; height:220px; z-index:1;"><a href="#obraz_pers"><img width="120" height="220" src="https://img.new-combats.com/i/obraz/' . $bot['sex'] . '/' . $bot['obraz'] . '" ' . $oi . '></a></div>
|
||||
<div style="position:absolute; width:120px; height:220px; z-index:1;"><a href="#obraz_pers"><img width="120" height="220" src="//img.new-combats.tech/i/obraz/' . $bot['sex'] . '/' . $bot['obraz'] . '" ' . $oi . '></a></div>
|
||||
<div style="position:absolute; width:120px; height:220px; z-index:3;" align="left">' . $eff . '</div>' . $anml . '
|
||||
</div>
|
||||
</td>
|
||||
|
||||
+1486
-1085
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ class DungeonEditor
|
||||
$this->bs = mysql_fetch_array(mysql_query('SELECT * FROM `bs_turnirs` WHERE `city` = "' . $u->info['city'] . '" AND `id` = "' . $this->info['bsid'] . '" AND `time_start` = "' . $this->info['time_start'] . '" LIMIT 1'));
|
||||
//Если БС закончена
|
||||
if (isset($this->bs['id']) && $this->bs['users'] - $this->bs['users_finish'] < 2) {
|
||||
$u->bsfinish($this->bs, false, null);
|
||||
\Location\DeathTower::finish($this->bs, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Enum;
|
||||
|
||||
enum ShopId: int
|
||||
{
|
||||
case MAIN = 1;
|
||||
case BEREZKA = 2;
|
||||
case LUKA = 5; // пещера тысячи проклятий
|
||||
case FLOWER = 6;
|
||||
case BOOKS = 7;
|
||||
case ANIMALS = 8; // магазин новичка
|
||||
case TAVERN = 9; // наковальня
|
||||
case IZLOM = 10;
|
||||
case BLOOD_ALTAR = 11; //алтарь крови
|
||||
case TEMPLE = 14;
|
||||
case MUSHROOMS = 17; // общий рыцарский
|
||||
case REFERALS = 27;
|
||||
case RULF_HRUNT = 33; // бездна
|
||||
case SHOP_KAT = 44; // магазин рульфа хрунта, а ты что такое?
|
||||
case LABORATORY = 45;
|
||||
case NEWBIE = 106; // пещера мглы
|
||||
case KNIGHTS_MAIN = 400; //магазин рефералов
|
||||
case SHOP_PRIZ = 404; // каморка Луки
|
||||
case SHOP_2 = 609; // магазин грибоеда??
|
||||
case ANVIL = 700; // катакомбы
|
||||
case ARTEFACTS = 777; //магазин самоцветов
|
||||
case DUNGEON_BEZDNA = 801; // храм?!
|
||||
case DUNGEON_PTP = 802; // излом?!
|
||||
case DUNGEON_CATACOMBS = 803; //лаборатория?!?!
|
||||
case DUNGEON_MISTY = 804;
|
||||
case CRYSTALS = 1050;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Enum;
|
||||
|
||||
enum StatFilterCellName: string
|
||||
{
|
||||
case Bonus = 'is_bonus';
|
||||
case Requirement = 'is_requirement';
|
||||
case Percentage = 'is_percentage';
|
||||
}
|
||||
+1258
-2840
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace FightRequest;
|
||||
|
||||
class FRHelper
|
||||
{
|
||||
/** Ń÷čňŕĺň đŕçđĺřĺííűĺ óđîâíč čăđîęîâ â ăđóďďîâűő çŕ˙âęŕő.
|
||||
* @param int $type ňčď ôčëüňđŕ.
|
||||
* @param int $userLevel óđîâĺíü čăđîęŕ ďîäŕţůĺăî çŕ˙âęó.
|
||||
* @return object
|
||||
*/
|
||||
public static function getTeammatesLevel(int $type, int $userLevel): object
|
||||
{
|
||||
$min = 0;
|
||||
$max = 21;
|
||||
switch ($type) {
|
||||
default:
|
||||
break;
|
||||
case 1: // ňîëüęî ěîĺăî č íčćĺ
|
||||
$max = $userLevel;
|
||||
break;
|
||||
case 2: // ňîëüęî íčćĺ ěîĺăî
|
||||
$max = $userLevel - 1;
|
||||
break;
|
||||
case 3: // ňîëüęî ěîĺăî
|
||||
$min = $userLevel;
|
||||
$max = $userLevel;
|
||||
break;
|
||||
case 4: // íĺ âűřĺ ěĺí˙ íŕ 1 óđîâĺíü
|
||||
$min = $userLevel;
|
||||
$max = $userLevel + 1;
|
||||
break;
|
||||
case 5: // íĺ íčćĺ ěĺí˙ íŕ 1 óđîâĺíü
|
||||
$min = $userLevel - 1;
|
||||
$max = $userLevel;
|
||||
break;
|
||||
case 6: // ěîé óđîâĺíü +- 1
|
||||
$min = $userLevel - 1;
|
||||
$max = $userLevel + 1;
|
||||
break;
|
||||
}
|
||||
return (object)[
|
||||
'min'=> $min,
|
||||
'max'=> $max,
|
||||
];
|
||||
}
|
||||
|
||||
/** Ń÷čňŕĺň đŕçđĺřĺííűĺ óđîâíč čăđîęîâ â őŕîňč÷ĺńęčő çŕ˙âęŕő.
|
||||
* @param int $type ňčď ôčëüňđŕ.
|
||||
* @param int $userLevel óđîâĺíü čăđîęŕ ďîäŕţůĺăî çŕ˙âęó.
|
||||
* @return object
|
||||
*/
|
||||
public static function getChaoticTeammatesLevel(int $type, int $userLevel): object
|
||||
{
|
||||
if (!in_array($type, [3, 6])) {
|
||||
$type = 0;
|
||||
}
|
||||
return self::getTeammatesLevel($type, $userLevel);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-54
@@ -11,15 +11,11 @@ class Filter
|
||||
}
|
||||
//
|
||||
//Смайлики
|
||||
private $sm = ["laugh" => 1, "fingal" => 1, "eek" => 1, "smoke" => 1, "hi" => 1, "bye" => 1, "king" => 1, "king2" => 1, "boks2" => 1, "boks" => 1, "gent" => 1, "lady" => 1, "tongue" => 1, "smil" => 1, "rotate" => 1, "ponder" => 1, "bow" => 1, "angel" => 1, "angel2" => 1, "hello" => 1, "dont" => 1, "idea" => 1, "mol" => 1, "super" => 1, "beer" => 1, "drink" => 1, "baby" => 1, "tongue2" => 1, "sword" => 1, "agree" => 1, "loveya" => 1, "kiss" => 1, "kiss2" => 1, "kiss3" => 1, "kiss4" => 1, "rose" => 1, "love" => 1, "love2" => 1, "confused" => 1, "yes" => 1, "no" => 1, "shuffle" => 1, "nono" => 1, "maniac" => 1, "privet" => 1, "ok" => 1, "ninja" => 1, "pif" => 1, "smash" => 1, "alien" => 1, "pirate" => 1, "gun" => 1, "trup" => 1, "mdr" => 1, "sneeze" => 1, "mad" => 1, "friday" => 1, "cry" => 1, "grust" => 1, "rupor" => 1, "fie" => 1, "nnn" => 1, "row" => 1, "red" => 1, "lick" => 1, "help" => 1, "wink" => 1, "jeer" => 1, "tease" => 1, "nunu" => 1, "inv" => 1, "duel" => 1, "susel" => 1, "nun" => 1, "kruger" => 1, "flowers" => 1, "horse" => 1, "hug" => 1, "str" => 1, "alch" => 1, "pal" => 1, "mag" => 1, "sniper" => 1, "vamp" => 1, "doc" => 1, "doc2" => 1, "sharp" => 1, "naem" => 1, "naem2" => 1, "naem3" => 1, "invis" => 1, "chtoza" => 1, "beggar" => 1, "sorry" => 1, "sorry2" => 1, "creator" => 1, "grace" => 1, "dustman" => 1, "carreat" => 1, "lordhaos" => 1, "ura" => 1, "elix" => 1, "dedmoroz" => 1, "snegur" => 1, "showng" => 1, "superng" => 1, "podz" => 1, "sten" => 1, "devil" => 1, "cat" => 1, "owl" => 1, "lightfly" => 1, "snowfight" => 1, "rocket" => 1, "ball" => 1, "smile" => 1, "fuck" => 1];
|
||||
private array $sm = ["laugh" => 1, "fingal" => 1, "eek" => 1, "smoke" => 1, "hi" => 1, "bye" => 1, "king" => 1, "king2" => 1, "boks2" => 1, "boks" => 1, "gent" => 1, "lady" => 1, "tongue" => 1, "smil" => 1, "rotate" => 1, "ponder" => 1, "bow" => 1, "angel" => 1, "angel2" => 1, "hello" => 1, "dont" => 1, "idea" => 1, "mol" => 1, "super" => 1, "beer" => 1, "drink" => 1, "baby" => 1, "tongue2" => 1, "sword" => 1, "agree" => 1, "loveya" => 1, "kiss" => 1, "kiss2" => 1, "kiss3" => 1, "kiss4" => 1, "rose" => 1, "love" => 1, "love2" => 1, "confused" => 1, "yes" => 1, "no" => 1, "shuffle" => 1, "nono" => 1, "maniac" => 1, "privet" => 1, "ok" => 1, "ninja" => 1, "pif" => 1, "smash" => 1, "alien" => 1, "pirate" => 1, "gun" => 1, "trup" => 1, "mdr" => 1, "sneeze" => 1, "mad" => 1, "friday" => 1, "cry" => 1, "grust" => 1, "rupor" => 1, "fie" => 1, "nnn" => 1, "row" => 1, "red" => 1, "lick" => 1, "help" => 1, "wink" => 1, "jeer" => 1, "tease" => 1, "nunu" => 1, "inv" => 1, "duel" => 1, "susel" => 1, "nun" => 1, "kruger" => 1, "flowers" => 1, "horse" => 1, "hug" => 1, "str" => 1, "alch" => 1, "pal" => 1, "mag" => 1, "sniper" => 1, "vamp" => 1, "doc" => 1, "doc2" => 1, "sharp" => 1, "naem" => 1, "naem2" => 1, "naem3" => 1, "invis" => 1, "chtoza" => 1, "beggar" => 1, "sorry" => 1, "sorry2" => 1, "creator" => 1, "grace" => 1, "dustman" => 1, "carreat" => 1, "lordhaos" => 1, "ura" => 1, "elix" => 1, "dedmoroz" => 1, "snegur" => 1, "showng" => 1, "superng" => 1, "podz" => 1, "sten" => 1, "devil" => 1, "cat" => 1, "owl" => 1, "lightfly" => 1, "snowfight" => 1, "rocket" => 1, "ball" => 1, "smile" => 1, "fuck" => 1];
|
||||
|
||||
public function e($t)
|
||||
{
|
||||
mysql_query(
|
||||
'INSERT INTO `chat` (`text`,`city`,`to`,`type`,`new`,`time`) VALUES ("#' . date('d.m.Y') . ' %' . date(
|
||||
'H:i:s'
|
||||
) . ': <b>' . mysql_real_escape_string($t) . '</b>","capitalcity","Игромир","6","1","-1")'
|
||||
);
|
||||
(new Chat())->debug($t, true);
|
||||
}
|
||||
|
||||
public function setOnline($online, $uid)
|
||||
@@ -36,7 +32,7 @@ class Filter
|
||||
|
||||
if ($add > 0) {
|
||||
$on = mysql_fetch_array(mysql_query('SELECT * FROM `online` WHERE `uid` = "' . $uid . '" LIMIT 1'));
|
||||
if (isset($on['id'])) {
|
||||
if (isset($on['uid'])) {
|
||||
$mt = 0;
|
||||
$lst = time();
|
||||
if (date('d', $on['lastUp']) != date('d', $lst)) {
|
||||
@@ -46,13 +42,13 @@ class Filter
|
||||
}
|
||||
$add = $on['time_all'] + $add;
|
||||
mysql_query(
|
||||
'UPDATE `online` SET `mainTime` = "' . $mt . '",`time_today` = "' . $on['time_today'] . '",`lastUp` = "' . $lst . '",`time_all` = "' . $add . '" WHERE `id` = "' . $on['id'] . '" LIMIT 1'
|
||||
'UPDATE `online` SET `mainTime` = "' . $mt . '",`time_today` = "' . $on['time_today'] . '",`lastUp` = "' . $lst . '",`time_all` = "' . $add . '" WHERE `uid` = "' . $on['uid'] . '" LIMIT 1'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function mystr($string)
|
||||
public function mystr($string): string
|
||||
{
|
||||
$str = strtolower($string);
|
||||
if (strtolower('S') != 's') {
|
||||
@@ -94,57 +90,22 @@ class Filter
|
||||
/* фильтр */
|
||||
$spam = mysql_fetch_array(mysql_query('SELECT * FROM `spam_word` WHERE `id` = 1 LIMIT 1'));
|
||||
$spam = $spam['data'];
|
||||
//
|
||||
$testEN = preg_replace('/[^A-z]*/i', '', $txt);
|
||||
$testEN2 = $txt;
|
||||
|
||||
$testEN2 = str_replace('"', '', $testEN2);
|
||||
$testEN2 = str_replace(' ', '', $testEN2);
|
||||
$testEN2 = str_replace('а', 'a', $testEN2);
|
||||
$testEN2 = str_replace('б', 'b', $testEN2);
|
||||
$testEN2 = str_replace('с', 'c', $testEN2);
|
||||
$testEN2 = str_replace('в', 'b', $testEN2);
|
||||
$testEN2 = str_replace('е', 'e', $testEN2);
|
||||
$testEN2 = str_replace('т', 't', $testEN2);
|
||||
$testEN2 = str_replace('о', 'o', $testEN2);
|
||||
$testEN2 = str_replace('р', 'p', $testEN2);
|
||||
$testEN2 = str_replace('м', 'm', $testEN2);
|
||||
$testEN2 = str_replace('н', 'h', $testEN2);
|
||||
$testEN2 = str_replace('у', 'y', $testEN2);
|
||||
$testEN2 = str_replace('к', 'k', $testEN2);
|
||||
$testEN2 = str_replace('и', 'u', $testEN2);
|
||||
$testEN2 = str_replace('х', 'x', $testEN2);
|
||||
$testEN2 = str_replace('я', '9', $testEN2);
|
||||
$testEN2 = str_replace('()', 'o', $testEN2);
|
||||
$testEN2 = str_replace('0', 'o', $testEN2);
|
||||
$testEN2 = preg_replace('/[^A-z]*/i', '', $testEN2);
|
||||
$testEN = preg_replace('/[^A-z]*/i', '', $txt);
|
||||
$testRU = preg_replace('/[^А-я]*/i', '', $txt);
|
||||
|
||||
$testRU2 = $txt;
|
||||
$testRU2 = str_replace('a', 'а', $testRU2);
|
||||
$testRU2 = str_replace('b', 'б', $testRU2);
|
||||
$testRU2 = str_replace('c', 'с', $testRU2);
|
||||
$testRU2 = str_replace('b', 'в', $testRU2);
|
||||
$testRU2 = str_replace('e', 'е', $testRU2);
|
||||
$testRU2 = str_replace('t', 'т', $testRU2);
|
||||
$testRU2 = str_replace('o', 'о', $testRU2);
|
||||
$testRU2 = str_replace('p', 'р', $testRU2);
|
||||
$testRU2 = str_replace('m', 'м', $testRU2);
|
||||
$testRU2 = str_replace('h', 'н', $testRU2);
|
||||
$testRU2 = str_replace('y', 'у', $testRU2);
|
||||
$testRU2 = str_replace('k', 'к', $testRU2);
|
||||
$testRU2 = str_replace('x', 'х', $testRU2);
|
||||
$testRU2 = str_replace('u', 'и', $testRU2);
|
||||
$testRU2 = str_replace('()', 'о', $testRU2);
|
||||
$testRU2 = str_replace('0', 'о', $testRU2);
|
||||
$testRU2 = preg_replace('/[^А-я]*/i', ' ', $testRU2);
|
||||
$testRU2 = preg_replace('/[^А-Я]*/i', ' ', $testRU2);
|
||||
$i = 0;
|
||||
$spe = explode('|', $spam);
|
||||
while ($i <= count($spe)) {
|
||||
if (isset($spe[$i]) && $spe[$i] != '' && $spe[$i] != 'new-combats.com' && (stristr(
|
||||
$testEN, $spe[$i]
|
||||
) || stristr($testRU, $spe[$i]))) {
|
||||
if (
|
||||
isset($spe[$i]) &&
|
||||
$spe[$i] != '' &&
|
||||
$spe[$i] != 'new-combats.tech' &&
|
||||
(
|
||||
stristr($testEN, $spe[$i]) ||
|
||||
stristr($testRU, $spe[$i])
|
||||
)
|
||||
) {
|
||||
$nospam .= '%' . $spe[$i];
|
||||
}
|
||||
$i++;
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**@deprecated вроде нигде не вызывается, никем не используется */
|
||||
class GameDealer
|
||||
{
|
||||
//Конфигурации
|
||||
private $c = [
|
||||
'db_name' => 'pay_operations', //Таблица в которую заносятся данные
|
||||
'db_host' => 'localhost',
|
||||
'db_user' => 'newcom1_abk',
|
||||
'db_pass' => '4nWYsIM[c?}P',
|
||||
'db_base' => 'newcom1_abk', /* Настройки платежей */
|
||||
'ip_list' => ['127,0,0,1,188.166.34.68,136.243.38.147,136.243.38.149,136.243.38.150,136.243.38.151,136.243.38.189,88.198.88.98'], //Указывать через запятую (Разрешенные IP)
|
||||
'key' => 'qtzl0igb', //gamedealer key
|
||||
'id' => '65643' //ID проекта
|
||||
], $BACK = []; //Результат который возвращаем в конце
|
||||
|
||||
//Кодируем из ЮТФ-8 в Кирилицу
|
||||
/**
|
||||
* @param $text
|
||||
* @return mixed
|
||||
* @deprecated
|
||||
*/
|
||||
public function in($text)
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
|
||||
//Кодируем из Кирилицу в ЮТФ-8
|
||||
|
||||
/**
|
||||
* @param $text
|
||||
* @return mixed
|
||||
* @deprecated
|
||||
*/
|
||||
public function out($text)
|
||||
{
|
||||
return $text;
|
||||
}
|
||||
|
||||
//Добавляем данные в базу данных
|
||||
public function add($type, $value, $money)
|
||||
{
|
||||
mysql_query('INSERT INTO `' . $this->c['db_name'] . '` (`time`,`type`,`ip`,`value`,`money`,`project`) VALUES ("' . time() . '","' . mysql_real_escape_string($type) . '","' . $_SERVER['HTTP_X_REAL_IP'] . '","' . mysql_real_escape_string($value) . '","' . mysql_real_escape_string($money) . '","' . mysql_real_escape_string($this->id) . '")');
|
||||
}
|
||||
|
||||
//Подключаемся к базе данных
|
||||
public function connect_db()
|
||||
{
|
||||
$db = mysql_connect($this->c['db_host'], $this->c['db_user'], $this->c['db_pass']) or die('Ошибка подключения к MySQL серверу!');
|
||||
mysql_select_db($this->c['db_base'], $db) or die('Ошибка подключения к базе данных!');
|
||||
mysql_query('SET NAMES utf8mb4');
|
||||
}
|
||||
|
||||
public function output($a, $v = null)
|
||||
{
|
||||
$r = '';
|
||||
$i = 0;
|
||||
while ($i < count($a)) {
|
||||
$rn = '';
|
||||
$tb = '';
|
||||
if ($v != null) {
|
||||
$rn = "\r\n";
|
||||
$tb = " ";
|
||||
}
|
||||
$r .= $rn . '<' . $a[$i][0] . '>';
|
||||
if (!is_array($a[$i][1])) {
|
||||
$rn = '';
|
||||
$tb = '';
|
||||
$r .= $rn . $tb . ($this->out($a[$i][1]));
|
||||
} else {
|
||||
if ($i > 0) {
|
||||
$r .= $rn;
|
||||
}
|
||||
$r .= $tb . ($this->output($a[$i][1], 1));
|
||||
}
|
||||
$r .= $rn . '</' . $a[$i][0] . '>';
|
||||
$i++;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
//Генерируем XML-файл
|
||||
public function backInformation()
|
||||
{
|
||||
header('Content-Type: text/html/force-download');
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
echo $this->output($this->BACK, 1);
|
||||
}
|
||||
|
||||
//Проверка существования персонажа
|
||||
public function test_accaunt($nick)
|
||||
{
|
||||
$r = false;
|
||||
$nick = mysql_fetch_array(mysql_query('SELECT `id` FROM `bank` WHERE `id` = "' . mysql_real_escape_string($nick) . '" LIMIT 1'));
|
||||
if (isset($nick['id'])) {
|
||||
$r = true;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
//Получает счет в банке по логину
|
||||
public function getBank($nick)
|
||||
{
|
||||
$nick = mysql_fetch_array(mysql_query('SELECT `id` FROM `users` WHERE `login` = "' . mysql_real_escape_string($nick) . '" LIMIT 1'));
|
||||
$nick = mysql_fetch_array(mysql_query('SELECT `id` FROM `bank` WHERE `uid` = "' . mysql_real_escape_string($nick['id']) . '" LIMIT 1'));
|
||||
return $nick['id'];
|
||||
}
|
||||
|
||||
//Поиск логина
|
||||
public function bank_user($nick)
|
||||
{
|
||||
$nick = mysql_fetch_array(mysql_query('SELECT `id`,`uid FROM `bank` WHERE `id` = "' . mysql_real_escape_string($nick) . '" LIMIT 1'));
|
||||
$nick = mysql_fetch_array(mysql_query('SELECT `id`,`login` FROM `users` WHERE `login` = "' . mysql_real_escape_string($nick['uid']) . '" LIMIT 1'));
|
||||
return $nick['login'];
|
||||
}
|
||||
|
||||
//Начинаем обработку запросов
|
||||
public function start_session()
|
||||
{
|
||||
|
||||
$ip = '';
|
||||
$ip = $_SERVER['HTTP_X_REAL_IP'];
|
||||
|
||||
//Подключаемся к БД
|
||||
$this->connect_db();
|
||||
|
||||
//Получаем данные запроса
|
||||
//$xml = file_get_contents('php://input');
|
||||
|
||||
//Парсинг XML запроса
|
||||
if (function_exists('simplexml_load_string')) {
|
||||
$xml = simplexml_load_string($xml);
|
||||
} else {
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Не удалось произвести обработку запроса']]]];
|
||||
die($this->backInformation());
|
||||
}
|
||||
|
||||
$this->id = $xml->projectid;
|
||||
|
||||
if (!in_array($ip, $this->c['ip_list'])) {
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Нет доступа с данного IP']]]];
|
||||
die($this->backInformation());
|
||||
}
|
||||
|
||||
//Обработка запросов
|
||||
if ($xml->method == 'check_balance') {
|
||||
//<sign>MD5(method+MD5(gdKey))</sign>
|
||||
|
||||
$sign = md5($xml->method . md5($this->c['key']));
|
||||
|
||||
if ($sign == $xml->sign) {
|
||||
//Баланс дилера
|
||||
$balance = 1000000;
|
||||
$this->BACK = [['gdanswer', [['status', '1'], ['desc', 'Баланс дилера: ' . $balance], ['balance', $balance]]]];
|
||||
$this->add('4', 'check:' . $xml->nick . ':1' . $r, 0);
|
||||
}
|
||||
|
||||
} elseif ($xml->method == 'check') {
|
||||
/*
|
||||
nick - логин персонажа <sign>MD5(nick+method+MD5(gdKey))</sign> */
|
||||
|
||||
$sign = md5($xml->nick . $xml->method . md5($this->c['key']));
|
||||
|
||||
if ($sign == $xml->sign) {
|
||||
$xml->nick = $this->in($xml->nick);
|
||||
if ($this->test_accaunt($xml->nick) == true) {
|
||||
//Персонаж найден и зачисляем ему игровую валюту
|
||||
$this->BACK = [['gdanswer', [['status', '1'], ['desc', 'Банковский счет найден']]]];
|
||||
$this->add('3', 'check:' . $xml->nick . ':1' . $r, 0);
|
||||
} else {
|
||||
//Персонаж не найден
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Платеж не обработан. Банковский счет не найден.']]]];
|
||||
$this->add('-1', 'Персонаж не найден:pay:' . $xml->nick . ':0', 0);
|
||||
}
|
||||
}
|
||||
} elseif ($xml->method == 'pay') {
|
||||
/* Проводим платеж
|
||||
nick - логин аккаунта , projectid - id проекта , sign , amount - деньги , payid - id платежа */
|
||||
|
||||
$sign = md5($xml->nick . $xml->projectid . $xml->amount . $xml->payid . $xml->method . md5($this->c['key']));
|
||||
|
||||
if ($sign == $xml->sign) {
|
||||
$xml->nick = $this->in($xml->nick);
|
||||
if ($this->test_accaunt($xml->nick)) {
|
||||
//Персонаж найден и зачисляем ему игровую валюту
|
||||
$bank = $this->test_accaunt($xml->nick);
|
||||
if ($bank > 0) {
|
||||
mysql_query('UPDATE `bank` SET `money2` = `money2` + ' . mysql_real_escape_string($xml->amount) . ' WHERE `id` = "' . mysql_real_escape_string($xml->nick) . '" LIMIT 1');
|
||||
$this->BACK = [['gdanswer', [['status', '1'], ['desc', 'Платеж прошел успешно'], ['id', $this->c['id']]]]];
|
||||
$this->add('2', 'pay:' . $xml->nick . ':' . $xml->projectid . ':' . $xml->sign . ':' . $xml->amount . ':' . $xml->payid . ':' . $bank['id'], $xml->amount);
|
||||
|
||||
$user = mysql_fetch_array(mysql_query('SELECT `id`,`uid` FROM `bank` WHERE `id` = "' . mysql_real_escape_string($xml->nick) . '" LIMIT 1'));
|
||||
$user = mysql_fetch_array(mysql_query('SELECT `id`,`login`,`city`,`sex`,`room` FROM `users` WHERE `id` = "' . mysql_real_escape_string($user['uid']) . '" LIMIT 1'));
|
||||
|
||||
mysql_query('UPDATE `users` SET `catch` = `catch` + ' . mysql_real_escape_string(floor($xml->amount)) . ' WHERE `id` = "' . mysql_real_escape_string($xml->nick) . '" LIMIT 1');
|
||||
|
||||
$r = '<span class=date>' . date('d.m.Y H:i') . '</span> Алхимик <img src=https://img.new-combats.com/i/align/align50.gif width=12 height=15 /><u><b>Enchanter</b> / Автоматическая оплата</u> сообщает: ';
|
||||
|
||||
if ($user['sex'] == 1) {
|
||||
$r .= 'Уважаемая';
|
||||
} else {
|
||||
$r .= 'Уважаемый';
|
||||
}
|
||||
|
||||
$r .= ' <b>' . $user['login'] . '</b>, на Ваш банковский счет №' . $bank . ' зачислено ' . $xml->amount . ' Ekr. Благодарим Вас за покупку!';
|
||||
|
||||
mysql_query("INSERT INTO `chat` (`new`,`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`) VALUES ('1','" . $user['city'] . "','" . $user['room'] . "','','" . $user['login'] . "','" . $r . "','-1','5','0')");
|
||||
|
||||
} else {
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'У пользователя отсутствует банк'], ['id', $this->c['id']]]]];
|
||||
$this->add('-1', 'У персонажа отсутствует банк:pay:' . $xml->nick . ':' . $xml->projectid . ':' . $xml->sign . ':' . $xml->amount . ':' . $xml->payid . ':' . $bank['id'], $xml->amount);
|
||||
}
|
||||
} else {
|
||||
//Персонаж не найден
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Платеж не обработан. Персонаж не найден.']]]];
|
||||
$this->add('-1', 'Персонаж не найден:pay:' . $xml->nick . ':0', 0);
|
||||
}
|
||||
} else {
|
||||
//Ошибка сигнатуры
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Ошибка сигнатуры']]]];
|
||||
$this->add('-1', 'Ошибка сигнатуры:pay:' . $xml->nick . ':0', 0);
|
||||
}
|
||||
} elseif ($xml->method == 'check_login') {
|
||||
/* Проверка аккаунта
|
||||
nick - логин аккаунта , projectid - id проекта , sign */
|
||||
$sign = md5($xml->nick . $xml->method . md5($this->c['key']));
|
||||
|
||||
if ($sign == $xml->sign) {
|
||||
$xml->nick = $this->in($xml->nick);
|
||||
if ($this->test_accaunt($xml->nick)) {
|
||||
//Персонаж найден
|
||||
$this->BACK = [['gdanswer', [['status', '1'], ['desc', 'Счет найден'], ['addinfo', $this->bank_user($xml->nick)]]]];
|
||||
$this->add('1', 'check_login:' . $xml->nick . ':1' . $r, 0);
|
||||
} else {
|
||||
//Персонаж не найден
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Счет не найден']]]];
|
||||
$this->add('-1', 'Персонаж не найден:check_login:' . $xml->nick . ':0', 0);
|
||||
}
|
||||
} else {
|
||||
//Ошибка сигнатуры
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Ошибка сигнатуры']]]];
|
||||
$this->add('-1', 'Ошибка сигнатуры:pay:' . $xml->nick . ':0', 0);
|
||||
}
|
||||
} else {
|
||||
$this->BACK = [['gdanswer', [['status', '-1'], ['desc', 'Неизвестный тип запроса']]]];
|
||||
$this->add('-1', 'Неизвестный тип запроса:error_method:gamedealer', 0);
|
||||
}
|
||||
|
||||
//Возвращаем результат
|
||||
$this->backInformation();
|
||||
}
|
||||
}
|
||||
|
||||
$pay = new GameDealer;
|
||||
$pay->start_session();
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
class ArraySorter
|
||||
{
|
||||
/**
|
||||
* Groups an array by a given key.
|
||||
*
|
||||
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
|
||||
*
|
||||
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
|
||||
* This variant allows $key to be closures.
|
||||
*
|
||||
* @param array $array The array to have grouping performed on.
|
||||
* @param mixed $key,... The key to group or split by. Can be a _string_,
|
||||
* an _integer_, a _float_, or a _callable_.
|
||||
*
|
||||
* If the key is a callback, it must return
|
||||
* a valid key from the array.
|
||||
*
|
||||
* If the key is _NULL_, the iterated element is skipped.
|
||||
*
|
||||
* ```
|
||||
* string|int callback ( mixed $item )
|
||||
* ```
|
||||
*
|
||||
* @return array|null Returns a multidimensional array or `null` if `$key` is invalid.
|
||||
*/
|
||||
public static function groupBy(array $array, $key): ?array
|
||||
{
|
||||
if (!is_string($key) && !is_int($key) && !is_float($key) && !is_callable($key)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$func = (!is_string($key) && is_callable($key) ? $key : null);
|
||||
$key2 = $key;
|
||||
|
||||
// Load the new array, splitting by the target key
|
||||
$grouped = [];
|
||||
foreach ($array as $value) {
|
||||
$key = null;
|
||||
|
||||
if (is_callable($func)) {
|
||||
$key = call_user_func($func, $value);
|
||||
} elseif (is_object($value) && property_exists($value, $key2)) {
|
||||
$key = $value->{$key2};
|
||||
} elseif (isset($value[$key2])) {
|
||||
$key = $value[$key2];
|
||||
}
|
||||
|
||||
if ($key === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$grouped[$key][] = $value;
|
||||
}
|
||||
|
||||
// Recursively build a nested grouping if more parameters are supplied
|
||||
// Each grouped array value is grouped according to the next sequential key
|
||||
if (func_num_args() > 2) {
|
||||
$args = func_get_args();
|
||||
|
||||
foreach ($grouped as $key => $value) {
|
||||
$params = array_merge([$value], array_slice($args, 2, func_num_args()));
|
||||
$grouped[$key] = call_user_func_array('array_group_by', $params);
|
||||
}
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
|
||||
class Comparsion
|
||||
{
|
||||
/** Íå äà¸ò çíà÷åíèþ âûéòè çà ïðåäåëû.
|
||||
* @param $value
|
||||
* @param $minimum
|
||||
* @param $maximum
|
||||
* @return mixed
|
||||
*/
|
||||
public static function minimax($value, $minimum, $maximum): mixed
|
||||
{
|
||||
if ($value < $minimum) {
|
||||
$value = $minimum;
|
||||
}
|
||||
if ($value > $maximum) {
|
||||
$value = $maximum;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class Conversion
|
||||
{
|
||||
/** Превращает строку data ('a=1|b=2|c=3') из БД в массив [a=>1, b=>2, c=>3].
|
||||
* @param string|null $dataString
|
||||
* @return array
|
||||
*/
|
||||
public static function dataStringToArray(?string $dataString): array
|
||||
{
|
||||
if (empty($dataString)) {
|
||||
return [];
|
||||
}
|
||||
$dataString = str_replace('||', '|', $dataString); // любители забивать руками параметры и задваивать разделители.
|
||||
|
||||
if (mb_substr($dataString, -1) === '|') {
|
||||
$dataString = rtrim($dataString, '|');
|
||||
}
|
||||
$arr = json_decode(str_replace(['=', '|'], ['":', ',"'], '{"' . $dataString . '}'), true);
|
||||
return $arr ?: [];
|
||||
}
|
||||
|
||||
/** Превращает массив [a=>1, b=>2, c=>3] в строку data ('a=1|b=2|c=3') для БД.
|
||||
* @param array $dataArray
|
||||
* @return string
|
||||
*/
|
||||
public static function arrayToDataString(array $dataArray): string
|
||||
{
|
||||
$str = json_encode($dataArray);
|
||||
return $str ? str_replace(['":', ',"', '{"', '}'], ['=', '|'], $str) : '';
|
||||
}
|
||||
|
||||
/** Превращает количество секунд в человекопонятное Х мес. Х дн. Х ч. Х мин. Х сек.,
|
||||
* используемое обычно для отображения игровых таймаутов.
|
||||
* @param int|string $seconds
|
||||
* @return string
|
||||
*/
|
||||
public static function secondsToTimeout(int|string $seconds): string
|
||||
{
|
||||
$seconds = (int)$seconds;
|
||||
$time = new DateTime();
|
||||
$time->setTimestamp($seconds);
|
||||
$sec = intval($time->format('s'));
|
||||
$min = intval($time->format('i'));
|
||||
$hr = intval($time->format('G'));
|
||||
$day = intval($time->format('j'));
|
||||
$month = intval($time->format('n'));
|
||||
$timeout = '';
|
||||
if ($month > 1) {
|
||||
$timeout .= $month . ' мес. ';
|
||||
}
|
||||
if ($day > 1) {
|
||||
$timeout .= $day . ' дн. ';
|
||||
}
|
||||
if ($hr) {
|
||||
$timeout .= $hr . ' ч. ';
|
||||
}
|
||||
if ($sec && !$min) {
|
||||
$timeout .= $sec . ' сек. ';
|
||||
} elseif ($min) {
|
||||
$timeout .= $min . ' мин. ';
|
||||
}
|
||||
return $timeout;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
class Mail
|
||||
{
|
||||
public static function send($to, $message, $subject = 'Бойцовский клуб'): int
|
||||
{
|
||||
$mail = new PHPMailer;
|
||||
try {
|
||||
$mail->IsSMTP();
|
||||
$mail->Host = 'smtp.mail.yahoo.com';
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = 'newcombats@yahoo.com';
|
||||
$mail->Password = 'uqcdbnsoagxcyysh';
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Port = 587;
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
$mail->setFrom('newcombats@yahoo.com', 'Бойцовский Клуб');
|
||||
$mail->addAddress($to); // Add a recipient
|
||||
|
||||
$mail->IsHTML();
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = '<div>' . $message . '</div>';
|
||||
$mail->AltBody = $message;
|
||||
$mail->send();
|
||||
return 1;
|
||||
} catch (Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
|
||||
/** All raw mathematics in one place. */
|
||||
class Math
|
||||
{
|
||||
/**
|
||||
* @param float|int $total
|
||||
* @param int|null $number
|
||||
* @return float
|
||||
*/
|
||||
public static function getPercentage($total, ?int $number): float
|
||||
{
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
}
|
||||
return $total > 0 ? round(($number * 100) / $total, 2) : 0;
|
||||
}
|
||||
|
||||
|
||||
public static function get100Percentage($total, ?int $number)
|
||||
{
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
}
|
||||
return min(self::getPercentage($total, $number), 100);
|
||||
}
|
||||
|
||||
/** Number-20% and Number+20% */
|
||||
public static function get20PercentRange($number): array
|
||||
{
|
||||
return [
|
||||
'min' => $number * ((100 - 20) / 100),
|
||||
'max' => $number * ((100 + 20) / 100),
|
||||
];
|
||||
}
|
||||
|
||||
public static function addPercent($num, $percent)
|
||||
{
|
||||
return $num + (($percent / 100) * $num);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
|
||||
class Table
|
||||
{
|
||||
public static function get($rows, $class = '', $fill = false): string
|
||||
{
|
||||
$c = '';
|
||||
$maxRows = sizeof(max($rows));
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if ($fill && sizeof($row) < $maxRows) {
|
||||
$row = array_merge($row, array_fill(0, $maxRows - sizeof($row), ''));
|
||||
}
|
||||
$c .= '<tr><td>' . implode('</td><td>', $row) . '</td></tr>';
|
||||
}
|
||||
|
||||
return (!empty($class) ? "<table class='$class'>" : '<table>') . $c . '</table>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
|
||||
class Images
|
||||
{
|
||||
public static function getSrc(int $id): string
|
||||
{
|
||||
$i = Db::getRow('select mime_type, img from images where id = ?', [$id]);
|
||||
return 'data:' . $i['mime_type'] . ';base64,' . base64_encode($i['img']);
|
||||
}
|
||||
|
||||
public static function getSrcByName(string $name): string
|
||||
{
|
||||
$i = Db::getRow('select mime_type, img from images where id = (select logo from clan where name = ?)', [$name]);
|
||||
return 'data:' . $i['mime_type'] . ';base64,' . base64_encode($i['img']);
|
||||
}
|
||||
|
||||
public static function getJson(int $id)
|
||||
{
|
||||
$stmt = Db::getRow('select mime_type, img from images where id = ?', [$id]);
|
||||
if (!$stmt) {
|
||||
$stmt = [];
|
||||
}
|
||||
return json_encode($stmt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Inf;
|
||||
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
|
||||
class Awards
|
||||
{
|
||||
private const KNIGHT = [
|
||||
1 => 'Рыцарь первого круга',
|
||||
2 => 'Рыцарь второго круга',
|
||||
3 => 'Рыцарь третьего круга',
|
||||
];
|
||||
private const SCHOLAR = [
|
||||
1 => 'Посвящённый первого круга',
|
||||
2 => 'Посвящённый второго круга',
|
||||
3 => 'Посвящённый третьего круга',
|
||||
];
|
||||
private const IZLOM = [
|
||||
1 => 'Аттестованный боец',
|
||||
2 => 'Опытный боец',
|
||||
3 => 'Ветеран',
|
||||
4 => 'Генерал',
|
||||
];
|
||||
private const DUNGEON_NAME = [
|
||||
'repdreamscity' => 'Водосток',
|
||||
'repizlom' => 'Излом Хаоса',
|
||||
'rep1' => 'Храм Знаний',
|
||||
];
|
||||
private array $awards = [];
|
||||
|
||||
public function __construct(int $userid)
|
||||
{
|
||||
$reputations = Db::getRow('select * from rep where id = ?', [$userid]) ?: [];
|
||||
$customAwards = Db::getRows('select text, img from users_ico where uid = ? and (endTime = 0 or endTime > unix_timestamp())', [$userid]);
|
||||
|
||||
foreach ($customAwards as $award) {
|
||||
$this->awards[] = ['', $award['text'], $award['img']];
|
||||
}
|
||||
|
||||
if (!empty($reputations)) {
|
||||
$this->addDungeonAwards($reputations);
|
||||
}
|
||||
}
|
||||
|
||||
private function addDungeonAwards(mixed $reputations): void
|
||||
{
|
||||
match (true) {
|
||||
$reputations['repdreamscity'] > 9999 => $this->awards[] = [self::DUNGEON_NAME['repdreamscity'], self::KNIGHT[3], 'i/ico/ric_kanal3.gif'],
|
||||
$reputations['repdreamscity'] > 4999 => $this->awards[] = [self::DUNGEON_NAME['repdreamscity'], self::KNIGHT[2], 'i/ico/ric_kanal2.gif'],
|
||||
$reputations['repdreamscity'] > 999 => $this->awards[] = [self::DUNGEON_NAME['repdreamscity'], self::KNIGHT[1], 'i/ico/ric_kanal1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['rep1'] > 9999 => $this->awards[] = [self::DUNGEON_NAME['rep1'], self::SCHOLAR[3], 'znrune_3.gif'],
|
||||
$reputations['rep1'] > 999 => $this->awards[] = [self::DUNGEON_NAME['rep1'], self::SCHOLAR[2], 'znrune_2.gif'],
|
||||
$reputations['rep1'] > 99 => $this->awards[] = [self::DUNGEON_NAME['rep1'], self::SCHOLAR[1], 'znrune_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repizlom'] > 24999 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[4], 'iz_zn_ver10_4.gif'],
|
||||
$reputations['repizlom'] > 9999 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[3], 'iz_zn_ver10_3.gif'],
|
||||
$reputations['repizlom'] > 999 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[2], 'iz_zn_ver10_2.gif'],
|
||||
$reputations['repizlom'] > 99 => $this->awards[] = [self::DUNGEON_NAME['repizlom'], self::IZLOM[1], 'iz_zn_ver10_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repcapitalcity'] > 24999 => $this->awards[] = ['Capital city', self::KNIGHT[2], 'zn1_2.gif'],
|
||||
$reputations['repcapitalcity'] > 9999 => $this->awards[] = ['Capital city', self::KNIGHT[1], 'zn1_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repangelscity'] > 24999 => $this->awards[] = ['Angels city', self::KNIGHT[2], 'zn2_2.gif'],
|
||||
$reputations['repangelscity'] > 9999 => $this->awards[] = ['Angels city', self::KNIGHT[1], 'zn2_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repdemonscity'] > 24999 => $this->awards[] = ['Demons city', self::KNIGHT[2], 'zn3_2.gif'],
|
||||
$reputations['repdemonscity'] > 9999 => $this->awards[] = ['Demons city', self::KNIGHT[1], 'zn3_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repdevilscity'] > 24999 => $this->awards[] = ['Devils city', self::KNIGHT[2], 'zn4_2.gif'],
|
||||
$reputations['repdevilscity'] > 9999 => $this->awards[] = ['Devils city', self::KNIGHT[1], 'zn4_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repsuncity'] > 24999 => $this->awards[] = ['Sun city', self::KNIGHT[2], 'zn5_2.gif'],
|
||||
$reputations['repsuncity'] > 9999 => $this->awards[] = ['Sun city', self::KNIGHT[1], 'zn5_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repsandcity'] > 24999 => $this->awards[] = ['Sand city', self::KNIGHT[2], 'zn7_2.gif'],
|
||||
$reputations['repsandcity'] > 9999 => $this->awards[] = ['Sand city', self::KNIGHT[1], 'zn7_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repemeraldscity'] > 24999 => $this->awards[] = ['Emeralds city', self::KNIGHT[2], 'zn6_2.gif'],
|
||||
$reputations['repemeraldscity'] > 9999 => $this->awards[] = ['Emeralds city', self::KNIGHT[1], 'zn6_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repmooncity'] > 24999 => $this->awards[] = ['Moon city', self::KNIGHT[2], 'zn9_2.gif'],
|
||||
$reputations['repmooncity'] > 9999 => $this->awards[] = ['Moon city', self::KNIGHT[1], 'zn9_1.gif'],
|
||||
default => '',
|
||||
};
|
||||
|
||||
match (true) {
|
||||
$reputations['repabandonedplain'] > 9999 => $this->awards[] = ['Гора Легиона', self::KNIGHT[2], '1_gora.gif'],
|
||||
$reputations['repabandonedplain'] > 999 => $this->awards[] = ['Гора Легиона', self::KNIGHT[1], '2_gora.gif'],
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
|
||||
public function addCustom(string $name, string $description, string $image): void
|
||||
{
|
||||
$this->awards[] = [$name, $description, $image];
|
||||
}
|
||||
|
||||
public function print(): void
|
||||
{
|
||||
foreach ($this->awards as $award) {
|
||||
$img = Config::img() . DIRECTORY_SEPARATOR . $award[2];
|
||||
if (!empty($award[0])) {
|
||||
$award[1] = "<b>$award[0]</b><br>$award[1]";
|
||||
}
|
||||
echo <<<HTML
|
||||
<img src="$img" alt="" onmouseover="top.hi(this,'$award[1]',event,0,0,1,0);" onmouseout="top.hic();" onmousedown="top.hic();" style="cursor: pointer;">
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Inf;
|
||||
|
||||
use Core\Db;
|
||||
use DateTimeImmutable;
|
||||
|
||||
class LastNames
|
||||
{
|
||||
private array $lastnames = [];
|
||||
|
||||
/** История имён
|
||||
* @param int $userid
|
||||
*/
|
||||
public function __construct(int $userid)
|
||||
{
|
||||
$names = Db::getRows('select * from lastnames where uid = ? order by time desc', [$userid]);
|
||||
$dt = new DateTimeImmutable();
|
||||
|
||||
foreach ($names as $name) {
|
||||
$dt->setTimestamp($name['time']);
|
||||
$this->lastnames[] = "«{$name['login']}» до " . $dt->format('d.m.Y H:i');
|
||||
}
|
||||
}
|
||||
|
||||
public function print(): void
|
||||
{
|
||||
echo $this->get();
|
||||
}
|
||||
|
||||
private function get(): string
|
||||
{
|
||||
if (empty($this->lastnames)) {
|
||||
return '';
|
||||
}
|
||||
return 'История имен:<br>' . implode('<br>', $this->lastnames);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Inf;
|
||||
|
||||
use Core\Config;
|
||||
use Helper\Conversion;
|
||||
|
||||
class Status
|
||||
{
|
||||
private array $statuses;
|
||||
|
||||
public function add(bool $condition, string $text, int|string|null $timeout = 0, ?string $img = ''): void
|
||||
{
|
||||
if (!$condition) {
|
||||
return;
|
||||
}
|
||||
if (!empty($timeout)) {
|
||||
$text .= ' ещё ' . Conversion::secondsToTimeout($timeout - time());
|
||||
}
|
||||
|
||||
$text = "<span style='vertical-align:middle;'>$text</span>";
|
||||
|
||||
if (!empty($img)) {
|
||||
$text = '<span><img src="' . Config::img() . DIRECTORY_SEPARATOR . $img . '" alt="' . $text . '" style="vertical-align:middle;"></span> ' . $text;
|
||||
}
|
||||
|
||||
$this->statuses[] = "<div>$text</div>"; // обёртка для центрирования картинки с текстом
|
||||
}
|
||||
|
||||
public function print(): void
|
||||
{
|
||||
if (empty($this->statuses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<br><div style="font-size: smaller;">' . implode('<br>', $this->statuses) . '</div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Inf;
|
||||
|
||||
use Core\Db;
|
||||
|
||||
class Twinks
|
||||
{
|
||||
private array $twinks = [];
|
||||
|
||||
/** Мульты персонажа
|
||||
* @param int $userid
|
||||
* @param int $twinkid
|
||||
*/
|
||||
public function __construct(int $userid, int $twinkid)
|
||||
{
|
||||
$twinks = Db::getRows('select login, level, twink from users_twink where uid = ? and twink != 0', [$userid]);
|
||||
foreach ($twinks as $twink) {
|
||||
$str = $twink['login'] . ' [' . $twink['level'] . ']';
|
||||
if ($twinkid === $twink['twink']) {
|
||||
$str = '<b style="color:#ff9900;">' . $str . '</b>';
|
||||
}
|
||||
$this->twinks[] = $str;
|
||||
}
|
||||
}
|
||||
|
||||
public function print(): void
|
||||
{
|
||||
echo $this->get();
|
||||
}
|
||||
|
||||
private function get(): string
|
||||
{
|
||||
if (empty($this->twinks)) {
|
||||
return '';
|
||||
}
|
||||
return 'Другие образы: ' . implode(', ', $this->twinks) . '<br>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Inf;
|
||||
|
||||
use Core\Config;
|
||||
|
||||
class Zodiac
|
||||
{
|
||||
private const ZODIAC = [
|
||||
1 => 'Овен',
|
||||
2 => 'Телец',
|
||||
3 => 'Близнецы',
|
||||
4 => 'Рак',
|
||||
5 => 'Лев',
|
||||
6 => 'Дева',
|
||||
7 => 'Весы',
|
||||
8 => 'Скорпион',
|
||||
9 => 'Стрелец',
|
||||
10 => 'Козерог',
|
||||
11 => 'Водолей',
|
||||
12 => 'Рыбы',
|
||||
];
|
||||
private int $day = 0;
|
||||
private int $month = 0;
|
||||
|
||||
public function __construct(string $date)
|
||||
{
|
||||
[$d, $m, $y] = explode('.', $date);
|
||||
if (!checkdate($d, $m, $y)) {
|
||||
return;
|
||||
}
|
||||
$this->day = (int)$d;
|
||||
$this->month = (int)$m;
|
||||
}
|
||||
|
||||
public function getImageLink(): string
|
||||
{
|
||||
if (empty($this->getName())) {
|
||||
return '#';
|
||||
}
|
||||
$id = array_flip(self::ZODIAC);
|
||||
return Config::img() . '/i/zodiac/' . $id[$this->getName()] . '.gif';
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
if (empty($this->day) || empty($this->month)) {
|
||||
return '';
|
||||
}
|
||||
$z = [
|
||||
1 => self::ZODIAC[10],
|
||||
self::ZODIAC[11],
|
||||
self::ZODIAC[12],
|
||||
self::ZODIAC[1],
|
||||
self::ZODIAC[2],
|
||||
self::ZODIAC[3],
|
||||
self::ZODIAC[4],
|
||||
self::ZODIAC[5],
|
||||
self::ZODIAC[6],
|
||||
self::ZODIAC[7],
|
||||
self::ZODIAC[8],
|
||||
self::ZODIAC[9],
|
||||
self::ZODIAC[10],
|
||||
];
|
||||
$lastDay = [1 => 19, 18, 20, 20, 21, 21, 22, 22, 21, 22, 21, 20, 19];
|
||||
return $this->day > $lastDay[$this->month] ? $z[$this->month + 1] : $z[$this->month];
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
//use Insallah\Tournament;
|
||||
|
||||
//require_once 'Core/Db.php';
|
||||
require_once 'Core/Math.php';
|
||||
require_once 'Core/Table.php';
|
||||
require_once 'Runes/Runes.php';
|
||||
//require_once 'Tournament/Tournament.php';
|
||||
//require_once 'Tournament/TournamentModel.php';
|
||||
require_once 'Achievements.php';
|
||||
|
||||
//Вместо крона для турнира.
|
||||
//if (Tournament::IS_ENABLED) {
|
||||
// (new Tournament())->startAllBattles();
|
||||
//}
|
||||
@@ -1,165 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
//use Core\Database;
|
||||
use Exception;
|
||||
//use http\Message;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
|
||||
class DbOld
|
||||
{
|
||||
/**
|
||||
* Настройки подключения
|
||||
* Лучше выносить в конфиг
|
||||
* self::DB_HOST -> Config::DB_HOST
|
||||
*/
|
||||
const DB_HOST = '127.0.0.1'; // localhost
|
||||
const DB_USER = 'newcom1_abk';
|
||||
const DB_PASSWORD = '4nWYsIM[c?}P';
|
||||
const DB_NAME = 'newcom1_abk';
|
||||
const CHARSET = 'utf8mb4';
|
||||
const DB_PREFIX = '';
|
||||
|
||||
/**
|
||||
* @var PDO
|
||||
*/
|
||||
static private $db;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* DB constructor.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (self::$instance === null) {
|
||||
try {
|
||||
self::$db = new PDO(
|
||||
'mysql:host=' . self::DB_HOST . ';dbname=' . self::DB_PREFIX . self::DB_NAME,
|
||||
self::DB_USER,
|
||||
self::DB_PASSWORD,
|
||||
[
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . self::CHARSET,
|
||||
]
|
||||
);
|
||||
// self::$db = Database::pdoinit();
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $stmt
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function query($stmt)
|
||||
{
|
||||
return self::$db->query($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $stmt
|
||||
* @return PDOStatement
|
||||
*/
|
||||
public static function prepare($stmt)
|
||||
{
|
||||
return self::$db->prepare($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @return int
|
||||
*/
|
||||
static public function exec($query)
|
||||
{
|
||||
return self::$db->exec($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
static public function lastInsertId()
|
||||
{
|
||||
return self::$db->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param array $args
|
||||
* @return PDOStatement
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function run($query, $args = [])
|
||||
{
|
||||
try {
|
||||
if (!$args) {
|
||||
return self::query($query);
|
||||
}
|
||||
$stmt = self::prepare($query);
|
||||
$stmt->execute($args);
|
||||
return $stmt;
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getRow($query, $args = [])
|
||||
{
|
||||
return self::run($query, $args)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public static function getRows($query, $args = [])
|
||||
{
|
||||
return self::run($query, $args)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getValue($query, $args = [])
|
||||
{
|
||||
$result = self::getRow($query, $args);
|
||||
if (!empty($result)) {
|
||||
$result = array_shift($result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public static function getColumn($query, $args = [])
|
||||
{
|
||||
return self::run($query, $args)->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
public static function sql($query, $args = [])
|
||||
{
|
||||
self::run($query, $args);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
/** All raw mathematics in one place. */
|
||||
class Math
|
||||
{
|
||||
/**
|
||||
* @param float|int $total
|
||||
* @param int|null $number
|
||||
* @return float
|
||||
*/
|
||||
public static function getPercentage($total, ?int $number): float
|
||||
{
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
}
|
||||
return $total > 0 ? round(($number * 100) / $total, 2) : 0;
|
||||
}
|
||||
|
||||
|
||||
public static function get100Percentage($total, ?int $number)
|
||||
{
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
}
|
||||
return min(self::getPercentage($total, $number), 100);
|
||||
}
|
||||
|
||||
/** Number-20% and Number+20% */
|
||||
public static function get20PercentRange($number): array
|
||||
{
|
||||
return [
|
||||
'min' => $number * ((100 - 20) / 100),
|
||||
'max' => $number * ((100 + 20) / 100),
|
||||
];
|
||||
}
|
||||
|
||||
public static function addPercent($num, $percent)
|
||||
{
|
||||
return $num + (($percent / 100) * $num);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
class Table
|
||||
{
|
||||
public static function get($rows, $class = '', $fill = false)
|
||||
{
|
||||
$c = '';
|
||||
$max_rows = sizeof(max($rows));
|
||||
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if ($fill && sizeof($row) < $max_rows) {
|
||||
$row = array_merge($row, array_fill(0, $max_rows - sizeof($row), ''));
|
||||
}
|
||||
$c .= '<tr><td>' . implode('</td><td>', $row) . '</td></tr>';
|
||||
}
|
||||
|
||||
return (!empty($class) ? "<table class='$class'>" : '<table>') . $c . '</table>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
/** All raw mathematics in one place. */
|
||||
class Math
|
||||
{
|
||||
/**
|
||||
* @param float|int $total
|
||||
* @param int|null $number
|
||||
* @return float
|
||||
*/
|
||||
public static function getPercentage($total, int $number): float
|
||||
{
|
||||
return $total > 0 ? round(($number * 100) / $total, 2) : 0;
|
||||
}
|
||||
|
||||
|
||||
public static function get100Percentage($total, int $number)
|
||||
{
|
||||
return min(self::getPercentage($total, $number), 100);
|
||||
}
|
||||
|
||||
/** Number-20% and Number+20% */
|
||||
public static function get20PercentRange($number): array
|
||||
{
|
||||
return [
|
||||
'min' => $number * ((100 - 20) / 100),
|
||||
'max' => $number * ((100 + 20) / 100),
|
||||
];
|
||||
}
|
||||
|
||||
public static function addPercent($num, $percent)
|
||||
{
|
||||
return $num + (($percent / 100) * $num);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
class Table
|
||||
{
|
||||
public static function get($rows, $class = '', $fill = false)
|
||||
{
|
||||
$c = '';
|
||||
$max_rows = sizeof(max($rows));
|
||||
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if ($fill && sizeof($row) < $max_rows) {
|
||||
$row = array_merge($row, array_fill(0, $max_rows - sizeof($row), ''));
|
||||
}
|
||||
$c .= '<tr><td>' . implode('</td><td>', $row) . '</td></tr>';
|
||||
}
|
||||
|
||||
return (!empty($class) ? "<table class='$class'>" : '<table>') . $c . '</table>' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
class TournamentModel
|
||||
{
|
||||
|
||||
/**
|
||||
* проверка уровня, стоимости эквипа, прочие проверки, что персонаж свободен
|
||||
* таймер ожидания 30 минут
|
||||
*
|
||||
* @param int $uid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getUserLevel(int $uid): int
|
||||
{
|
||||
$db = new Db();
|
||||
$level = $db::getValue('select level from users where id = ? and level between 8 and 12 and battle = 0', [$uid]);
|
||||
return $level ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid
|
||||
* @param int|null $level
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEkrOverpriced(int $uid, ?int $level = null): bool
|
||||
{
|
||||
$db = new Db();
|
||||
if (is_null($level)) {
|
||||
$level = $db::getValue('select level from users where id = ?', [$uid]);
|
||||
}
|
||||
$wearedItemsEkrPrice = $db::getValue('select sum(2price) from items_users where inOdet > 0 and uid = ?', [$uid]);
|
||||
return $wearedItemsEkrPrice > Tournament::ekrOverpriceFormula($level);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isEnoughExperience(int $uid): bool
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getValue('select exp from stats where id = ?', [$uid]) >= Tournament::MIN_EXP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isRestrictedToJoin(int $uid): bool
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getValue('select count(*) from eff_users where uid = ? and id_eff = 486 and `delete` = 0', [$uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isStarted(int $tid): bool
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getValue('select count(*) from tournaments where start_time = -1 and tid = ?', [$tid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Считаем сколько игроков ждут в заявке на турнир.
|
||||
*
|
||||
* @param int $tid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getWaitingMembersQuantity(int $tid): int
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getValue('select count(*) from tournaments_users where tid = ?', [$tid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Создание нового турнира.
|
||||
*
|
||||
* @param int $tid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function createTournament(int $tid): void
|
||||
{
|
||||
$db = new Db();
|
||||
$db::sql('insert into tournaments (tid) values (?)', [$tid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Игрок присоединяется к турниру и телепортируется в турнирную комнату.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param int $tid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function joinTournament(int $uid, int $tid): void
|
||||
{
|
||||
/** Кастомные комнаты 25008 - 25012. */
|
||||
$roomId = 25000 + $tid;
|
||||
$db = new Db();
|
||||
$db::sql('insert into tournaments_users (tid, uid) values (?, ?)', [$tid, $uid]);
|
||||
self::teleport($uid, $roomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Старт турнира.
|
||||
*
|
||||
* @param int $tid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function startTournament(int $tid): void
|
||||
{
|
||||
$db = new Db();
|
||||
$db::sql('update tournaments set start_time = -1 where tid = ?', [$tid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Чистим базы от прошедшего турнира.
|
||||
*
|
||||
* @param int $tid
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function destroyTournament(int $tid): void
|
||||
{
|
||||
$db = new Db();
|
||||
//Убедиться что в базе настроен foreign_keys и последует автоочистка tournaments_users !!!
|
||||
$db::sql('delete from tournaments where tid = ?', [$tid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получаем список бойцов и бьём их на пары. Возвращаем списки пар + 1 последний без пары если есть.
|
||||
*
|
||||
* @param array $fightersList
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFightersTeams(array $fightersList): array
|
||||
{
|
||||
$db = new Db();
|
||||
$query = sprintf("select id from users where battle = 0 and id in (%s)", implode(', ', $fightersList));
|
||||
return array_chunk($db::getColumn($query), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Выбираем живых бойцов не сражающихся в данный момент.
|
||||
*
|
||||
* @param int $tid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getFreeFighters(int $tid): array
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getColumn('select uid from tournaments_users where tid = ? and death_time = 0 order by uid', [$tid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Выбираем победителей. Смещаем массив, чтобы возврат шёл с единицы.
|
||||
*
|
||||
* @param int $tid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getWinners(int $tid): array
|
||||
{
|
||||
$db = new Db();
|
||||
$winners = $db::getColumn('select uid from tournaments_users where tid = ? order by death_time desc limit 3', [$tid]);
|
||||
return [
|
||||
1 => $winners[0],
|
||||
2 => $winners[1],
|
||||
3 => $winners[2]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Пробуем выкусить проигравшего в последней турнирной битве и удалить эту самую битву во избежание.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getLooser()
|
||||
{
|
||||
$query = '
|
||||
select uid, battle
|
||||
from
|
||||
battle_users,
|
||||
(select id, team_win
|
||||
from battle
|
||||
where
|
||||
team_win > 0 and
|
||||
typeBattle = 25000
|
||||
order by time_over desc
|
||||
limit 1) as last_battle
|
||||
where
|
||||
battle_users.battle = last_battle.id and
|
||||
battle_users.team != last_battle.team_win and
|
||||
battle_users.uid in (select uid from tournaments_users where death_time = 0)';
|
||||
|
||||
$query2 = 'select bu.uid from battle b
|
||||
inner join battle_users bu on b.team_win != bu.team and b.id = bu.battle
|
||||
inner join tournaments_users tu on bu.uid = tu.uid
|
||||
where typeBattle = 25000 and death_time = 0 order by b.time_start desc limit 1';
|
||||
$db = new Db;
|
||||
$row = $db::getRow($query);
|
||||
return $row['uid'] ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Выбывший из турнира покидает комнату и получает время смерти.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param bool $winner
|
||||
* @return void
|
||||
*/
|
||||
public static function removeFighter(int $uid, bool $winner = false): void
|
||||
{
|
||||
if (!$uid) {
|
||||
return;
|
||||
}
|
||||
//$winner_timer_add = $winner? 500 : 0; # Последный ДОЛЖЕН быть последним.
|
||||
$db = new Db();
|
||||
$db::sql('update tournaments_users set death_time = unix_timestamp() + 500 where death_time = 0 and uid = ?', [$uid]);
|
||||
self::teleport($uid, 9);
|
||||
//fixme: Классы не подключаются друг к другу. Нужно менять архитектуру игры. :(
|
||||
Db::sql("update users_achiv set trn = trn + 1 where id = ?", [$uid]);
|
||||
//(new Achievements(\user::start()))->updateCounter('trn');
|
||||
}
|
||||
|
||||
/**
|
||||
* Узнаём id турнира по id игрока.
|
||||
*
|
||||
* @param int $uid
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getTournamentIdByUserId(int $uid)
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getValue('select tid from tournaments_users where uid = ?', [$uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Попробуем стартонуть поединок.
|
||||
* 25000 - Уникальный id поединка под турниры.
|
||||
* noinc - запрет на вмешательство
|
||||
* invis - невидимый бой
|
||||
*
|
||||
* @param int $uid1
|
||||
* @param int $uid2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function startBattle(int $uid1, int $uid2): void
|
||||
{
|
||||
$db = new Db();
|
||||
$check = Db::getValue('select count(*) from users where id in (?, ?) and battle = 0', [$uid1, $uid2]);
|
||||
if ($check !== 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db::exec('insert into battle (city, time_start, timeout, type, invis, noinc, travmChance, typeBattle)
|
||||
values (\'capitalcity\', unix_timestamp(), 60, 0, 1, 1, 0, 25000)');
|
||||
$bid = $db::lastInsertId(); // ВАЖНО!
|
||||
$db::sql('update stats set team = 1, hpNow = hpAll, mpNow = mpAll where id = ?', [$uid1]);
|
||||
$db::sql('update stats set team = 2, hpNow = hpAll, mpNow = mpAll where id = ?', [$uid2]);
|
||||
$db::sql('update users set battle = ? where id in (?, ?)', [$bid, $uid1, $uid2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Узнаём логин персонажа по его id.
|
||||
*
|
||||
* @param int $uid
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function uidToLogin(int $uid)
|
||||
{
|
||||
$db = new Db();
|
||||
return $db::getValue('select login from users where id = ?', [$uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Телепорт по комнатам.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param int $roomId
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function teleport(int $uid, int $roomId): void
|
||||
{
|
||||
$db = new Db();
|
||||
$db::sql('update users set room = ? where id = ?', [$roomId, $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Нет проверок $message потому что оно всегда задаётся в коде и игрок на него не влияет.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function sysMessage(string $message): void
|
||||
{
|
||||
if (!empty($message)) {
|
||||
$db = new Db();
|
||||
$message = "<span style='font-weight: bold; color: forestgreen;'>$message</span>";
|
||||
$db::sql('insert into chat (time, type, text, new, da) values (unix_timestamp(), 6, ?, 1, 1)', [$message]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Генерирует множественный запрос сразу на $quantity однотипных предметов в инвентарь пользователя $uid.
|
||||
*
|
||||
* @param int $uid
|
||||
* @param int $quantity
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function givePrizeItems(int $uid, int $quantity): void
|
||||
{
|
||||
$query = 'insert into items_users (item_id, uid, data, iznosMAX, lastUPD, time_create)
|
||||
values (4754, :uid, :data, 1, unix_timestamp(), unix_timestamp())';
|
||||
$args = [
|
||||
'uid' => $uid,
|
||||
'data' => 'nosale=1|musor=1|sudba=' . self::uidToLogin($uid) . '|lvl=8|tr_s1=0|tr_s2=0|tr_s3=0|tr_s4=0'
|
||||
];
|
||||
$db = new Db();
|
||||
$stmt = $db::prepare($query);
|
||||
for ($i = 0; $i < $quantity; $i++) {
|
||||
$stmt->execute($args);
|
||||
}
|
||||
}
|
||||
|
||||
/** Эффект-ограничитель на участие в турнире.
|
||||
* @param int $uid
|
||||
* @param int $unixtime
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function giveDelay(int $uid, int $unixtime): void
|
||||
{
|
||||
$db = new Db();
|
||||
$query = 'insert into eff_users (id_eff, uid, name, timeUse) VALUES (?,?,?,?)';
|
||||
$args = [486, $uid, 'Призёр городского турнира!', $unixtime];
|
||||
$db::sql($query, $args);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class Config
|
||||
const STEP_EKR = 151;
|
||||
const DELAY_EFFECT_ID = 486;
|
||||
const CUSTOM_BATTLE_ID = 25000;
|
||||
const PRIZE_ITEM_ID = 4754;
|
||||
const PRIZE_ITEM_ID = 0;
|
||||
const RETURN_ROOM = 9;
|
||||
const MINIMUM_USER_LEVEL = 8;
|
||||
|
||||
|
||||
@@ -168,6 +168,10 @@ class GameConnector
|
||||
if (empty($message)) {
|
||||
return;
|
||||
}
|
||||
Db::sql('insert into chat (`time`, type, `text`, new, da) values (unix_timestamp(), 6, ?, 1, 1)', [$message]);
|
||||
$cmsg = new \ChatMessage();
|
||||
$cmsg->setDa(1);
|
||||
$cmsg->setType(6);
|
||||
$cmsg->setText($message);
|
||||
(new \Chat())->sendMsg($cmsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Item\Data;
|
||||
|
||||
use Model\Constant\Stat;
|
||||
|
||||
class Bonuses
|
||||
{
|
||||
private Stat $stat;
|
||||
private array $result = [];
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->stat = new Stat();
|
||||
|
||||
foreach ($data as $bonusName => $value) {
|
||||
if (!$this->stat->getBonusNames()[$bonusName]) {
|
||||
$this->result[$bonusName] = $value; //fixme на период отладки для отлова забытых
|
||||
//continue;
|
||||
}
|
||||
$this->result[$this->stat->getBonusNames()[$bonusName]] = $value;
|
||||
}
|
||||
$this->armor($data);
|
||||
}
|
||||
|
||||
private function armor(array $data): void
|
||||
{
|
||||
$min = 0;
|
||||
$max = 0;
|
||||
$type = [
|
||||
1 => 'головы',
|
||||
2 => 'корпуса',
|
||||
3 => 'пояса',
|
||||
4 => 'ног',
|
||||
];
|
||||
foreach ($type as $k => $v) {
|
||||
if (!empty($data['mib' . $k])) {
|
||||
$min = $data['mib' . $k];
|
||||
$max = $data['mib' . $k];
|
||||
}
|
||||
if (!empty($data['mab' . $k])) {
|
||||
if (empty($data['mib' . $k])) {
|
||||
$min = $data['mab' . $k];
|
||||
}
|
||||
$max = $data['mab' . $k];
|
||||
}
|
||||
if (empty($min) && empty($max)) {
|
||||
return;
|
||||
}
|
||||
$this->result['Броня ' . $v] = $min . ' - ' . $max;
|
||||
}
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function addZonb(): void
|
||||
{
|
||||
if (isset($this->result[$this->stat->getBonusNames()['zonb']])) {
|
||||
$this->result[$this->stat->getBonusNames()['zonb']]++;
|
||||
} else {
|
||||
$this->result[$this->stat->getBonusNames()['zonb']] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Item\Data;
|
||||
|
||||
class Properties
|
||||
{
|
||||
public static array $names = [
|
||||
'damage' => 'Урон',
|
||||
];
|
||||
private array $result = [];
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->damage($data);
|
||||
}
|
||||
|
||||
private function damage(array $data): void
|
||||
{
|
||||
$min = 0;
|
||||
$max = 0;
|
||||
if (!empty($data['yron_min'])) {
|
||||
$min = $data['yron_min'];
|
||||
$max = $data['yron_min'];
|
||||
}
|
||||
if (!empty($data['yron_max'])) {
|
||||
if (empty($data['yron_min'])) {
|
||||
$min = $data['yron_max'];
|
||||
}
|
||||
$max = $data['yron_max'];
|
||||
}
|
||||
if (empty($min) && empty($max)) {
|
||||
return;
|
||||
}
|
||||
$this->result[self::$names['damage']] = $min . ' - ' . $max;
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Item\Data;
|
||||
|
||||
use Model\Constant\Stat;
|
||||
|
||||
class Requirements
|
||||
{
|
||||
private static array $sex = [
|
||||
0 => 'Мужской',
|
||||
1 => 'Женский',
|
||||
];
|
||||
private static array $align = [
|
||||
1 => 'Свет',
|
||||
2 => 'Хаос',
|
||||
3 => 'Тьма',
|
||||
7 => 'Нейстралитет',
|
||||
9 => 'Дитя подземелья',
|
||||
];
|
||||
private int $alignValue = 0;
|
||||
|
||||
private array $result = [];
|
||||
private Stat $stat;
|
||||
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->stat = new Stat();
|
||||
foreach ($data as $requirementName => $value) {
|
||||
if (!$this->stat->getRequirementNames()[$requirementName]) {
|
||||
$this->result[$requirementName] = $value; //fixme на период отладки для отлова забытых
|
||||
//continue;
|
||||
}
|
||||
if ($requirementName === 'sex') {
|
||||
if (self::$sex[$value]) {
|
||||
$value = self::$sex[$value];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($requirementName === 'align') {
|
||||
if (self::$align[$value]) {
|
||||
$this->alignValue = $value;
|
||||
$this->result[$requirementName]['sysvalue'] = $value;
|
||||
$value = self::$align[$value];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//$this->result[$this->stat->getRequirementNames()[$requirementName]] = $value;
|
||||
|
||||
$this->result[$requirementName] = [
|
||||
'name' => $this->stat->getRequirementNames()[$requirementName],
|
||||
'value' => $value,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get(): array
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/** Число для отрисовки иконки.
|
||||
* @return int
|
||||
*/
|
||||
public function getAlign(): int
|
||||
{
|
||||
return $this->alignValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Item;
|
||||
|
||||
use Core\Db;
|
||||
use Helper\Conversion;
|
||||
|
||||
class DataModel
|
||||
{
|
||||
private array $data = [];
|
||||
|
||||
public function __construct(int $itemId)
|
||||
{
|
||||
$datastring = Db::getValue('select data from items_main_data where items_id = ?', [$itemId]);
|
||||
if (empty($datastring)) {
|
||||
return;
|
||||
}
|
||||
$this->data = Conversion::dataStringToArray($datastring);
|
||||
}
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getRequirements(): array
|
||||
{
|
||||
return $this->getPrefixed('tr_');
|
||||
}
|
||||
|
||||
private function getPrefixed(string $prefix): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->data as $k => $v) {
|
||||
if (str_starts_with($k, $prefix)) {
|
||||
$result[str_replace($prefix, '', $k)] = $v;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getBonuses(): array
|
||||
{
|
||||
return $this->getPrefixed('add_');
|
||||
}
|
||||
|
||||
public function getProperties(): array
|
||||
{
|
||||
return $this->getPrefixed('sv_');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
|
||||
/** Предметы которые никому не принадлежат. Не перепутай! */
|
||||
class ItemModel
|
||||
{
|
||||
private $item;
|
||||
public function __construct(int $id)
|
||||
{
|
||||
$this->item = Db::getRow('select * from items_main where id = ?', [$id]);
|
||||
}
|
||||
|
||||
public static function getItemData(int $id): string
|
||||
{
|
||||
return Db::getValue('select data from items_main_data where items_id = ?', [$id]);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->item['name'];
|
||||
}
|
||||
|
||||
public function getImage()
|
||||
{
|
||||
return $this->item['img'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace Location;
|
||||
|
||||
use Chat;
|
||||
use ChatMessage;
|
||||
use Delo;
|
||||
use User;
|
||||
|
||||
class DeathTower
|
||||
{
|
||||
public static function finish($id, $bu, $di)
|
||||
{
|
||||
$user = User::start();
|
||||
if ($bu) {
|
||||
/* � ���� ��� ��������� ������ */
|
||||
$i = 0;
|
||||
while ($i < count($bu[$i])) {
|
||||
if ($bu[$i]['lose'] > 0 || $bu[$i]['nich']) {
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `lose` = "' . $bu[$i]['lose'] . '", `nick` = "' . $bu[$i]['nich'] . '" WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `bs_turnirs` SET `users_finish` = `users_finish` + 1 WHERE `id` = "' . $id['id'] . '" LIMIT 1'
|
||||
);
|
||||
/* ������� ����� */
|
||||
if ($bu['inBot'] == 0) {
|
||||
$pls1 = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`, `bsid`, `money`, `finish`, `time`, `inBot`, `uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = 0 AND `time` = "' . $id['time_start'] . '" AND `inBot` = "' . $bu[$i]['id'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($pls1['id'])) {
|
||||
mysql_query('DELETE FROM `users` WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `stats` WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1');
|
||||
|
||||
//���������� �������� �� �����
|
||||
$spi = mysql_query(
|
||||
'SELECT `id`,`item_id` FROM `items_users` WHERE `uid` = "' . $bu[$i]['id'] . '" LIMIT 500'
|
||||
);
|
||||
$ins = '';
|
||||
while ($pli = mysql_fetch_array($spi)) {
|
||||
$ins .= '("' . $di['dn_id'] . '","' . $pli['item_id'] . '","' . time(
|
||||
) . '","' . $di['x'] . '","' . $di['y'] . '"),';
|
||||
}
|
||||
|
||||
$ins = rtrim($ins, ',');
|
||||
mysql_query(
|
||||
'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES ' . $ins . ''
|
||||
);
|
||||
mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $pls1['inBot'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $pls1['inBot'] . '" LIMIT 1');
|
||||
mysql_query(
|
||||
'UPDATE `bs_zv` SET `finish` = "' . time(
|
||||
) . '" WHERE `id` = "' . $pls1['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pls1['uid'] . '" LIMIT 1');
|
||||
}
|
||||
}
|
||||
$id['users_finish']++;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if ($id['users'] - $id['users_finish'] >= 2) {
|
||||
return;
|
||||
}
|
||||
$win = [];
|
||||
$sp = mysql_query(
|
||||
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = "0" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
|
||||
);
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$ur = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$ub = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($ur['id']) && isset($ub['id']) && $ub['lose'] <= 0 && $ub['nich'] <= 0) {
|
||||
$win = $ub;
|
||||
$winr = $ur;
|
||||
}
|
||||
}
|
||||
|
||||
$chat = new Chat();
|
||||
$cmsg = new ChatMessage();
|
||||
|
||||
/* ��������� �� */
|
||||
if (isset($win['id']) && $win['lose'] == 0 && $win['nich'] == 0 && $win['id'] > 0) {
|
||||
//���� ����������
|
||||
$bsep = 0;
|
||||
if ($winr['level'] < 6) {
|
||||
$bsep = 2500;
|
||||
} elseif ($winr['level'] < 7) {
|
||||
$bsep = 5000;
|
||||
} elseif ($winr['level'] < 8) {
|
||||
$bsep = 15000;
|
||||
} elseif ($winr['level'] < 9) {
|
||||
$bsep = 25000;
|
||||
} else {
|
||||
$bsep = 50000;
|
||||
}
|
||||
/* ������ ���� */
|
||||
$mn = (round($id['money'] / 100 * 85));
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `money` = `money` + "' . $mn . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `exp` = `exp` + "' . $bsep . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
|
||||
);
|
||||
/* ��� */
|
||||
$cmsg->setTo($winr['login']);
|
||||
$cmsg->setText(
|
||||
"�����������! �� �������� � ������� "����� ������"! �������� �����: $bsep, ������: $mn ��."
|
||||
);
|
||||
$cmsg->setType(6);
|
||||
$chat->sendMsg($cmsg);
|
||||
|
||||
$cmsg->setTo('');
|
||||
$cmsg->setIsAlert(true);
|
||||
$cmsg->setText(
|
||||
"���������� ������ "����� ������", ���������� �������: <strong>{$winr['login']}</strong>! �����������!"
|
||||
);
|
||||
$cmsg->setType(5);
|
||||
$chat->sendMsg($cmsg);
|
||||
|
||||
Delo::add(
|
||||
1,
|
||||
'WinTournament.' . $user->info['city'],
|
||||
$uid,
|
||||
'"<span style="color: #C65F00; ">WinTournament.' . $user->info['city'] . '</span>" (����� ������): �������� "<strong>' . $mn . '</strong> ��."',
|
||||
);
|
||||
|
||||
} else {
|
||||
/* ��� */
|
||||
$cmsg->setIsAlert(true);
|
||||
$cmsg->setType(5);
|
||||
$cmsg->setText('���������� ������ ������ ������, ���������� �������: �����������.');
|
||||
}
|
||||
|
||||
$sp = mysql_query(
|
||||
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
|
||||
);
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$ur = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$ub = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($ub['id'])) {
|
||||
//del
|
||||
mysql_query('DELETE FROM `users` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `stats` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
|
||||
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
|
||||
//upd
|
||||
mysql_query(
|
||||
'UPDATE `bs_zv` SET `finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pl['uid'] . '" LIMIT 1');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Location;
|
||||
|
||||
use Core\Db;
|
||||
use DTO\KnowledgeTempleItem;
|
||||
use User;
|
||||
|
||||
class KnowledgeTemple
|
||||
{
|
||||
private string $error = '';
|
||||
|
||||
/** Ïëàâêà ïðåäìåòà
|
||||
* @param int $id id ïðåäìåòà
|
||||
* @return string ñòàòóñ ñîáûòèÿ
|
||||
*/
|
||||
public function smeltItem(int $id): string
|
||||
{
|
||||
$item = new KnowledgeTempleItem(User\ItemsModel::getOwnedItemById(User::start()->info['id'], $id));
|
||||
if (!$this->isSmeltable($item)) {
|
||||
return $this->error;
|
||||
}
|
||||
User\ItemsModel::delete($id);
|
||||
return 'Óäà÷íî ðàñòâîðåí ïðåäìåò "' . $item->name . '"!' . self::addReputation(1);
|
||||
}
|
||||
|
||||
private function isSmeltable(KnowledgeTempleItem $item): bool
|
||||
{
|
||||
$reputation = User::start()->rep['rep1'];
|
||||
if (!$item->exists()) {
|
||||
$this->error = 'Ïðåäìåò íå íàéäåí.';
|
||||
} elseif ($item->level < 4 && $item->id != 1035) {
|
||||
$this->error = 'Ïðåäìåò äîëæåí áûòü 4-ãî è âûøå óðîâíÿ';
|
||||
} elseif (
|
||||
!in_array($item->type, [1, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22]) &&
|
||||
$item->id != 1035
|
||||
) {
|
||||
$this->error = 'Õðåí âàì, à íå ðóíû! Êóäà êèäàåøü ïðåäìåò? Íå ïîäõîäèò îí! Ïðèõîäè êàê áóäåò ÷òî-òî ñòîþùåå!';
|
||||
} elseif ($item->level >= 7 && $reputation < 0) {
|
||||
$this->error = 'Äëÿ ðàñòâîðåíèÿ ïðåäìåòîâ 7-ãî è ñòàðøå óðîâíÿ òðåáóåòñÿ çíàê Õðàìà Çíàíèé ïåðâîãî êðóãà';
|
||||
} elseif ($item->level >= 9 && $reputation < 1000) {
|
||||
$this->error = 'Äëÿ ðàñòâîðåíèÿ ïðåäìåòîâ 9-ãî è ñòàðøå óðîâíÿ òðåáóåòñÿ çíàê Õðàìà Çíàíèé âòîðîãî êðóãà';
|
||||
} elseif ($item->level >= 10 && $reputation < 10000) {
|
||||
$this->error = 'Äëÿ ðàñòâîðåíèÿ ïðåäìåòîâ 10-ãî è ñòàðøå óðîâíÿ òðåáóåòñÿ çíàê Õðàìà Çíàíèé òðåòüåãî êðóãà';
|
||||
}
|
||||
return empty($this->error);
|
||||
}
|
||||
|
||||
public static function addReputation(int $value): string
|
||||
{
|
||||
if ($value < 1) {
|
||||
trigger_error(self::class . '::addReputation - $value can not be below zero.');
|
||||
}
|
||||
Db::sql('update rep set rep1 = rep1 + ? where id = ?', [$value, User::start()->info['id']]);
|
||||
User::start()->rep['rep1'] += $value;
|
||||
return "Ïîëó÷åíî ðåïóòàöèè: +$value åä.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace Location;
|
||||
|
||||
use Chat;
|
||||
use ChatMessage;
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
use ItemModel;
|
||||
use Model\ActionModel;
|
||||
use User;
|
||||
use User\ItemsModel;
|
||||
|
||||
class Loto
|
||||
{
|
||||
private array $prizes = [];
|
||||
private const PRIZE_IMAGE = 0;
|
||||
private const PRIZE_NAME = 1;
|
||||
private const PRIZE_RARITY = 2;
|
||||
private const PRIZE_ROW_ID = 3;
|
||||
private const PRIZE_ITEM_ID = 4;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$loto = Db::getRows('select * from loto order by id');
|
||||
foreach ($loto as $prize) {
|
||||
$item = new ItemModel($prize['idgame']);
|
||||
$this->prizes[] = [
|
||||
$item->getImage(),
|
||||
$item->getName(),
|
||||
ltrim($prize['type'], $prize['type'][0]),
|
||||
$prize['id'],
|
||||
$prize['idgame'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function getPrizeListByRarity(): string
|
||||
{
|
||||
$prizelist = '';
|
||||
$rarity = [1 => 'Частое', 'Нормальное', 'Нечастое', 'Редкое', 'Очень редкое', 'Невероятно редкое',];
|
||||
$prizelistSortedByRarity = $this->prizes;
|
||||
usort($prizelistSortedByRarity, fn($a, $b) => $a[self::PRIZE_RARITY] <=> $b[self::PRIZE_RARITY]);
|
||||
foreach ($prizelistSortedByRarity as $prize) {
|
||||
$prizelist .= '<tr>';
|
||||
$prizelist .= '<td><img src="' . Config::get('img2') .
|
||||
'/i/items/' . $prize[self::PRIZE_IMAGE] . '" alt="' . $prize[self::PRIZE_NAME] . '"></td>';
|
||||
$prizelist .= '<td>' . $prize[self::PRIZE_NAME] . '</td>';
|
||||
$prizelist .= '<td class="chanceitem">' . $rarity[$prize[self::PRIZE_RARITY]] . ' выпадение</td>';
|
||||
$prizelist .= '</tr>';
|
||||
}
|
||||
return $prizelist;
|
||||
}
|
||||
|
||||
public function getPrizes(): array
|
||||
{
|
||||
return $this->prizes;
|
||||
}
|
||||
|
||||
public function roll(): array
|
||||
{
|
||||
$result = [];
|
||||
$prizes = $this->prizes;
|
||||
shuffle($prizes);
|
||||
$d100 = rand(1, 1000);
|
||||
|
||||
if ($d100 <= 5) {
|
||||
$itemTier = 6;
|
||||
} elseif ($d100 <= 10) {
|
||||
$itemTier = 5;
|
||||
} elseif ($d100 <= 30) {
|
||||
$itemTier = 4;
|
||||
} elseif ($d100 <= 70) {
|
||||
$itemTier = 3;
|
||||
} elseif ($d100 <= 150) {
|
||||
$itemTier = 2;
|
||||
} else {
|
||||
$itemTier = 1;
|
||||
}
|
||||
|
||||
foreach ($prizes as $prize) {
|
||||
if (intval($prize[self::PRIZE_RARITY]) === $itemTier) {
|
||||
$result = $prize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'row_id' => $result[self::PRIZE_ROW_ID],
|
||||
'item_id' => $result[self::PRIZE_ITEM_ID],
|
||||
'name' => $result[self::PRIZE_NAME],
|
||||
];
|
||||
}
|
||||
|
||||
public static function freeRoll(string $uidCheck): void
|
||||
{
|
||||
$user = User::start()->info;
|
||||
$am = new ActionModel($user['id']);
|
||||
$titm = $am->getLastByValsAndTime('loto', 24 * 60 * 60);
|
||||
if (intval($uidCheck) != $user['id']) {
|
||||
echo 'No user!';
|
||||
exit;
|
||||
}
|
||||
if ($titm) {
|
||||
echo 'Wait asign!';
|
||||
exit;
|
||||
}
|
||||
$loto = new Loto();
|
||||
$prize = $loto->roll();
|
||||
ItemsModel::addItem($prize['item_id'], $user['id'], '|frompisher=1|nosale=1' . $user['login']);
|
||||
$cmsg = new ChatMessage();
|
||||
$cmsg->setText("<b>{$user['login']}</b> выиграл в бесплатной рулетке <b>{$prize['name']}</b>!");
|
||||
$cmsg->setType(6);
|
||||
(new Chat())->sendMsg($cmsg);
|
||||
ActionModel::new($user, 'loto', $prize['item_id']);
|
||||
echo $prize['row_id'];
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function paidRoll(string $uidCheck): void
|
||||
{
|
||||
$u = User::start();
|
||||
|
||||
if ($uidCheck == 'ekr') {
|
||||
echo $u->info['money2'];
|
||||
exit;
|
||||
}
|
||||
if (intval($uidCheck) != $u->info['id']) {
|
||||
echo "No user!";
|
||||
exit;
|
||||
}
|
||||
if ($u->info['money2'] < 5) {
|
||||
echo "No Ekr!";
|
||||
exit;
|
||||
}
|
||||
$loto = new Loto();
|
||||
$prize = $loto->roll();
|
||||
ItemsModel::addItem($prize['item_id'], $u->info['id'], '|frompisher=1|nosale=1' . $u->info['login']);
|
||||
$u->info['money2'] = $u->info['money2'] - 5;
|
||||
$u->addEkr(-5);
|
||||
$cmsg = new ChatMessage();
|
||||
$cmsg->setText("<b>{$u->info['login']}</b> выиграл в платной рулетке <b>{$prize['name']}</b>!");
|
||||
$cmsg->setType(6);
|
||||
(new Chat())->sendMsg($cmsg);
|
||||
echo $prize['row_id'];
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
<?php
|
||||
|
||||
namespace Location;
|
||||
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
use Delo;
|
||||
use Enum\ShopId;
|
||||
use Helper\Conversion;
|
||||
use Item\Data\Bonuses;
|
||||
use Item\Data\Properties;
|
||||
use Item\Data\Requirements;
|
||||
use Item\DataModel;
|
||||
use Model\Constant\ShopOtdel;
|
||||
use User;
|
||||
|
||||
class Shop
|
||||
{
|
||||
public ShopOtdel $shopOtdel;
|
||||
private ShopId $shopId;
|
||||
private array $wares;
|
||||
private int $otdel;
|
||||
private int $itemId;
|
||||
private $buyer;
|
||||
|
||||
public function __construct(ShopId $shopId, int $otdel = 1)
|
||||
{
|
||||
$this->shopOtdel = new ShopOtdel();
|
||||
$this->otdel = $otdel;
|
||||
$this->itemId = intval($_GET['itmid']);
|
||||
$this->shopId = $shopId;
|
||||
$this->wares = Db::getRows('select * from
|
||||
items_shop
|
||||
left join items_main on items_shop.item_id = items_main.id
|
||||
where sid = ? and r = ? and kolvo > 0 order by pos', [$shopId->value, $otdel]);
|
||||
|
||||
$this->buyer = new class {
|
||||
public function getId(): int
|
||||
{
|
||||
return User::start()->info['id'];
|
||||
}
|
||||
|
||||
public function getCredits(): float
|
||||
{
|
||||
return User::start()->info['money'];
|
||||
}
|
||||
|
||||
public function getEuroCredits(): float
|
||||
{
|
||||
return User::start()->info['money2'];
|
||||
}
|
||||
|
||||
public function getVoinstvennost(): int
|
||||
{
|
||||
return (int)User::start()->rep['rep3'] - (int)User::start()->rep['rep3_buy'];
|
||||
}
|
||||
|
||||
public function getNextAct()
|
||||
{
|
||||
return User::start()->info['nextAct']; // что ты такое?!
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return User::start()->isAdmin();
|
||||
}
|
||||
|
||||
public function hasEnough(string $parameter, int $value): bool
|
||||
{
|
||||
return User::start()->stats[$parameter] >= $value;
|
||||
}
|
||||
|
||||
public function hasExactly(string $parameter, int $value): bool
|
||||
{
|
||||
return User::start()->stats[$parameter] === $value;
|
||||
}
|
||||
|
||||
public function hasEnoughCredits(int $itemprice): bool
|
||||
{
|
||||
return $this->getCredits() >= $itemprice;
|
||||
}
|
||||
|
||||
public function hasEnoughEuroCredits(int $itemprice): bool
|
||||
{
|
||||
return $this->getEuroCredits() >= $itemprice;
|
||||
}
|
||||
|
||||
public function hasEnoughVoinstvennost(int $itemprice): bool
|
||||
{
|
||||
return $this->getVoinstvennost() >= $itemprice;
|
||||
}
|
||||
};
|
||||
if ($this->buyer->isAdmin()) {
|
||||
if (isset($_GET['itmup'])) {
|
||||
$this->itemUp();
|
||||
} elseif (isset($_GET['itmdown'])) {
|
||||
$this->itemDown();
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] === "GET") {
|
||||
if ($_GET['itmup']) {
|
||||
$this->itemUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function itemUp(): void
|
||||
{
|
||||
$this->changeItemPositionByInt(-1);
|
||||
}
|
||||
|
||||
private function changeItemPositionByInt(int $modificator): void
|
||||
{
|
||||
Db::sql('update items_shop set pos = pos + ? where sid = ? and r = ? and item_id = ? and kolvo > 0',
|
||||
[$modificator, $this->shopId->value, $this->otdel, $this->itemId]);
|
||||
}
|
||||
|
||||
private function itemDown(): void
|
||||
{
|
||||
$this->changeItemPositionByInt(1);
|
||||
}
|
||||
|
||||
public function printWares(): void
|
||||
{
|
||||
foreach ($this->wares as $pl) {
|
||||
$data = new DataModel($pl['item_id']);
|
||||
$itemRequirements = new Requirements($data->getRequirements());
|
||||
$itemBonuses = new Bonuses($data->getBonuses());
|
||||
$itemProperties = new Properties($data->getProperties());
|
||||
$itemData = $data->getAll();
|
||||
|
||||
$pl['price_1'] = $this->calculateMinimalPrice($pl['price1'], $pl['price_1'], $pl['tr_items']);
|
||||
$pl['price_2'] = $this->calculateMinimalPrice($pl['price2'], $pl['price_2'], $pl['tr_items']);
|
||||
|
||||
if (($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) {
|
||||
$itemBonuses->addZonb();
|
||||
}
|
||||
|
||||
$is2 = $this->name($pl['name'], $pl['renameadd'], $pl['item_id']);
|
||||
|
||||
if ($pl['massa'] > 0) {
|
||||
$is2 .= '(Масса: ' . round($pl['massa'], 2) . ')';
|
||||
}
|
||||
|
||||
$is2 .= $this->icons($itemRequirements->getAlign(), $itemData['art'], $itemData['sudba']);
|
||||
$is2 .= $this->price($pl['price_1'], $pl['price_2'], $pl['price_4']);
|
||||
|
||||
if ($pl['kolvo'] < 50) {
|
||||
$is2 .= ' <small style="color: crimson;">(остаток на складе: <strong>' . $pl['kolvo'] . '</strong>)</small>';
|
||||
}
|
||||
|
||||
$is2 .= $this->needItems($pl['tr_items']);
|
||||
|
||||
//долговечность
|
||||
if ($pl['iznos'] > 0) {
|
||||
$pl['iznosMAXi'] = $pl['iznos'];
|
||||
}
|
||||
if ($pl['iznosMAXi'] > 0 && $pl['iznosMAXi'] < 1000) {
|
||||
$is2 .= 'Долговечность: 0/' . $pl['iznosMAXi'] . '<br>';
|
||||
}
|
||||
|
||||
if ($itemData['battleUseZd'] > 0) {
|
||||
$is2 .= 'Задержка использования: ' . Conversion::secondsToTimeout($itemData['battleUseZd']) . '<br>';
|
||||
}
|
||||
|
||||
$is2 = rtrim($is2, '<br>');
|
||||
|
||||
//Срок годности предмета
|
||||
if ($itemData['srok'] > 0) {
|
||||
$pl['srok'] = $itemData['srok'];
|
||||
}
|
||||
if ($pl['srok'] > 0) {
|
||||
$is2 .= '<br>Срок годности: ' . Conversion::secondsToTimeout($pl['srok']);
|
||||
}
|
||||
if ($pl['magic_chance'] > 0) {
|
||||
$is2 .= '<br>Вероятность срабатывания: ' . min([$pl['magic_chance'], 100]) . '%';
|
||||
}
|
||||
|
||||
//Продолжительность действия магии:
|
||||
if ((int)$pl['magic_inci'] > 0) {
|
||||
$magicDuration = Db::getValue('select actiontime from eff_main where id2 = ?', [(int)$pl['magic_inci']]);
|
||||
|
||||
if ($magicDuration > 0) {
|
||||
$is2 .= '<br>Продолжительность действия: ' . Conversion::secondsToTimeout($magicDuration);
|
||||
}
|
||||
}
|
||||
|
||||
if ($itemRequirements->get()) {
|
||||
$is2 .= '<br><strong>Требуется минимальное:</strong>';
|
||||
$is2 .= '<ul style="margin: 0; padding: 0 30px;">';
|
||||
foreach ($itemRequirements->get() as $dataName => $dataInfo) {
|
||||
if ($dataName === 'align' || $dataName === 'sex') {
|
||||
$value = $dataName === 'align' ? intval($dataInfo['sysvalue']) : intval($dataInfo['value']);
|
||||
$is2 .= $this->buyer->hasExactly($dataName, $value) ? '<li>' : '<li style="color: crimson; list-style-type: \'× \';">';
|
||||
} else {
|
||||
$is2 .= $this->buyer->hasEnough($dataName, intval($dataInfo['value'])) ? '<li>' : '<li style="color: crimson; list-style-type: \'× \';">';
|
||||
}
|
||||
$name = empty($dataInfo['name']) ? $dataName : $dataInfo['name'];
|
||||
$is2 .= $name . ': ' . $dataInfo['value'];
|
||||
//$is2 .= $dataName . ': ' . $dataInfo;
|
||||
$is2 .= '</li>';
|
||||
}
|
||||
$is2 .= '</ul>';
|
||||
}
|
||||
|
||||
if ($itemBonuses->get()) {
|
||||
$is2 .= '<br><strong>Действует на:</strong>';
|
||||
$is2 .= '<ul style="margin: 0; padding: 0 30px;">';
|
||||
foreach ($itemBonuses->get() as $name => $value) {
|
||||
if ($name === 'Броня') {
|
||||
$is2 .= '<li>' . $name . ': ' . $value . '</li>';
|
||||
continue;
|
||||
}
|
||||
$color = $value > 0 ? 'darkgreen' : 'darkred';
|
||||
$is2 .= '<li style="color: ' . $color . '">' . $name . ': ' . ($value > 0 ? '+' . $value : $value) . '</li>';
|
||||
}
|
||||
$is2 .= '</ul>';
|
||||
}
|
||||
|
||||
$is2 .= '<br><strong>Свойства предмета:</strong>';
|
||||
foreach ($itemProperties->get() as $name => $value) {
|
||||
$is2 .= '<br>' . $name . ': ' . $value;
|
||||
}
|
||||
|
||||
if ($pl['2too'] === 1) {
|
||||
$is2 .= '<br>Второе оружие';
|
||||
}
|
||||
if ($pl['2h'] === 1) {
|
||||
$is2 .= '<br>Двуручное оружие';
|
||||
}
|
||||
|
||||
if (!empty($itemData['imposed'])) {
|
||||
if (empty($itemData['imposed_name'])) {
|
||||
$itemData['imposed_name'] = 'Неизвестное зачарование';
|
||||
}
|
||||
$itemData['imposed_name'] = str_replace('Чары ', '', $itemData['imposed_name']);
|
||||
$is2 .= '<br><span style="color: maroon;">Зачарование:</span> ' . $itemData['imposed_name'];
|
||||
}
|
||||
|
||||
if (!empty($itemData['free_stats']) && $itemData['free_stats'] > 0) {
|
||||
$is2 .= '<br> +' . $itemData['free_stats'] . ' дополнительных характеристик';
|
||||
}
|
||||
|
||||
//Встроенная магия
|
||||
if (!empty($pl['magic_inci']) || !empty($pl['magic_inc'])) {
|
||||
if (empty($pl['magic_inc'])) {
|
||||
$pl['magic_inc'] = $pl['magic_inci'];
|
||||
}
|
||||
$magic = Db::getRow('select id2, mname, minfo, img from eff_main where type1 = 12345 and id2 = ?', [$pl['magic_inc']]);
|
||||
if ($magic['id2']) {
|
||||
$is2 .= '<br><div>Встроено заклятие <img alt="' . $magic['mname'] . '" src="' . Config::img() . '/i/eff/' . $magic['img'] . '"> ' . $magic['minfo'] . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$is2 .= $this->getcomplect($itemData['complect']);
|
||||
|
||||
if ($pl['max_text'] - $pl['use_text'] > 0) {
|
||||
$is2 .= '<div>Количество символов: ' . ($pl['max_text'] - $pl['use_text']) . '</div>';
|
||||
}
|
||||
|
||||
$is2 .= '<small>';
|
||||
|
||||
if (!empty($itemData['gravi'])) {
|
||||
$is2 .= '<br><span style="font-size: x-large; font-family: consolas, monospace; background-color: darkseagreen; color: ghostwhite; padding: 0 5px;">' . $itemData['gravi'] . '</span>';
|
||||
}
|
||||
|
||||
if (!empty($itemData['info'])) {
|
||||
$pl['info'] .= '<br>' . $itemData['info'];
|
||||
}
|
||||
if (!empty($pl['info'])) {
|
||||
$is2 .= '<div style="border: 2px dashed whitesmoke; background-color: silver;">' . $pl['info'] . '</div>';
|
||||
}
|
||||
|
||||
if (isset($itemData['noremont'])) {
|
||||
$is2 .= '<div style="color:brown;">Предмет не подлежит ремонту</div>';
|
||||
}
|
||||
|
||||
if (isset($itemData['nosale'])) {
|
||||
$is2 .= '<div style="color:brown;">Предмет нельзя продать</div>';
|
||||
}
|
||||
|
||||
if (isset($itemData['nomodif'])) {
|
||||
$is2 .= '<div style="color:brown;">Предмет нельзя улучшать</div>';
|
||||
}
|
||||
|
||||
if (isset($itemData['nodelete'])) {
|
||||
$is2 .= '<div style="color:brown;">Предмет нельзя выбросить</div>';
|
||||
}
|
||||
|
||||
if (isset($itemData['sleep_moroz']) && $itemData['sleep_moroz'] > 0) {
|
||||
$is2 .= '<div style="color:brown;">Предмет не портится во время сна</div>';
|
||||
}
|
||||
|
||||
$is2 .= '</small>';
|
||||
|
||||
$is1 = $this->imageAndControls($pl['id'], $pl['type'], $pl['img'], $pl['name'], $pl['price_1'], $pl['price_2']);
|
||||
|
||||
echo <<<HTML
|
||||
<div style="padding: 7px; text-align: center; vertical-align: middle;" class="left">$is1</div>
|
||||
<div style="padding: 7px;" class="right">{$this->adminOptions($pl['id'], $pl['pos'])} $is2</div>
|
||||
HTML;
|
||||
|
||||
}
|
||||
if (empty($this->wares)) {
|
||||
echo '<div style="grid-column: 1 / 3; padding: 7px; margin: auto">Прилавок магазина пуст.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateMinimalPrice($basePrice, $shopPrice, $needItems)
|
||||
{
|
||||
if ($shopPrice < 0.01 && !$needItems) {
|
||||
$shopPrice = $basePrice;
|
||||
}
|
||||
if ($shopPrice < 0) {
|
||||
$shopPrice = 0;
|
||||
}
|
||||
return $shopPrice;
|
||||
}
|
||||
|
||||
private function name(string $name, ?string $defaultName, int $itemid): string
|
||||
{
|
||||
$styleSuffix = '';
|
||||
if ($this->shopId === ShopId::SHOP_2) {
|
||||
$styleSuffix = 'WL';
|
||||
}
|
||||
if (!empty($defaultName)) {
|
||||
$name .= ' (Предмет: ' . $defaultName . ')';
|
||||
}
|
||||
if (!empty($styleSuffix)) {
|
||||
$name = '<span class="icos_' . $styleSuffix . '">' . $name . ' <small> ' . $styleSuffix . ' </small></span>';
|
||||
}
|
||||
return '<a id="sit_' . $itemid . '" href="/item/' . $itemid . '" target="_blank">' . $name . '</a> ';
|
||||
}
|
||||
|
||||
private function icons(?int $align, ?int $artefact, ?int $destiny): string
|
||||
{
|
||||
$str = ' ';
|
||||
if (!empty($align)) {
|
||||
$str .= '<img src="' . Config::img() . '/i/align/align' . $align . '.gif" alt="Требуется склонность">';
|
||||
}
|
||||
if (!empty($artefact)) {
|
||||
$str .= '<img src="' . Config::img() . '/i/artefact.gif" alt="Артефакт">';
|
||||
}
|
||||
$str .= $this->destiny($destiny);
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function destiny($d): string
|
||||
{
|
||||
if (empty($d)) {
|
||||
return '';
|
||||
}
|
||||
if ($d == 0) {
|
||||
$str = 'первым, кто наденет его';
|
||||
} elseif ($d == 1) {
|
||||
$str = 'первым, кто возьмёт его';
|
||||
} else {
|
||||
$str = $d;
|
||||
}
|
||||
return '<img
|
||||
title="Этот предмет будет связан общей судьбой с ' . $str . '. Никто другой не сможет его использовать."
|
||||
src="' . Config::img() . '/i/destiny0.gif"
|
||||
alt="Общая судьба">';
|
||||
}
|
||||
|
||||
private function price(int $credits, int $eurocredits, int $voinstvennost): string
|
||||
{
|
||||
$result = 'Цена: ';
|
||||
if ($this->shopId === ShopId::SHOP_2) {
|
||||
$result .= $this->printColoredValue($this->buyer->getVoinstvennost() >= $voinstvennost, $voinstvennost);
|
||||
$result .= ' Воинственности ';
|
||||
} elseif ($this->shopId === ShopId::BEREZKA || $this->shopId === ShopId::ARTEFACTS) {
|
||||
$result .= '<span style="color: cornflowerblue;">';
|
||||
$result .= $this->printColoredValue($this->buyer->getEuroCredits() >= $eurocredits, $eurocredits);
|
||||
$result .= ' екр.</span> ';
|
||||
} else {
|
||||
$result .= $this->printColoredValue($this->buyer->getCredits() >= $credits, $credits);
|
||||
$result .= ' кр.';
|
||||
}
|
||||
return '<br><strong>' . $result . '</strong> ';
|
||||
}
|
||||
|
||||
/**
|
||||
* Если в первом параметре передаётся false, строка во втором параметре красится в красный цвет.
|
||||
* @param bool $check
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
private function printColoredValue(bool $check, $value): string
|
||||
{
|
||||
$color = $check ? 'inherit' : 'red';
|
||||
return sprintf('<span style="color:%s;">%s</span>', $color, $value);
|
||||
}
|
||||
|
||||
private function needItems(string $items): string
|
||||
{
|
||||
if (!$items || Config::get('noitembuy')) {
|
||||
return '';
|
||||
}
|
||||
$result = '';
|
||||
$trn = true;
|
||||
|
||||
$itemsArray = explode(',', $items);
|
||||
foreach ($itemsArray as $keyvalue) {
|
||||
[$key, $value] = explode('=', $keyvalue);
|
||||
if (!empty($key) && !empty($value)) {
|
||||
$neededItemName = Db::getValue('select name from items_main where id = ?', [$key]);
|
||||
if ($neededItemName) {
|
||||
$neededItemsInInventoryCount = Db::getValue(
|
||||
'select count(*) from items_users where item_id = ? and inShop = 0 and inOdet = 0 and `delete` in (0,1000) and uid = ?',
|
||||
[$key, $this->buyer->getId()]);
|
||||
if ($neededItemsInInventoryCount < (int)$value) {
|
||||
$trn = false;
|
||||
}
|
||||
$result .= '[<strong>' . $neededItemName . '</strong>] x' . $value . ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->printColoredValue($trn, '<br>Требует предмет: ' . rtrim($result, ', ') . ' ') . '<br>';
|
||||
}
|
||||
|
||||
private function getcomplect(?int $complect): string
|
||||
{
|
||||
if (!isset($complect)) {
|
||||
return '';
|
||||
}
|
||||
$cname = 'Неизвестный Комплект';
|
||||
$text = '';
|
||||
$stmt = Db::getRows('select * from complects where com = ? order by x', [$complect]);
|
||||
foreach ($stmt as $row) {
|
||||
$cname = $row['name'];
|
||||
$text .= ' • <span style="color: green;">' . $row['x'] . ' предметов</span>:<br>';
|
||||
//действие комплекта
|
||||
$complectBonuses = new Bonuses(Conversion::dataStringToArray($row['data']));
|
||||
foreach ($complectBonuses->get() as $name => $value) {
|
||||
$text .= ' <span style="color: darkgreen;">';
|
||||
if ($name === 'Броня') {
|
||||
$text .= $name . ': ' . $value;
|
||||
} else {
|
||||
$text .= $name . ': ' . ($value > 0 ? '+' . $value : $value);
|
||||
}
|
||||
$text .= '</span><br>';
|
||||
}
|
||||
}
|
||||
return "<br>Часть комплекта: <strong>$cname</strong><br><small>$text</small>";
|
||||
}
|
||||
|
||||
private function imageAndControls(int $id, int $type, string $image, string $name, float $credits, float $eurocredits): string
|
||||
{
|
||||
if ($type == 71) {
|
||||
$result = '<img src="' . Config::img() . '/i/items/' . $image . '" width="80" alt="' . $name . '"><br>';
|
||||
} else {
|
||||
$result = '<img src="' . Config::img() . '/i/items/' . $image . '" alt="' . $name . '"><br>';
|
||||
}
|
||||
if ($this->shopId == ShopId::SHOP_2) {
|
||||
$js = <<<JS
|
||||
<button onClick="top.buyShopNow($id,'?otdel=$this->otdel&buyVn=$id&sd4={$this->buyer->getNextAct()}','$name')">Купить</button>
|
||||
JS;
|
||||
} elseif (($this->shopId == ShopId::BEREZKA || $this->shopId == ShopId::ARTEFACTS) && $this->buyer->hasEnoughEuroCredits($eurocredits)) {
|
||||
$js = <<<JS
|
||||
<button onClick="top.buyShopNow($id,'?otdel=$this->otdel&buyEkr=$id&sd4={$this->buyer->getNextAct()}','$name',$eurocredits,'екр.')">Купить</button>
|
||||
JS;
|
||||
} elseif ($this->buyer->hasEnoughCredits($credits)) {
|
||||
$js = <<<JS
|
||||
<button onClick="top.buyShopNow($id,'?otdel=$this->otdel&buy=$id&sd4={$this->buyer->getNextAct()}','$name',$credits,'кр.')">Купить</button>
|
||||
JS;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $result . $js;
|
||||
}
|
||||
|
||||
private function adminOptions(int $itemId, int $itemPosition): string
|
||||
{
|
||||
if (!$this->buyer->isAdmin()) {
|
||||
return '';
|
||||
}
|
||||
$time = microtime();
|
||||
return <<<HTML
|
||||
<div style="float:right">
|
||||
<a href="?otdel=$this->otdel&itmid=$itemId&itmup=1#itmdown$itemId">↿</a>
|
||||
$itemPosition
|
||||
<a href="?otdel=$this->otdel&itmid=$itemId&itmdown=1#itmdown$itemId">⇂</a>
|
||||
<button onclick="window.open('/item_edit_data.php?edit_item_data=$itemId','winEdi1','width=850,height=400,top=400,left=500,resizable=no,scrollbars=yes,status=no')">
|
||||
Редактировать предмет
|
||||
</button>
|
||||
<button onclick="location.href='/main.php?timeWorld=$time&otdel=$this->otdel#itmShop$itemId'">Обновить</button>
|
||||
</div><br>
|
||||
HTML;
|
||||
}
|
||||
|
||||
public function buy(int $itemid): string
|
||||
{
|
||||
$sql = 'select sid, items_shop.price_1, name from items_shop left join items_main on item_id = id where item_id = ? and sid = ?';
|
||||
$item = Db::getRow($sql, [$itemid, $this->shopId->value]);
|
||||
if (!$this->buyer->hasEnoughCredits($item['price_1'])) {
|
||||
return 'Покупка не удалась.';
|
||||
}
|
||||
|
||||
$newId = User\ItemsModel::addItem($itemid, $this->buyer->getId());
|
||||
Db::sql('update items_users set `1price` = ? where id = ?', [$item['price_1'], $newId]);
|
||||
User::start()->info['money'] -= $item['price_1'];
|
||||
User::start()->addKr(-$item['price_1']);
|
||||
Delo::add(1, "shopid:{$item['sid']}", $this->buyer->getId(), "Покупка «{$item['name']}» по цене {$item['price_1']}.", $item['price_1']);
|
||||
return "Вы купили «{$item['name']}» по цене {$item['price_1']}.";
|
||||
}
|
||||
|
||||
public function buyEkr(int $itemid): string
|
||||
{
|
||||
$sql = 'select sid, items_shop.price_2, name from items_shop left join items_main on item_id = id where item_id = ? and sid = ?';
|
||||
$item = Db::getRow($sql, [$itemid, $this->shopId->value]);
|
||||
if (!$this->buyer->hasEnoughEuroCredits($item['price_2'])) {
|
||||
return 'Покупка не удалась.';
|
||||
}
|
||||
|
||||
$newId = User\ItemsModel::addItem($itemid, $this->buyer->getId());
|
||||
Db::sql('update items_users set `2price` = ? where id = ?', [$item['price_2'], $newId]);
|
||||
User::start()->info['money2'] -= $item['price_2'];
|
||||
User::start()->addEkr(-$item['price_2']);
|
||||
Delo::add(1, "shopid:{$item['sid']}", $this->buyer->getId(), "Покупка «{$item['name']}» по цене {$item['price_2']}.", $item['price_2']);
|
||||
return "Вы купили «{$item['name']}» по цене {$item['price_2']}.";
|
||||
}
|
||||
|
||||
public function buyVn(int $itemid): string
|
||||
{
|
||||
$sql = 'select sid, items_shop.price_4, name from items_shop left join items_main on item_id = id where item_id = ? and sid = ?';
|
||||
$item = Db::getRow($sql, [$itemid, $this->shopId->value]);
|
||||
if (!$this->buyer->hasEnoughVoinstvennost($item['price_4'])) {
|
||||
return 'Покупка не удалась.';
|
||||
}
|
||||
|
||||
$newId = User\ItemsModel::addItem($itemid, $this->buyer->getId());
|
||||
Db::sql('update items_users set `4price` = ? where id = ?', [$item['price_4'], $newId]);
|
||||
User::start()->rep['rep3'] -= $item['price_4'];
|
||||
User::start()->addVoinstvennost(-$item['price_4']);
|
||||
Delo::add(1, "shopid:{$item['sid']}", $this->buyer->getId(), "Покупка «{$item['name']}» по цене {$item['price_4']}.", $item['price_4']);
|
||||
return "Вы купили «{$item['name']}» по цене {$item['price_4']}.";
|
||||
}
|
||||
|
||||
public function getUsedOtdels(): array
|
||||
{
|
||||
$result = [];
|
||||
foreach (Db::getColumn('select r from items_shop where sid = ? group by r', [$this->shopId->value]) as $v) {
|
||||
$result[$v] = $this->shopOtdel->getName($v);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUserWallet(): string
|
||||
{
|
||||
$result = '';
|
||||
if ($this->shopId === ShopId::MAIN) {
|
||||
$result = $this->buyer->getCredits() . ' кр.';
|
||||
} elseif (in_array($this->shopId, [ShopId::BEREZKA, ShopId::ARTEFACTS])) {
|
||||
$result = $this->buyer->getEuroCredits() . ' екр.';
|
||||
} elseif ($this->shopId === ShopId::SHOP_2) {
|
||||
$result = $this->buyer->getVoinstvennost() . ' воинственности.';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
|
||||
class LocationResponse
|
||||
{
|
||||
private const MSG = [
|
||||
'your-position' => 'Ваше местоположение',
|
||||
'move-bk' => 'Проход через <b>Бойцовский клуб</b>',
|
||||
'move-zalu4' => 'Проход через <b>Зал паладинов</b>',
|
||||
'move-map_halls' => 'Проход через <b>Залы</b>',
|
||||
'move-to-sek4' => 'Проход через <b>Рыцарский</b> или <b>Торговый</b> зал',
|
||||
'move-sek5' => 'Проход через <b>Торговый зал</b>',
|
||||
'move-sek6' => 'Проход через <b>Рыцарский зал</b>',
|
||||
];
|
||||
|
||||
private static function thisInfRm($id): array
|
||||
{
|
||||
$rm = Db::getRow('select id, name from room where code = ?', [$id]);
|
||||
|
||||
if (isset($rm['id'])) {
|
||||
$rown = Db::getValue('select count(*) from users where online > unix_timestamp() - 120 and room = ?', [$rm['id']]);
|
||||
return [$id, $rm['name'], $rown];
|
||||
}
|
||||
return ['false', 'Здание было разрушено', 0];
|
||||
}
|
||||
|
||||
public static function init(
|
||||
int $tmGo,
|
||||
int $tmGol,
|
||||
$roomFile,
|
||||
$roomName,
|
||||
): string {
|
||||
$r = match ($roomFile) {
|
||||
'bk' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig',
|
||||
'left' => '241',
|
||||
'top' => '128',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_bk', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_klub1', 'params' => self::thisInfRm('1.180.0.15')],
|
||||
['id' => 'map_klub2', 'params' => self::thisInfRm('1.180.0.225')],
|
||||
['id' => 'map_klub3', 'params' => self::thisInfRm('1.180.0.2')],
|
||||
['id' => 'map_klub4', 'params' => self::thisInfRm('1.180.0.4')],
|
||||
['id' => 'map_klub5', 'params' => self::thisInfRm('1.180.0.5')],
|
||||
['id' => 'map_klub6', 'params' => self::thisInfRm('1.180.0.16')],
|
||||
['id' => 'map_klub7', 'params' => self::thisInfRm('1.180.0.9')],
|
||||
],
|
||||
'buttons' => [
|
||||
['Возврат', 'main.php?homeworld=true'],
|
||||
['Карта клуба', 'main.php?clubmap=true'],
|
||||
['Форум', "window.open('" . Config::get('forum') . "', 'forum', 'location=yes,menubar=yes,status=yes,resizable=yes,toolbar=yes,scrollbars=yes,scrollbars=yes')"],
|
||||
['Подсказка', "window.open('/encicl/help/top1.html', 'help', 'height=300,width=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes')"],
|
||||
],
|
||||
],
|
||||
'zv1' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig',
|
||||
'left' => '154',
|
||||
'top' => '148',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
|
||||
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub3', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub4', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_klub5', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub6', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
|
||||
],
|
||||
],
|
||||
'zv2' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig',
|
||||
'left' => '395',
|
||||
'top' => '142',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
|
||||
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub3', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_klub4', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub5', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub6', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
|
||||
],
|
||||
],
|
||||
'zv3' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig',
|
||||
'left' => '337',
|
||||
'top' => '79',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
|
||||
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub3', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub4', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub5', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_klub6', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
|
||||
],
|
||||
],
|
||||
'zv4' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig',
|
||||
'left' => '139',
|
||||
'top' => '79',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
|
||||
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub3', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub4', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub5', 'params' => [false, self::MSG['move-bk']]],
|
||||
['id' => 'map_klub6', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
|
||||
],
|
||||
],
|
||||
'zalu' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig1',
|
||||
'left' => '337',
|
||||
'top' => '117',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_halls', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_zalu3', 'params' => [false, self::MSG['move-zalu4']]],
|
||||
['id' => 'map_zalu4', 'params' => self::thisInfRm('1.180.0.16')],
|
||||
['id' => 'map_zalu6', 'params' => [false, self::MSG['move-zalu4']]],
|
||||
['id' => 'map_zalu7', 'params' => self::thisInfRm('1.180.0.3')],
|
||||
|
||||
],
|
||||
],
|
||||
'zalu_pal' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig1',
|
||||
'left' => '163',
|
||||
'top' => '28',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_halls', 'params' => self::thisInfRm('1.180.0.15')],
|
||||
['id' => 'map_zalu3', 'params' => self::thisInfRm('1.180.0.xx')],
|
||||
['id' => 'map_zalu4', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_zalu6', 'params' => self::thisInfRm('1.180.0.0')],
|
||||
['id' => 'map_zalu7', 'params' => [false, self::MSG['move-map_halls']]],
|
||||
],
|
||||
],
|
||||
'bk2' => [
|
||||
'status' => 'success',
|
||||
'location' => [
|
||||
'bg' => 'navig3',
|
||||
'left' => '162',
|
||||
'top' => '125',
|
||||
],
|
||||
'goto' => [
|
||||
['id' => 'map_2stair', 'params' => [false, self::MSG['your-position']]],
|
||||
['id' => 'map_sec1', 'params' => self::thisInfRm('1.180.0.3')],
|
||||
['id' => 'map_sec2', 'params' => self::thisInfRm('1.180.0.xx')],
|
||||
['id' => 'map_sec3', 'params' => [false, self::MSG['move-sek5']]],
|
||||
['id' => 'map_sec4', 'params' => [false, self::MSG['move-to-sek4']]],
|
||||
['id' => 'map_sec5', 'params' => self::thisInfRm('1.180.0.221')],
|
||||
['id' => 'map_sec6', 'params' => self::thisInfRm('1.180.0.224')],
|
||||
['id' => 'map_sec7', 'params' => [false, self::MSG['move-sek6']]],
|
||||
],
|
||||
],
|
||||
default => [],
|
||||
};
|
||||
if (!empty($r)) {
|
||||
$r['location']['name'] = $roomName;
|
||||
$r['location']['tgo'] = $tmGo * 10;
|
||||
$r['location']['tgo1'] = $tmGol * 10;
|
||||
}
|
||||
$r = json_encode($r);
|
||||
return $r ?: '';
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user