Вход Регистрация
Файл: war/ataka.php
Строк: 269
<?php
    
/*
    Автор скрипта DarkSlayer
    Связь: icq 471777781, почта darkslayer@mail.ua
    Сайт поддержки игры darkslayer.ru
    -----
    Запрещено снятие копирайта внизу страниц без согласования с автором игры.
    В случае снятия копирайта последует обращение к вашему хостинг-провайдеру с жалобой о нарушении вами авторских прав и последующей блокировкой вашего аккаунта.
    */
define('_ON_CMS'1);
require_once 
'../includes/start.php';
require_once 
'../includes/function.php';
require_once 
'../includes/header.php';

if(
$game==OR $level==OR $ban!=0){
header('Location: ../index.php');
}
$a1=$_GET['a1'];
$a2=$_GET['a2'];
$s mysql_query("SELECT * FROM `army` WHERE `id`='".check(mysql_real_escape_string($a1))."'");
$a1 mysql_fetch_array($s);
$q mysql_query("SELECT * FROM `army` WHERE `id`='".check(mysql_real_escape_string($a2))."'");
$a2 mysql_fetch_array($q);
$pl1 mysql_query("SELECT * FROM `planet` WHERE `id`='".$a1['onpl']."'");
$pl mysql_fetch_array($pl1);    
$p mysql_query("SELECT * FROM `users` WHERE `id`='".$a2['uid']."'");
$u mysql_fetch_array($p);
$tma=round(($realtime-$newtime)/($realtime-$u['newtime']), 2);
if(
$a1['onpl']==$a2['onpl'] AND $a1['xpl']==$a2['xpl'] AND $a1['ypl']==$a2['ypl'] AND $a1['uid']!=$a2['uid'] AND (($a1['fr_id']==$a2['fr_id'] AND $a1['fr_id']==AND $a2['fr_id']==0) OR ($a1['fr_id']!=$a2['fr_id'] AND $a1['fr_id']!=AND $a2['fr_id']==0) OR ($a1['fr_id']!=$a2['fr_id'] AND $a1['fr_id']==AND $a2['fr_id']!=0) OR ($a1['fr_id']!=$a2['fr_id'] AND $a1['fr_id']!=AND $a2['fr_id']!=0))){    
$sum_unit1=$a1['u1']+$a1['u2']+$a1['u3']+$a1['u4']+$a1['u5']+$a1['u6']+$a1['u7']+$a1['u8']+$a1['u9']+$a1['u10']+$a1['u11']+$a1['u12'];
if(
$a1['time']>=$realtime){echo '<div class="conts"><img src="../images/time.gif" alt="image" /> Отдых 'intval(($a1['time']-$realtime)/60) .' минут</div>';}else{    
if(
$sum_unit1==0){echo '<div class="conts">В вашем отряде нет войск и он не может атаковать</div>';}else{
if(
$tma>1.4 AND $use_id!=$pl['uid']){echo '<img src="../images/war.jpg" alt="" /> Вы не можете атаковать отряд так как время вашей игры в '.$tma.' раза превышает время игры его владельца';}else{
if(
$tma<0.6 AND $use_id!=$pl['uid']){echo '<img src="../images/war.jpg" alt="" /> Вы не можете атаковать отряд так как время вашей игры в '.$tma.' раза меньше времени игры его владельца';}else{
    
    echo 
'<div class="top">Сражение</div>';
    
$wb=$_GET['o'];
    if(
$wb!=1){
                            echo 
'<div class="conts">Ваш отряд: '.rasa($a1['rasa']).' <span class="'.crasa($a1['rasa']).'">'.$a1['name'].'</span><br/>Отряд противника: '.rasa($a2['rasa']).' <span class="'.crasa($a2['rasa']).'">'.$a2['name'].'</span></div>';
                            echo 
'<div class="conts"><img src="../images/army.gif" alt="image" /> Вы уверенны что хотите атаковать отряд?<br/>';
                            echo 
'<a href="?o=1&amp;a1='.$a1['id'].'&amp;a2='.$a2['id'].'">Да</a> или <a href="army.php?a1='.$a1['id'].'&amp;a2='.$a2['id'].'">Отмена</a></div>';
                            }else{
require_once 
'../includes/battle_function.php';    
                
$p1 mysql_query("SELECT * FROM `units` WHERE `uid`='".check(mysql_real_escape_string($a1['uid']))."'");
$r1 mysql_fetch_array($p1);        
$p2 mysql_query("SELECT * FROM `units` WHERE `uid`='".check(mysql_real_escape_string($a2['uid']))."'");
$r2 mysql_fetch_array($p2);    



        
        
//ОТРЯД №1
        //u1
        
$u1l1=intval($a1['u1']*(live(1,$a1['rasa'])+((live(1,$a1['rasa'])/10)*$r1['r1'])));
        
////////////
        
if($a1['at1']==1){$u1az1at1=$a1['u1']*(az(1,$a1['rasa'])+(az(1,$a1['rasa'])/10));}else{$u1az1at1=0;}
        if(
$a1['at1']==2){$u1az1at2=$a1['u1']*(az(1,$a1['rasa'])+(az(1,$a1['rasa'])/10));}else{$u1az1at2=0;}
        if(
$a1['at1']==3){$u1az1at3=$a1['u1']*(az(1,$a1['rasa'])+(az(1,$a1['rasa'])/10));}else{$u1az1at3=0;}
        
////////////
        
if($a1['at1']==1){$u1av1at1=$a1['u1']*(av(1,$a1['rasa'])+(av(1,$a1['rasa'])/10));}else{$u1av1at1=0;}
        if(
$a1['at1']==2){$u1av1at2=$a1['u1']*(av(1,$a1['rasa'])+(av(1,$a1['rasa'])/10));}else{$u1av1at2=0;}
        if(
$a1['at1']==3){$u1av1at3=$a1['u1']*(av(1,$a1['rasa'])+(av(1,$a1['rasa'])/10));}else{$u1av1at3=0;}
        
//u2
        
$u1l2=intval($a1['u2']*(live(2,$a1['rasa'])+((live(2,$a1['rasa'])/10)*$r1['r2'])));
        
////////////
        
if($a1['at2']==1){$u1az2at1=$a1['u2']*(az(2,$a1['rasa'])+(az(2,$a1['rasa'])/10));}else{$u1az2at1=0;}
        if(
$a1['at2']==2){$u1az2at2=$a1['u2']*(az(2,$a1['rasa'])+(az(2,$a1['rasa'])/10));}else{$u1az2at2=0;}
        if(
$a1['at2']==3){$u1az2at3=$a1['u2']*(az(2,$a1['rasa'])+(az(2,$a1['rasa'])/10));}else{$u1az2at3=0;}
        
////////////
        
if($a1['at2']==1){$u1av2at1=$a1['u2']*(av(2,$a1['rasa'])+(av(2,$a1['rasa'])/10));}else{$u1av2at1=0;}
        if(
$a1['at2']==2){$u1av2at2=$a1['u2']*(av(2,$a1['rasa'])+(av(2,$a1['rasa'])/10));}else{$u1av2at2=0;}
        if(
$a1['at2']==3){$u1av2at3=$a1['u2']*(av(2,$a1['rasa'])+(av(2,$a1['rasa'])/10));}else{$u1av2at3=0;}
        
//u3
        
$u1l3=intval($a1['u3']*(live(3,$a1['rasa'])+((live(3,$a1['rasa'])/10)*$r1['r3'])));
        
////////////
        
if($a1['at3']==1){$u1az3at1=$a1['u3']*(az(3,$a1['rasa'])+(az(3,$a1['rasa'])/10));}else{$u1az3at1=0;}
        if(
$a1['at3']==2){$u1az3at2=$a1['u3']*(az(3,$a1['rasa'])+(az(3,$a1['rasa'])/10));}else{$u1az3at2=0;}
        if(
$a1['at3']==3){$u1az3at3=$a1['u3']*(az(3,$a1['rasa'])+(az(3,$a1['rasa'])/10));}else{$u1az3at3=0;}
        
////////////
        
if($a1['at3']==1){$u1av3at1=$a1['u3']*(av(3,$a1['rasa'])+(av(3,$a1['rasa'])/10));}else{$u1av3at1=0;}
        if(
$a1['at3']==2){$u1av3at2=$a1['u3']*(av(3,$a1['rasa'])+(av(3,$a1['rasa'])/10));}else{$u1av3at2=0;}
        if(
$a1['at3']==3){$u1av3at3=$a1['u3']*(av(3,$a1['rasa'])+(av(3,$a1['rasa'])/10));}else{$u1av3at3=0;}
        
//u4
        
$u1l4=intval($a1['u4']*(live(4,$a1['rasa'])+((live(4,$a1['rasa'])/10)*$r1['r4'])));
        
////////////
        
if($a1['at4']==1){$u1az4at1=$a1['u4']*(az(4,$a1['rasa'])+(az(4,$a1['rasa'])/10));}else{$u1az4at1=0;}
        if(
$a1['at4']==2){$u1az4at2=$a1['u4']*(az(4,$a1['rasa'])+(az(4,$a1['rasa'])/10));}else{$u1az4at2=0;}
        if(
$a1['at4']==3){$u1az4at3=$a1['u4']*(az(4,$a1['rasa'])+(az(4,$a1['rasa'])/10));}else{$u1az41at3=0;}
        
////////////
        
if($a1['at4']==1){$u1av4at1=$a1['u4']*(av(4,$a1['rasa'])+(av(4,$a1['rasa'])/10));}else{$u1av4at1=0;}
        if(
$a1['at4']==2){$u1av4at2=$a1['u4']*(av(4,$a1['rasa'])+(av(4,$a1['rasa'])/10));}else{$u1av4at2=0;}
        if(
$a1['at4']==3){$u1av4at3=$a1['u4']*(av(4,$a1['rasa'])+(av(4,$a1['rasa'])/10));}else{$u1av4at3=0;}
        
//u5
        
$u1l5=intval($a1['u5']*(live(5,$a1['rasa'])+((live(5,$a1['rasa'])/10)*$r1['r5'])));
        
////////////
        
if($a1['at5']==1){$u1az5at1=$a1['u5']*(az(5,$a1['rasa'])+(az(5,$a1['rasa'])/10));}else{$u1az5at1=0;}
        if(
$a1['at5']==2){$u1az5at2=$a1['u5']*(az(5,$a1['rasa'])+(az(5,$a1['rasa'])/10));}else{$u1az5at2=0;}
        if(
$a1['at5']==3){$u1az5at3=$a1['u5']*(az(5,$a1['rasa'])+(az(5,$a1['rasa'])/10));}else{$u1az5at3=0;}
        
////////////
        
if($a1['at5']==1){$u1av5at1=$a1['u5']*(av(5,$a1['rasa'])+(av(5,$a1['rasa'])/10));}else{$u1av5at1=0;}
        if(
$a1['at5']==2){$u1av5at2=$a1['u5']*(av(5,$a1['rasa'])+(av(5,$a1['rasa'])/10));}else{$u1av5at2=0;}
        if(
$a1['at5']==3){$u1av5at3=$a1['u5']*(av(5,$a1['rasa'])+(av(5,$a1['rasa'])/10));}else{$u1av5at3=0;}
        
//u6
        
$u1l6=intval($a1['u6']*(live(6,$a1['rasa'])+((live(6,$a1['rasa'])/10)*$r1['r6'])));
        
////////////
        
if($a1['at6']==1){$u1az6at1=$a1['u6']*(az(6,$a1['rasa'])+(az(6,$a1['rasa'])/10));}else{$u1az6at1=0;}
        if(
$a1['at6']==2){$u1az6at2=$a1['u6']*(az(6,$a1['rasa'])+(az(6,$a1['rasa'])/10));}else{$u1az6at2=0;}
        if(
$a1['at6']==3){$u1az6at3=$a1['u6']*(az(6,$a1['rasa'])+(az(6,$a1['rasa'])/10));}else{$u1az6at3=0;}
        
////////////
        
if($a1['at6']==1){$u1av6at1=$a1['u6']*(av(6,$a1['rasa'])+(av(6,$a1['rasa'])/10));}else{$u1av6at1=0;}
        if(
$a1['at6']==2){$u1av6at2=$a1['u6']*(av(6,$a1['rasa'])+(av(6,$a1['rasa'])/10));}else{$u1av6at2=0;}
        if(
$a1['at6']==3){$u1av6at3=$a1['u6']*(av(6,$a1['rasa'])+(av(6,$a1['rasa'])/10));}else{$u1av6at3=0;}
        
//u7
        
$u1l7=intval($a1['u7']*(live(7,$a1['rasa'])+((live(7,$a1['rasa'])/10)*$r1['r7'])));
        
////////////
        
if($a1['at7']==1){$u1az7at1=$a1['u7']*(az(7,$a1['rasa'])+(az(7,$a1['rasa'])/10));}else{$u1az7at1=0;}
        if(
$a1['at7']==2){$u1az7at2=$a1['u7']*(az(7,$a1['rasa'])+(az(7,$a1['rasa'])/10));}else{$u1az7at2=0;}
        if(
$a1['at7']==3){$u1az7at3=$a1['u7']*(az(7,$a1['rasa'])+(az(7,$a1['rasa'])/10));}else{$u1az7at3=0;}
        
////////////
        
if($a1['at7']==1){$u1av7at1=$a1['u7']*(av(7,$a1['rasa'])+(av(7,$a1['rasa'])/10));}else{$u1av7at1=0;}
        if(
$a1['at7']==2){$u1av7at2=$a1['u7']*(av(7,$a1['rasa'])+(av(7,$a1['rasa'])/10));}else{$u1av7at2=0;}
        if(
$a1['at7']==3){$u1av7at3=$a1['u7']*(av(7,$a1['rasa'])+(av(7,$a1['rasa'])/10));}else{$u1av7at3=0;}
        
//u8
        
$u1l8=intval($a1['u8']*(live(8,$a1['rasa'])+((live(8,$a1['rasa'])/10)*$r1['r8'])));
        
////////////
        
if($a1['at8']==1){$u1az8at1=$a1['u8']*(az(8,$a1['rasa'])+(az(8,$a1['rasa'])/10));}else{$u1az8at1=0;}
        if(
$a1['at8']==2){$u1az8at2=$a1['u8']*(az(8,$a1['rasa'])+(az(8,$a1['rasa'])/10));}else{$u1az8at2=0;}
        if(
$a1['at8']==3){$u1az8at3=$a1['u8']*(az(8,$a1['rasa'])+(az(8,$a1['rasa'])/10));}else{$u1az8at3=0;}
        
////////////
        
if($a1['at8']==1){$u1av8at1=$a1['u8']*(av(8,$a1['rasa'])+(av(8,$a1['rasa'])/10));}else{$u1av8at1=0;}
        if(
$a1['at8']==2){$u1av8at2=$a1['u8']*(av(8,$a1['rasa'])+(av(8,$a1['rasa'])/10));}else{$u1av8at2=0;}
        if(
$a1['at8']==3){$u1av8at3=$a1['u8']*(av(8,$a1['rasa'])+(av(8,$a1['rasa'])/10));}else{$u1av8at3=0;}
        
//u9
        
$u1l9=intval($a1['u9']*(live(9,$a1['rasa'])+((live(9,$a1['rasa'])/10)*$r1['r9'])));
        
////////////
        
if($a1['at9']==1){$u1az9at1=$a1['u9']*(az(9,$a1['rasa'])+(az(9,$a1['rasa'])/10));}else{$u1az9at1=0;}
        if(
$a1['at9']==2){$u1az9at2=$a1['u9']*(az(9,$a1['rasa'])+(az(9,$a1['rasa'])/10));}else{$u1az9at2=0;}
        if(
$a1['at9']==3){$u1az9at3=$a1['u9']*(az(9,$a1['rasa'])+(az(9,$a1['rasa'])/10));}else{$u1az9at3=0;}
        
////////////
        
if($a1['at9']==1){$u1av9at1=$a1['u9']*(av(9,$a1['rasa'])+(av(9,$a1['rasa'])/10));}else{$u1av9at1=0;}
        if(
$a1['at9']==2){$u1av9at2=$a1['u9']*(av(9,$a1['rasa'])+(av(9,$a1['rasa'])/10));}else{$u1av9at2=0;}
        if(
$a1['at9']==3){$u1av9at3=$a1['u9']*(av(9,$a1['rasa'])+(av(9,$a1['rasa'])/10));}else{$u1av9at3=0;}
        
//u10
        
$u1l10=intval($a1['u10']*(live(10,$a1['rasa'])+((live(10,$a1['rasa'])/10)*$r1['r10'])));
        
////////////
        
if($a1['at10']==1){$u1az10at1=$a1['u10']*(az(10,$a1['rasa'])+(az(10,$a1['rasa'])/10));}else{$u1az10at1=0;}
        if(
$a1['at10']==2){$u1az10at2=$a1['u10']*(az(10,$a1['rasa'])+(az(10,$a1['rasa'])/10));}else{$u1az10at2=0;}
        if(
$a1['at10']==3){$u1az10at3=$a1['u10']*(az(10,$a1['rasa'])+(az(10,$a1['rasa'])/10));}else{$u1az10at3=0;}
        
////////////
        
if($a1['at10']==1){$u1av10at1=$a1['u10']*(av(10,$a1['rasa'])+(av(10,$a1['rasa'])/10));}else{$u1av10at1=0;}
        if(
$a1['at10']==2){$u1av10at2=$a1['u10']*(av(10,$a1['rasa'])+(av(10,$a1['rasa'])/10));}else{$u1av10at2=0;}
        if(
$a1['at10']==3){$u1av10at3=$a1['u10']*(av(10,$a1['rasa'])+(av(10,$a1['rasa'])/10));}else{$u1av10at3=0;}
        
//u11
        
$u1l11=intval($a1['u11']*(live(11,$a1['rasa'])+((live(11,$a1['rasa'])/10)*$r1['r11'])));
        
////////////
        
if($a1['at11']==1){$u1az11at1=$a1['u11']*(az(11,$a1['rasa'])+(az(11,$a1['rasa'])/10));}else{$u1az11at1=0;}
        if(
$a1['at11']==2){$u1az11at2=$a1['u11']*(az(11,$a1['rasa'])+(az(11,$a1['rasa'])/10));}else{$u1az11at2=0;}
        if(
$a1['at11']==3){$u1az11at3=$a1['u11']*(az(11,$a1['rasa'])+(az(11,$a1['rasa'])/10));}else{$u1az11at3=0;}
        
////////////
        
if($a1['at11']==1){$u1av11at1=$a1['u11']*(av(11,$a1['rasa'])+(av(11,$a1['rasa'])/10));}else{$u1av11at1=0;}
        if(
$a1['at11']==2){$u1av11at2=$a1['u11']*(av(11,$a1['rasa'])+(av(11,$a1['rasa'])/10));}else{$u1av11at2=0;}
        if(
$a1['at11']==3){$u1av11at3=$a1['u11']*(av(11,$a1['rasa'])+(av(11,$a1['rasa'])/10));}else{$u1av11at3=0;}
        
//u12
        
$u1l12=intval($a1['u12']*(live(12,$a1['rasa'])+((live(12,$a1['rasa'])/10)*$r1['r12'])));
        
////////////
        
if($a1['at12']==1){$u1az12at1=$a1['u12']*(az(12,$a1['rasa'])+(az(12,$a1['rasa'])/10));}else{$u1az12at1=0;}
        if(
$a1['at12']==2){$u1az12at2=$a1['u12']*(az(12,$a1['rasa'])+(az(12,$a1['rasa'])/10));}else{$u1az12at2=0;}
        if(
$a1['at12']==3){$u1az12at3=$a1['u12']*(az(12,$a1['rasa'])+(az(12,$a1['rasa'])/10));}else{$u1az12at3=0;}
        
////////////
        
if($a1['at12']==1){$u1av12at1=$a1['u12']*(av(12,$a1['rasa'])+(av(12,$a1['rasa'])/10));}else{$u1av12at1=0;}
        if(
$a1['at12']==2){$u1av12at2=$a1['u12']*(av(12,$a1['rasa'])+(av(12,$a1['rasa'])/10));}else{$u1av12at2=0;}
        if(
$a1['at12']==3){$u1av12at3=$a1['u12']*(av(12,$a1['rasa'])+(av(12,$a1['rasa'])/10));}else{$u1av12at3=0;}
        
        
$l1type1=$u1l1+$u1l2+$u1l3+$u1l4;
        
$l1type2=$u1l5+$u1l6+$u1l7;
        
$l1type3=$u1l8+$u1l9+$u1l10+$u1l11+$u1l12;
        
        
$az1at1=$u1az1at1+$u1az2at1+$u1az3at1+$u1az4at1+$u1az5at1+$u1az6at1+$u1az7at1+$u1az8at1+$u1az9at1+$u1az10at1+$u1az11at1+$u1az12at1;
        
$az1at2=$u1az1at2+$u1az2at2+$u1az3at2+$u1az4at2+$u1az5at2+$u1az6at2+$u1az7at2+$u1az8at2+$u1az9at2+$u1az10at2+$u1az11at2+$u1az12at2;
        
$az1at3=$u1az1at3+$u1az2at3+$u1az3at3+$u1az4at3+$u1az5at3+$u1az6at3+$u1az7at3+$u1az8at3+$u1az9at3+$u1az10at3+$u1az11at3+$u1az12at3;
        
$av1at1=$u1av1at1+$u1av2at1+$u1av3at1+$u1av4at1+$u1av5at1+$u1av6at1+$u1av7at1+$u1av8at1+$u1av9at1+$u1av10at1+$u1av11at1+$u1av12at1;
        
$av1at2=$u1av1at2+$u1av2at2+$u1av3at2+$u1av4at2+$u1av5at2+$u1av6at2+$u1av7at2+$u1av8at2+$u1av9at2+$u1av10at2+$u1av11at2+$u1av12at2;
        
$av1at3=$u1av1at3+$u1av2at3+$u1av3at3+$u1av4at3+$u1av5at3+$u1av6at3+$u1av7at3+$u1av8at3+$u1av9at3+$u1av10at3+$u1av11at3+$u1av12at3;
        
        
//ОТРЯД №2
        //u1
        
$u2l1=intval($a2['u1']*(live(1,$a2['rasa'])+((live(1,$a2['rasa'])/10)*$r2['r1'])));
        
////////////
        
if($a2['at1']==1){$u2az1at1=$a2['u1']*(az(1,$a2['rasa'])+(az(1,$a2['rasa'])/10));}else{$u2az1at1=0;}
        if(
$a2['at1']==2){$u2az1at2=$a2['u1']*(az(1,$a2['rasa'])+(az(1,$a2['rasa'])/10));}else{$u2az1at2=0;}
        if(
$a2['at1']==3){$u2az1at3=$a2['u1']*(az(1,$a2['rasa'])+(az(1,$a2['rasa'])/10));}else{$u2az1at3=0;}
        
////////////
        
if($a2['at1']==1){$u2av1at1=$a2['u1']*(av(1,$a2['rasa'])+(av(1,$a2['rasa'])/10));}else{$u2av1at1=0;}
        if(
$a2['at1']==2){$u2av1at2=$a2['u1']*(av(1,$a2['rasa'])+(av(1,$a2['rasa'])/10));}else{$u2av1at2=0;}
        if(
$a2['at1']==3){$u2av1at3=$a2['u1']*(av(1,$a2['rasa'])+(av(1,$a2['rasa'])/10));}else{$u2av1at3=0;}
        
//u2
        
$u2l2=intval($a2['u2']*(live(2,$a2['rasa'])+((live(2,$a2['rasa'])/10)*$r2['r2'])));
        
////////////
        
if($a2['at2']==1){$u2az2at1=$a2['u2']*(az(2,$a2['rasa'])+(az(2,$a2['rasa'])/10));}else{$u2az2at1=0;}
        if(
$a2['at2']==2){$u2az2at2=$a2['u2']*(az(2,$a2['rasa'])+(az(2,$a2['rasa'])/10));}else{$u2az2at2=0;}
        if(
$a2['at2']==3){$u2az2at3=$a2['u2']*(az(2,$a2['rasa'])+(az(2,$a2['rasa'])/10));}else{$u2az2at3=0;}
        
////////////
        
if($a2['at2']==1){$u2av2at1=$a2['u2']*(av(2,$a2['rasa'])+(av(2,$a2['rasa'])/10));}else{$u2av2at1=0;}
        if(
$a2['at2']==2){$u2av2at2=$a2['u2']*(av(2,$a2['rasa'])+(av(2,$a2['rasa'])/10));}else{$u2av2at2=0;}
        if(
$a2['at2']==3){$u2av2at3=$a2['u2']*(av(2,$a2['rasa'])+(av(2,$a2['rasa'])/10));}else{$u2av2at3=0;}
        
//u3
        
$u2l3=intval($a2['u3']*(live(3,$a2['rasa'])+((live(3,$a2['rasa'])/10)*$r2['r3'])));
        
////////////
        
if($a2['at3']==1){$u2az3at1=$a2['u3']*(az(3,$a2['rasa'])+(az(3,$a2['rasa'])/10));}else{$u2az3at1=0;}
        if(
$a2['at3']==2){$u2az3at2=$a2['u3']*(az(3,$a2['rasa'])+(az(3,$a2['rasa'])/10));}else{$u2az3at2=0;}
        if(
$a2['at3']==3){$u2az3at3=$a2['u3']*(az(3,$a2['rasa'])+(az(3,$a2['rasa'])/10));}else{$u2az3at3=0;}
        
////////////
        
if($a2['at3']==1){$u2av3at1=$a2['u3']*(av(3,$a2['rasa'])+(av(3,$a2['rasa'])/10));}else{$u2av3at1=0;}
        if(
$a2['at3']==2){$u2av3at2=$a2['u3']*(av(3,$a2['rasa'])+(av(3,$a2['rasa'])/10));}else{$u2av3at2=0;}
        if(
$a2['at3']==3){$u2av3at3=$a2['u3']*(av(3,$a2['rasa'])+(av(3,$a2['rasa'])/10));}else{$u2av3at3=0;}
        
//u4
        
$u2l4=intval($a2['u4']*(live(4,$a2['rasa'])+((live(4,$a2['rasa'])/10)*$r2['r4'])));
        
////////////
        
if($a2['at4']==1){$u2az4at1=$a2['u4']*(az(4,$a2['rasa'])+(az(4,$a2['rasa'])/10));}else{$u2az4at1=0;}
        if(
$a2['at4']==2){$u2az4at2=$a2['u4']*(az(4,$a2['rasa'])+(az(4,$a2['rasa'])/10));}else{$u2az4at2=0;}
        if(
$a2['at4']==3){$u2az4at3=$a2['u4']*(az(4,$a2['rasa'])+(az(4,$a2['rasa'])/10));}else{$u2az41at3=0;}
        
////////////
        
if($a2['at4']==1){$u2av4at1=$a2['u4']*(av(4,$a2['rasa'])+(av(4,$a2['rasa'])/10));}else{$u2av4at1=0;}
        if(
$a2['at4']==2){$u2av4at2=$a2['u4']*(av(4,$a2['rasa'])+(av(4,$a2['rasa'])/10));}else{$u2av4at2=0;}
        if(
$a2['at4']==3){$u2av4at3=$a2['u4']*(av(4,$a2['rasa'])+(av(4,$a2['rasa'])/10));}else{$u2av4at3=0;}
        
//u5
        
$u2l5=intval($a2['u5']*(live(5,$a2['rasa'])+((live(5,$a2['rasa'])/10)*$r2['r5'])));
        
////////////
        
if($a2['at5']==1){$u2az5at1=$a2['u5']*(az(5,$a2['rasa'])+(az(5,$a2['rasa'])/10));}else{$u2az5at1=0;}
        if(
$a2['at5']==2){$u2az5at2=$a2['u5']*(az(5,$a2['rasa'])+(az(5,$a2['rasa'])/10));}else{$u2az5at2=0;}
        if(
$a2['at5']==3){$u2az5at3=$a2['u5']*(az(5,$a2['rasa'])+(az(5,$a2['rasa'])/10));}else{$u2az5at3=0;}
        
////////////
        
if($a2['at5']==1){$u2av5at1=$a2['u5']*(av(5,$a2['rasa'])+(av(5,$a2['rasa'])/10));}else{$u2av5at1=0;}
        if(
$a2['at5']==2){$u2av5at2=$a2['u5']*(av(5,$a2['rasa'])+(av(5,$a2['rasa'])/10));}else{$u2av5at2=0;}
        if(
$a2['at5']==3){$u2av5at3=$a2['u5']*(av(5,$a2['rasa'])+(av(5,$a2['rasa'])/10));}else{$u2av5at3=0;}
        
//u6
        
$u2l6=intval($a2['u6']*(live(6,$a2['rasa'])+((live(6,$a2['rasa'])/10)*$r2['r6'])));
        
////////////
        
if($a2['at6']==1){$u2az6at1=$a2['u6']*(az(6,$a2['rasa'])+(az(6,$a2['rasa'])/10));}else{$u2az6at1=0;}
        if(
$a2['at6']==2){$u2az6at2=$a2['u6']*(az(6,$a2['rasa'])+(az(6,$a2['rasa'])/10));}else{$u2az6at2=0;}
        if(
$a2['at6']==3){$u2az6at3=$a2['u6']*(az(6,$a2['rasa'])+(az(6,$a2['rasa'])/10));}else{$u2az6at3=0;}
        
////////////
        
if($a2['at6']==1){$u2av6at1=$a2['u6']*(av(6,$a2['rasa'])+(av(6,$a2['rasa'])/10));}else{$u2av6at1=0;}
        if(
$a2['at6']==2){$u2av6at2=$a2['u6']*(av(6,$a2['rasa'])+(av(6,$a2['rasa'])/10));}else{$u2av6at2=0;}
        if(
$a2['at6']==3){$u2av6at3=$a2['u6']*(av(6,$a2['rasa'])+(av(6,$a2['rasa'])/10));}else{$u2av6at3=0;}
        
//u7
        
$u2l7=intval($a2['u7']*(live(7,$a2['rasa'])+((live(7,$a2['rasa'])/10)*$r2['r7'])));
        
////////////
        
if($a2['at7']==1){$u2az7at1=$a2['u7']*(az(7,$a2['rasa'])+(az(7,$a2['rasa'])/10));}else{$u2az7at1=0;}
        if(
$a2['at7']==2){$u2az7at2=$a2['u7']*(az(7,$a2['rasa'])+(az(7,$a2['rasa'])/10));}else{$u2az7at2=0;}
        if(
$a2['at7']==3){$u2az7at3=$a2['u7']*(az(7,$a2['rasa'])+(az(7,$a2['rasa'])/10));}else{$u2az7at3=0;}
        
////////////
        
if($a2['at7']==1){$u2av7at1=$a2['u7']*(av(7,$a2['rasa'])+(av(7,$a2['rasa'])/10));}else{$u2av7at1=0;}
        if(
$a2['at7']==2){$u2av7at2=$a2['u7']*(av(7,$a2['rasa'])+(av(7,$a2['rasa'])/10));}else{$u2av7at2=0;}
        if(
$a2['at7']==3){$u2av7at3=$a2['u7']*(av(7,$a2['rasa'])+(av(7,$a2['rasa'])/10));}else{$u2av7at3=0;}
        
//u8
        
$u2l8=intval($a2['u8']*(live(8,$a2['rasa'])+((live(8,$a2['rasa'])/10)*$r2['r8'])));
        
////////////
        
if($a2['at8']==1){$u2az8at1=$a2['u8']*(az(8,$a2['rasa'])+(az(8,$a2['rasa'])/10));}else{$u2az8at1=0;}
        if(
$a2['at8']==2){$u2az8at2=$a2['u8']*(az(8,$a2['rasa'])+(az(8,$a2['rasa'])/10));}else{$u2az8at2=0;}
        if(
$a2['at8']==3){$u2az8at3=$a2['u8']*(az(8,$a2['rasa'])+(az(8,$a2['rasa'])/10));}else{$u2az8at3=0;}
        
////////////
        
if($a2['at8']==1){$u2av8at1=$a2['u8']*(av(8,$a2['rasa'])+(av(8,$a2['rasa'])/10));}else{$u2av8at1=0;}
        if(
$a2['at8']==2){$u2av8at2=$a2['u8']*(av(8,$a2['rasa'])+(av(8,$a2['rasa'])/10));}else{$u2av8at2=0;}
        if(
$a2['at8']==3){$u2av8at3=$a2['u8']*(av(8,$a2['rasa'])+(av(8,$a2['rasa'])/10));}else{$u2av8at3=0;}
        
//u9
        
$u2l9=intval($a2['u9']*(live(9,$a2['rasa'])+((live(9,$a2['rasa'])/10)*$r2['r9'])));
        
////////////
        
if($a2['at9']==1){$u2az9at1=$a2['u9']*(az(9,$a2['rasa'])+(az(9,$a2['rasa'])/10));}else{$u2az9at1=0;}
        if(
$a2['at9']==2){$u2az9at2=$a2['u9']*(az(9,$a2['rasa'])+(az(9,$a2['rasa'])/10));}else{$u2az9at2=0;}
        if(
$a2['at9']==3){$u2az9at3=$a2['u9']*(az(9,$a2['rasa'])+(az(9,$a2['rasa'])/10));}else{$u2az9at3=0;}
        
////////////
        
if($a2['at9']==1){$u2av9at1=$a2['u9']*(av(9,$a2['rasa'])+(av(9,$a2['rasa'])/10));}else{$u2av9at1=0;}
        if(
$a2['at9']==2){$u2av9at2=$a2['u9']*(av(9,$a2['rasa'])+(av(9,$a2['rasa'])/10));}else{$u2av9at2=0;}
        if(
$a2['at9']==3){$u2av9at3=$a2['u9']*(av(9,$a2['rasa'])+(av(9,$a2['rasa'])/10));}else{$u2av9at3=0;}
        
//u10
        
$u2l10=intval($a2['u10']*(live(10,$a2['rasa'])+((live(10,$a2['rasa'])/10)*$r2['r10'])));
        
////////////
        
if($a2['at10']==1){$u2az10at1=$a2['u10']*(az(10,$a2['rasa'])+(az(10,$a2['rasa'])/10));}else{$u2az10at1=0;}
        if(
$a2['at10']==2){$u2az10at2=$a2['u10']*(az(10,$a2['rasa'])+(az(10,$a2['rasa'])/10));}else{$u2az10at2=0;}
        if(
$a2['at10']==3){$u2az10at3=$a2['u10']*(az(10,$a2['rasa'])+(az(10,$a2['rasa'])/10));}else{$u2az10at3=0;}
        
////////////
        
if($a2['at10']==1){$u2av10at1=$a2['u10']*(av(10,$a2['rasa'])+(av(10,$a2['rasa'])/10));}else{$u2av10at1=0;}
        if(
$a2['at10']==2){$u2av10at2=$a2['u10']*(av(10,$a2['rasa'])+(av(10,$a2['rasa'])/10));}else{$u2av10at2=0;}
        if(
$a2['at10']==3){$u2av10at3=$a2['u10']*(av(10,$a2['rasa'])+(av(10,$a2['rasa'])/10));}else{$u2av10at3=0;}
        
//u11
        
$u2l11=intval($a2['u11']*(live(11,$a2['rasa'])+((live(11,$a2['rasa'])/10)*$r2['r11'])));
        
////////////
        
if($a2['at11']==1){$u2az11at1=$a2['u11']*(az(11,$a2['rasa'])+(az(11,$a2['rasa'])/10));}else{$u2az11at1=0;}
        if(
$a2['at11']==2){$u2az11at2=$a2['u11']*(az(11,$a2['rasa'])+(az(11,$a2['rasa'])/10));}else{$u2az11at2=0;}
        if(
$a2['at11']==3){$u2az11at3=$a2['u11']*(az(11,$a2['rasa'])+(az(11,$a2['rasa'])/10));}else{$u2az11at3=0;}
        
////////////
        
if($a2['at11']==1){$u2av11at1=$a2['u11']*(av(11,$a2['rasa'])+(av(11,$a2['rasa'])/10));}else{$u2av11at1=0;}
        if(
$a2['at11']==2){$u2av11at2=$a2['u11']*(av(11,$a2['rasa'])+(av(11,$a2['rasa'])/10));}else{$u2av11at2=0;}
        if(
$a2['at11']==3){$u2av11at3=$a2['u11']*(av(11,$a2['rasa'])+(av(11,$a2['rasa'])/10));}else{$u2av11at3=0;}
        
//u12
        
$u2l12=intval($a2['u12']*(live(12,$a2['rasa'])+((live(12,$a2['rasa'])/10)*$r2['r12'])));
        
////////////
        
if($a2['at12']==1){$u2az12at1=$a2['u12']*(az(12,$a2['rasa'])+(az(12,$a2['rasa'])/10));}else{$u2az12at1=0;}
        if(
$a2['at12']==2){$u2az12at2=$a2['u12']*(az(12,$a2['rasa'])+(az(12,$a2['rasa'])/10));}else{$u2az12at2=0;}
        if(
$a2['at12']==3){$u2az12at3=$a2['u12']*(az(12,$a2['rasa'])+(az(12,$a2['rasa'])/10));}else{$u2az12at3=0;}
        
////////////
        
if($a2['at12']==1){$u2av12at1=$a2['u12']*(av(12,$a2['rasa'])+(av(12,$a2['rasa'])/10));}else{$u2av12at1=0;}
        if(
$a2['at12']==2){$u2av12at2=$a2['u12']*(av(12,$a2['rasa'])+(av(12,$a2['rasa'])/10));}else{$u2av12at2=0;}
        if(
$a2['at12']==3){$u2av12at3=$a2['u12']*(av(12,$a2['rasa'])+(av(12,$a2['rasa'])/10));}else{$u2av12at3=0;}
        
        
$l2type1=$u2l1+$u2l2+$u2l3+$u2l4;
        
$l2type2=$u2l5+$u2l6+$u2l7;
        
$l2type3=$u2l8+$u2l9+$u2l10+$u2l11+$u2l12;
        
        
$az2at1=$u2az1at1+$u2az2at1+$u2az3at1+$u2az4at1+$u2az5at1+$u2az6at1+$u2az7at1+$u2az8at1+$u2az9at1+$u2az10at1+$u2az11at1+$u2az12at1;
        
$az2at2=$u2az1at2+$u2az2at2+$u2az3at2+$u2az4at2+$u2az5at2+$u2az6at2+$u2az7at2+$u2az8at2+$u2az9at2+$u2az10at2+$u2az11at2+$u2az12at2;
        
$az2at3=$u2az1at3+$u2az2at3+$u2az3at3+$u2az4at3+$u2az5at3+$u2az6at3+$u2az7at3+$u2az8at3+$u2az9at3+$u2az10at3+$u2az11at3+$u2az12at3;
        
$av2at1=$u2av1at1+$u2av2at1+$u2av3at1+$u2av4at1+$u2av5at1+$u2av6at1+$u2av7at1+$u2av8at1+$u2av9at1+$u2av10at1+$u2av11at1+$u2av12at1;
        
$av2at2=$u2av1at2+$u2av2at2+$u2av3at2+$u2av4at2+$u2av5at2+$u2av6at2+$u2av7at2+$u2av8at2+$u2av9at2+$u2av10at2+$u2av11at2+$u2av12at2;
        
$av2at3=$u2av1at3+$u2av2at3+$u2av3at3+$u2av4at3+$u2av5at3+$u2av6at3+$u2av7at3+$u2av8at3+$u2av9at3+$u2av10at3+$u2av11at3+$u2av12at3;
        
        
        
$u1t1=($l1type1-$az2at1)/($l1type1/100);
        if(
$l1type1==0)$u1t1=100;
        if(
$u1t1<=0)$u1t1=0;
        
$u1t2=($l1type2-$az2at2)/($l1type2/100);
        if(
$l1type2==0)$u1t2=100;
        if(
$u1t2<=0)$u1t2=0;
        
$u1t3=($l1type3-$az2at3)/($l1type3/100);
        if(
$l1type3==0)$u1t3=100;
        if(
$u1t3<=0)$u1t3=0;
        
$u1t4=($l1type1-$av2at1)/($l1type1/100);
        if(
$l1type1==0)$u1t4=100;
        if(
$u1t4<=0)$u1t4=0;
        
$u1t5=($l1type2-$av2at2)/($l1type2/100);
        if(
$l1type2==0)$u1t5=100;
        if(
$u1t5<=0)$u1t5=0;
        
$u1t6=($l1type3-$av2at3)/($l1type3/100);
        if(
$l1type3==0)$u1t6=100;
        if(
$u1t6<=0)$u1t6=0;
        
        
        
$u2t1=($l2type1-$az1at1)/($l2type1/100);
        if(
$l2type1==0)$u2t1=100;
        if(
$u2t1<=0)$u2t1=0;
        
$u2t2=($l2type2-$az1at2)/($l2type2/100);
        if(
$l2type2==0)$u2t2=100;
        if(
$u2t2<=0)$u2t2=0;
        
$u2t3=($l2type3-$az1at3)/($l2type3/100);
        if(
$l2type3==0)$u2t3=100;
        if(
$u2t3<=0)$u2t3=0;
        
$u2t4=($l2type1-$av1at1)/($l2type1/100);
        if(
$l2type1==0)$u2t4=100;
        if(
$u2t4<=0)$u2t4=0;
        
$u2t5=($l2type2-$av1at2)/($l2type2/100);
        if(
$l2type2==0)$u2t5=100;
        if(
$u2t5<=0)$u2t5=0;
        
$u2t6=($l2type3-$av1at3)/($l2type3/100);
        if(
$l2type3==0)$u2t6=100;
        if(
$u2t6<=0)$u2t6=0;
        
        
$u1a1=intval(($a1['u1']-($a1['u1']/100)*$u1t1)+($a1['u1']-($a1['u1']/100)*$u1t4));
        
$u1a2=intval(($a1['u2']-($a1['u2']/100)*$u1t1)+($a1['u2']-($a1['u2']/100)*$u1t4));
        
$u1a3=intval(($a1['u3']-($a1['u3']/100)*$u1t1)+($a1['u3']-($a1['u3']/100)*$u1t4));
        
$u1a4=intval(($a1['u4']-($a1['u4']/100)*$u1t1)+($a1['u4']-($a1['u4']/100)*$u1t4));
        
$u1a5=intval(($a1['u5']-($a1['u5']/100)*$u1t2)+($a1['u5']-($a1['u5']/100)*$u1t5));
        
$u1a6=intval(($a1['u6']-($a1['u6']/100)*$u1t2)+($a1['u6']-($a1['u6']/100)*$u1t5));
        
$u1a7=intval(($a1['u7']-($a1['u7']/100)*$u1t2)+($a1['u7']-($a1['u7']/100)*$u1t5));
        
$u1a8=intval(($a1['u8']-($a1['u8']/100)*$u1t3)+($a1['u8']-($a1['u8']/100)*$u1t6));
        
$u1a9=intval(($a1['u9']-($a1['u9']/100)*$u1t3)+($a1['u9']-($a1['u9']/100)*$u1t6));
        
$u1a10=intval(($a1['u10']-($a1['u10']/100)*$u1t3)+($a1['u10']-($a1['u10']/100)*$u1t6));
        
$u1a11=intval(($a1['u11']-($a1['u11']/100)*$u1t3)+($a1['u11']-($a1['u11']/100)*$u1t6));
        
$u1a12=intval(($a1['u12']-($a1['u12']/100)*$u1t3)+($a1['u12']-($a1['u12']/100)*$u1t6));
        
        
$u2a1=intval(($a2['u1']-($a2['u1']/100)*$u2t1)+($a2['u1']-($a2['u1']/100)*$u2t4));
        
$u2a2=intval(($a2['u2']-($a2['u2']/100)*$u2t1)+($a2['u2']-($a2['u2']/100)*$u2t4));
        
$u2a3=intval(($a2['u3']-($a2['u3']/100)*$u2t1)+($a2['u3']-($a2['u3']/100)*$u2t4));
        
$u2a4=intval(($a2['u4']-($a2['u4']/100)*$u2t1)+($a2['u4']-($a2['u4']/100)*$u2t4));
        
$u2a5=intval(($a2['u5']-($a2['u5']/100)*$u2t2)+($a2['u5']-($a2['u5']/100)*$u2t5));
        
$u2a6=intval(($a2['u6']-($a2['u6']/100)*$u2t2)+($a2['u6']-($a2['u6']/100)*$u2t5));
        
$u2a7=intval(($a2['u7']-($a2['u7']/100)*$u2t2)+($a2['u7']-($a2['u7']/100)*$u2t5));
        
$u2a8=intval(($a2['u8']-($a2['u8']/100)*$u2t3)+($a2['u8']-($a2['u8']/100)*$u2t6));
        
$u2a9=intval(($a2['u9']-($a2['u9']/100)*$u2t3)+($a2['u9']-($a2['u9']/100)*$u2t6));
        
$u2a10=intval(($a2['u10']-($a2['u10']/100)*$u2t3)+($a2['u10']-($a2['u10']/100)*$u2t6));
        
$u2a11=intval(($a2['u11']-($a2['u11']/100)*$u2t3)+($a2['u11']-($a2['u11']/100)*$u2t6));
        
$u2a12=intval(($a2['u12']-($a2['u12']/100)*$u2t3)+($a2['u12']-($a2['u12']/100)*$u2t6));
        
        if(
$u1a1<or $u1a1>$a1['u1'])$u1a1=$a1['u1'];
        if(
$u1a2<or $u1a2>$a1['u2'])$u1a2=$a1['u2'];
        if(
$u1a3<or $u1a3>$a1['u3'])$u1a3=$a1['u3'];
        if(
$u1a4<or $u1a4>$a1['u4'])$u1a4=$a1['u4'];
        if(
$u1a5<or $u1a5>$a1['u5'])$u1a5=$a1['u5'];
        if(
$u1a6<or $u1a6>$a1['u6'])$u1a6=$a1['u6'];
        if(
$u1a7<or $u1a7>$a1['u7'])$u1a7=$a1['u7'];
        if(
$u1a8<or $u1a8>$a1['u8'])$u1a8=$a1['u8'];
        if(
$u1a9<or $u1a9>$a1['u9'])$u1a9=$a1['u9'];
        if(
$u1a10<or $u1a10>$a1['u10'])$u1a10=$a1['u10'];
        if(
$u1a11<or $u1a11>$a1['u11'])$u1a11=$a1['u11'];
        if(
$u1a12<or $u1a12>$a1['u12'])$u1a12=$a1['u12'];
        if(
$u1a13<or $u1a13>$a1['u13'])$u1a13=$a1['u13'];
        
        
        if(
$u2a1<or $u2a1>$a2['u1'])$u2a1=$a2['u1'];
        if(
$u2a2<or $u2a2>$a2['u2'])$u2a2=$a2['u2'];
        if(
$u2a3<or $u2a3>$a2['u3'])$u2a3=$a2['u3'];
        if(
$u2a4<or $u2a4>$a2['u4'])$u2a4=$a2['u4'];
        if(
$u2a5<or $u2a5>$a2['u5'])$u2a5=$a2['u5'];
        if(
$u2a6<or $u2a6>$a2['u6'])$u2a6=$a2['u6'];
        if(
$u2a7<or $u2a7>$a2['u7'])$u2a7=$a2['u7'];
        if(
$u2a8<or $u2a8>$a2['u8'])$u2a8=$a2['u8'];
        if(
$u2a9<or $u2a9>$a2['u9'])$u2a9=$a2['u9'];
        if(
$u2a10<or $u2a10>$a2['u10'])$u2a10=$a2['u10'];
        if(
$u2a11<or $u2a11>$a2['u11'])$u2a11=$a2['u11'];
        if(
$u2a12<or $u2a12>$a2['u12'])$u2a12=$a2['u12'];
        if(
$u2a13<or $u2a13>$a2['u13'])$u2a13=$a2['u13'];
        
        
$units1=($a1['u1']-$u1a1)+($a1['u2']-$u1a2)+($a1['u3']-$u1a3)+($a1['u4']-$u1a4)+($a1['u5']-$u1a5)+($a1['u6']-$u1a6)+($a1['u7']-$u1a7)+($a1['u9']-$u1a9)+($a1['u10']-$u1a10)+($a1['u11']-$u1a11)+($a1['u12']-$u1a12);
        
$units2=($a2['u1']-$u2a1)+($a2['u2']-$u2a2)+($a2['u3']-$u2a3)+($a2['u4']-$u2a4)+($a2['u5']-$u2a5)+($a2['u6']-$u2a6)+($a2['u7']-$u2a7)+($a2['u9']-$u2a9)+($a2['u10']-$u2a10)+($a2['u11']-$u2a11)+($a2['u12']-$u2a12);
        
//echo '<div class="c">Армия '.$a1['name'].'<br/>ЛН: '.$l1type1.' - '.$az2at1.' <b>['.$u1t1.'% | '.$u1t4.'%]</b>/ТН: '.$l1type2.' - '.$az2at2.' <b>['.$u1t2.'% | '.$u1t5.'%]</b>/ВЗД: '.$l1type3.' - '.$az2at3.'/'.$av1at3.' <b>['.$u1t3.'% | '.$u1t6.'%]</b></div>';
        //echo '<div class="c">Армия '.$a2['name'].'<br/>ЛН: '.$l2type1.' - '.$az1at1.' <b>['.$u2t1.'% | '.$u2t4.'%]</b>/ТН: '.$l2type2.' - '.$az1at2.' <b>['.$u2t2.'% | '.$u2t5.'%]</b>/ВЗД: '.$l2type3.' - '.$az1at3.'/'.$av2at3.' <b>['.$u2t3.'% | '.$u2t6.'%]</b></div>';
        
if($u1t1+$u1t2+$u1t3+$u1t4+$u1t5+$u1t6>=$u2t1+$u2t2+$u2t3+$u2t4+$u2t5+$u2t6){
        
$result1=1;
        
$result2=2;
        }
        if(
$u1t1+$u1t2+$u1t3+$u1t4+$u1t5+$u1t6<$u2t1+$u2t2+$u2t3+$u2t4+$u2t5+$u2t6){
        
$result1=2;
        
$result2=1;
        }
        
        
/////Очки опыта фракции
        
$opyt1=($u2a1*live(1,$a2['rasa']))+($u2a2*live(2,$a2['rasa']))+($u2a3*live(3,$a2['rasa']))+($u2a4*live(4,$a2['rasa']))+($u2a5*live(5,$a2['rasa']))+($u2a6*live(6,$a2['rasa']))+($u2a7*live(7,$a2['rasa']))+($u2a8*live(8,$a2['rasa']))+($u2a9*live(9,$a2['rasa']))+($u2a10*live(10,$a2['rasa']))+($u2a11*live(11,$a2['rasa']))+($u2a12*live(12,$a2['rasa']));
        
$fropyt1=$opyt1/100;
        
$fropyt1=round($fropyt12);
        if(
$fr_id!=0)mysql_query("UPDATE `fractions` SET `opyt`=opyt+'".$fropyt1."' WHERE `id`='".$fr_id."';");
        
$opyt2=($u1a1*live(1,$a1['rasa']))+($u1a2*live(2,$a1['rasa']))+($u1a3*live(3,$a1['rasa']))+($u1a4*live(4,$a1['rasa']))+($u1a5*live(5,$a1['rasa']))+($u1a6*live(6,$a1['rasa']))+($u1a7*live(7,$a1['rasa']))+($u1a8*live(8,$a1['rasa']))+($u1a9*live(9,$a1['rasa']))+($u1a10*live(10,$a1['rasa']))+($u1a11*live(11,$a1['rasa']))+($u1a12*live(12,$a1['rasa']));
        
$fropyt2=$opyt2/100;
        
$fropyt2=round($fropyt22);
        if(
$u['fr_id']!=0)mysql_query("UPDATE `fractions` SET `opyt`=opyt+'".$fropyt2."' WHERE `id`='".$u['fr_id']."';");
        
        
        
mysql_query("INSERT INTO `log_battle` SET `aid1`='".$a1['id']."', `aid2`='".$a2['id']."', `rasa1`='".$a1['rasa']."', `rasa2`='".$a2['rasa']."', `name1`='".$a1['name']."', `name2`='".$a2['name']."', `time`='".time()."', `result`='".$result1."', `uid`='".$a1['uid']."',
            `d1`='"
.$u1a1."',
            `d2`='"
.$u1a2."',
            `d3`='"
.$u1a3."',
            `d4`='"
.$u1a4."',
            `d5`='"
.$u1a5."',
            `d6`='"
.$u1a6."',
            `d7`='"
.$u1a7."',
            `d8`='"
.$u1a8."',
            `d9`='"
.$u1a9."',
            `d10`='"
.$u1a10."',
            `d11`='"
.$u1a11."',
            `d12`='"
.$u1a12."',
            `u1`='"
.$a1['u1']."',
            `u2`='"
.$a1['u2']."',
            `u3`='"
.$a1['u3']."',
            `u4`='"
.$a1['u4']."',
            `u5`='"
.$a1['u5']."',
            `u6`='"
.$a1['u6']."',
            `u7`='"
.$a1['u7']."',
            `u8`='"
.$a1['u8']."',
            `u9`='"
.$a1['u9']."',
            `u10`='"
.$a1['u10']."',
            `u11`='"
.$a1['u11']."',
            `u12`='"
.$a1['u12']."';");
            
mysql_query("INSERT INTO `log_battle` SET `aid1`='".$a2['id']."', `aid2`='".$a1['id']."', `rasa1`='".$a2['rasa']."', `rasa2`='".$a1['rasa']."', `name1`='".$a2['name']."', `name2`='".$a1['name']."',  `time`='".time()."', `result`='".$result2."', `uid`='".$a2['uid']."',
            `d1`='"
.$u2a1."',
            `d2`='"
.$u2a2."',
            `d3`='"
.$u2a3."',
            `d4`='"
.$u2a4."',
            `d5`='"
.$u2a5."',
            `d6`='"
.$u2a6."',
            `d7`='"
.$u2a7."',
            `d8`='"
.$u2a8."',
            `d9`='"
.$u2a9."',
            `d10`='"
.$u2a10."',
            `d11`='"
.$u2a11."',
            `d12`='"
.$u2a12."',
            `u1`='"
.$a2['u1']."',
            `u2`='"
.$a2['u2']."',
            `u3`='"
.$a2['u3']."',
            `u4`='"
.$a2['u4']."',
            `u5`='"
.$a2['u5']."',
            `u6`='"
.$a2['u6']."',
            `u7`='"
.$a2['u7']."',
            `u8`='"
.$a2['u8']."',
            `u9`='"
.$a2['u9']."',
            `u10`='"
.$a2['u10']."',
            `u11`='"
.$a2['u11']."',
            `u12`='"
.$a2['u12']."';");    
        
mysql_query("UPDATE `army` SET
            `time`=
$realtime+300,
            `u1`=u1-'"
.$u1a1."',
            `u2`=u2-'"
.$u1a2."',
            `u3`=u3-'"
.$u1a3."',
            `u4`=u4-'"
.$u1a4."',
            `u5`=u5-'"
.$u1a5."',
            `u6`=u6-'"
.$u1a6."',
            `u7`=u7-'"
.$u1a7."',
            `u8`=u8-'"
.$u1a8."',
            `u9`=u9-'"
.$u1a9."',
            `u10`=u10-'"
.$u1a10."',
            `u11`=u11-'"
.$u1a11."',
            `u12`=u12-'"
.$u1a12."' WHERE `id`='".$a1['id']."';");
        
mysql_query("UPDATE `army` SET
            `time`=
$realtime+300,
            `u1`=u1-'"
.$u2a1."',
            `u2`=u2-'"
.$u2a2."',
            `u3`=u3-'"
.$u2a3."',
            `u4`=u4-'"
.$u2a4."',
            `u5`=u5-'"
.$u2a5."',
            `u6`=u6-'"
.$u2a6."',
            `u7`=u7-'"
.$u2a7."',
            `u8`=u8-'"
.$u2a8."',
            `u9`=u9-'"
.$u2a9."',
            `u10`=u10-'"
.$u2a10."',
            `u11`=u11-'"
.$u2a11."',
            `u12`=u12-'"
.$u2a12."' WHERE `id`='".$a2['id']."';");
            
        if(
$u1t1+$u1t2+$u1t3+$u1t4+$u1t5+$u1t6==$u2t1+$u2t2+$u2t3+$u2t4+$u2t5+$u2t6){
        echo 
'<div class="cont"><span class="green">Отряды в сражении получили одинаковое кол-во урона!</span></div>';
        }    
            
        if(
$u1t1+$u1t2+$u1t3+$u1t4+$u1t5+$u1t6>$u2t1+$u2t2+$u2t3+$u2t4+$u2t5+$u2t6){
        echo 
'<div class="cont"><span class="green">Ваш отряд выиграл сражение!</span></div>';
        if(
$a2['xpl']>7)$otrx=$a2['xpl']-1;
        if(
$a2['xpl']<7)$otrx=$a2['xpl']+1;
        if(
$a2['xpl']==7)$otrx=$a2['xpl'];
        if(
$a2['xpl']!=7)$otry=$a2['ypl'];
        if(
$a2['xpl']==AND $a2['ypl']>7)$otry=$a2['ypl']-1;
        if(
$a2['xpl']==AND $a2['ypl']<7)$otry=$a2['ypl']+1;
        if(
$a2['ypl']==7)$otry=$a2['ypl'];
        
mysql_query("UPDATE `army` SET `xpl`='".$otrx."', `ypl`='".$otry."' WHERE `id`='".$a2['id']."';");
        }
        if(
$u1t1+$u1t2+$u1t3+$u1t4+$u1t5+$u1t6<$u2t1+$u2t2+$u2t3+$u2t4+$u2t5+$u2t6){
        echo 
'<div class="cont"><span class="red">Ваш отряд проиграл сражение!</span></div>';
        if(
$a1['xpl']>7)$otrx=$a1['xpl']-1;
        if(
$a1['xpl']<7)$otrx=$a1['xpl']+1;
        if(
$a1['xpl']==7)$otrx=$a1['xpl'];
        if(
$a1['xpl']!=7)$otry=$a1['ypl'];
        if(
$a1['xpl']==AND $a1['ypl']>7)$otry=$a1['ypl']-1;
        if(
$a1['xpl']==AND $a1['ypl']<7)$otry=$a1['ypl']+1;
        if(
$a1['ypl']==7)$otry=$a1['ypl'];
        
mysql_query("UPDATE `army` SET `xpl`='".$otrx."', `ypl`='".$otry."' WHERE `id`='".$a1['id']."';");
        }
        if(
$units1<=0){
        
$h mysql_query("SELECT * FROM `war` WHERE `uid1`='".$a1['uid']."' AND `uid2`='".$pl['uid']."' AND `planet`='".$a1['onpl']."'");
        
$w mysql_fetch_array($h);
        if(
$w['name']!='')$onpl mysql_result(mysql_query("SELECT COUNT(*) FROM `army` WHERE `onpl`='".$a1['onpl']."' AND `uid`='".$a1['uid']."';"), 0);
        if(
$onpl-1==0){
        
mysql_query("UPDATE `sosed` SET `war`=0 WHERE `uid1`='".$a1['uid']."' AND `uid2`='".$pl['uid']."' AND `planet`='".$a1['onpl']."';");
        
mysql_query("UPDATE `planet_loc` SET `uid`='".$pl['uid']."', `occupy`=0 WHERE `planet_id`='".$a1['onpl']."' AND `uid`='".$a1['uid']."';");
        
mysql_query("DELETE FROM `war` WHERE `id`='".$w['id']."';");
                            }
        
$apl1 mysql_query("SELECT * FROM `planet` WHERE `id`='".$a1['planet']."'");
        
$apl mysql_fetch_array($apl1);
        
mysql_query("INSERT INTO `doklad` SET `uid`='".$a1['uid']."', `time`='" time() . "', `type`=4, `text`='Ваш отряд <b>".$a1['name']."</b> был разбит отрядом <b>".$a2['name']."</b> на локации x:".$pl['x']." y:".$pl['y']." планеты <b>".$pl['name']."</b>';");
        
mysql_query("UPDATE `army` SET `xpl`=7, `ypl`=7, `onpl`='".$apl['id']."', `x`='".$apl['x']."', `y`='".$apl['y']."' WHERE `id`='".$a1['id']."';");
        
mysql_query("UPDATE `sector_loc` SET `x`='".$apl['x']."', `y`='".$apl['y']."' WHERE `aid`='".$a1['id']."';");
        }
        if(
$units2<=0){
        
$h mysql_query("SELECT * FROM `war` WHERE `uid1`='".$a2['uid']."' AND `uid2`='".$pl['uid']."' AND `planet`='".$a2['onpl']."'");
        
$w mysql_fetch_array($h);
        if(
$w['name']!='')$onpl mysql_result(mysql_query("SELECT COUNT(*) FROM `army` WHERE `onpl`='".$a2['onpl']."' AND `uid`='".$a2['uid']."';"), 0);
        if(
$onpl-1==0){
        
mysql_query("UPDATE `sosed` SET `war`=0 WHERE `uid1`='".$a2['uid']."' AND `uid2`='".$pl['uid']."' AND `planet`='".$a2['onpl']."';");
        
mysql_query("UPDATE `planet_loc` SET `uid`='".$pl['uid']."', `occupy`=0 WHERE `planet_id`='".$a2['onpl']."' AND `uid`='".$a2['uid']."';");
        
mysql_query("DELETE FROM `war` WHERE `id`='".$w['id']."';");
                            }
        
$apl1 mysql_query("SELECT * FROM `planet` WHERE `id`='".$a2['planet']."'");
        
$apl mysql_fetch_array($apl1);
        
mysql_query("INSERT INTO `doklad` SET `uid`='".$a2['uid']."', `time`='" time() . "', `type`=4, `text`='Ваш отряд <b>".$a2['name']."</b> был разбит отрядом <b>".$a1['name']."</b> на локации x:".$pl['x']." y:".$pl['y']." планеты <b>".$pl['name']."</b>';");
        
mysql_query("UPDATE `army` SET `xpl`=7, `ypl`=7, `onpl`='".$apl['id']."', `x`='".$apl['x']."', `y`='".$apl['y']."' WHERE `id`='".$a2['id']."';");
        
mysql_query("UPDATE `sector_loc` SET `x`='".$apl['x']."', `y`='".$apl['y']."' WHERE `aid`='".$a2['id']."';");
        }
        
        echo 
'<div class="top">Отряд '.rasa($a1['rasa']).' <span class="'.crasa($a1['rasa']).'">'.$a1['name'].'</span> [<span class="green">ваш</span>]
        <br/>Получил '
.$opyt2.' ед. урона</div>';
        echo 
'<div class="conts">';
        if(
$a1['u1']!=0)echo ''.rasa($a1['rasa']).' '.units(1$a1['rasa']).': '.$a1['u1'].' [<span class="green">-'.$u1a1.'</span>]<br/>';
        if(
$a1['u2']!=0)echo ''.rasa($a1['rasa']).' '.units(2$a1['rasa']).': '.$a1['u2'].' [<span class="green">-'.$u1a2.'</span>]<br/>';
        if(
$a1['u3']!=0)echo ''.rasa($a1['rasa']).' '.units(3$a1['rasa']).': '.$a1['u3'].' [<span class="green">-'.$u1a3.'</span>]<br/>';
        if(
$a1['u4']!=0)echo ''.rasa($a1['rasa']).' '.units(4$a1['rasa']).': '.$a1['u4'].' [<span class="green">-'.$u1a4.'</span>]<br/>';
        if(
$a1['u5']!=0)echo ''.rasa($a1['rasa']).' '.units(5$a1['rasa']).': '.$a1['u5'].' [<span class="green">-'.$u1a5.'</span>]<br/>';
        if(
$a1['u6']!=0)echo ''.rasa($a1['rasa']).' '.units(6$a1['rasa']).': '.$a1['u6'].' [<span class="green">-'.$u1a6.'</span>]<br/>';
        if(
$a1['u7']!=0)echo ''.rasa($a1['rasa']).' '.units(7$a1['rasa']).': '.$a1['u7'].' [<span class="green">-'.$u1a7.'</span>]<br/>';
        if(
$a1['u8']!=0)echo ''.rasa($a1['rasa']).' '.units(8$a1['rasa']).': '.$a1['u8'].' [<span class="green">-'.$u1a8.'</span>]<br/>';
        if(
$a1['u9']!=0)echo ''.rasa($a1['rasa']).' '.units(9$a1['rasa']).': '.$a1['u9'].' [<span class="green">-'.$u1a9.'</span>]<br/>';
        if(
$a1['u10']!=0)echo ''.rasa($a1['rasa']).' '.units(10$a1['rasa']).': '.$a1['u10'].' [<span class="green">-'.$u1a10.'</span>]<br/>';
        if(
$a1['u11']!=0)echo ''.rasa($a1['rasa']).' '.units(11$a1['rasa']).': '.$a1['u11'].' [<span class="green">-'.$u1a11.'</span>]<br/>';
        if(
$a1['u12']!=0)echo ''.rasa($a1['rasa']).' '.units(12$a1['rasa']).': '.$a1['u12'].' [<span class="green">-'.$u1a12.'</span>]<br/>';
        echo 
'</div>';
        echo 
'<div class="top">Отряд '.rasa($a2['rasa']).' <span class="'.crasa($a2['rasa']).'">'.$a2['name'].'</span> [<span class="red">противник</span>]
        <br/>Получил '
.$opyt1.' ед. урона</div>';
        echo 
'<div class="conts">';
        if(
$a2['u1']!=0)echo ''.rasa($a2['rasa']).' '.units(1$a2['rasa']).': '.$a2['u1'].' [<span class="green">-'.$u2a1.'</span>]<br/>';
        if(
$a2['u2']!=0)echo ''.rasa($a2['rasa']).' '.units(2$a2['rasa']).': '.$a2['u2'].' [<span class="green">-'.$u2a2.'</span>]<br/>';
        if(
$a2['u3']!=0)echo ''.rasa($a2['rasa']).' '.units(3$a2['rasa']).': '.$a2['u3'].' [<span class="green">-'.$u2a3.'</span>]<br/>';
        if(
$a2['u4']!=0)echo ''.rasa($a2['rasa']).' '.units(4$a2['rasa']).': '.$a2['u4'].' [<span class="green">-'.$u2a4.'</span>]<br/>';
        if(
$a2['u5']!=0)echo ''.rasa($a2['rasa']).' '.units(5$a2['rasa']).': '.$a2['u5'].' [<span class="green">-'.$u2a5.'</span>]<br/>';
        if(
$a2['u6']!=0)echo ''.rasa($a2['rasa']).' '.units(6$a2['rasa']).': '.$a2['u6'].' [<span class="green">-'.$u2a6.'</span>]<br/>';
        if(
$a2['u7']!=0)echo ''.rasa($a2['rasa']).' '.units(7$a2['rasa']).': '.$a2['u7'].' [<span class="green">-'.$u2a7.'</span>]<br/>';
        if(
$a2['u8']!=0)echo ''.rasa($a2['rasa']).' '.units(8$a2['rasa']).': '.$a2['u8'].' [<span class="green">-'.$u2a8.'</span>]<br/>';
        if(
$a2['u9']!=0)echo ''.rasa($a2['rasa']).' '.units(9$a2['rasa']).': '.$a2['u9'].' [<span class="green">-'.$u2a9.'</span>]<br/>';
        if(
$a2['u10']!=0)echo ''.rasa($a2['rasa']).' '.units(10$a2['rasa']).': '.$a2['u10'].' [<span class="green">-'.$u2a10.'</span>]<br/>';
        if(
$a2['u11']!=0)echo ''.rasa($a2['rasa']).' '.units(11$a2['rasa']).': '.$a2['u11'].' [<span class="green">-'.$u2a11.'</span>]<br/>';
        if(
$a2['u12']!=0)echo ''.rasa($a2['rasa']).' '.units(12$a2['rasa']).': '.$a2['u12'].' [<span class="green">-'.$u2a12.'</span>]<br/>';
        echo 
'</div>';
        echo 
'<div class="conts"><a href="../game/pl_army.php?a='.$a1['id'].'"><<К отряду</a></div>';
}}}}}}
div('<a href="../">В игру</a>','conts');
require_once 
'../includes/footer.php';
?>
Онлайн: 0
Реклама