' . str_replace(' ', ' ', $allprice[3]) . ''; } else { $allprice = str_replace(' ', ' ', $allprice[2]); } } function replaceLogText(array $d, string $text): string { $d = [ 'login1' => $d['login1'] ?? '', 'login2' => $d['login2'] ?? '', 'prm' => $d['prm'] ?? '', 'time1' => $d['time1'] ?? 0, 'time2' => $d['time2'] ?? 0, 't1' => $d['t1'] ?? 0, 't2' => $d['t2'] ?? 0, ]; $rep1 = <<{$d['login1']} HTML; $rep2 = <<{$d['login2']} HTML; $search = [ '{u1}', '{u2}', '{pr}', '^^^^', '{tm1}', '{tm2}', '{tm3}', '{tm4}', ]; $replace = [ $rep1, $rep2, "{$d['prm']}", '=', '' . date('H:i', (int)$d['time1']) . '', '' . date('H:i', (int)$d['time2']) . '', '' . date('d.m.y H:i', (int)$d['time1']) . '', '' . date('d.m.y H:i', (int)$d['time2']) . '', ]; return str_replace($search, $replace, $text); } function testlog($pl) { global $log_text; if ($pl['type'] != 1 && $pl['type'] != 6) { return $pl['text']; } $d = []; foreach (explode('||', $pl['vars']) as $value) { $r = explode('=', $value); if (empty($r[0])) { continue; } $d[$r[0]] = $r[1]; } # По неведомой причине команды в базу падают с id 0 и 1, а не 1 и 2. Что ломает все логи. if (isset($d['t1'], $d['t2'])) { $d['t1']++; $d['t2']++; } //обычный удар $rt = replaceLogText($d, $pl['text']); $k01 = 1; $zb1 = [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0]; $zb2 = [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0]; if (isset($d['bl1']) && $d['bl1'] > 0) { $b11 = 1; $b12 = $d['bl1']; while ($b11 <= $d['zb1']) { $zb1[$b12] = 1; if ($b12 >= 5 || $b12 < 0) { $b12 = 0; } $b12++; $b11++; } } if (isset($d['bl2']) && $d['bl2'] > 0) { $b11 = 1; $b12 = $d['bl2']; while ($b11 <= $d['zb2']) { $zb2[$b12] = 1; if ($b12 >= 5 || $b12 < 0) { $b12 = 0; } $b12++; $b11++; } } if (isset($d['t1'], $d['t2'])) { while ($k01 <= 5) { $zns01 = ''; $zns02 = ''; $j01 = 1; while ($j01 <= 5) { $zab1 = '0'; $zab2 = '0'; if ($j01 == $k01) { $zab1 = '1'; $zab2 = '1'; } $zab1 .= $zb1[$j01]; $zab2 .= $zb2[$j01]; $zns01 .= ''; $zns02 .= ''; $j01++; } $rt = str_replace('{zn1_' . $k01 . '}', $zns01, $rt); $rt = str_replace('{zn2_' . $k01 . '}', $zns02, $rt); $k01++; } } $j = 1; while ($j <= 21) { //замена R - игрок 1 if (isset($d['s2'])) { $r = $log_text[$d['s1']][$j]; $k = 0; if (is_array($r)) { while ($k <= count($r)) { if (isset($log_text[$d['s1']][$j][$k])) { $rt = str_replace('{1x' . $j . 'x' . $k . '}', $log_text[$d['s1']][$j][$k], $rt); } $k++; } } } //замена R - игрок 2 if (isset($d['s2'])) { $r = $log_text[$d['s2']][$j]; $k = 0; if (is_array($r)) { while ($k <= count($r)) { if (isset($log_text[$d['s2']][$j][$k])) { $rt = str_replace('{2x' . $j . 'x' . $k . '}', $log_text[$d['s2']][$j][$k], $rt); } $k++; } } } $j++; } //заменяем данные повторно $rt = replaceLogText($d, $rt); //закончили заменять $pl['text'] = $rt; return $pl['text']; } function getTeamColoredLogin(array $us): string { $login = new Login($us['align'], $us['clan'], $us['level'], $us['login']); $us['team']++; return "$login->fullLogin"; } $r = ''; $p = ''; $b = << HTML; if ($btl['team_win'] != -1) { if (!isset($_GET['analiz'])) { $b .= << Поиск :
HTML; } else { $b .= << HTML; } } $b .= ""; if (isset($btl['id']) && $btl['team_win'] != -1 && isset($_GET['analiz'])) { function rzv($v): string { $v = explode('.', $v); return isset($v[1]) ? "$v[0].$v[1]" : "$v[0].0"; } $tmStart = floor(($btl['time_over'] - $btl['time_start']) / 6) / 10; $tmStart = rzv($tmStart); $tbtl = ''; if ($btl['invis'] > 0) { $tbtl .= ''; } $tbtl = "Тип боя: $tbtl (" . ($btl['type'] == 1 ? 'кулачный' : 'физический') . " поединок) "; if ($btl['izlom'] > 0) { $tbtl .= 'Волна: ' . $btl['izlomRoundSee'] . '     '; } $tbtl .= 'Продолжительность боя: ' . $tmStart . ' мин.
'; $users = []; $uids = []; //Поулчаем инфо $tpas = [ 1 => 'X', 2 => '', 3 => '', 4 => '¤', 5 => 'X', 6 => '', 7 => '', 8 => '', ]; $tpbs = [ 0 => '', 1 => '', 2 => '', 3 => 'X', 4 => 'X', 5 => '', 6 => '', 7 => '', 8 => '', ]; $battleUsers = Db::getRows('select * from battle_users where battle = ?', [$btl['id']]); foreach ($battleUsers as $pl) { if (isset($uids[$pl['id']])) { continue; } $i = count($users); $users[$i] = $pl; $uids[$pl['uid']] = $i; $users[$i]['value'] = [ 'y' => 0, //уворотов+парирований+блоков щитом 'b' => 0, //успешных блоков 'p' => 0, //не успешных блоков, по персонажу попали 'zb' => [ //Список зон блока ], 'sa' => [ //Статистика ударов 0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', ], 'sb' => [ //Статистика блоков 0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', ], ]; $battleStatUser1 = Db::getRows('select * from battle_stat where battle = ? and uid1 = ? order by id', [$btl['id'], $pl['uid']]); foreach ($battleStatUser1 as $pl2) { if (!isset($users[$i]['yrn'])) { $users[$i]['yrn'] = 0; } if (!isset($users[$i]['yrn_krit'])) { $users[$i]['yrn_krit'] = 0; } if (!isset($users[$i]['ga'])) { $users[$i]['ga'] = 0; } if (!isset($users[$i]['gaa'])) { $users[$i]['gaa'] = 0; } if (!isset($users[$i]['gak'])) { $users[$i]['gak'] = 0; } if (!isset($users[$i]['zona'])) { $users[$i]['zona'] = []; } if (!isset($users[$i]['zonb'])) { $users[$i]['zonb'] = []; } //Обновляем данные $users[$i]['yrn'] += $pl2['yrn']; $users[$i]['yrn_krit'] += $pl2['yrn_krit']; //Статистика далее $users[$i]['gaa']++; if ($users[$i]['yrn'] > 0) { $users[$i]['ga']++; } if ($users[$i]['yrn_krit'] > 0) { $users[$i]['gak']++; } //Получаем куда бил игрок $j = 0; while ($j < $pl2['ma']) { if (!isset($pl2['a'][$j])) { $j++; continue; } if (!isset($users[$i]['zona'][$pl2['a'][$j]])) { $users[$i]['zona'][$pl2['a'][$j]] = 0; } $users[$i]['zona'][$pl2['a'][$j]]++; $za = $pl2['a'][$j]; $k = 1; while ($k <= 5) { if ($za == $k) { $tpa = $pl2['type_a'][$j]; $zag[$k] = true; $users[$i]['value']['sa'][$k] .= $tpas[$tpa]; } else { $zag[$k] = false; } $k++; } $j++; } $j = $pl2['b']; $k = 0; while ($k < $pl2['mb']) { if ($j > 5) { $j = 1; } $users[$i]['value']['zb'][] = [0 => $j, 1 => 0]; if (!isset($users[$i]['zonb'][$j])) { $users[$i]['zonb'][$j] = 0; } $users[$i]['zonb'][$j]++; $j++; $k++; } // $k = 1; while ($k <= 5) { if (empty($zag[$k])) { $users[$i]['value']['sa'][$k] .= ' '; } $k++; } // } // $battleStatUser2 = Db::getRows('select * from battle_stat where battle = ? and uid2 = ? order by id', [$btl['id'], $pl['uid']]); $k = 0; foreach ($battleStatUser2 as $pl2) { if (!isset($users[$i]['_yrn'])) { $users[$i]['_yrn'] = 0; } if (!isset($users[$i]['_yrn_krit'])) { $users[$i]['_yrn_krit'] = 0; } //Обновляем данные $users[$i]['_yrn'] -= $pl2['yrn']; $users[$i]['_yrn_krit'] -= $pl2['yrn_krit']; //Получаем куда били игрока $j = 0; $zag = []; while ($j < $pl2['ma']) { if (!isset($pl2['type_a'][$j])) { $pl2['type_a'][$j] = 0; } $users[$i]['value']['zb'][$k][1] = $pl2['type_a'][$j]; if ($pl2['type_a'][$j] == 2 || $pl2['type_a'][$j] == 6 || $pl2['type_a'][$j] == 7 || $pl2['type_a'][$j] == 8) { $users[$i]['value']['y']++; } elseif ($pl2['type_a'][$j] == 3) { $users[$i]['value']['b']++; } else { $users[$i]['value']['p']++; } $j++; } $k++; } //Статистика блоков $k = 0; $h = 0; $bjj = []; while ($k < count($users[$i]['value']['zb'])) { $zb = (int)$users[$i]['value']['zb'][$k][0]; $zt = (int)$users[$i]['value']['zb'][$k][1]; $bjj[$zb] = true; $users[$i]['value']['sb'][$zb] .= $tpbs[$zt]; if ($h < 1) { $h++; } else { $d = 1; while ($d <= 5) { if (empty($bjj[$d])) { $users[$i]['value']['sb'][$d] .= ' '; } $d++; } $bjj = []; $h = 0; } $k++; } } $usr = ''; $tm = []; $tm_u = []; $tm_v = []; $i = 0; while ($i < count($users)) { if ($users[$i] > 0) { $us = $users[$i]; if (!isset($tm[$us['team']])) { $tm[$us['team']] = ''; $tm_v[] = (int)$us['team']; } $tm_u[$us['team']][] = $i; $tm[$us['team']] .= getTeamColoredLogin($us); $tm[$us['team']] .= ', '; unset($us); } $i++; } $i = 0; while ($i < count($tm_v)) { $usr .= rtrim($tm[$tm_v[$i]], ', '); if ($i < count($tm_v) - 1) { $usr .= '   против   '; } $i++; } $strroll = ''; foreach ($tm_v as $team) { $team_data = ['g' => false]; foreach ($tm_u[$team] as $teamuser) { if ($users[$teamuser]['id'] < 1) { continue; } $rh = "{$users[$teamuser]['value']['sa'][1]}
{$users[$teamuser]['value']['sa'][2]}
{$users[$teamuser]['value']['sa'][3]}
{$users[$teamuser]['value']['sa'][4]}
{$users[$teamuser]['value']['sa'][5]}"; $strroll .= ''; $strroll .= " " . getTeamColoredLogin($users[$teamuser]) . ""; $strroll .= "
голову
грудь
живот
пояс
ноги
"; $strroll .= "
$rh
"; $strroll .= ''; } } $usr = '

Участники поединка

' . $usr . '

'; $r = <<$b
$tbtl $p Статус битвы: $allprice


$usr
$p

Последовательность ударов

$strroll
ЛогинУдар вПоследовательность ударов
(X - удачный удар, ¤ - критический удар пробив блок , X - критический удар, Ξ - крит + инвалидность, X - доп. магический удар,
  - противник блокировал удар, - увернулся, - парировал, - отбил щитом)

Последовательность блоков

$strroll
ЛогинБлокПоследовательность блоков
(X - удачный блок, X - пробили блок критом, - пропустил удар, - увернулся, - парировал, - отбил щитом)

Суммарно

HTML; foreach ($tm_v as $team) { $team_data = [ 'g' => false, 'ga' => 0, 'gaa' => 0, 'gak' => 0, 'hp' => 0, 'hpAll' => 0, 'yrn' => 0, 'yrn_krit' => 0, '_yrn' => 0, '_yrn_krit' => 0, 'val_b' => 0, 'val_y' => 0, 'val_p' => 0, 'heal' => 0, ]; foreach ($tm_u[$team] as $teamuser) { if ($users[$teamuser]['id'] < 1) { continue; } foreach ($team_data as $k => $v) { if ($k == 'g') { continue; } if (!isset($users[$teamuser][$k])) { $users[$teamuser][$k] = $v; } } $team_data['g'] = true; $users[$teamuser]['heal'] = $users[$teamuser]['hp'] - $users[$teamuser]['hpAll'] - $users[$teamuser]['_yrn']; $users[$teamuser]['heal'] = max($users[$teamuser]['heal'], 0); $users[$teamuser]['hp'] = max($users[$teamuser]['hp'], 0); $users[$teamuser]['yrn'] = max($users[$teamuser]['yrn'], 0); $users[$teamuser]['yrn_krit'] = max($users[$teamuser]['yrn_krit'], 0); $users[$teamuser]['_yrn'] = min($users[$teamuser]['_yrn'], 0); $users[$teamuser]['_yrn_krit'] = min($users[$teamuser]['_yrn_krit'], 0); $team_data['ga'] += $users[$teamuser]['ga']; $team_data['gaa'] += $users[$teamuser]['gaa']; $team_data['gak'] += $users[$teamuser]['gak']; $team_data['hp'] += $users[$teamuser]['hp']; $team_data['hpAll'] += $users[$teamuser]['hpAll']; $team_data['yrn'] += $users[$teamuser]['yrn']; $team_data['yrn_krit'] += $users[$teamuser]['yrn_krit']; $team_data['_yrn'] += $users[$teamuser]['_yrn']; $team_data['_yrn_krit'] += $users[$teamuser]['_yrn_krit']; $team_data['val_b'] += $users[$teamuser]['val_b']; $team_data['val_y'] += $users[$teamuser]['val_y']; $team_data['val_p'] += $users[$teamuser]['val_p']; $team_data['heal'] += $users[$teamuser]['heal']; $winw = ''; if ($users[$teamuser]['hp'] === 0) { $users[$teamuser]['hp'] = '0'; $winw = 'Погиб'; } else { $winw = 'Выжил'; } $coloredLogin = getTeamColoredLogin($users[$teamuser]); if (!isset($users[$teamuser]['zona'][1])) { $users[$teamuser]['zona'][1] = 0; } if (!isset($users[$teamuser]['zona'][2])) { $users[$teamuser]['zona'][2] = 0; } if (!isset($users[$teamuser]['zona'][3])) { $users[$teamuser]['zona'][3] = 0; } if (!isset($users[$teamuser]['zona'][4])) { $users[$teamuser]['zona'][4] = 0; } if (!isset($users[$teamuser]['zona'][5])) { $users[$teamuser]['zona'][5] = 0; } if (!isset($users[$teamuser]['zonb'][1])) { $users[$teamuser]['zonb'][1] = 0; } if (!isset($users[$teamuser]['zonb'][2])) { $users[$teamuser]['zonb'][2] = 0; } if (!isset($users[$teamuser]['zonb'][3])) { $users[$teamuser]['zonb'][3] = 0; } if (!isset($users[$teamuser]['zonb'][4])) { $users[$teamuser]['zonb'][4] = 0; } if (!isset($users[$teamuser]['zonb'][5])) { $users[$teamuser]['zonb'][5] = 0; } $r .= << HTML; } if (!$team_data['g']) { continue; } $winw = '--'; if ($team_data['hp'] < 1) { $team_data['hp'] = 0; } else { $winw = 'Победитель'; } $r .= << HTML; } $r .= << Логин - имя персонажа и уровень жизни: [сейчас/всего]
Удары - статистика ударов по областям: голова/грудь/живот/пояс/ноги
Блоки - статистика блоков по областям: голова/грудь/живот/пояс/ноги
Попадания - удачных попаданий (из них критов) / всего ударов
Защита - ударов заблокировано / уворотов / пропущено ударов
Урон - выбито HP из противников / из них критами
Потери - получено повреждений
Вылечено - восстановлено HP
HTML; } elseif (!isset($btl['id'])) { $r = '
Скорее всего Архивариус снова потерял пергамент с хрониками боев...
'; } else { include('jx/battle/log_text.php'); $getp = $_GET['p'] ?? 0; $getp = (int)$getp; //Получаем логи $min = max((int)round(12 * ($getp - 1)), 0); $max = $min + 11; $based = 'battle_logs_save'; $check = Db::getValue('select count(*) from battle_logs_save where battle = ? and id_hod between ? and ? order by id_hod, time', [$btl['id'], $min, $max]) < 1; if ($check) { $based = 'battle_logs'; } //генерируем страницы $pmax = Db::getValue("select id_hod from $based where battle = ? order by id_hod desc limit 1", [$btl['id']]); $pmax = ceil($pmax / 12); if ($min > round(12 * ($pmax - 1))) { $min = round(12 * ($pmax - 1)); $max = $min + 11; } $i = 1; $code = PassGen::intCode(); while ($i <= $pmax) { if ($getp == $i || $getp > $pmax && $i == $pmax || $getp < 1 && $i == 1) { $p .= ' ' . $i . ' '; } else { $p .= ' ' . $i . ' '; } $i++; } $h = 0; $clr = '#f2e5e0'; $cclr = ''; $savedbattlelogs = Db::getRows("select * from $based where battle = ? and id_hod between ? and ? order by id_hod, id limit 200", [$btl['id'], $min, $max + 1]); foreach ($savedbattlelogs as $pl) { $pl['text'] = testlog($pl); $pl['text'] = str_replace('\"', '"', $pl['text']); if ($h != $pl['id_hod']) { if ($h > 0) { $clr = $clr == '#f2e5e0' ? '#f2e5e5' : '#f2e5e0'; $cclr = 'border-top:1px solid #b1b1b1;'; } $h = $pl['id_hod']; } $r .= '
' . $pl['text'] . '
'; $cclr = ''; } //собираем страницу $p = 'Страницы: ' . $p; $usr = ''; if ($btl['team_win'] == -1) { $aliveusers = Db::getRows('select login, level, align, clan, team, hpNow, hpAll from users left join stats on users.id = stats.id where battle = ? and hpNow > 0', [$btl['id']]); $usrs = [-1 => []]; foreach ($aliveusers as $pl) { if (!isset($usrs[$pl['team']])) { $usrs[$pl['team']] = ''; $usrs[-1][count($usrs[-1])] = $pl['team']; } $hpnow = (int)ceil($pl['hpNow']); $hpall = (int)$pl['hpAll']; $usrs[$pl['team']] = getTeamColoredLogin($pl) . "[$hpnow/$hpall]"; } if (count($usrs[-1]) > 0) { $i = 0; while ($i < count($usrs[-1])) { $usr .= rtrim($usrs[$usrs[-1][$i]], ','); if (count($usrs[-1]) > $i + 1) { $usr .= '   против   '; } $i++; } } if ($usr != '') { $usr = '
' . $usr . '

'; } } $tbtl = ''; if ($btl['invis'] > 0) { $tbtl .= ''; } if ($btl['type'] == 0) { $tbtl = 'Тип боя: ' . $tbtl . ' (физический поединок)     '; } elseif ($btl['type'] == 1) { $tbtl = 'Тип боя: ' . $tbtl . ' (кулачный поединок)     '; } elseif ($btl['type'] == 250) { $tbtl = ''; $tbtl = 'Тип боя: ' . $tbtl . ' (Война Кланов)     '; } elseif ($btl['smert'] == 1) { $tbtl = ''; $tbtl = 'Тип боя: ' . $tbtl . ' (Жесточайшее Сражение)     '; } else { $tbtl = 'Тип боя: ' . $tbtl . ' (физический поединок)     '; } if ($btl['izlom'] > 0) { $tbtl .= 'Волна: ' . $btl['izlomRoundSee'] . '     '; } $r = <<$b
$tbtl $p Статус битвы: $allprice


$r
$usr
$p
HTML; } ?> Архив: Поединки


