2022-06-07 14:18:03 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Insallah;
|
|
|
|
|
|
|
|
|
|
class Runes
|
|
|
|
|
{
|
2022-06-07 20:47:50 +00:00
|
|
|
|
/** Создаём руну в зависимости от уровня.
|
|
|
|
|
* @param $level
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2022-06-07 14:18:03 +00:00
|
|
|
|
public static function get($level)
|
|
|
|
|
{
|
|
|
|
|
if (!in_array($level, [8, 9, 10])) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
$power = [8 => 3, 9 => 5, 10 => 7];
|
|
|
|
|
$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 = [
|
2022-06-07 20:47:50 +00:00
|
|
|
|
's1' => ['Сила', mt_rand(1, 3)],
|
|
|
|
|
's2' => ['Ловкость', mt_rand(1, 3)],
|
|
|
|
|
's3' => ['Интуиция', mt_rand(1, 3)],
|
|
|
|
|
's5' => ['Интеллект', mt_rand(1, 3)],
|
|
|
|
|
'pa1' => ['Мощности Колющего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'pa2' => ['Мощности Рубящего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'pa3' => ['Мощности Дробящего урона', mt_rand(1, $power[$level])],
|
|
|
|
|
'pa4' => ['Мощности Режущего урона', mt_rand(1, $power[$level])],
|
2022-06-07 14:18:03 +00:00
|
|
|
|
'm2' => ['???', mt_rand(5, 15)],
|
2022-06-07 20:47:50 +00:00
|
|
|
|
'm3' => ['МК', mt_rand(1, 3)],
|
|
|
|
|
'antm3' => ['ПМК', mt_rand(1, 3)],
|
2022-06-07 14:18:03 +00:00
|
|
|
|
'm5' => ['???', mt_rand(5, 10)],
|
2022-06-07 20:47:50 +00:00
|
|
|
|
'm11' => ['Мощности Магии стихии', mt_rand(1, $power[$level])],
|
2022-06-07 14:18:03 +00:00
|
|
|
|
'hpAll' => ['HP', mt_rand(5, 15)],
|
|
|
|
|
'mpAll' => ['MP', mt_rand(10, 20)],
|
2022-06-07 20:47:50 +00:00
|
|
|
|
'pzm' => ['Подавление защиты от магии', 1]
|
2022-06-07 14:18:03 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$rune = $runes[array_rand($runes)]; // arr (s, pa\m, rand9\mpAll, other)
|
2022-06-08 23:45:53 +00:00
|
|
|
|
$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]];
|
2022-06-07 14:18:03 +00:00
|
|
|
|
$resultRune = array_combine($rune, $runeVals);
|
2022-06-08 23:45:53 +00:00
|
|
|
|
$resultText = array_combine($runeTxt, $runeVals);
|
2022-06-07 20:47:50 +00:00
|
|
|
|
if ($level < 10) { // Отрезаем параметр 4.
|
2022-06-07 14:18:03 +00:00
|
|
|
|
array_pop($resultRune);
|
|
|
|
|
array_pop($resultText);
|
|
|
|
|
}
|
2022-06-07 20:47:50 +00:00
|
|
|
|
if ($level < 9) { // Отрезаем параметр 3.
|
2022-06-07 14:18:03 +00:00
|
|
|
|
array_pop($resultRune);
|
|
|
|
|
array_pop($resultText);
|
|
|
|
|
}
|
2022-06-07 20:47:50 +00:00
|
|
|
|
//Строчка data в базу
|
2022-06-08 23:45:53 +00:00
|
|
|
|
$returnData = '|' . http_build_query($resultRune, '', '|');
|
|
|
|
|
$returnData = str_replace('|', '|add_', $returnData);
|
2022-06-07 20:47:50 +00:00
|
|
|
|
//Строчка человекопонятных параметров в статус.
|
2022-06-08 23:45:53 +00:00
|
|
|
|
$returnText = urldecode(http_build_query($resultText, '', ', '));
|
|
|
|
|
$returnText = 'Характеристики Руны: ' . str_replace('=', ': +', $returnText) . '.';
|
2022-06-07 14:18:03 +00:00
|
|
|
|
return [$returnData, $returnText];
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-07 20:47:50 +00:00
|
|
|
|
/** Выкусывает руну из предмета.
|
|
|
|
|
*
|
2022-06-08 22:35:08 +00:00
|
|
|
|
* @param array $itemDataArray
|
2022-06-07 20:47:50 +00:00
|
|
|
|
* data предмета
|
|
|
|
|
*
|
|
|
|
|
* @return array массив, item - предмет, rune - руна из предмета, rune_id - id руны.
|
|
|
|
|
* Оба в подготовленном строчном формате для data
|
|
|
|
|
*/
|
2022-06-08 22:35:08 +00:00
|
|
|
|
public static function removeRuneData($itemDataArray)
|
2022-06-07 20:47:50 +00:00
|
|
|
|
{
|
|
|
|
|
# Ищем есть ли в предмете руна определённого типа.
|
2022-06-08 22:35:08 +00:00
|
|
|
|
$runeid = array_search('rune_id', array_flip($itemDataArray));
|
2022-06-07 20:47:50 +00:00
|
|
|
|
if (!in_array($runeid, [6001, 6002, 6003])) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
$bonusArgs = 0;
|
|
|
|
|
# В зависимости от типа руны считаем количество элементов-бонусов.
|
|
|
|
|
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 = [];
|
2022-06-08 22:35:08 +00:00
|
|
|
|
$item = [];
|
|
|
|
|
foreach ($itemDataArray as $key => $value) {
|
2022-06-07 20:47:50 +00:00
|
|
|
|
if ($key == 'rune') {
|
|
|
|
|
$args = 4 + $bonusArgs;
|
|
|
|
|
}
|
|
|
|
|
if ($args > 0) {
|
|
|
|
|
$rune[$key] = $value;
|
|
|
|
|
$args--;
|
2022-06-08 22:35:08 +00:00
|
|
|
|
continue;
|
2022-06-07 20:47:50 +00:00
|
|
|
|
}
|
2022-06-08 22:35:08 +00:00
|
|
|
|
$item[$key] = $value;
|
2022-06-07 20:47:50 +00:00
|
|
|
|
}
|
2022-06-08 22:35:08 +00:00
|
|
|
|
|
|
|
|
|
unset($rune['rune'], $rune['rune_id'], $rune['rune_name'], $rune['rune_lvl']);
|
|
|
|
|
|
2022-06-07 20:47:50 +00:00
|
|
|
|
return [
|
2022-06-08 22:35:08 +00:00
|
|
|
|
'item' => urldecode('|' . http_build_query($item, '', '|')),
|
|
|
|
|
'rune' => urldecode('|' . http_build_query($rune, '', '|')),
|
2022-06-07 20:47:50 +00:00
|
|
|
|
'rune_id' => (int)$runeid
|
|
|
|
|
];
|
2022-06-07 14:18:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|