Вход Регистрация
Файл: ewar/dung.php
Строк: 413
<?php

    
include("includes/config.php");
    include(
"includes/header.php");
    include(
"class/dung.php");
    
    
$dm authUser();
    
    if (!
$dm) {
    
        
header("Location: index.php");
        
        exit;
    
    }
    
    if (
$id == false) {
    
        
$dung = new Dung($dm['id']);
        
$chapterId = (@$_GET['chapterId'] AND is_numeric($_GET['chapterId'])) ? (int) ($_GET['chapterId']) : false;
        
$taskId    = (@$_GET['taskId'] AND is_numeric($_GET['taskId'])) ? (int) ($_GET['taskId']) : false;
        
        if (
$chapterId) {
        
            
$chapter $dung -> chapterId($chapterId);
            
            if (!
$chapter OR @$chapter['id'] > $dm['dungChapter']) {
            
                
juosta($dm['statusas'],$neskaityti_laiskai);
                
                
header("Location: dung.php");
                
                exit;
            
            }
            
            
$listTasks  $dung -> listTasks($chapterId);
            
$countTasks $dung -> countTasks($chapterId); 
            
            
arsort($listTasks);
            
            
juosta($dm['statusas'],$neskaityti_laiskai);
            
            if (
$taskId) {
            
                
$task $dung -> taskId($chapterId$taskId);
                
                if (
$task) {
                
                    if (
$chapter['id'] < $dm['dungChapter'] OR ($taskId 1) <= $dm['dungTask']) {
                    
                        if (
$dm['mp'] >= 50) {
                        
                            
mysql_query("UPDATE `vartotojai` SET mp = mp-50 WHERE `id` = ".$dm['id']." LIMIT 1");
                            
                            
$dung -> startFight($dm$chapterId$task);
                            
                            
header("Location: dung.php?id=battle");
                            
                            exit;
                        
                        }
                        else
                        {
                        
                            echo 
"<div class="center juosta2 tr">
                            "
.$language['puolimui_reikia_minimum2']."
                            <br/>
                            <table align="
center">
                            <tr>
                            <td valign="
middle">
                            <img src="
img/potion.png" alt="*"/>
                            </td>
                            <td valign="
middle">
                            "
.$language['zvalumo_uzpilas']."
                            <br/>
                            <span class="
small">".$language['100_energijai_ir_sveikatai']."</span>
                            <br/>
                            <span class="
small">".$language['kaina'].": <img src="img/icons/gold.png" alt="*"/> 10</span>
                            </td>
                            </tr>
                            </table>
                            <a class="
btn_red" href="lab.php?id=wiz&amp;potion=1&amp;r=4&amp;chapterId=$chapterId"><span>".$language['atkurti']."</span></a>
                            </div>
                            <div class="
razdel5"></div>";
                        
                        }
                    
                    }
                
                }
            
            }
            
            foreach(
$listTasks as $tId => $task) {
            
                if (
$chapter['id'] < $dm['dungChapter'] OR ($tId 1) <= $dm['dungTask']) {
                
                    echo 
"<div class="b_dung_level">
                    <a href="
dung.php?chapterId=$chapterId&amp;taskId=$tId" class="block">
                    <div class="
shadow"></div>
                    <span class="
unit _white">
                    <i class="
face f".$chapterId."_".$tId.""></i>
                    </span>
                    <div class="
content">
                    <span class="
name">$tId. ".$task['name']."</span>
                    <span class="
btn _r _gold _corner">
                    <span>"
.$language['uzpulti_uz']." <img src="img/icons/energy.png" alt="*"/> 50</span>
                    </span>
                    </div>
                    </a>
                    </div>
                    <div class="
razdel5"></div>";
                
                }
            
            }
            
            echo 
"<div class="razdel5"></div>
            <div class="
center">
            <a class="
btn_red" href="dung.php"><span>".$language['grizti']."</span></a>
            </div>"
;
        
        }
        else
        {
        
            
$listChapters $dung -> listChapters();
            
            
arsort($listChapters);
            
            
juosta($dm['statusas'],$neskaityti_laiskai);
            
            
$countGame = (int) ($dm['mp'] / 50);
            
            if (isset(
$_GET['auto'])) {
            
                if (
$dm['mp'] >= 50 AND $dm['g'] >= 1) {
                
                    if (
$countGame) {
                    
                        
$dungTask = ($dm['dungTask'] == 0) ? $dm['dungTask'] + $dm['dungTask'];
                        
$dungChapter = ($dm['dungChapter'] > $dung -> countChapters()) ? $dung -> countChapters() : $dm['dungChapter'];
                        
$task $dung -> taskId($dungChapter$dungTask);
                        
$minusEnergy $countGame 50;
                        
$result = array(
                            
'count' => array(
                                
'game' => 0,
                                
'win'  => 0,
                                
'lose' => 0
                            
),
                            
'rExp'        => 0,
                            
'rSilver'    => 0,
                            
'rGold'        => 0,
                            
'rChapter'    => $dm['dungChapter'],
                            
'rTask'        => $dm['dungTask'] + 1
                        
);
                        
                        for(
$cGame 1$cGame <= $countGame$cGame ++) {
                        
                            
$dung -> startFight($dm$dungChapter$task);
                            
$final false;
                            
                            while(!
$final) {
                            
                                
$final $dung -> attack($dm);
                                
                                if (
$final) {
                                
                                    
$result['win'] = $final['win'];
                                    
$result['count']['game'] ++;
                                    
$result['rExp'] += $final['rExp'];
                                    
$result['rSilver'] += $final['rSilver'];
                                    
$result['rGold'] += $final['rGold'];
                                    
$result['rChapter'] = $final['rChapter'];
                                    
$result['rTask'] = $final['rTask'];
                                    
                                    if (
$final['win']) {
                                    
                                        
$result['count']['win'] ++;
                                    
                                    }
                                    else
                                    {
                                    
                                        
$result['count']['lose'] ++;
                                    
                                    }
                                
                                }
                            
                            }
                        
                        }
                        
                        
$dung -> updateResult($result);
                        
                        
mysql_query("UPDATE `vartotojai` SET `mp` = '".($dm['mp'] - $minusEnergy)."', g = g-1 WHERE `id` = ".$dm['id']." LIMIT 1");
                        
                        
header("Location: dung.php?id=battle");
                        
                        exit;
                    
                    }
                
                }
                else
                {
                
                    echo 
"<div class="center juosta2 tr">
                    <span class="
bold red">".$language['truksta']." <img src="img/icons/gold.png" alt="*"/> 1.</span>
                    <div class="
razdel5"></div>
                    <a class="
btn_red" href="stool.php?id=pay"><span>".$language['nusipirkti']."</span></a>
                    </div>
                    <div class="
razdel5"></div>";
                
                }
            
            }
            
            echo 
"<div class="center text_p">
            <img src="
img/town/dungeon.png" alt="*"/>
            <br/>
            <span class="
bold">".$language['kovok_paslaptinguose_pozemiuose_ir_nugalek_priesus']."</span>
            </div>
            <div class="
razdel5"></div>";
            
            foreach(
$listChapters as $cId => $chapter) {
            
                if (
$cId <= $dm['dungChapter']) {
                
                    echo 
"<div class="b_dung_chapter">
                    <a class="
chapter _d$cId" href="dung.php?chapterId=$cId">
                    <span class="
_p".$chapter['quality']."">
                    
$cId. ".$chapter['name']."
                    <p class="
small"><small class="type">".$dung -> nameQuality($chapter['quality'])." ".$language['pozemis_is_mazosios']."</small></p>
                    </span>
                    </a>
                    </div>"
;
                
                }
            
            }
            
            if (
$dm['mp'] >= 50 && $countGame 0) {
            
                echo 
"<div class="razdel5"></div>
                <div class="
center">
                <span class="
lime">".$language['tu_gali_sukovoti_']."</span>
                <div class="
razdel5"></div>
                <a class="
btn_red" href="dung.php?auto=1"><span>$countGame ".$language['kovu_uz']." <img src="img/icons/gold.png" alt="*"/> 1</span></a>
                </div>"
;
            
            }
        
        }
    
    }
    elseif (
$id == "battle") {
    
        
$dung = new Dung($dm['id']);
        
$fight $dung -> getFight();
        
        if (!
$fight) {
        
            
header("Location: dung.php");
            
            exit;
        
        }
        
        if (
$fight['type'] == 'fight') {
        
            if (isset(
$_GET['akmuo']) AND $dm['akmuo'] > 0) {
            
                
$dung -> activeAkmuo($dm);
            
            }
            
            if (isset(
$_GET['zole']) AND $dm['zole'] > 0) {
            
                
$dung -> activeZole($dm);
            
            }
            
            if (isset(
$_GET['attack'])) {
            
                
$final $dung -> attack($dmtrue);
                
                if (
$final) {
                
                    
header("Location: dung.php?id=battle");
                    
                    exit;
                
                }
            
            }
            
            if (isset(
$_GET['autoFight'])) {
            
                
$final false;
                
                while(!
$final) {
                
                    
$final $dung -> attack($dm);
                    
                    if (
$final) {
                    
                        
header("Location: dung.php?id=battle");
                        
                        exit;
                    
                    }
                
                }
            
            }
            
            
$zenklas zenklas($dm['statusas']);
            
$myParams $dung -> getMyParams();
            
$my_user_add_hp $myParams['my_user_add_hp'];
            
$opponent $dung -> getOpponentParams();
            
$uUron $dung -> getUserUron();
            
$bUron $dung -> getBotsUron();
            
            
$width1 ceil(($myParams['battle_hp'] / $myParams['other_hp']) * 100);
            
$width2 = (($bUron) ? (int) (($bUron $myParams['other_hp']) * 100) : 0);
            
$width2 = ($width2 100) ? 100 $width2;
            
            if (
$width1 $width2 100) {
            
                
$width2 100 $width1;
            
            }
            
            
$width3 ceil(($opponent['battle_hp'] / $opponent['other_hp']) * 100);
            
$width4 = (($uUron) ? (int) (($uUron $opponent['other_hp']) * 100) : 0);
            
$width4 = ($width4 100) ? 100 $width4;
            
            
juosta($dm['statusas'],$neskaityti_laiskai);
            
            echo 
"<div class="left juosta2 tr">
            <span class="
yellow bold"><img src="img/icons/player.png" alt="*"/> $zenklas".$myParams['name']." <img src="img/icons/health.png" alt="*"/> ".$myParams['battle_hp']."</span><div class="fr bold">".(($my_user_add_hp 0) ? '<span class="lime">+'.$my_user_add_hp.'</span>' '')." ".((@$bUron) ? ' <span class="red">-'.$bUron.'</span>' '')."</div>
            <div class="
razdel5"></div>
            <span class="
bl prg-bar border1">
            <span class="
bl fl prg-blue" style="width$width1%">&nbsp;</span>
            <span class="
bl fl prg-red" style="width$width2%">&nbsp;</span>
            </span>
            <div class="
razdel5"></div>
            <span class="
ml5 yellow bold"><img src="img/icons/dung_bot.png" alt="*"/> ".$language['priesininkas']." <img src="img/icons/health.png" alt="*"/> ".$opponent['battle_hp']."</span><div class="fr bold"> ".((@$uUron) ? ' <span class="red">-'.$uUron.'</span>' '')."</div>
            <div class="
razdel5"></div>
            <span class="
bl prg-bar border1">
            <span class="
bl fl prg-blue" style="width$width3%">&nbsp;</span>
            <span class="
bl fl prg-red" style="width$width4%">&nbsp;</span>
            </span>
            </div>"
;
            
            if (
count($myParams['skills'])) {
            
                echo 
"<div class="razdel5"></div>
                <div class="
center juosta2 tr">";
                
                foreach(
$myParams['skills'] as $sId => $a) {
                
                    echo 
"<img src="img/ability/$sId.".$a.".png" width="25px" height="25px" alt="*"/> ";
                
                }
                
                echo 
"</div>";
            
            }
            
            echo 
"<div class="razdel5"></div>
            <div class="
center juosta2 tr">
            <table align="
center">
            <tr>
            <td valign="
middle">";
            
            if (
$myParams['akmuo_time'] > time()) {
            
                echo 
"<img src="img/stone.png" width="40px" height="40px" alt="*"/>
                <br/>
                <img src="
img/icons/stone_min.png" alt="*"/> ";
                
                if (
$dm['js2'] == false) {
                
                    echo 
val($myParams['akmuo_time'] - time());
                
                }
                else
                {
                
                    
$rand_sk rand(1000000,9999999);
                    
                    echo 
"<span id="setTime$rand_sk"></span><span id="getTime$rand_sk" style="display:none;">".($myParams['akmuo_time'] - time())."</span>";
                    
                    
js_count($myParams['akmuo_time'] - time(),$rand_sk,1);
                
                }
                
                echo 
" ".$language['val']."";
            
            }
            else
            {
            
                echo 
"<a href="dung.php?id=battle&amp;attack&amp;akmuo"><img src="img/stone.png" width="40px" height="40px" alt="*"/></a>
                <br/>
                <img src="
img/icons/stone_min.png" alt="*"/> <span class="bold ".($dm['akmuo'] > 0 ? "lime" : "red")."">".$language['akmuo']." (".$dm['akmuo'].")</span>";
            
            }
            
            echo 
"</td>
            <td valign="
middle">";
            
            if (
$myParams['zole_time'] > time()) {
            
                echo 
"<img src="img/grass.png" width="40px" height="40px" alt="*"/>
                <br/>
                <img src="
img/icons/grass_min.png" alt="*"/> ";
                
                if (
$dm['js2'] == false) {
                
                    echo 
val($myParams['zole_time'] - time());
                
                }
                else
                {
                
                    
$rand_sk rand(1000000,9999999);
                    
                    echo 
"<span id="setTime$rand_sk"></span><span id="getTime$rand_sk" style="display:none;">".($myParams['zole_time'] - time())."</span>";
                    
                    
js_count($myParams['zole_time'] - time(),$rand_sk,1);
                
                }
                
                echo 
" ".$language['val']."";
            
            }
            else
            {
            
                echo 
"<a href="dung.php?id=battle&amp;attack&amp;zole"><img src="img/grass.png" width="40px" height="40px" alt="*"/></a>
                <br/>
                <img src="
img/icons/grass_min.png" alt="*"/> <span class="bold ".($dm['zole'] > 0 ? "lime" : "red")."">".$language['zole']." (".$dm['zole'].")</span>";
            
            }
            
            echo 
"</td>
            </tr>
            </table>
            </div>
            <div class="
razdel5"></div>
            <div class="
center">
            <a class="
btn_red" href="dung.php?id=battle&amp;attack"><span>".$language['atakuoti']."</span></a>
            <div class="
razdel5"></div>
            <a class="
btn_red" href="dung.php?id=battle&amp;autoFight"><span>".$language['autokova']."</span></a>
            </div>"
;
        
        }
        else if (
$fight['type'] == 'result') {
        
            
$result $dung -> getResult();
            
            
juosta($dm['statusas'],$neskaityti_laiskai);
            
            echo 
"<div class="juosta2 tr center">";
            
            if (
$result['win']) {
            
                echo 
"<span class="bold lime">".$language['pergale']."</span>";
            
            }
            else
            {
            
                echo 
"<span class="bold red">".$language['pralaimejimas']."</span>";
            
            }
            
            echo 
"<div class="razdel5"></div>";
            
            if (@
$result['count']) {
            
                echo 
"<div class="left">
                "
.$language['pravestos'].": <span class="lime">".$result['count']['game']."</span> ".$language['kovos']."
                <br/>
                "
.$language['pergaliu'].": <span class="lime">".$result['count']['win']."</span>
                <br/>
                "
.$language['pralaimejimu'].": <span class="red">".$result['count']['lose']."</span>
                </div>
                <div class="
razdel5"></div>";
            
            }
            
            echo 
"".((@$result['newChapter'] === TRUE) ? "<span class="bold lime">".$language['tu_atidarei_nauja_lokacija']."</span><br/>" "")."
            <span class="
lime">".$language['atlygis'].":</span>
            <br/>
            "
.(($result['rGold'] > 0) ? "<img src="img/icons/gold.png" alt="*"/> ".$result['rGold'].", " "")."
            <img src="
img/icons/silver.png" alt="*"/> ".n_f($result['rSilver'])." ".$language['ir']." <img src="img/icons/exp.png" alt="*"/> ".n_f($result['rExp']).".
            </div>
            <div class="
razdel5"></div>
            <div class="
center">
            <a class="
btn_red" href="dung.php?chapterId=".(($dm['dungChapter'] > $dung -> countChapters()) ? ($dm['dungChapter'] - 1) : $dm['dungChapter']).""><span>".$language['i_lokacija']."</span></a>
            </div>"
;
        
        }
        
        if (!@
$result['count']) {
        
            
$journal $dung -> getJournal();
            
            echo 
"<div class="razdel5"></div>
            <div class="
juosta2 tr">";
            
            
$dung -> d_journal($journal);
            
            echo 
"</div>";
        
        }
    
    }
    else
    {
    
        
header("Location: index.php");
    
    }
    
    include(
"includes/foot.php");

?>
Онлайн: 2
Реклама