456 lines
17 KiB
PHP
456 lines
17 KiB
PHP
<?php
|
||
|
||
use Core\Config;
|
||
use Core\ConversionHelper;
|
||
use Core\Db;
|
||
use User\Effects;
|
||
|
||
if (!defined('GAME')) {
|
||
die();
|
||
}
|
||
if ($u->room['file'] != 'znahar') {
|
||
return;
|
||
}
|
||
|
||
$err = '';
|
||
|
||
function getLevelsData()
|
||
{
|
||
global $u;
|
||
return Db::getRow('select
|
||
sum(skills) as sum_skills,
|
||
sum(nskills) as sum_nskills,
|
||
sum(ability) as sum_abilities,
|
||
sum(vinos) as sum_vinos,
|
||
sum(duh) as sum_duh
|
||
from levels where upLevel < ?', [$u->info['upLevel']]);
|
||
}
|
||
|
||
function testSkills(): int
|
||
{
|
||
global $u;
|
||
return getLevelsData()['sum_skills'] + $u->rep['add_skills'];
|
||
}
|
||
|
||
function testSkills2(): int
|
||
{
|
||
global $u;
|
||
return getLevelsData()['sum_nskills'] + $u->rep['add_skills2'];
|
||
}
|
||
|
||
function testAbilities(): int
|
||
{
|
||
global $u;
|
||
return getLevelsData()['sum_abilities'] + $u->rep['add_stats'];
|
||
}
|
||
|
||
function testStat5()
|
||
{
|
||
return 3 + getLevelsData()['sum_vinos'];
|
||
}
|
||
|
||
function testStat7()
|
||
{
|
||
return getLevelsData()['sum_duh'];
|
||
}
|
||
|
||
function zact($i): void
|
||
{
|
||
global $u;
|
||
Db::sql('insert into aaa_znahar (act, point, uid, time,city) values (?,0,?,unix_timestamp(),?)', [$i, $u->info['id'], $u->info['city']]);
|
||
}
|
||
|
||
#------------------Запросы и прочее
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$vinos = [
|
||
/* level,summvinos*/
|
||
"0" => 3,
|
||
"1" => 4,
|
||
"2" => 5,
|
||
"3" => 6,
|
||
"4" => 7,
|
||
"5" => 8,
|
||
"6" => 9,
|
||
"7" => 10,
|
||
"8" => 11,
|
||
"9" => 13,
|
||
"10" => 16,
|
||
"11" => 21,
|
||
"12" => 41,
|
||
"21" => 41,
|
||
];
|
||
//минимальный уровень для статов
|
||
$minlvl = [
|
||
1 => 0,
|
||
2 => 0,
|
||
3 => 0,
|
||
4 => 0,
|
||
5 => 4,
|
||
6 => 7,
|
||
7 => 10,
|
||
8 => 12,
|
||
9 => 15,
|
||
10 => 20,
|
||
11 => 0,
|
||
];
|
||
|
||
if (Effects::hasInjury($u->info['id'])) {
|
||
$err = 'У вас травма. Вы не можете пользоваться услугами знахаря!';
|
||
} elseif (isset($_GET['unprist'])) {
|
||
$addictionId = (int)$_GET['unprist'];
|
||
if (Effects::hasAddiction($addictionId, $u->info['id'])) {
|
||
zact(4);
|
||
//сброс пристрастия
|
||
Effects::removeById($u->info['id'], $addictionId);
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$err = 'Все прошло успешно.';
|
||
} else {
|
||
$err = 'Пристрастие не найдено.';
|
||
}
|
||
} elseif (isset($_POST['dropstats'])) {
|
||
zact(3);
|
||
|
||
//сброс статов
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$st['s1'] = 3;
|
||
$st['s2'] = 3;
|
||
$st['s3'] = 3;
|
||
$st['s4'] = testStat5();
|
||
$st['s5'] = 0;
|
||
$st['s6'] = 0;
|
||
$st['s7'] = testStat7();
|
||
$st['s8'] = 0;
|
||
$st['s9'] = 0;
|
||
$st['s10'] = 0;
|
||
$st['s11'] = 0;
|
||
$st['s12'] = 0;
|
||
$st['s13'] = 0;
|
||
$st['s14'] = 0;
|
||
$st['s15'] = 0;
|
||
$st = ConversionHelper::arrayToDataString($st);
|
||
$n1 = testAbilities();
|
||
$n2 = $u->info['skills'];
|
||
$n3 = $u->info['sskills'];
|
||
$n4 = $u->info['nskills'];
|
||
Db::sql('update stats set wipe = 0, stats = ?, ability = ?, skills = ?, sskills = ?, nskills = ? where id = ?', [$st, $n1, $n2, $n3, $n4, $u->info['id']]);
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$err = 'Все прошло успешно.';
|
||
} elseif (isset($_POST['dropmastery'])) {
|
||
zact(1);
|
||
//сброс статов
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$st['a1'] = 0;
|
||
$st['a2'] = 0;
|
||
$st['a3'] = 0;
|
||
$st['a4'] = 0;
|
||
$st['a5'] = 0;
|
||
$st['a6'] = 0;
|
||
$st['mg1'] = 0;
|
||
$st['mg2'] = 0;
|
||
$st['mg3'] = 0;
|
||
$st['mg4'] = 0;
|
||
$st['mg5'] = 0;
|
||
$st['mg6'] = 0;
|
||
$st['mg7'] = 0;
|
||
$st = ConversionHelper::arrayToDataString($st);
|
||
$n1 = $u->info['ability'];
|
||
$n2 = testSkills();
|
||
$n3 = $u->info['sskills'];
|
||
$n4 = $u->info['nskills'];
|
||
Db::sql('update stats set wipe = 0, stats = ?, ability = ?, skills = ?, sskills = ?, nskills = ? where id = ?', [$st, $n1, $n2, $n3, $n4, $u->info['id']]);
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$err = 'Все прошло успешно.';
|
||
} elseif (isset($_POST['dropmastery'])) {
|
||
//Старая версия
|
||
zact(1);
|
||
//сброс характеристик
|
||
$u->info['wipe'] = 3;
|
||
$u->wipe();
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$err = 'Умения покинули вас.';
|
||
} elseif (isset($_POST['dropperks'])) {
|
||
zact(1);
|
||
|
||
//сброс особенностей
|
||
$u->info['wipe'] = 3.5;
|
||
$u->wipe();
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
$err = 'Особенности покинули вас.';
|
||
|
||
} elseif (isset($_GET['movestat'])) {
|
||
//общее кол-во статов
|
||
$allStats = $st['s1'] + $st['s2'] + $st['s3'] + $st['s4'] + $st['s5'] + $st['s6'] + $st['s7'] + $st['s8'] + $st['s9'] + $st['s10'];
|
||
$allStatsTesto = $allStats;
|
||
$no = 0;
|
||
$st_l = 0;
|
||
for ($i = 1; $i <= 10; $i++) {
|
||
if (isset($_GET['s' . $i]) && ($st['s' . $i] + (int)$_GET['s' . $i]) >= 0 && $i <= 10) {
|
||
if ($minlvl[$i] > $u->info['level'] && $st['s' . $i] < (int)$_GET['s' . $i]) {
|
||
$no++;
|
||
} else {
|
||
if ((int)$_GET['s' . $i] > 0) {
|
||
$st_l += (int)$_GET['s' . $i];
|
||
}
|
||
$st['s' . $i] += (int)$_GET['s' . $i];
|
||
$allStatsNew += (int)$_GET['s' . $i];
|
||
$allStatsTesto += (int)$_GET['s' . $i];
|
||
}
|
||
}
|
||
}
|
||
|
||
if ($allStatsTesto != $allStats) {
|
||
$no++;
|
||
}
|
||
|
||
if ($no == 0) {
|
||
|
||
zact(5);
|
||
|
||
if (
|
||
$st['s1'] >= 3 &&
|
||
$st['s2'] >= 3 &&
|
||
$st['s3'] >= 3 &&
|
||
$st['s4'] >= testStat5() &&
|
||
$st['s5'] >= 0 &&
|
||
$st['s6'] >= 0 &&
|
||
$st['s7'] >= testStat7() &&
|
||
$st['s8'] >= 0 &&
|
||
$st['s9'] >= 0 &&
|
||
$st['s10'] >= 0
|
||
) {
|
||
//Желательно проверку на статы по уровню (можно ли этот стат поднимать на текущем уровне перса)
|
||
$u->info['stats'] = ConversionHelper::arrayToDataString($st);
|
||
Db::sql('update stats set stats = ? where id = ?', [$u->info['stats'], $u->info['id']]);
|
||
|
||
//Надо добавить UPDATE в базе свободных статов
|
||
$u->stats = $u->getStats($u->info['id'], 0, 1);
|
||
$u->testItems($u->info['id'], $u->stats, 0);
|
||
$st = ConversionHelper::dataStringToArray($u->info['stats']);
|
||
}
|
||
}
|
||
}
|
||
|
||
$err = "<span style='color: red;'>$err</span>";
|
||
#------------------Запросы и прочее
|
||
?>
|
||
<STYLE>
|
||
.H3 {
|
||
COLOR: #8f0000;
|
||
FONT-FAMILY: Arial, serif;
|
||
FONT-SIZE: 12pt;
|
||
FONT-WEIGHT: bold;
|
||
text-align: center;
|
||
}
|
||
|
||
body {
|
||
margin-top: 5px;
|
||
margin-left: 5px;
|
||
background-color: #e2e0e0;
|
||
|
||
}
|
||
|
||
#mmoves, #mmoves3 {
|
||
background-color: #FFFFCC;
|
||
overflow: visible;
|
||
position: absolute;
|
||
border-color: #666666;
|
||
border-style: solid;
|
||
border-width: 1px;
|
||
padding: 2px;
|
||
}
|
||
|
||
#mmoves3 {
|
||
z-index: 101;
|
||
}
|
||
|
||
#mmoves {
|
||
white-space: nowrap;
|
||
}
|
||
</STYLE>
|
||
<SCRIPT>
|
||
function gfastshow(dsc, dx, dy) {
|
||
top.fullfastshow(document, mmoves3, window.event, dsc, dx, dy);
|
||
}
|
||
|
||
function ghideshow() {
|
||
top.fullhideshow(mmoves3);
|
||
}
|
||
</SCRIPT>
|
||
</HEAD>
|
||
<body marginwidth=5 marginheight=5>
|
||
<div id="mmoves3" style="visibility:hidden;">
|
||
|
||
</div>
|
||
<SCRIPT src='<?= Config::img() ?>/i/commoninf.js'></SCRIPT>
|
||
<TABLE style="width: 100%">
|
||
<TR>
|
||
<TD>
|
||
<DIV class='H3'>Комната Знахаря</DIV>
|
||
<?= $err; ?><?php
|
||
if ($u->error != '') {
|
||
echo '<br><span style="float:right; color: red; " >' . $u->error . '</span>';
|
||
}
|
||
if ($re != '') {
|
||
echo '<br><span style="float:right; color: red; font-weight: bold;" >' . $re . '</span>';
|
||
}
|
||
?><BR>
|
||
<div style="font-weight: bold; font-style: italic; margin-bottom: 16px;">
|
||
Запахи трав наполняют помещение, непонятные и пугающие предметы скрываются в пляшущих тенях...<BR>
|
||
Говорят, здесь можно изменить свою судьбу. Стать кем-то иным... кем раньше был лишь в мечтах...
|
||
</div>
|
||
</TD>
|
||
<TD width=1 valign=top>
|
||
<table border="0" cellpadding="0" cellspacing="0">
|
||
<tr align="right" valign="top">
|
||
<td>
|
||
<!-- -->
|
||
<?= $goLis; ?>
|
||
<!-- -->
|
||
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DEDEDE">
|
||
<tr>
|
||
<td bgcolor="#D3D3D3">
|
||
<img src="<?= Config::img() ?>/i/move/links.gif" width="9" height="7"/>
|
||
</td>
|
||
<td bgcolor="#D3D3D3" nowrap>
|
||
<a href="javascript:void(0)" class="menutop" onClick="location='main.php?loc=1.180.0.3&rnd=<?= PassGen::intCode() ?>';" title="<?php thisInfRm('1.180.0.3', 1); ?>">
|
||
Бойцовский Клуб
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<div id="mmoves" style="visibility:hidden;"></div>
|
||
</TD>
|
||
</TR>
|
||
</TABLE>
|
||
<TABLE>
|
||
<TR bgcolor=#D8D8D8>
|
||
<TD><IMG width=20 height=20 src='<?= Config::img() ?>/i/strsmall.gif'> Характеристики</TD>
|
||
<TD><IMG width=20 height=20 src='<?= Config::img() ?>/i/cureelixirsmall.gif'> Пристрастия</TD>
|
||
<TD><IMG width=20 height=20 src='<?= Config::img() ?>/i/weaponsmall.gif'> Прочее</TD>
|
||
<TR>
|
||
<TD width=270 valign=top>
|
||
<SCRIPT>
|
||
var mylvl = <?=$u->info['level']; ?>;
|
||
//////////////Название,параметр,всего, +сколько, до скольки сбросить(макс возможное),сколько сбрасывать/прибавлять
|
||
var pr = [
|
||
'Сила', 's1', <?=(0 + $st['s1'])?>, <?=$u->stats['s1'] - $st['s1'];?>, 3, 0, <?=$minlvl[1];?>,
|
||
'Ловкость', 's2', <?=(0 + $st['s2'])?>, <?=$u->stats['s2'] - $st['s2'];?>, 3, 0, <?=$minlvl[2];?>,
|
||
'Интуиция', 's3', <?=(0 + $st['s3'])?>, <?=$u->stats['s3'] - $st['s3'];?>, 3, 0, <?=$minlvl[3];?>,
|
||
'Выносливость', 's4', <?=(0 + $st['s4'])?>, 0, <?=$vinos[$u->info['level']]?>, 0, <?=$minlvl[4];?>,
|
||
'Интеллект', 's5', <?=(0 + $st['s5'])?>, <?=$u->stats['s5'] - $st['s5'];?>, 0, 0, <?=$minlvl[5];?>,
|
||
'Мудрость', 's6', <?=(0 + $st['s6'])?>, 0, 0, 0, <?=$minlvl[6];?>,
|
||
'Духовность', 's7', <?=(0 + $st['s7'])?>, 0, 0, 0, <?=$minlvl[7];?>,
|
||
'Воля', 's8', <?=(0 + $st['s8'])?>, 0, 0, 0, <?=$minlvl[8];?>,
|
||
'Свобода Духа', 's9', <?=(0 + $st['s9'])?>, 0, 0, 0, <?=$minlvl[9];?>,
|
||
'Божественность', 's10', <?=(0 + $st['s10'])?>, 0, 0, 0, <?=$minlvl[10];?>
|
||
];
|
||
|
||
function getprstr(i) {
|
||
let ss = pr[i] + ": " + (pr[i + 2] + pr[i + 3] + pr[i + 5]);
|
||
if (pr[i + 3] || pr[i + 5]) {
|
||
ss += " (" + pr[i + 2];
|
||
if (pr[i + 3]) {
|
||
ss += (pr[i + 3] < 0 ? "" : "+") + pr[i + 3]
|
||
}
|
||
if (pr[i + 5]) {
|
||
if (pr[i + 5] > 0) {
|
||
ss += " <span style='color: green;'>+" + pr[i + 5];
|
||
} else {
|
||
ss += " <span style='color: maroon;'>" + pr[i + 5];
|
||
}
|
||
ss += "</span>";
|
||
}
|
||
ss += ")";
|
||
}
|
||
return ss;
|
||
}
|
||
|
||
var freepr = 0;
|
||
var movecost = 5;
|
||
|
||
function modpr(i, to) {
|
||
if (to == 1 && freepr == 0) {
|
||
return;
|
||
}
|
||
if (to == -1 && pr[i + 2] + pr[i + 5] <= pr[i + 4]) {
|
||
return;
|
||
}
|
||
pr[i + 5] += to;
|
||
freepr -= to;
|
||
document.all["pr" + i].innerHTML = getprstr(i);
|
||
document.all["prfree"].innerHTML = freepr;
|
||
var moves = 0;
|
||
for (j = 0; j < pr.length; j += 7) {
|
||
if (pr[j + 5] > 0) {
|
||
moves += pr[j + 5]
|
||
}
|
||
|
||
}
|
||
movedonebutton.disabled = (freepr || moves == 0 ? true : false);
|
||
}
|
||
|
||
function movedone() {
|
||
if (freepr) {
|
||
return;
|
||
}
|
||
var s = "";
|
||
for (j = 0; j < pr.length; j += 7) {
|
||
if (pr[j + 5]) {
|
||
s += "&" + pr[j + 1] + "=" + pr[j + 5];
|
||
}
|
||
|
||
}
|
||
if (!s) {
|
||
return
|
||
}
|
||
|
||
location = "?movestat=0.<?= PassGen::intCode() ?>&sd4=<?=$u->info['id']?>" + s;
|
||
}
|
||
|
||
let s = "<TABLE>";
|
||
for (let i = 0; i < pr.length; i += 7) {
|
||
if (pr[i + 2] != -1 && mylvl >= pr[i + 6]) {
|
||
s += "<TR><TD width=200 id=pr" + i + ">" + getprstr(i) + "</TD>";
|
||
s += '<TD><img src=<?= Config::img() ?>/i/minus.gif onclick="modpr(' + i + ',-1)" style="cursor: hand;"> '
|
||
s += '<img src=<?= Config::img() ?>/i/plus.gif onclick="modpr(' + i + ',1)" style="cursor: hand;"></TR>';
|
||
}
|
||
}
|
||
s += "</TABLE>";
|
||
s += "<small>(осталось: <span id='prfree'>0</span>, распределений: <span id='prmoves'>0</span>)<BR>";
|
||
document.write(s);
|
||
</SCRIPT>
|
||
<input type=button onClick="movedone();" id='movedonebutton' class="btn" value="Применить" disabled>
|
||
</TD>
|
||
<TD width=270 valign=top>
|
||
<?php
|
||
$sp = Db::getRows('select * from eff_users left join eff_main on eff_users.id_eff = eff_main.id2 where (id_eff between 301 and 304 or id_eff between 321 and 332) and `delete` = 0 and uid = ?', [$u->info['id']]);
|
||
foreach ($sp as $addiction): ?>
|
||
<img style="display: inline-block; vertical-align: bottom;" src="<?= Config::img() ?>/i/eff/<?= $addiction['img'] ?>" alt="<?= $addiction['name'] ?>">
|
||
<a style="font-size: small" href="/main.php?unprist=<?= $addiction['id'] ?>">вылечить</a><br>
|
||
<?php endforeach;
|
||
if (empty($sp)): ?>
|
||
<div style="font-size: small; text-align: center; margin-top: 50px;">У вас нет пристрастий</div>
|
||
<?php endif; ?>
|
||
</TD>
|
||
<TD valign=top><BR>
|
||
Навыки владения оружием и магией (<?= testSkills() ?>)<BR>
|
||
<form method=post>
|
||
<INPUT type=submit name='dropmastery' class="btn" value='Сбросить' onClick="return confirm('Вы действительно хотите сбросить умения?')">
|
||
<HR style="border:0;border-bottom:1px solid grey">
|
||
</form>
|
||
Особенности персонажа (<?= testSkills2() ?>)<BR>
|
||
<form method=post>
|
||
<INPUT type=submit name='dropperks' class="btn" value='Сбросить' onClick="return confirm('Вы действительно хотите сбросить особенности?')">
|
||
<HR style="border:0;border-bottom:1px solid grey">
|
||
</form>
|
||
Характеристики (<?= testAbilities() ?>/<?= (9 + testStat5() + testStat7()) ?>)<BR>
|
||
<form method=post>
|
||
<INPUT type=submit name='dropstats' class="btn" value='Сбросить' onClick="return confirm('Вы действительно хотите сбросить все характеристики до минимального уровня?')">
|
||
</form>
|
||
</TABLE>
|
||
<small>Прежде чем перераспределять свои параметры, Вам необходимо полностью их сбросить</small>
|
||
|