<?
session_start();
ob_start();
include 'inc/statistic.php';
if (!isset($_SESSION['id']))
{
header ("location: logout.php");
exit('incorrect');
}
include 'inc/config.system.php';
include 'inc/config.game.php';
$to = def($_GET['to']);
$ataker = b($_SESSION['id']);
$defer = b($to);
if (abs(lvl($ataker['exp'])-lvl($defer['exp']))>=10
OR $ataker['hp']<=25
OR $defer['hp']<=25
OR $ataker['race']==$defer['race']
OR $defer['timer']>time())
{
Header("Location: z_main.php");
exit;
}
$sila_a = ($ataker['pow']*$ataker['agi']*8+$ataker['stam']*$ataker['chr']+$ataker['s_double']*100+$ataker['s_chance_kick']*7+$ataker['s_dam']*10)*($ataker['hp']/$ataker['hp_max']);
$sila_d = ($defer['def']*$defer['agi']*9+$defer['stam']*$defer['chr']+$defer['s_block']*100+$defer['s_chance_blow']*6+$defer['s_dam']*8)*($defer['hp']/$defer['hp_max']);
$timer=time()+3600; //òàéìåğ çàùèòû íà ÷àñ
if ($sila_a > $sila_d)
{
$gold=ceil(($defer['gold']*0.1)/$defer['chest']);
$exp=rand(2,6);
// ïîáåäèòåëü ataker
if (lvl($ataker['exp'])< lvl($ataker['exp']+$exp)){$hp_up=25;}else{$hp_up=0;}
count_query("UPDATE user
SET gold=gold+'$gold', exp=exp+'$exp', stat_battle=stat_battle+1, stat_win=stat_win+1, stat_prey=stat_prey+3, hp_max=hp_max+'$hp_up',stat_gold_p=stat_gold_p+'$gold', stat_dam_p=stat_dam_p+ '".$defer['hp']."'
WHERE id = '".$ataker['id']."'");
count_query("INSERT
INTO mail (to_id, msg)
VALUES ('".$ataker['id']."',
'Girdiğiniz savaştan ".$gold."<img src=img/res2.gif alt=altın align=absmiddle border=0> Altın, ".$exp." deneyim puanı kazandınız.')");
// ïğîèãğàâøèé defer
count_query("UPDATE user
SET gold=gold-'$gold', stat_battle=stat_battle+1, stat_loss=stat_loss+1, stat_gold_m=stat_gold_m+'$gold', stat_dam_m=stat_dam_m+'".$defer['hp']."', hp_now = 1,timer='$timer'
WHERE id = '".$defer['id']."'");
count_query("INSERT
INTO mail (to_id, msg)
VALUES ('".$defer['id']."',
'Savaş Raporu')");
Header("Location: z_msgshow.php?box=in"); exit;
}
else
{
$gold=ceil(($ataker['gold']*0.1)/$ataker['chest']);
$exp=rand(2,6);
// ïîáåäèòåëü defer
if (lvl($defer['exp'])< lvl($defer['exp']+$exp)){$hp_up=25;}else{$hp_up=0;}
count_query("UPDATE user
SET gold=gold+'$gold', exp=exp+'$exp', stat_battle=stat_battle+1, stat_win=stat_win+1, stat_prey=stat_prey+3, hp_max=hp_max+'$hp_up', stat_gold_p=stat_gold_p+'$gold', stat_dam_p=stat_dam_p+ '".$ataker['hp']."'
WHERE id = '".$defer['id']."'");
count_query("INSERT
INTO mail (to_id, msg)
VALUES ('".$defer['id']."',
'Kazandınız.')");
// ïğîèãğàâøèé ataker
count_query("UPDATE user
SET gold=gold-'$gold', stat_battle=stat_battle+1, stat_loss=stat_loss+1, stat_gold_m=stat_gold_m+'$gold', stat_dam_m=stat_dam_m+'".$ataker['hp']."', hp_now = 1, timer='$timer'
WHERE id = '".$ataker['id']."'");
count_query("INSERT
INTO mail (to_id, msg)
VALUES ('".$ataker['id']."',
'Savaşı kaybettiniz')");
Header("Location: z_msgshow.php?box=in"); exit;
};
?>
<?include 'tpl/top.php';?>
ddsdsdsds
<?include 'tpl/footer.php';?>