Файл: public_html/js/camp.js
Строк: 250
<?php
function runServerTimeTimer_camp() {
time_serv++;
ost=time_att+1-time_serv;
n_1=time_navik1-time_serv;
n_2=time_navik2-time_serv;
if(time_att<time_serv){
document.getElementById('time_att').innerHTML ='';
}else{
document.getElementById('time_att').innerHTML ='('+ost+')';
}
if(time_navik1<time_serv){
document.getElementById('time_moln').innerHTML ='';
}else{
document.getElementById('time_moln').innerHTML =n_1;
}
if(time_navik2<time_serv){
document.getElementById('time_isc').innerHTML ='';
}else{
document.getElementById('time_isc').innerHTML =n_2;
}
}
function hp_del(user,vrag) {
document.getElementById('hp_del_v').style.display ='none';
document.getElementById('hp_del_u').style.display ='none';
}
function hp_isc_del() {
document.getElementById('hp_isc_u').style.display ='none';
}
function attack_camp(url) {
if(time_att<time_serv){
var xhr = new XMLHttpRequest();
xhr.open('GET',url, false);
xhr.send();
if (xhr.status != 200) {
alert('Ошибка');
} else {
stats = JSON.parse(xhr.responseText);
if(stats.error!=0){
window.location = "/camp";
}else{
time_att=stats.time_att;
time_serv=stats.time_serv;
document.getElementById('time_att').innerHTML ='(2)';
if(typeof(stats.hp_regen) != "undefined" && stats.hp_regen !== null) {
hp_user=stats.hp_regen;}
hp_user=stats.hp_user;
att_user=stats.att_user;
if(typeof(stats.att_vrag) != "undefined" && stats.att_vrag !== null) {
att_vrag=stats.att_vrag;
hp_user=hp_user-att_vrag;
}
if(hp_vrag>0){
hp_vrag=stats.hp_vrag-att_user;
if(hp_user<1){hp_user=0;window.location = "/camp";}
if(hp_vrag<1){hp_vrag=0;
window.location = "/camp";}
proc_user=(hp_user/hp_user_max)*100;if(proc_user>100){proc_user=100;}
proc_vrag=(hp_vrag/hp_vrag_max)*100;
document.getElementById('hp_proc_block2_v').style.width =proc_vrag+'%';
document.getElementById('hp_proc_block2_u').style.width =proc_user+'%';
document.getElementById('hp_proc_block2_small_v').style.width =proc_vrag+'%';
document.getElementById('hp_proc_block2_small_u').style.width =proc_user+'%';
document.getElementById('hp_small_v').innerHTML =hp_vrag;
document.getElementById('hp_small_u').innerHTML =hp_user;
document.getElementById('hp_del_v').innerHTML ='-'+att_user;
document.getElementById('hp_del_v').style.display ='block';
document.getElementById('log_boi').innerHTML='<div class="c8 t_13">Вы нанесли '+att_user+' урона</div>'+document.getElementById('log_boi').innerHTML;
if(typeof(stats.att_vrag) != "undefined" && stats.att_vrag !== null) {
document.getElementById('hp_del_u').innerHTML ='-'+att_vrag;
document.getElementById('hp_del_u').style.display ='block';
document.getElementById('log_boi').innerHTML='<div class="c9 t_13">Враг нанес '+att_vrag+' урона</div>'+document.getElementById('log_boi').innerHTML
}
setTimeout("hp_del()", 1000);
}else{
window.location = "/camp";}}}}}
function isc(url) {
if(time_navik1<time_serv){
var xhr = new XMLHttpRequest();
xhr.open('GET',url, false);
xhr.send();
if (xhr.status != 200) {
alert('Перезагрузите игру');
} else {
stats = JSON.parse(xhr.responseText);
if(stats.error!=0){
}else{
hp_user=stats.hp;
time_navik1=stats.time_add;
document.getElementById('log_boi').innerHTML='<div class="c8 t_13">Вы вылечили себя на '+stats.hp_add+' здоровья</div>'+document.getElementById('log_boi').innerHTML;
proc_user=(hp_user/hp_user_max)*100;if(proc_user>100){proc_user=100;}
document.getElementById('hp_proc_block2_u').style.width =proc_user+'%';
document.getElementById('hp_proc_block2_small_u').style.width =proc_user+'%';
document.getElementById('hp_small_u').innerHTML =hp_user;
document.getElementById('hp_isc_u').innerHTML ='+'+stats.hp_add;
document.getElementById('hp_isc_u').style.display ='block';
setTimeout("hp_isc_del()", 1000);
if(typeof(stats.att_vrag) != "undefined" && stats.att_vrag !== null) {
document.getElementById('log_boi').innerHTML='<div class="c9 t_13">Враг нанес '+stats.att_vrag+' урона</div>'+document.getElementById('log_boi').innerHTML
}
}}}}
function moln(url) {
if(time_navik2<time_serv){
var xhr = new XMLHttpRequest();
xhr.open('GET',url, false);
xhr.send();
if (xhr.status != 200) {
alert('Перезагрузите игру');
} else {
stats = JSON.parse(xhr.responseText);
if(stats.error!=0){
}else{
time_navik2=stats.time_add;
att_user=stats.att_user;
if(hp_vrag>0){
hp_vrag=hp_vrag-att_user;
if(hp_vrag<1){hp_vrag=0;
window.location = "/camp";
}
proc_vrag=(hp_vrag/hp_vrag_max)*100;
document.getElementById('hp_proc_block2_v').style.width =proc_vrag+'%';
document.getElementById('hp_proc_block2_small_v').style.width =proc_vrag+'%';
document.getElementById('hp_small_v').innerHTML =hp_vrag;
document.getElementById('hp_del_v').innerHTML ='-'+att_user;
document.getElementById('hp_del_v').style.display ='block';
document.getElementById('log_boi').innerHTML='<div class="c8 t_13">Вы нанесли навыком Разряд '+att_user+' урона</div>'+document.getElementById('log_boi').innerHTML;
if(typeof(stats.att_vrag) != "undefined" && stats.att_vrag !== null) {
document.getElementById('hp_del_u').innerHTML ='-'+stats.att_vrag;
document.getElementById('hp_del_u').style.display ='block';
document.getElementById('log_boi').innerHTML='<div class="c9 t_13">Враг нанес '+stats.att_vrag+' урона</div>'+document.getElementById('log_boi').innerHTML
}
setTimeout("hp_del()", 1000);
}else{
window.location = "/camp";
}
}}}}
function timer(times,id_class,time_kon,time_r) {
function renderTimer() {var hours = Math.floor(times / 3600);var minutes = Math.floor((times / 60) % 60);var seconds = times % 60;
if(hours<1){hours='';}else{hours+=' ч ';}if(minutes<1){minutes='';}else{minutes+=' м ';}if(time_kon - time_r<1){seconds='';}else{seconds+=' c ';}
if(time_kon<time_r){
document.getElementById(id_class).innerHTML ='';
}else{
document.getElementById(id_class).innerHTML = (hours + minutes + seconds);}
}
function TimeTimer2() {times--;time_r++;renderTimer();}
TimeTimer2();
setInterval(TimeTimer2, 1000);
}
?>