Бойцовский Клуб  




Логин Удары Блоки Попадания Защита Урон Потери Вылечено
$winw $coloredLogin [{$users[$teamuser]['hp']}/{$users[$teamuser]['hpAll']}] {$users[$teamuser]['zona'][1]}/{$users[$teamuser]['zona'][2]}/{$users[$teamuser]['zona'][3]}/{$users[$teamuser]['zona'][4]}/{$users[$teamuser]['zona'][5]} {$users[$teamuser]['zonb'][1]}/{$users[$teamuser]['zonb'][2]}/{$users[$teamuser]['zonb'][3]}/{$users[$teamuser]['zonb'][4]}/{$users[$teamuser]['zonb'][5]} {$users[$teamuser]['ga']}({$users[$teamuser]['gak']})/{$users[$teamuser]['gaa']} {$users[$teamuser]['value']['b']}/{$users[$teamuser]['value']['y']}/{$users[$teamuser]['value']['p']} {$users[$teamuser]['yrn']}/{$users[$teamuser]['yrn_krit']} {$users[$teamuser]['_yrn']} {$users[$teamuser]['heal']}
$winw Всего [{$team_data['hp']}/{$team_data['hpAll']}] {$team_data['ga']}({$team_data['gak']})/{$team_data['gaa']} {$team_data['val_b']}/{$team_data['val_y']}/{$team_data['val_p']} {$team_data['yrn']}/{$team_data['yrn_krit']} {$team_data['_yrn']} {$team_data['heal']}