Вход Регистрация
Файл: monst/core/pag/coliseum.php
Строк: 187
<?
upd_loc
('coliseum');

if ( 
count($user['coliseum_log']) == 15 ) {
    
$_users -> update(
        [
            
'id' => $user['id']
        ],

        [
            
'$set' => [
                
'coliseum_num' => 0,
                
'coliseum_log' => 0,
                
'coliseum_enemyId' => 0,
                
'next_coliseum_time' => 0,
            ]
        ]
    );

    
g('/coliseum');
}


$C_num 30;

//if ( $user['vip_time'] > time() ) {
//    $C_num = 30;
//}

$gold 1;
$silver 50;
$exp 20;

if ( 
$user['part'] == ) {
    
$gold 1;
    
$silver 100;
    
$exp 30;

}

if ( 
$user['part'] == ) {
    
$gold 2;
    
$silver 150;
    
$exp 40;

}


if ( 
$user['vip_time'] > time() ) {
    
$gold $gold 2;
    
$silver $silver 2;
    
$exp $exp 2;
}

//if ( $user['level'] >= 10 ) {
//    $gold = 4;
//    $silver = 300;
//    $exp = 50;
//}

?>


    <div class='op_top_im'>

<img src='/core/i/pic/coliseum.jpg?2' alt='' class='title_img' />
    </div>

<div style='position: relative; top: -100px; color: #756861; height: 0;'>
    <span style='background: #000; font-size: 20px;'><?=$lang['coliseum.php']['title']?></span><br/>
    <span style='background: #000; font-size: 11px;'><?=$lang['coliseum.php']['title_text']?></span><br/>
</div>

<!--<div class='padding'>-->
<!--    <div style='text-align: center; color: #756861; border-top: 1px solid #756861;'>-->
<!--        --><?//=$lang['coliseum.php']['desc']?><!--<br/>-->
<!--    </div>-->
<!--</div>-->

<!--<br/>-->

<div style='text-align: center;'>

<?
//$_users -> update(
//    [
//        'id' => $user['id']
//    ],
//
//    [
//        '$set' => [
//            'next_coliseum_time' => time() + 60 * 2,
//        ]
//    ]
//);


if ( $user['next_coliseum_time'] > AND $user['next_coliseum_time'] < time() ) {
    
$_users -> update(
        [
            
'id' => $user['id']
        ],

        [
            
'$set' => [
                
'coliseum_log' => 0,
                
'coliseum_num' => 0,
                
'coliseum_enemyId' => 0,

                
'next_coliseum_time' => 0,
            ]
        ]
    );
    
g('/coliseum');
}

if ( 
$user['coliseum_log'] == ) {
    
$log = [];

    for ( 
$i 1$i <= $C_num$i++ ) {
        
$log[$i] = 0;
    }

    
$_users -> update(
        [
            
'id' => $user['id']
        ],

        [
            
'$set' => [
                
'coliseum_log' => $log
            
]
        ]
    );
    
g('/coliseum');
}



