Вход Регистрация
Файл: resources/views/game/battles/arena/battle.blade.php
Строк: 252
<?php
@extends('layouts.main')

@
section('content')
    <
script>
        $(
init);
        
setInterval(moveStatus1000);
        function 
moveStatus()
        {
            $.
ajax({
                
url'/api/arena/moveStatus/{{ $battle->id }}',
                
success: function(data)
                {
                    var 
round Number.parseInt($("#round").html());
                    if(
round != data.roundNumlocation.reload();
                    if(
data.moveTime != '') $("#moveTime").html(data.moveTime);
                    else $(
"#moveTime").html('0 секунд');
                    $(
"#move").html(data.move);
                    if(
data.status == 0)
                    {
                        $(
"#attack11, #attack12, #attack21, #attack22").css('display''none');
                    }
                    else if(
data.status == 1)
                    {
                        if(
data.pick1 == 0) $("#attack11, #attack21").css('display''inline');
                        if(
data.pick2 == 0) $("#attack12, #attack22").css('display''inline');
                    }
                    else if(
data.status == 2)
                    {
                        $(
"#mainContent").detach();
                        $(
'<center><div class="box"><div class="media"><div class="media-body"><h4 class="media-heading">Раунд закончен<br>Победитель: '+data.winner+'</h4></div></div></div></center>').prependTo('#battleArena').fadeOut(2500, function() { location.reload(); });
                    }
                    else if(
data.status == 3)
                    {
                        $(
"#mainContent").detach();
                        $(
'<center><div class="box"><div class="media"><div class="media-body"><h4 class="media-heading">Раунд закончен в ничью</h4></div></div></div></center>').prependTo('#battleArena').fadeOut(2500, function() { location.reload(); });
                    }
                    else if(
data.status == 4)
                    {
                        $(
"#mainContent").detach();
                        $(
'<center><div class="box"><div class="media"><div class="media-body"><h4 class="media-heading">Битва окончена Победил '+data.winner+'</h4></div></div></div></center>').prependTo('#battleArena').fadeOut(2500, function(){ location.replace('/arena/result'); });
                    }
                    else if(
data.status == 5location.replace('/arena');
                    if(
data.health.opp1 <= 0)
                    {
                        $(
"#opponentCard1").fadeOut(2000);
                        $(
"#opponentCard2").attr('class''col-xs-12');
                    }
                    if(
data.health.opp2 <= 0)
                    {
                        $(
"#opponentCard2").fadeOut(2000);
                        $(
"#opponentCard1").attr('class''col-xs-12');
                    }
                    if(
data.health.my1 <= 0)
                    {
                        $(
"#myCard1").fadeOut(2000);
                        $(
"#myCard2").attr('class''col-xs-12');
                    }
                    if(
data.health.my2 <= 0)
                    {
                        $(
"#myCard2").fadeOut(2000);
                        $(
"#myCard1").attr('class''col-xs-12');
                    }
                    $(
"#opponentCard1Health").html(data.health.opp1);
                    $(
"#opponentCard2Health").html(data.health.opp2);
                    $(
"#myCard1Health").html(data.health.my1);
                    $(
"#myCard2Health").html(data.health.my2);
                }
            });
        }
        function 
init()
        {
            $(
"#attack11, #attack12, #attack21, #attack22").click(attack);
            
moveStatus();
        }
        function 
attack()
        {
            var 
href;
            if(
this.id == 'attack11'href "/arena/battle/attack/{{ $battle->id }}/{{ $myCard1->id }}/{{ $opponentCard1->id }}";
            else if(
this.id == 'attack12'href "/arena/battle/attack/{{ $battle->id }}/{{ $myCard2->id }}/{{ $opponentCard1->id }}";
            else if(
this.id == 'attack21'href "/arena/battle/attack/{{ $battle->id }}/{{ $myCard1->id }}/{{ $opponentCard2->id }}";
            else 
href "/arena/battle/attack/{{ $battle->id }}/{{ $myCard2->id }}/{{ $opponentCard2->id }}";
            $.
ajax({
                
urlhref,
                
success: function(data)
                {
                    if(
data.status == 'ok')
                    {
                        var 
cardId '#opponentCard'+data.opponentCard;
                        if(
data.myCard == 1) $("#attack11, #attack21").css('display''none');
                        else $(
"#attack12, #attack22").css('display''none');
                        $(
cardId).jrumble();
                        $(
cardId).trigger('startRumble');
                        
setTimeout(function() {
                            $(
cardId).trigger('stopRumble');
                        }, 
1000);
                    }
                    else
                    {
                        $(
'<center><div class="box"><div class="media"><div class="media-body"><h4 class="media-heading">'+data.message+'</h4></div></div></div></center>').prependTo("#mainContent").fadeOut(5000);
                    }
                }
            });
        }
    </
script>
    <
div class="row" id="battleArena">
        <
span id="mainContent">
            <
center>
                <
font color="white">
                    @if(
$opponentCard1->health 0)
                        <
div class="col-xs-{{ $opponentCard2->health > 0 ? 6 : 12 }}" id="opponentCard1">
                            <
img src="/images/cards/{{ $opponentCard1->getCardUserInfo->getCardInfo->image }}.png"><br>
                            
HP: <span id="opponentCard1Health">{{ $opponentCard1->health }}</span>/{{ $opponentCard1->getCardUserInfo->getCardInfo->health+Services::getUpgradeBonus($opponentCard1->getCardUserInfo->getCardInfo->health$opponentCard1->getCardUserInfo->upgrade_level) }}</br>
                            <
center>
                                <
font color="black">
                                    <
button id="attack11" style="display: none;">1</button>
                                    <
button id="attack12" style="display: none;">2</button>
                                </
font>
                            </
center>
                            <
br>
                        </
div>
                    @endif
                    @if(
$opponentCard2->health 0)
                        <
div class="col-xs-{{ $opponentCard1->health > 0 ? 6 : 12 }}" id="opponentCard2">
                            <
img src="/images/cards/{{ $opponentCard2->getCardUserInfo->getCardInfo->image }}.png"><br>
                            
HP: <span id="opponentCard2Health">{{ $opponentCard2->health }}</span>/{{ $opponentCard2->getCardUserInfo->getCardInfo->health+Services::getUpgradeBonus($opponentCard2->getCardUserInfo->getCardInfo->health$opponentCard2->getCardUserInfo->upgrade_level) }}</br>
                            <
center>
                                <
font color="black">
                                    <
button id="attack21" style="display: none;">1</button>
                                    <
button id="attack22" style="display: none;">2</button>
                                </
font>
                            </
center>
                        </
br>
                        </
div>
                    @endif
                                        <
center>
                    
Мои карты
                 
</center>

                    @if(
$myCard1->health 0)
                        <
div class="col-xs-{{ $myCard2->health > 0 ? 6 : 12 }}" id="myCard1">
                                <
img src="/images/cards/{{ $myCard1->getCardUserInfo->getCardInfo->image }}.png"><br>
                                
HP: <span id="myCard1Health">{{ $myCard1->health }}</span>/{{ $myCard1->getCardUserInfo->getCardInfo->health+Services::getUpgradeBonus($myCard1->getCardUserInfo->getCardInfo->health$myCard1->getCardUserInfo->upgrade_level) }}
                        </
div>
                    @endif
                    @if(
$myCard2->health 0)
                        <
div class="col-xs-{{ $myCard1->health > 0 ? 6 : 12 }}" id="myCard2">
                                <
img src="/images/cards/{{ $myCard2->getCardUserInfo->getCardInfo->image }}.png"><br>
                                
HP: <span id="myCard2Health">{{ $myCard2->health }}</span>/{{ $myCard2->getCardUserInfo->getCardInfo->health+Services::getUpgradeBonus($myCard2->getCardUserInfo->getCardInfo->health$myCard2->getCardUserInfo->upgrade_level) }}
                        </
div>
                    @endif
                </
font>
            </
center>
        </
span>
    </
div>
    <
center>
                    <
div class = "box">
                    <
div class="media">
          <
div class="media-body">
            <
h4 class="media-heading">
                    
Раунд №<span id="round">{{ $battle->round }}</span><br>
                    
Счёт по раундам: {{ $battle->user1 == Auth::user()->id $battle->user1_win $battle->user2_win }}:{{ $battle->user1 != Auth::user()->id $battle->user2_win $battle->user1_win }}<br>
                    
Ходит: <span id="move">{{ Services::userInfo($battle->move)->login }}</span><br>
                    
Время хода: <span id="moveTime">{{ Services::timer($battle->move_time-time()) }}</span><br>
                     </
div></div></div>
                 </
center>
@
endsection
?>
Онлайн: 1
Реклама