Скажем спасибо inf.php ради которого пришлось переделывать всё! #12
This commit is contained in:
parent
1655ea11fc
commit
19407c04fa
226
_incl_data/class/Achievements.php
Normal file
226
_incl_data/class/Achievements.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
use Insallah\Db;
|
||||
use Insallah\Math;
|
||||
use Insallah\Table;
|
||||
|
||||
class Achievements
|
||||
{
|
||||
private $user;
|
||||
private $info;
|
||||
private $data = [
|
||||
'zb' => [
|
||||
'questname' => 'Ежедн.Задания',
|
||||
'quest' => 'Выполнить задания бабки.',
|
||||
'check' => ['Заданий', 5, 25, 50, 100, 250],
|
||||
'prize' => ['Жетон <br>успеха <br>', 5, 20, 40, 60, 100],
|
||||
'startlink' => 11
|
||||
],
|
||||
'vx' => [
|
||||
'questname' => 'Хаотические бои',
|
||||
'quest' => 'Победить в хаотических боях.',
|
||||
'check' => ['Побед', 50, 300, 400, 500, 1000],
|
||||
'prize' => ['екр.', 25, 50, 75, 100, 200],
|
||||
'startlink' => 21
|
||||
],
|
||||
'snt' => [
|
||||
'questname' => 'Сундук трупожора',
|
||||
'quest' => 'Открыть сундук трупожора.',
|
||||
'check' => ['Открытий', 5, 25, 50, 100, 250],
|
||||
'prize' => ['екр.', 10, 25, 50, 75, 200],
|
||||
'startlink' => 31
|
||||
],
|
||||
'rp' => [
|
||||
'questname' => 'Руны 8 лвл.',
|
||||
'quest' => 'Получить руну при плавке плохих заготовок. [S]',
|
||||
'check' => ['Рун', 5, 10, 25, 50, 100],
|
||||
'prize' => ['Плохие <br> заготовки <br>', 5, 7, 10, 12, 15],
|
||||
'startlink' => 41
|
||||
],
|
||||
'rn' => [
|
||||
'questname' => 'Руны 9 лвл.',
|
||||
'quest' => 'Получить руну при плавке нормальных заготовок. [M]',
|
||||
'check' => ['Рун', 5, 10, 15, 25, 50],
|
||||
'prize' => ['Нормальные <br> заготовки <br>', 5, 7, 9, 12, 15],
|
||||
'startlink' => 51
|
||||
],
|
||||
'rb' => [
|
||||
'questname' => 'Руны 10 лвл.',
|
||||
'quest' => 'Получить руну при плавке идеальных заготовок. [L]',
|
||||
'check' => ['Рун', 2, 5, 8, 11, 15],
|
||||
'prize' => ['Идеальные <br> заготовки <br>', 2, 4, 6, 10, 15],
|
||||
'startlink' => 61
|
||||
],
|
||||
'pg' => [
|
||||
'questname' => 'Героич. Сражения',
|
||||
'quest' => 'Поучаствовать в героическом сражении.',
|
||||
'check' => ['Участий', 100, 200, 400, 600, 1000],
|
||||
'prize' => ['Жетон <br>успеха <br>', 10, 20, 40, 60, 80],
|
||||
'startlink' => 71
|
||||
],
|
||||
'bv' => [
|
||||
'questname' => 'Продажи Бабушке',
|
||||
'quest' => 'Продать бабушке найденные вещи в пещере.',
|
||||
'check' => ['Продаж', 5, 25, 50, 100, 250],
|
||||
'prize' => ['кр.', 500, 1000, 2000, 4000, 5000],
|
||||
'startlink' => 81
|
||||
],
|
||||
'kw' => [
|
||||
'questname' => 'Клан Поединки',
|
||||
'quest' => 'Победить в клановой войне.',
|
||||
'check' => ['Побед', 5, 10, 15, 20, 25],
|
||||
'prize' => ['Свиток <br> кланового<br> опыта ', 1, 2, 5, 10, 15],
|
||||
'startlink' => 91
|
||||
],
|
||||
'pa' => [ # not implemented!
|
||||
'questname' => 'Покровительство',
|
||||
'quest' => 'Получить покровительство Ангела.',
|
||||
'check' => ['Получено', 5, 25, 50, 100, 250],
|
||||
'prize' => null,
|
||||
'startlink' => null
|
||||
],
|
||||
'bs' => [
|
||||
'questname' => 'Башня смерти',
|
||||
'quest' => 'Победы в башне смерти.',
|
||||
'check' => ['Побед', 1, 5, 10, 50, 500],
|
||||
'prize' => ['екр.', 1, 5, 10, 50, 200],
|
||||
'startlink' => 101
|
||||
],
|
||||
'trn' => [ # not implemented!
|
||||
'questname' => null,
|
||||
'quest' => 'Победы в турнирах.',
|
||||
'check' => ['Побед', 25, 50, 100, 200, 500],
|
||||
'prize' => ['екр.', 25, 25, 25, 25, 50],
|
||||
'startlink' => 111
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(user $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->info = Db::getRow('select * from users_achiv where id = ?', [$user->info['id']]);
|
||||
}
|
||||
|
||||
private function prizeName($int, $string)
|
||||
{
|
||||
return in_array($string, ['екр.', 'кр.']) ? $int . ' ' . $string : $string . ' ' . $int;
|
||||
}
|
||||
|
||||
private function drawSunduk($nagr, $whatInside, $tier)
|
||||
{
|
||||
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 = '';
|
||||
$this->calculateCurrent(1);
|
||||
|
||||
foreach ($this->data as $key => $value) {
|
||||
//Бля, какую херню приходится городить!
|
||||
//Первое число = требование следующего тира минус требование текущего тира (надо набрать)
|
||||
//Второе число = количество достижений минус требование текущего тира (набрал)
|
||||
//Требования текущего тира отнимаются чтобы каждый тир начинал считать процент с 0.
|
||||
//Пизды дать тому, кто так уебански называет переменные, что нужно полдня въезжать что происходит.
|
||||
//И хер поменяешь - всё сломается. FFUUUUUUUUUUUUUU!!! Ins.
|
||||
$percentToSuccess = Math::get100Percentage(
|
||||
$value['check'][$this->info['klas' . $key] + 1] - $value['check'][$this->info['klas' . $key]],
|
||||
$this->info[$key] - $value['check'][$this->info['klas' . $key]]
|
||||
);
|
||||
//klas$name динамически рассчитыватся исходя из $name в базе
|
||||
$string .= '<h4>' . empty($value['questname']) ? $value['quest'] : $value['questname'] . '</h4>';
|
||||
$string .= '<strong>' . $value['quest'] . '</strong><br>';
|
||||
$string .= 'Текущий Ранг: <strong>' . $this->info['klas' . $key] . '</strong> ';
|
||||
$string .= 'Количество ' . mb_strtolower($value['check'][0]) . ': <strong>' . $this->info[$key] . ' =' . $percentToSuccess . '%</strong>';
|
||||
|
||||
$string .= Table::get([
|
||||
['Ранги', 1, 2, 3, 4, 5],
|
||||
$value['check'],
|
||||
[
|
||||
'Награда',
|
||||
$this->prizeName($value['prize'][1], $value['prize'][0]),
|
||||
$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])
|
||||
]
|
||||
], 'prizelist', true);
|
||||
# If has new tier, AND only first 5 tiers AND prize is set.
|
||||
if (
|
||||
$this->info['klas' . $key] > $this->info[$key . '_n'] &&
|
||||
in_array($this->info[$key . '_n'], [0, 1, 2, 3, 4]) &&
|
||||
!empty($value['prize']) &&
|
||||
!empty($value['startlink'])
|
||||
) {
|
||||
$string .= '<br>Награда:<br>';
|
||||
$string .= $this->drawSunduk(
|
||||
$this->info[$key . '_n'] + $value['startlink'],
|
||||
$this->prizeName($value['prize'][$this->info[$key . '_n'] + 1], $value['prize'][0]),
|
||||
$this->info[$key . '_n'] + 1
|
||||
);
|
||||
}
|
||||
$string .= '<hr>';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function calculateCurrent($check = null)
|
||||
{
|
||||
$this->info['bs'] = $this->user->info['win_bs'];
|
||||
foreach ($this->info as $k => $v) {
|
||||
if (empty($this->info[$k]) && is_null($check)) {
|
||||
continue;
|
||||
}
|
||||
$this->info["klas$k"] = 0;
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
if ($this->info[$k] >= $this->data[$k]['check'][$i]) {
|
||||
$this->info["klas$k"] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
$this->calculateCurrent();
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function getCheckedInfo()
|
||||
{
|
||||
$this->calculateCurrent(1);
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
public function updateTier($name)
|
||||
{
|
||||
Db::sql("update users_achiv set $name = $name + 1 where id = ?", [$this->user->info['id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function hasNoTier4Access($nagr)
|
||||
{
|
||||
return $this->user->info['level'] < 9 && in_array($nagr, [14, 15, 24, 25, 34, 35, 44, 45, 54, 55, 64, 65, 74, 75, 84, 85, 94, 95, 104, 105]);
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
}
|
17
_incl_data/class/Insallah/Core/Math.php
Normal file
17
_incl_data/class/Insallah/Core/Math.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Insallah;
|
||||
|
||||
/** All raw mathematics in one place. */
|
||||
class Math
|
||||
{
|
||||
public static function getPercentage($total, $number)
|
||||
{
|
||||
return $total > 0 ? round(($number * 100) / $total, 2) : 0;
|
||||
}
|
||||
|
||||
public static function get100Percentage($total, $number)
|
||||
{
|
||||
return min(self::getPercentage($total, $number), 100);
|
||||
}
|
||||
}
|
22
_incl_data/class/Insallah/Core/Table.php
Normal file
22
_incl_data/class/Insallah/Core/Table.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
12567
modules_data/__user.php
12567
modules_data/__user.php
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,3 @@
|
||||
<script>
|
||||
let elem = document.getElementById('se-pre-con');
|
||||
elem.parentNode.removeChild(elem);
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
use Insallah\Db;
|
||||
@ -11,107 +6,17 @@ if (!defined('GAME')) {
|
||||
die();
|
||||
}
|
||||
|
||||
const TIERS = 'Ранги';
|
||||
const PRIZE = 'Награда';
|
||||
|
||||
$achievement_data = [
|
||||
'zb' => [
|
||||
'quest' => 'Выполнить задания бабки.',
|
||||
'check' => ['Заданий', 5, 25, 50, 100, 250],
|
||||
'prize' => ['Жетон <br>успеха <br>', 5, 20, 40, 60, 100],
|
||||
'startlink' => 11
|
||||
],
|
||||
'vx' => [
|
||||
'quest' => 'Победить в хаотических боях.',
|
||||
'check' => ['Побед', 50, 300, 400, 500, 1000],
|
||||
'prize' => ['екр.', 25, 50, 75, 100, 200],
|
||||
'startlink' => 21
|
||||
],
|
||||
'snt' => [
|
||||
'quest' => 'Открыть сундук трупожора.',
|
||||
'check' => ['Открытий', 5, 25, 50, 100, 250],
|
||||
'prize' => ['екр.', 10, 25, 50, 75, 200],
|
||||
'startlink' => 31
|
||||
],
|
||||
'rp' => [
|
||||
'quest' => 'Получить руну при плавке плохих заготовок. [S]',
|
||||
'check' => ['Рун', 5, 10, 25, 50, 100],
|
||||
'prize' => ['Плохие <br> заготовки <br>', 5, 7, 10, 12, 15],
|
||||
'startlink' => 41
|
||||
],
|
||||
'rn' => [
|
||||
'quest' => 'Получить руну при плавке нормальных заготовок. [M]',
|
||||
'check' => ['Рун', 5, 10, 15, 25, 50],
|
||||
'prize' => ['Нормальные <br> заготовки <br>', 5, 7, 9, 12, 15],
|
||||
'startlink' => 51
|
||||
],
|
||||
'rb' => [
|
||||
'quest' => 'Получить руну при плавке идеальных заготовок. [L]',
|
||||
'check' => ['Рун', 2, 5, 8, 11, 15],
|
||||
'prize' => ['Идеальные <br> заготовки <br>', 2, 4, 6, 10, 15],
|
||||
'startlink' => 61
|
||||
],
|
||||
'pg' => [
|
||||
'quest' => 'Поучаствовать в героическом сражении.',
|
||||
'check' => ['Участий', 100, 200, 400, 600, 1000],
|
||||
'prize' => ['Жетон <br>успеха <br>', 10, 20, 40, 60, 80],
|
||||
'startlink' => 71
|
||||
],
|
||||
'bv' => [
|
||||
'quest' => 'Продать бабушке найденные вещи в пещере.',
|
||||
'check' => ['Продаж', 5, 25, 50, 100, 250],
|
||||
'prize' => ['кр.', 500, 1000, 2000, 4000, 5000],
|
||||
'startlink' => 81
|
||||
],
|
||||
'kw' => [
|
||||
'quest' => 'Победить в клановой войне.',
|
||||
'check' => ['Побед', 5, 10, 15, 20, 25],
|
||||
'prize' => ['Свиток <br> кланового<br> опыта ', 1, 2, 5, 10, 15],
|
||||
'startlink' => 91
|
||||
],
|
||||
'pa' => [ # not implemented!
|
||||
'quest' => 'Получить покровительство Ангела.',
|
||||
'check' => ['Получено', 5, 25, 50, 100, 250],
|
||||
'prize' => null,
|
||||
'startlink' => null
|
||||
],
|
||||
'bs' => [
|
||||
'quest' => 'Победы в башне смерти.',
|
||||
'check' => ['Побед', 1, 5, 10, 50, 500],
|
||||
'prize' => ['екр.', 1, 5, 10, 50, 200],
|
||||
'startlink' => 101
|
||||
],
|
||||
'trn' => [ # not implemented!
|
||||
'quest' => 'Победы в турнирах.',
|
||||
'check' => ['Побед', 25, 50, 100, 200, 500],
|
||||
'prize' => ['екр.', 25, 25, 25, 25, 50],
|
||||
'startlink' => 111
|
||||
],
|
||||
];
|
||||
|
||||
function table($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;
|
||||
if (empty($u)) {
|
||||
$u = user::start();
|
||||
}
|
||||
|
||||
$ai = $u->achivInf($u->info['id'], 1);
|
||||
$a = new Achievements($u);
|
||||
$ai = $a->getCheckedInfo();
|
||||
|
||||
if (isset($_GET['nagr'])) {
|
||||
$nagrtxt = 'За выполненное достижение Вы получили ';
|
||||
if (
|
||||
in_array($_GET['nagr'], [14, 15, 24, 25, 34, 35, 44, 45, 54, 55, 64, 65, 74, 75, 84, 85, 94, 95, 104, 105]) &&
|
||||
$u->info['level'] < 9
|
||||
) {
|
||||
|
||||
if ($a->hasNoTier4Access($_GET['nagr'])) {
|
||||
$nagrtxt = 'Вы не можете получить эту награду на этом уровне!';
|
||||
} elseif ( //бабка задание zb
|
||||
in_array($_GET['nagr'], [11, 12, 13, 14, 15]) &&
|
||||
@ -119,179 +24,106 @@ if (isset($_GET['nagr'])) {
|
||||
$ai['klaszb'] > $ai['zb_n']
|
||||
) {
|
||||
$ai['zb_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['zb_n'], 'zb');
|
||||
$i = 0;
|
||||
while ($i < $achievement_data['zb']['prize'][$ai['zb_n']]) {
|
||||
$u->addItem(10020, $u->info['id'], '');
|
||||
$i++;
|
||||
}
|
||||
$nagrtxt .= 'Жетон успеха X' . $achievement_data['zb']['prize'][$ai['zb_n']];
|
||||
$a->updateTier('zb_n');
|
||||
$a->givePrizeItems(10020, 'zb');
|
||||
$nagrtxt .= 'Жетон успеха X' . $a->getData()['zb']['prize'][$ai['zb_n']];
|
||||
} elseif ( //Хаот задание vx
|
||||
in_array($_GET['nagr'], [21, 22, 23, 24, 25]) &&
|
||||
in_array($ai['vx_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klasvx'] > $ai['vx_n']
|
||||
) {
|
||||
$ai['vx_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['vx_n'], 'vx');
|
||||
Db::sql('update users set money2 = money2 + ? where id = ?',
|
||||
[$achievement_data['vx']['prize'][$ai['vx_n']], $u->info['id']]);
|
||||
$nagrtxt .= $achievement_data['vx']['prize'][$ai['vx_n']] . $achievement_data['vx']['prize'][0];
|
||||
$a->updateTier('vx_n');
|
||||
$u->addEkr($a->getData()['vx']['prize'][$ai['vx_n']]);
|
||||
$nagrtxt .= $a->getData()['vx']['prize'][$ai['vx_n']] . $a->getData()['vx']['prize'][0];
|
||||
} elseif ( //Сундуки трупожора snt
|
||||
in_array($_GET['nagr'], [31, 32, 33, 34, 35]) &&
|
||||
in_array($ai['snt_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klassnt'] > $ai['snt_n']
|
||||
) {
|
||||
$ai['snt_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['snt_n'], 'snt');
|
||||
Db::sql('update users set money2 = money2 + ? where id = ?',
|
||||
[$achievement_data['snt']['prize'][$ai['snt_n']], $u->info['id']]);
|
||||
$nagrtxt .= $achievement_data['snt']['prize'][$ai['snt_n']] . $achievement_data['snt']['prize'][0];
|
||||
$a->updateTier('snt_n');
|
||||
$u->addEkr($a->getData()['snt']['prize'][$ai['snt_n']]);
|
||||
$nagrtxt .= $a->getData()['snt']['prize'][$ai['snt_n']] . $a->getData()['snt']['prize'][0];
|
||||
} elseif ( //Руны 8 лвл. rp
|
||||
in_array($_GET['nagr'], [41, 42, 43, 44, 45]) &&
|
||||
in_array($ai['rp_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klasrp'] > $ai['rp_n']
|
||||
) {
|
||||
$ai['rp_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['rp_n'], 'rp');
|
||||
$i = 0;
|
||||
while ($i < $achievement_data['rp']['prize'][$ai['rp_n']]) {
|
||||
$u->addItem(10038, $u->info['id'], '');
|
||||
$i++;
|
||||
}
|
||||
$nagrtxt .= 'Плохие Заготовки X' . $achievement_data['rp']['prize'][$ai['rp_n']];
|
||||
$a->updateTier('rp_n');
|
||||
$a->givePrizeItems(10038, 'rp');
|
||||
$nagrtxt .= 'Плохие Заготовки X' . $a->getData()['rp']['prize'][$ai['rp_n']];
|
||||
} elseif ( //Руны 9 лвл. rn
|
||||
in_array($_GET['nagr'], [51, 52, 53, 54, 55]) &&
|
||||
in_array($ai['rn_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klasrn'] > $ai['rn_n']
|
||||
) {
|
||||
$ai['rn_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['rn_n'], 'rn');
|
||||
$i = 0;
|
||||
while ($i < $achievement_data['rn']['prize'][$ai['rn_n']]) {
|
||||
$u->addItem(10039, $u->info['id'], '');
|
||||
$i++;
|
||||
}
|
||||
$nagrtxt .= 'Нормальные Заготовки X' . $achievement_data['rn']['prize'][$ai['rn_n']];
|
||||
$a->updateTier('rn_n');
|
||||
$a->givePrizeItems(10039, 'rn');
|
||||
$nagrtxt .= 'Нормальные Заготовки X' . $a->getData()['rn']['prize'][$ai['rn_n']];
|
||||
} elseif ( //Руны 10 лвл. rb
|
||||
in_array($_GET['nagr'], [61, 62, 63, 64, 65]) &&
|
||||
in_array($ai['rb_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klasrb'] > $ai['rb_n']
|
||||
) {
|
||||
$ai['rb_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['rb_n'], 'rb');
|
||||
$i = 0;
|
||||
while ($i < $achievement_data['rb']['prize'][$ai['rb_n']]) {
|
||||
$u->addItem(10040, $u->info['id'], '');
|
||||
$i++;
|
||||
}
|
||||
$nagrtxt .= 'Идеальные Заготовки X' . $achievement_data['rb']['prize'][$ai['rb_n']];
|
||||
$a->updateTier('rb_n');
|
||||
$a->givePrizeItems(10040, 'rb');
|
||||
$nagrtxt .= 'Идеальные Заготовки X' . $a->getData()['rb']['prize'][$ai['rb_n']];
|
||||
} elseif ( //Героик pg
|
||||
in_array($_GET['nagr'], [71, 72, 73, 74, 75]) &&
|
||||
in_array($ai['pg_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klaspg'] > $ai['pg_n']
|
||||
) {
|
||||
$ai['pg_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['pg_n'], 'pg');
|
||||
$i = 0;
|
||||
while ($i < $achievement_data['pg']['prize'][$ai['pg_n']]) {
|
||||
$u->addItem(10020, $u->info['id'], '');
|
||||
$i++;
|
||||
}
|
||||
$nagrtxt .= 'Жетон Успеха X' . $achievement_data['pg']['prize'][$ai['pg_n']];
|
||||
$a->updateTier('pg_n');
|
||||
$a->givePrizeItems(10020, 'pg');
|
||||
$nagrtxt .= 'Жетон Успеха X' . $a->getData()['pg']['prize'][$ai['pg_n']];
|
||||
} elseif ( //Продать бабушке найденные вещи в пещере bv
|
||||
in_array($_GET['nagr'], [81, 82, 83, 84, 85]) &&
|
||||
in_array($ai['bv_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klasbv'] > $ai['bv_n']
|
||||
) {
|
||||
$ai['bv_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['bv_n'], 'bv');
|
||||
Db::sql('update users set money = money + ? where id = ?',
|
||||
[$achievement_data['bv']['prize'][$ai['bv_n']], $u->info['id']]);
|
||||
$nagrtxt .= $achievement_data['bv']['prize'][$ai['bv_n']] . $achievement_data['bv']['prize'][0];
|
||||
$a->updateTier('bv_n');
|
||||
$u->addKr($a->getData()['bv']['prize'][$ai['bv_n']]);
|
||||
$nagrtxt .= $a->getData()['bv']['prize'][$ai['bv_n']] . $a->getData()['bv']['prize'][0];
|
||||
} elseif ( //Клан вар kw
|
||||
in_array($_GET['nagr'], [91, 92, 93, 94, 95]) &&
|
||||
in_array($ai['kw_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klaskw'] > $ai['kw_n']
|
||||
) {
|
||||
$ai['kw_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['kw_n'], 'kw');
|
||||
$i = 0;
|
||||
while ($i < $achievement_data['kw']['prize'][$ai['kw_n']]) {
|
||||
$u->addItem(4917, $u->info['id'], '');
|
||||
$i++;
|
||||
}
|
||||
$nagrtxt .= 'Клановый опыт +50000 X' . $achievement_data['kw']['prize'][$ai['kw_n']];
|
||||
$a->updateTier('kw_n');
|
||||
$a->givePrizeItems(4917, 'kw');
|
||||
$nagrtxt .= 'Клановый опыт +50000 X' . $a->getData()['kw']['prize'][$ai['kw_n']];
|
||||
} elseif ( //Башня смерти задание bs
|
||||
in_array($_GET['nagr'], [101, 102, 103, 104, 105]) &&
|
||||
in_array($ai['bs_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klasbs'] > $ai['bs_n']
|
||||
) {
|
||||
$ai['bs_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['bs_n'], 'bs');
|
||||
Db::sql('update users set money2 = money2 + ? where id = ?',
|
||||
[$achievement_data['bs']['prize'][$ai['bs_n']], $u->info['id']]);
|
||||
$nagrtxt .= $achievement_data['bs']['prize'][$ai['bs_n']] . $achievement_data['bs']['prize'][0];
|
||||
$a->updateTier('bs_n');
|
||||
$u->addEkr($a->getData()['bs']['prize'][$ai['bs_n']]);
|
||||
$nagrtxt .= $a->getData()['bs']['prize'][$ai['bs_n']] . $a->getData()['bs']['prize'][0];
|
||||
} elseif ( //Турниры победы trn
|
||||
in_array($_GET['nagr'], [111, 112, 113, 114, 115]) &&
|
||||
in_array($ai['trn_n'], [0, 1, 2, 3, 4]) &&
|
||||
$ai['klastrn'] > $ai['trn_n']
|
||||
) {
|
||||
$ai['trn_n'] += 1;
|
||||
$u->rangup($u->info['id'], $ai['trn_n'], 'trn');
|
||||
Db::sql('update users set money2 = money2 + ? where id = ?',
|
||||
[$achievement_data['trn']['prize'][$ai['trn_n']], $u->info['id']]);
|
||||
$nagrtxt .= $achievement_data['trn']['prize'][$ai['trn_n']] . $achievement_data['trn']['prize'][0];
|
||||
$a->updateTier('trn_n');
|
||||
$u->addEkr($a->getData()['trn']['prize'][$ai['trn_n']]);
|
||||
$nagrtxt .= $a->getData()['trn']['prize'][$ai['trn_n']] . $a->getData()['trn']['prize'][0];
|
||||
}
|
||||
//Тоже бы вынести в класс чата.
|
||||
Db::sql('insert into chat (new, city, room, `to`, `text`, `time`, type) values (?,?,?,?,?,?,?)',
|
||||
[1, $u->info['city'], $u->info['room'], $u->info['login'], $nagrtxt, -1, 6]);
|
||||
|
||||
Db::sql('insert into chat (new, city, room, login, `to`, `text`, `time`, type, toChat) values (?,?,?,?,?,?,?,?,?)',
|
||||
[1, $u->info['city'], $u->info['room'], $u->info['login'], $nagrtxt, -1, 6, 0]);
|
||||
//-------------
|
||||
}
|
||||
function drawSunduk($nagr, $whatInside, $tier)
|
||||
{
|
||||
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"
|
||||
]);
|
||||
}
|
||||
|
||||
$data = null;
|
||||
foreach ($achievement_data as $key => $value) {
|
||||
$data .= '<h4>' . $ai['name' . $key] . '</h4>';
|
||||
$data .= '<strong>' . $value[$key]['quest'] . '</strong>';
|
||||
$data .= 'Сейчас у Вас Ранг: <strong>' . $ai['klas' . $key] . '</strong>';
|
||||
$data .= 'Количество выполнений: <strong>' . $ai[$key] . ' =' . $ai['klasP' . $key] . '%</strong>';
|
||||
$data .= table([
|
||||
[TIERS, 1, 2, 3, 4, 5],
|
||||
$value[$key]['check'],
|
||||
array_merge([PRIZE], $value[$key]['prize'])
|
||||
], 'prizelist', true);
|
||||
# If has new tier, AND only first 5 tiers AND prize is set.
|
||||
if (
|
||||
$ai['klas' . $key] > $ai[$key . '_n'] &&
|
||||
in_array($ai[$key . '_n'], [0, 1, 2, 3, 4]) &&
|
||||
!empty($value[$key]['prize']) &&
|
||||
!empty($value[$key]['startlink'])
|
||||
) {
|
||||
$data .= '<br>' . PRIZE . ':<br>';
|
||||
if (in_array($value[$key]['prize'][0], ['екр.', 'кр.'])) {
|
||||
$sundukName = $value[$key]['prize'][$ai[$key . '_n'] + 1] . $value[$key]['prize'][0];
|
||||
} else {
|
||||
$sundukName = $value[$key]['prize'][0] . $value[$key]['prize'][$ai[$key . '_n'] + 1];
|
||||
}
|
||||
|
||||
$data .= drawSunduk(
|
||||
$ai[$key . '_n'] + $value[$key]['startlink'],
|
||||
$sundukName,
|
||||
$ai[$key . '_n'] + $value[$key]['startlink']
|
||||
);
|
||||
}
|
||||
$data .= '<hr>';
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
@ -299,7 +131,7 @@ foreach ($achievement_data as $key => $value) {
|
||||
table.prizelist {
|
||||
border-spacing: 1px;
|
||||
border-collapse: separate;
|
||||
min-width: 500px;
|
||||
min-width: 600px;
|
||||
}
|
||||
|
||||
table.prizelist tr {
|
||||
@ -329,5 +161,9 @@ foreach ($achievement_data as $key => $value) {
|
||||
|
||||
<H3>Достижения</H3>
|
||||
|
||||
<?= $data;
|
||||
unset($data);
|
||||
<?= $a->getList(); ?>
|
||||
|
||||
<script>
|
||||
let elem = document.getElementById('se-pre-con');
|
||||
elem.parentNode.removeChild(elem);
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user