if ( 
$user['coliseum_log'][$C_num] > ) {
    if (empty(
$user['next_coliseum_time'])) {
        
$_users->update(
            [
                
'id' => $user['id']
            ],

            [
                
'$set' => [
                    
'next_coliseum_time' => time() + 60 60 2
                
]
            ]
        );

        
g('/coliseum');
    }

    if (
$user['next_coliseum_time'] > time()) {
        
$time $user['next_coliseum_time'] - time();
        
?>
<!--    <div style='height: 0;'>-->
<!--    <div style='position: relative; top: 20px; opacity: 0.8;'>-->

        <div style='backg2round: #000; padding: 20px; color: #999;'>
                <?= $lang['coliseum.php']['time_to_unlock'?> <span
                        style='color: indianred;'><?= hm($time0110?></span><br/>
            </div>
<!--    </div>-->
<!--    </div>-->
        <br/>
    <?
    
}
}
        
// else {




if (!$user['coliseum_enemyId']) {
    
new_enemy();
    
g('/coliseum');
}


$enemyId $user['coliseum_enemyId'];
$enemy $_users->findOne(
    [
        
'id' => $enemyId
    
]
);


if ( 
$user['coliseum_log'][$C_num] < ) {




    if (isset(
$_GET['attack'])) {
        
$user_param_sum $user['st'] + $user['hp'] + $user['armor'];
        
$enemy_param_sum $enemy['st'] + $enemy['hp'] + $enemy['armor'];

        
$win 0;

        if (
$user_param_sum $enemy_param_sum) {
            
$win 1;
        } elseif (
$user_param_sum == $enemy_param_sum) {
            if (
mt_rand(1100) <= 50) {
                
$win 1;
            }
        }

//        else {
//            $percent = 50;
//
//            if ( mt_rand(1, 100) <= $percent ) {
//                $win = 1;
//            }
//        }

        
$num $user['coliseum_num'];
        
$user['coliseum_log'][$num 1] = 1;

        
new_enemy();

        if (
$win) {
            
// quest
            
foreach ($quest as $q) {
                if (
$q['type'] == 'coliseum_count') {
                    
$quest_db[$q['id']]['count'] += 1;
                }
            }
            
//

            
foreach ($quest as $q) {
                if (
$q['type'] == 'coliseum_win') {
                    
$quest_db[$q['id']]['count'] += 1;
                }
            }


            foreach (
$daily as $q) {
                if (
$q['type'] == 'coliseum_count') {
                    
$daily_db[$q['id']]['count'] += 1;
                }
            }
            
//

            
foreach ($daily as $q) {
                if (
$q['type'] == 'coliseum_win') {
                    
$daily_db[$q['id']]['count'] += 1;
                }
            }



            
$user['coliseum_log'][$num] = 2;

            
$_users->update(
                [
                    
'id' => $user['id']
                ],

                [
                    
'$set' => [
                        
'gold' => $user['gold'] + $gold,
                        
'silver' => $user['silver'] + $silver,
                        
'exp' => $user['exp'] + $exp,

                        
'coliseum_log' => $user['coliseum_log'],
                        
'coliseum_num' => $num 1,
                        
'quest' => $quest_db,
                        
'daily' => $daily_db,
                    ]
                ]
            );

            
g('/coliseum?win');
        } else {
            
// quest
            
foreach ($quest as $q) {
                if (
$q['type'] == 'coliseum_count') {
                    
$quest_db[$q['id']]['count'] += 1;
                }
            }
            
//

            
foreach ($daily as $q) {
                if (
$q['type'] == 'coliseum_count') {
                    
$daily_db[$q['id']]['count'] += 1;
                }
            }

            
$user['coliseum_log'][$num] = 3;

            
$_users->update(
                [
                    
'id' => $user['id']
                ],

                [
                    
'$set' => [
                        
'gold' => $user['gold'] + floor($gold 2),
                        
'silver' => $user['silver'] + floor($silver 2),
                        
'exp' => $user['exp'] + floor($exp 2),

                        
'coliseum_log' => $user['coliseum_log'],
                        
'coliseum_num' => $num 1,
                        
'quest' => $quest_db,
                        
'daily' => $daily_db,
                    ]
                ]
            );

            
g('/coliseum?lose');
        }

    }
}
    if ( isset(
$_GET['win']) ) {
        
?>
<!--        <div style='height: 0;'>-->
<!--            <div style='position: relative; top: 20px; background: #000; opacity: 0.8;'>-->
                <span style='color: yellowgreen; font-size: 30px;'><?=$lang['coliseum.php']['win']?></span><br/>

                <img src='<?=$gold_icon?>' alt='' width='50'/><span class='gold_color'><?=num($gold)?></span>
                <img src='<?=$silver_icon?>' alt='' width='50'/><span class='silver_color'><?=num($silver)?></span>
                <img src='<?=$exp_icon?>' alt='' width='50'/><span class='exp_color'><?=num($exp)?></span>

        <br/><br/>

        <!--            </div>-->
<!---->
<!--        </div>-->
        <?
    
}

    if ( isset(
$_GET['lose']) ) {
        
?>
<!--        <div style='height: 0;'>-->
<!--            <div style='position: relative; top: 20px; background: #000; opacity: 0.8;'>-->

                <span style='color: indianred; font-size: 30px;'><?=$lang['coliseum.php']['lose']?></span><br/>

        <img src='<?=$gold_icon?>' alt='' width='50'/><span class='gold_color'><?=num($gold 2)?></span>
        <img src='<?=$silver_icon?>' alt='' width='50'/><span class='silver_color'><?=num(round($silver 2))?></span>
                <img src='<?=$exp_icon?>' alt='' width='50'/><span class='exp_color'><?=num(round($exp 2))?></span>
<!--            </div>-->
<!--        </div>-->

<br/>        <br/>
        <?
    
}


    if ( 
$user['coliseum_log'][$C_num] < ) {
        
?>
        <a href='/coliseum?attack'>
        <?
    
}

    
?>

            <div class='opacity_monster_im'>
            <img src='<?=av($enemyId)?>' alt='' width='200'/><br/>
            </div>
        <div><?=Name($enemy['id'])?></div>


        <img src='/core/i/user/hp.png?3' alt='' width='15'/><span class='hp_color'><?=num($enemy['hp'])?></span>
        <img src='/core/i/user/st.png?2' alt='' width='15'/><span class='st_color'><?=num($enemy['st'])?></span>
        <img src='/core/i/user/armor.png?2' alt='' width='15'/><span class='armor_color'><?=num($enemy['armor'])?></span>

    <?
    
if ( $user['coliseum_log'][$C_num] < ) {
        
?>
        </a>
        <?
    
}
    
?>

    <br/>
    <br/>
    <?


//}


$log $user['coliseum_log'];

//print_r($log);

for ( $i 1$i <= $C_num$i++ ) {
    
$n $log[$i];

    if ( 
$n == $color '#777';
    if ( 
$n == $color '#999';
    if ( 
$n == $color 'yellowgreen';
    if ( 
$n == $color 'indianred';

    
?>
    <span style='color: <?=$color?>; font-size: 18px;'>&bull;</span>
    <?

//    if ( $i == 15 ) print '<br/>';
}

?>
</div>
<?

function new_enemy() {
    global 
$user$_users;

    
$find $_users -> aggregate(
        [
            [
                
'$match' => [
                    
'level' => [
                        
'$gte' => $user['level'] - 5,
                        
'$lte' => $user['level'] + 5
                    
],

                    
'id' => [
                        
'$ne' => $user['id']
                    ]
                ],
            ],

            [
                
'$sample' => [
                    
'size' => 1
                
]
            ]
        ]
    );

    
$enemy $find['result'][0];

    
$num $user['coliseum_num'] + 1;
    
$user['coliseum_log'][$num] = 1;

    if ( 
$find ) {
        
$_users -> update(
            [
                
'id' => $user['id']
            ],

            [
                
'$set' => [
                    
'coliseum_enemyId' => $enemy['id'],
                    
'coliseum_log' => $user['coliseum_log'],
                    
'coliseum_num' => $num
                
]
            ]
        );
    }

}
Онлайн: 1
Реклама