Файл: bk/fight.php
Строк: 125
<?php
$setMsg = '';
$sesTime = isset($_SESSION['bot_trainers_health']) ? $_SESSION['bot_trainers_health'] : 0;
if (100 > $user['bk_health'] && time() > $sesTime) {
$user['bk_health'] = $user['bk_health'] + 2;
if (100 < $user['bk_health']) $user['bk_health'] = 100;
mysql_query("UPDATE users SET bk_health = '$user[bk_health]' WHERE id = '$user[id]' LIMIT 1");
$_SESSION['bot_trainers_health'] = time() + 30;
}
$stop = false;
function getRandMsg($file, $user_1 = '', $user_2 = '') {
$file = file('../upload/bk/'.$file.'.dat');
return sprintf($file[array_rand($file)], $user_1, $user_2);
}
if (preg_match("#!(.+?)[(.*?)](s|$)#i", $msg, $arr)) {
$_res = mysql_fetch_assoc(mysql_query("SELECT * FROM users WHERE user = '".mysql_real_escape_string($arr[2])."' LIMIT 1"));
if (!isset($_SESSION['blow_time'])) $_SESSION['blow_time'] = 0;
if ($_SESSION['blow_time'] > time()) {
$setMsg = $user['user'] . ', передохните ' . ($_SESSION['blow_time'] - time()) . ' сек.';
} elseif ($arr[2] == 'Рефери') {
$setMsg = getRandMsg('vip_user', $user['user']);
} elseif (!isset($_res['id']) || !online_user($_res['id']) || online_user($_res['id']) && user_inf($_res['id'], 'room') != 'room' . $rm) {
$setMsg = getRandMsg('no_user', $user['user'], $arr[2]);
} elseif ($_res['id'] == $user['id']) {
$setMsg = $user['user'] . ', зачем бить себя?';
} else {
$data = file_get_contents('../upload/bk/hands_feet.dat');
if (preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$ex = explode('|::|', $force_preg[0]);
if (count($ex) == 3) {
if (time() > $_res['bk_trauma'] && $_res['bk_health']) {
$blowStart = 10;
$blow = ceil(($blowStart / mt_rand(70, 100)) * (mt_rand(1, ($user['bk_force'] + $ex[1])) - mt_rand(1, $_res['bk_endurance'])));
if (0 >= $blow) $blow = mt_rand(1, ceil($blowStart / 2));
$mazila = mt_rand(1, $_res['bk_adroitness']) - mt_rand(1, $user['bk_accuracy']);
$sql_us_1 = '';
$sql_us_2 = '';
if ($mazila > mt_rand(1, 100)) {
$sql_us_1 = " bk_accuracy = '" . minus($user['bk_accuracy'], mt_rand(1, 3)) . "',";
$sql_us_2 = " bk_adroitness = '" . minus($_res['bk_adroitness'], mt_rand(1, 3)) . "',";
$blow = 0;
$setMsg = getRandMsg('mazila', $user['user'], $_res['user']);
} else {
if (minus($_res['bk_health'], $blow)) {
$ex2 = explode('#', $ex[2]);
$setMsg = $user['user'] . ', ' . $ex2[array_rand($ex2)] . '<br/>' . $_res['user'] . ' потерял ' . $blow . '% здоровья.';
} else {
$setMsg = getRandMsg('victory', $user['user'], $_res['user']);
$sql_us_1 = " bk_victories = bk_victories+1,";
$sql_us_2 = " bk_defeats = (bk_defeats+1), bk_trauma = '".(time() + 120)."',";
}
}
mysql_query("UPDATE users SET
bk_force = '" . minus($user['bk_force'], mt_rand(1, 3)) . "',
$sql_us_1
bk_endurance = '" . minus($user['bk_endurance'], mt_rand(1, 3)) . "'
WHERE id = '$user[id]' LIMIT 1");
mysql_query("UPDATE users SET
bk_force = '" . minus($_res['bk_force'], mt_rand(1, 3)) . "',
$sql_us_2
bk_endurance = '" . minus($_res['bk_endurance'], mt_rand(1, 3)) . "',
bk_health = '" . minus($_res['bk_health'], $blow) . "'
WHERE id = '$_res[id]' LIMIT 1");
$_SESSION['blow_time'] = time() + 10;
$_SESSION['bot_trainers_health'] = time() + 30;
} else $setMsg = getRandMsg('trauma', $user['user'], $_res['user']);
}
$stop = true;
}
$data = file_get_contents('../upload/bk/weapons.dat');
if (!$stop && preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$ex = explode('|::|', $force_preg[0]);
if (count($ex) == 5) {
if ($user['bk_weapons'] != $ex[0]) {
$setMsg = getRandMsg('no_weapons', $user['user']);
} elseif(time() > $_res['bk_trauma'] && $_res['bk_health']) {
$blowStart = 20;
$blow = ceil(($blowStart / mt_rand(70, 100)) * (mt_rand(1, ($user['bk_force'] + $ex[1])) - mt_rand(1, $_res['bk_endurance'])));
if (0 >= $blow) $blow = mt_rand(1, ceil($blowStart / 2));
$mazila = mt_rand(1, $_res['bk_adroitness']) - mt_rand(1, $user['bk_accuracy']);
$sql_us_1 = '';
$sql_us_2 = '';
if ($mazila > mt_rand(1, 100)) {
$sql_us_1 = " bk_accuracy = '" . minus($user['bk_accuracy'], mt_rand(1, 3)) . "',";
$sql_us_2 = " bk_adroitness = '" . minus($_res['bk_adroitness'], mt_rand(1, 3)) . "',";
$blow = 0;
$setMsg = getRandMsg('mazila', $user['user'], $_res['user']);
} else {
if (minus($_res['bk_health'], $blow)) {
$ex2 = explode('#', $ex[4]);
$setMsg = $user['user'] . ', ' . $ex2[array_rand($ex2)] . '<br/>' . $_res['user'] . ' потерял ' . $blow . '% здоровья.';
} else {
$setMsg = getRandMsg('victory', $user['user'], $_res['user']);
$sql_us_1 = " bk_victories = bk_victories+1,";
$sql_us_2 = " bk_defeats = (bk_defeats+1), bk_trauma = '".(time() + 120)."',";
}
}
mysql_query("UPDATE users SET
bk_force = '" . minus($user['bk_force'], mt_rand(1, 3)) . "',
$sql_us_1
bk_endurance = '" . minus($user['bk_endurance'], mt_rand(1, 3)) . "'
WHERE id = '$user[id]' LIMIT 1");
mysql_query("UPDATE users SET
bk_force = '" . minus($_res['bk_force'], mt_rand(1, 3)) . "',
$sql_us_2
bk_endurance = '" . minus($_res['bk_endurance'], mt_rand(1, 3)) . "',
bk_health = '" . minus($_res['bk_health'], $blow) . "'
WHERE id = '$_res[id]' LIMIT 1");
$_SESSION['blow_time'] = time() + 10;
$_SESSION['bot_trainers_health'] = time() + 30;
} else $setMsg = getRandMsg('trauma', $user['user'], $_res['user']);
}
$stop = true;
}
}
$_SESSION['Defeat'] = $_res['user'];
}
if (!$stop && preg_match("#!(.+?)(s|$)#i", $msg, $arr)) {
$data = file_get_contents('../upload/bk/weapons.dat');
if (preg_match('/'.$arr[1].'|::|.*?n/is', $data, $force_preg)) {
$ex = explode('|::|', $force_preg[0]);
if (count($ex) == 5) {
if ($user['balls'] > $ex[2]) {
$ex2 = explode('#', $ex[3]);
$setMsg = $user['user'] . ', ' . $ex2[array_rand($ex2)];
mysql_query("UPDATE users SET balls = (balls-" . $ex[2] . "), bk_weapons = '" . mysql_real_escape_string($ex[0]) . "' WHERE id = '$user[id]' LIMIT 1");
} else $setMsg = getRandMsg('little_balls', $user['user']);
}
$stop = true;
}
}
$defeat = isset($_SESSION['bot_bk_defeat']) ? $_SESSION['bot_bk_defeat'] : 0;
if (time() < $user['bk_trauma'] && time() > $defeat) {
$_SESSION['bot_bk_defeat'] = time() + 20;
$ids = mt_rand(100000, 999999);
mysql_query("INSERT INTO message SET
id = '$ids',
user = '$user[user]',
who = '$user[id]',
time = '" . (time() + 1) . "',
msg = '" . mysql_real_escape_string(getRandMsg('defeat', $_SESSION['Defeat'])) . "',
room = '$rm'");
}
if ($setMsg != '') {
$ids = mt_rand(100000, 999999);
mysql_query("INSERT INTO message SET
id = '$ids',
user = 'Рефери',
who = '0',
time = '" . (time() + 1) . "',
msg = '" . mysql_real_escape_string($setMsg) . "',
room = '$rm'");
}
?>