battles/cronjobs/pole_cron.php
2018-12-13 16:52:02 +02:00

27 lines
1.1 KiB
PHP

<?php
require_once "../config.php";
// Осталось понять что делает, зачем написан и какой интервал запуска.
// 4 hours: time() + 14400;
$q = db::c()->query('SELECT `value` FROM `variables` WHERE `var` = "?s"', 'pole_random')->fetch_assoc();
for ($i = 0; $i < 41; $i++) {
$rand = mt_rand(1, 9);
if ($rand == 1) $h = 100;
elseif ($rand == 2) $h = 80;
elseif ($rand == 3) $h = 70;
elseif ($rand == 4) $h = 60;
elseif ($rand == 5) $h = 50;
elseif ($rand == 6) $h = 40;
elseif ($rand == 7 || $rand == 8 || $rand == 9) $h = 0;
$h += $h * mt_rand(1, 11) / 10;
$rekr = 0.1 + mt_rand(1, 13) / 100;
db::c()->query('UPDATE `pole` SET `type` = ?i, `heals` = ?i, `ekr` = ?i WHERE `id` = ?i', $rand, $h, $rekr, $i);
}
if (empty($q['value']))
db::c()->query('UPDATE `variables` SET `value` = ?i WHERE `var` = "?s"', (time() + 14400), 'pole_random');
elseif ($q['value'] < time())
db::c()->query('UPDATE `variables` SET `value` = `value` + 14400 WHERE `var` = "?s"', 'pole_random');