2022-06-11 11:32:31 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Insallah;
|
|
|
|
|
|
|
|
|
|
class Runes
|
|
|
|
|
{
|
2023-01-10 16:29:32 +00:00
|
|
|
|
/** Создаём руну в зависимости от уровня.
|
2022-06-11 11:32:31 +00:00
|
|
|
|
* @param $level
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function get($level)
|
|
|
|
|
{
|
|
|
|
|
if (!in_array($level, [8, 9, 10])) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
2022-12-19 18:26:14 +00:00
|
|
|
|
$power = [8 => 3, 9 => 3, 10 => 5];
|
2022-06-11 11:32:31 +00:00
|
|
|
|
$stats = [8 => 1, 9 => 3, 10 => 3];
|
|
|
|
|
$rand9 = array_rand(array_flip(['hpAll', 'm2', 'm5']));
|
|
|
|
|
$runes = [
|
|
|
|
|
['s1', 'pa2', $rand9, 'antm3'],
|
|
|
|
|
['s1', 'pa3', $rand9, 'za'],
|
|
|
|
|
['s2', 'pa1', $rand9, 'antm3'],
|
|
|
|
|
['s2', 'pa1', $rand9, 'm3'],
|
|
|
|
|
['s3', 'pa4', $rand9, 'm3'],
|
|
|
|
|
['s5', 'm11', 'mpAll', 'pzm']
|
|
|
|
|
];
|
|
|
|
|
$vars = [
|
2023-01-10 16:29:32 +00:00
|
|
|
|
's1' => ['Сила', mt_rand(1, $stats[$level])],
|
|
|
|
|
's2' => ['Ловкость', mt_rand(1, $stats[$level])],
|
|
|
|
|
's3' => ['Интуиция', mt_rand(1, $stats[$level])],
|
|
|
|
|
's5' => ['Интеллект', mt_rand(1, $stats[$level])],
|
|
|
|
|
'pa1' => ['Мощности Колющего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'pa2' => ['Мощности Рубящего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'pa3' => ['Мощности Дробящего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'pa4' => ['Мощности Режущего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'm2' => ['мф. Против Критического Удара', mt_rand(5, 15)],
|
|
|
|
|
'm3' => ['МК', mt_rand(1, 3)],
|
|
|
|
|
'antm3' => ['ПМК', mt_rand(1, 3)],
|
|
|
|
|
'm5' => ['мф. Против Увертывания', mt_rand(5, 10)],
|
|
|
|
|
'm11' => ['Мощности Магии стихии', mt_rand(1, $power[$level])],
|
2022-06-11 11:32:31 +00:00
|
|
|
|
'hpAll' => ['HP', mt_rand(5, 15)],
|
|
|
|
|
'mpAll' => ['MP', mt_rand(10, 20)],
|
2023-01-10 16:29:32 +00:00
|
|
|
|
'pzm' => ['Подавление защиты от магии', 1],
|
|
|
|
|
'za' => ['Защита от Урона', mt_rand(5, 10)],
|
|
|
|
|
'zma' => ['Защита от Магии', mt_rand(5, 10)]
|
2022-06-11 11:32:31 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$rune = $runes[array_rand($runes)]; // arr (s, pa\m, rand9\mpAll, other)
|
|
|
|
|
$runeTxt = [$vars[$rune[0]][0], $vars[$rune[1]][0], $vars[$rune[2]][0], $vars[$rune[3]][0]];
|
|
|
|
|
$runeVals = [$vars[$rune[0]][1], $vars[$rune[1]][1], $vars[$rune[2]][1], $vars[$rune[3]][1]];
|
|
|
|
|
$resultRune = array_combine($rune, $runeVals);
|
|
|
|
|
$resultText = array_combine($runeTxt, $runeVals);
|
2023-01-10 16:29:32 +00:00
|
|
|
|
if ($level < 10) { // Отрезаем параметр 4.
|
2022-06-11 11:32:31 +00:00
|
|
|
|
array_pop($resultRune);
|
|
|
|
|
array_pop($resultText);
|
|
|
|
|
}
|
2023-01-10 16:29:32 +00:00
|
|
|
|
if ($level < 9) { // Отрезаем параметр 3.
|
2022-06-11 11:32:31 +00:00
|
|
|
|
array_pop($resultRune);
|
|
|
|
|
array_pop($resultText);
|
|
|
|
|
}
|
2023-01-10 16:29:32 +00:00
|
|
|
|
//Строчка data в базу
|
2022-06-11 11:32:31 +00:00
|
|
|
|
$returnData = '|' . http_build_query($resultRune, '', '|');
|
|
|
|
|
$returnData = str_replace('|', '|add_', $returnData);
|
2023-01-10 16:29:32 +00:00
|
|
|
|
//Строчка человекопонятных параметров в статус.
|
2022-12-19 18:26:14 +00:00
|
|
|
|
$returnText = urldecode(http_build_query($resultText, '', ', '));
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$returnText = 'Характеристики Руны: ' . str_replace('=', ': +', $returnText) . '.';
|
2022-06-11 11:32:31 +00:00
|
|
|
|
return [$returnData, $returnText];
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
/** Выкусывает руну из предмета.
|
2022-06-11 11:32:31 +00:00
|
|
|
|
*
|
|
|
|
|
* @param array $itemDataArray
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* data предмета
|
2022-06-11 11:32:31 +00:00
|
|
|
|
*
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* @return array массив, item - предмет, rune - руна из предмета, rune_id - id руны.
|
|
|
|
|
* Оба в подготовленном строчном формате для data
|
2022-06-11 11:32:31 +00:00
|
|
|
|
*/
|
|
|
|
|
public static function removeRuneData($itemDataArray)
|
|
|
|
|
{
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# Ищем есть ли в предмете руна определённого типа.
|
2022-06-11 11:32:31 +00:00
|
|
|
|
$runeid = array_search('rune_id', array_flip($itemDataArray));
|
|
|
|
|
if (!in_array($runeid, [6001, 6002, 6003])) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
$bonusArgs = 0;
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# В зависимости от типа руны считаем количество элементов-бонусов.
|
2022-06-11 11:32:31 +00:00
|
|
|
|
if ($runeid === 6001) {
|
|
|
|
|
$bonusArgs = 2;
|
|
|
|
|
}
|
|
|
|
|
if ($runeid === 6002) {
|
|
|
|
|
$bonusArgs = 3;
|
|
|
|
|
}
|
|
|
|
|
if ($runeid === 6003) {
|
|
|
|
|
$bonusArgs = 4;
|
|
|
|
|
}
|
|
|
|
|
$args = 0; //basic rune values - rune, id, name, lvl
|
|
|
|
|
$rune = [];
|
|
|
|
|
$item = [];
|
|
|
|
|
foreach ($itemDataArray as $key => $value) {
|
|
|
|
|
if ($key == 'rune') {
|
|
|
|
|
$args = 4 + $bonusArgs;
|
|
|
|
|
}
|
|
|
|
|
if ($args > 0) {
|
|
|
|
|
$rune[$key] = $value;
|
|
|
|
|
$args--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$item[$key] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($rune['rune'], $rune['rune_id'], $rune['rune_name'], $rune['rune_lvl']);
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'item' => urldecode('|' . http_build_query($item, '', '|')),
|
|
|
|
|
'rune' => urldecode('|' . http_build_query($rune, '', '|')),
|
|
|
|
|
'rune_id' => (int)$runeid
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkParts($part1, $part2, $part3, $reputation)
|
|
|
|
|
{
|
|
|
|
|
$level8 = [10038, 6001];
|
|
|
|
|
$level9 = [10039, 6002];
|
|
|
|
|
$level10 = [10040, 6003];
|
|
|
|
|
if (
|
|
|
|
|
in_array($part1, $level8) &&
|
|
|
|
|
in_array($part2, $level8) &&
|
|
|
|
|
in_array($part3, $level8) &&
|
|
|
|
|
$reputation >= 100
|
|
|
|
|
) {
|
|
|
|
|
$itm = 6001;
|
|
|
|
|
$runelevel = 8;
|
|
|
|
|
$query = 'update users_achiv set rp = rp + 1 where id = %d';
|
|
|
|
|
} elseif (
|
|
|
|
|
in_array($part1, $level9) &&
|
|
|
|
|
in_array($part2, $level9) &&
|
|
|
|
|
in_array($part3, $level9) &&
|
|
|
|
|
$reputation >= 1000
|
|
|
|
|
) {
|
|
|
|
|
$itm = 6002;
|
|
|
|
|
$runelevel = 9;
|
|
|
|
|
$query = 'update users_achiv set rn = rn + 1 where id = %d';
|
|
|
|
|
} elseif (
|
|
|
|
|
in_array($part1, $level10) &&
|
|
|
|
|
in_array($part2, $level10) &&
|
|
|
|
|
in_array($part3, $level10) &&
|
|
|
|
|
$reputation >= 1000
|
|
|
|
|
) {
|
|
|
|
|
$itm = 6003;
|
|
|
|
|
$runelevel = 10;
|
|
|
|
|
$query = 'update users_achiv set rb = rb + 1 where id = %d';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return empty($itm) || empty($runelevel) || empty($query) ? [] : [
|
|
|
|
|
'rune_id' => $itm,
|
|
|
|
|
'rune_level' => $runelevel,
|
|
|
|
|
'query' => $query
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|