Файл: monst/core/jphp/ca/index.php
Строк: 176
<?
$HOME = $_SERVER['DOCUMENT_ROOT'];
include $HOME . '/core/in/j.php';
//$_d -> remove();
$ca = $_ca -> findOne(
[
'id' => 1
]
);
if ( !$ca ) {
exit;
}
if ( $user['hp'] <= 0 ) {
$_users -> update(
[
'id' => $user['id']
],
[
'$set' => [
'hp' => $user['hpf']
]
]
);
?>
<script>
window.location = '/ca';
</script>
<?
exit;
} else {
if ( $ca['count'] <= 0 ) {
?>
<script>
clearInterval(indexInterval);
$('#monster_img').hide();
$('#monster_img_gray').show();
$('#monster_count').hide();
$('#effect_killed').show();
$('#monster_panel').hide();
$('#user_panel').hide();
</script>
<div style='height: 0;'>
<div style='background: #000; padding: 20px; position: relative; font-size: 20px; top: 300px; z-index: 2000;'>
<?=$lang['ca']['battle_end']?>
</div>
</div>
<?
// числим квесты
if ( $user['last_ca_id'] != $ca['uniq_id'] ) {
$upd = 0;
foreach ( $ca['user_ids'] as $user_id => $user_time ) {
if ( $user_id == $user['id'] ) {
$upd = 1;
}
}
if ( $upd ) {
// quest
foreach ($quest as $q) {
if ($q['type'] == 'ca') {
$quest_db[$q['id']]['count'] += 1;
}
}
//
foreach ($daily as $q) {
if ($q['type'] == 'ca') {
$daily_db[$q['id']]['count'] += 1;
}
}
$_users->update(
[
'id' => $user['id']
],
[
'$set' => [
'last_ca_id' => $ca['uniq_id'],
'quest' => $quest_db,
'daily' => $daily_db
]
]
);
}
}
// атака отбита
$ca_timer = (int)file_get_contents($HOME . '/core/data/ca_timer.dat');
if ( $ca_timer == '-1' ) {
// $rnd = rand(1, 2);
$timer = time() + (60 * 60 * 1);
$fp = fopen($HOME . '/core/data/ca_timer.dat', 'w+');
fwrite($fp, $timer);
fclose($fp);
}
} else {
if ($ca['hp'] <= 0) {
// монстр убит (минусуем count, даём черепа)
// награда дается случайному игроку из тех кто реально сейчас бьёт
$user_ids = [];
foreach ( $ca['user_ids'] as $user_id => $user_time ) {
if ( time() - $user_time <= 60 * 2 ) {
$user_ids[] = $user_id;
}
}
$rand_user = $user_ids[rand(0, count($user_ids) - 1)]; // ему даём череп
$log = '';
$log = '<img src="'.$ca['m']['icon'].'" alt="" width="15"/>'.$ca['m']['name'].' '.$lang['ca']['dead'].'. <img src="'.av($user['id']).'" alt="" width="15"/>' . Name($rand_user).' '.$lang['ca']['get'].' <img src="/core/i/game/skull.png" alt="" width="15"/><span class="skull_color">1</span> <br/>' . $log;
$log = '<span style="color: #777;">' . date('H:i:s') . '</span><br/>' . $log;
$log = $log . '--<br/>' . $ca['log'];
$_ca -> update(
[
'id' => 1
],
[
'$set' => [
'hp' => $ca['m']['hp'],
'count' => $ca['count'] - 1,
'log' => $log
]
]
);
$find = $_users -> findOne(
[
'id' => $rand_user
]
);
$_users -> update(
[
'id' => $find['id']
],
[
'$set' => [
'skull' => $find['skull'] + 1
]
]
);
} else {
// монстр жив, нихуя не делаем )))))
}
}
}
?>
<div style='text-align: center;'>
<img id='effect_killed' src="/core/i/effect/killed.png?2" style='display: none; position: absolute; le2ft: 130px; top: 100px; z-index: 1001; width: 200px;'/>
<img id='effect' src="/core/i/effect/bum.png" style='display: none; position: absolute; z-index: 1001; width: 200px;'/>
<img OnClick='attack();' id='monster_img' src='<?=$ca['m']['icon']?>?<?=filemtime($HOME .$ca['m']['icon'])?>' alt='' style='width: 100%; cursor: pointer;'/>
<img id='monster_img_gray' src='<?=$ca['m']['icon']?>?<?=filemtime($HOME .$ca['m']['icon'])?>' alt='' style='width: 100%;-webkit-filter: grayscale(100%); filter: grayscale(100%); display: none;'/>
</div>
<div id='monster_count' style='font-size: 50px; position: absolute; top: 150px; le2ft: 50px; margin-left: 20px; color: #ccc;'>
<?=$ca['count']?>
</div>
<?
$monsterhp_percent = round($ca['hp'] / $ca['m']['hp'] * 100);
if ($monsterhp_percent < 0) $monsterhp_percent = 0;
?>
<div id='monster_panel' style='background: #000;'>
<div style='display: inline-block;'>
<img src='<?=$ca['m']['icon']?>' alt='' width='50'/>
</div>
<div style='display: inline-block; text-align: left; vertical-align: bottom; padding: 5px;'>
<span style='color: #999;'><?=$ca['m']['name']?></span>
<div>
<img src='/core/i/user/hp.png?3' alt='' width='10'/><span class='hp_color'
style='font-size: 11px;'><?= num($ca['hp']) ?></span>
<img src='/core/i/user/st.png?2' alt='' width='10'/><span class='st_color'
style='font-size: 11px;'><?= num($ca['m']['st']) ?></span>
<img src='/core/i/user/armor.png?2' alt='' width='10'/><span class='armor_color'
style='font-size: 11px;'><?= num($ca['m']['armor']) ?></span>
</div>
<div style='background: #222; width: 200px; height: 15px; margin: auto; margin: 2px;'>
<div style='background: indianred; width: <?= $monsterhp_percent ?>%; height: 15px;'></div>
</div>
</div>
</div>
<?
$userhp_percent = round($user['hp'] / $user['hpf'] * 100);
if ($userhp_percent < 0) $userhp_percent = 0;
?>
<div id='user_panel' style='background: #000; text-align: center;'>
<div>
<div style='display: inline-block; vertical-align: bottom;'>
<img src='/core/i/user/no_av.jpg' alt='' width='50'/>
</div>
<div style='display: inline-block; text-align: left; vertical-align: top; padding: 5px;'>
<span style='color: #999;'><?= Name($user['id']) ?></span>
<div>
<img src='/core/i/user/hp.png?3' alt='' width='10'/><span class='hp_color'
style='font-size: 11px;'><?= num($user['hp']) ?></span>
<img src='/core/i/user/st.png?2' alt='' width='10'/><span class='st_color'
style='font-size: 11px;'><?= $user['st'] ?></span>
<img src='/core/i/user/armor.png?2' alt='' width='10'/><span class='armor_color'
style='font-size: 11px;'><?= $user['armor'] ?></span>
</div>
<div style='background: #222; width: 200px; height: 15px; margin: auto; margin: 2px;'>
<div style='background: steelblue; width: <?= $userhp_percent ?>%; height: 15px;'></div>
</div>
</div>
</div>
</div>
<div style='text-align: left; background: #000; padding: 20px;'>
<?=$lang['ca']['users']?>:<br/>
<?
$i = 0;
if ( $ca['count'] > 0 ) {
foreach ( $ca['user_ids'] as $user_id => $user_time ) {
if ( time() - $user_time <= 60 * 2 ) {
?>
<a href='/id<?=$user_id?>'><img src='<?=av($user_id)?>' alt='' width='15'/><?=Name($user_id)?></a>,
<?
$i++;
}
}
} else {
foreach ( $ca['user_ids'] as $user_id => $user_time ) {
?>
<a href='/id<?=$user_id?>'><img src='<?=av($user_id)?>' alt='' width='15'/><?=Name($user_id)?></a>,
<?
$i++;
}
}
if ( !$i ) {
?>
<?=$lang['ca']['users_empty']?><br/>
<?
}
?>
</div>
<?
$logs = '';
$log_array = explode('<br/>', $ca['log']);
for ( $i = 0; $i < 30; $i++) {
if ( isset($log_array[$i]) ) {
$logs .= $log_array[$i].'<br/>';
}
}
?>
<br/>
<div style='text-align: center; margin:auto;ma2x-wi2dth: 300px; col2or: #5a6879; font-size: 12px;'>
<?=$logs?>
</div>