battles/pole_cron.php
2018-01-28 18:40:49 +02:00

74 lines
2.0 KiB
PHP

<?
include("config.php");
$nowtime = time();
$info_pole = mysql_fetch_array(mysql_query("SELECT `value` FROM `variables` WHERE `var` = 'pole_random' LIMIT 1"));
$ff_time = time();
$f_time = $ff_time + 14400;
if($info_pole['value'] == '') {
for($i = 0; $i < 41; $i++) {
$hrand = rand(1, 11)/10;
$rand = rand(1, 9);
$rekrr = 30/30;
$rekr = rand(1, $rekrr)/10;
$bonus = rand(1, 13)/10;
$bonuss = $rekr*$bonus;
$rekrr = $rekr+$bonuss;
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;
}
$hh = $h*$hrand;
$h = $h+$hh;
mysql_query("UPDATE `pole` SET `type` = '".$rand."', `heals` = '".$h."', `ekr` = '".$rekrr."' WHERE `id` = '".$i."' LIMIT 1");
}
mysql_query("UPDATE `variables` SET `value` = '".$f_time."' WHERE `var` = '".$info_pole['var']."' LIMIT 1");
} else{
if($info_pole['value'] < $nowtime){
for($i = 0; $i < 41; $i++) {
$hrand = rand(1, 11)/10;
$rand = rand(1, 9);
$rekrr = 30/30;
$rekr = rand(1, $rekrr)/10;
$bonus = rand(1, 13)/10;
$bonuss = $rekr*$bonus;
$rekrr = $rekr+$bonuss;
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;
}
$hh = $h * $hrand;
$h = $h + $hh;
mysql_query("UPDATE `pole` SET `type` = '".$rand."', `heals` = '".$h."', `ekr` = '".$rekrr."' WHERE `id` = '".$i."' LIMIT 1");
}
mysql_query("UPDATE `variables` SET `value` = `value`+'14400' WHERE `var` = '".$info_pole['var']."' LIMIT 1");
}
}
?>