x.player == nick)
wiersz.append(`${get_status(player.troops)} | ${get_status(player.buildings)} | ${get_status(player.defense)} | `)
}
$("#player_data_table").addClass('vis')
})
})
();
$(document.body).on('click','.player_stats',function() {
let player_name = $(this).closest('tr').find('td').first().find('a[href*=info_player]').text()
villages = [];
let player_id = $(this).attr('player_id')
get_player_data(player_id,player_name)
})
$(document.body).on('click','.player_def',function() {
let player_name = $(this).closest('tr').find('td').first().find('a[href*=info_player]').text()
def = [];
let player_id = $(this).attr('player_id')
get_player_def(player_id,player_name)
})
function get_status(bool) {
if (bool == true) {
return 'OK'
} else {
return 'NOK'
}
}
function get_bad_status(bool) {
if (bool == false) {
return 'NOK'
} else {
return ''
}
}
function get_player_data(player_id,player_name) {
$("#player_data").html('
'+player_name+' ')
let link1_s = `${link1}&player_id=${player_id}`
let link2_s = `${link3}&player_id=${player_id}`
let html = ''
promises.push = ($.ajax({
method:'POST',
url:link2_s,
data:'&1',
dataType: 'html',
success: function(data,status) {
let table_1 = $(data).find('table.w100')
table_1.attr('id','player_data_table')
html += ' | ' + `Wioska |
|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| Mieszane wojska | Typ wioski | Rozmiar ofa | Duży off bez maszyn | ` + '
'
//$("#player_data").html(table)
promises2.push( $.ajax({
method:'POST',
url:link1_s,
data:'&1',
dataType: 'html',
success: function(data,status) {
let table_2 = $(data).find('table.w100')
let table_processing_1 = table_1.find('tr').not(':first')
let table_processing_2 = table_2.find('tr').not(':first')
for (let i=0;i off) {villages[current_id].typ_wioski = 'DEF'} else {villages[current_id].typ_wioski = 'OFF'}
if (def > 1000 && off > 1000) {villages[current_id].mieszaniec = true} else {villages[current_id].mieszaniec = false}
if (villages[current_id].typ_wioski == 'OFF' && villages[current_id].a_taran < 300 ) {villages[current_id].brak_maszyn = true} else {villages[current_id].brak_maszyn = false}
if (villages[current_id].typ_wioski == 'OFF' && villages[current_id].off >= 19500 ) {villages[current_id].full_off = true} else {villages[current_id].full_off = false}
for (let j=0;j<14;j++) {
if (j == 0 || j == 13) {columns_html += '' + $(pierwszy_wiersz[j]).html() + ' | '}
else {columns_html += '' + $(pierwszy_wiersz[j]).html() + ' | '}
}
let typ_ofa
let bez_maszyn = ''
if (villages[current_id].typ_wioski == 'OFF') {
if (villages[current_id].off >= 19500) {typ_ofa = 'full'}
if (villages[current_id].off < 14500) {typ_ofa = 'mniejszy'}
if (villages[current_id].off < 19500 && villages[current_id].off >= 14500) {typ_ofa = '3/4'}
if (villages[current_id].off >= 9500 && villages[current_id].a_taran < 150) {bez_maszyn = 'NOK'}
}
columns_html += '' + get_bad_status(!villages[current_id].mieszaniec) + ' | '
columns_html += '' + villages[current_id].typ_wioski + ' | '
if (villages[current_id].typ_wioski == 'OFF') {
columns_html += '' + typ_ofa + ' | '
columns_html += '' + bez_maszyn + ' | '
}
else {
columns_html += ' | '
columns_html += ' | '
}
html += '' + columns_html + '
';
columns_html = ''
for (let j=0;j<12;j++) {
columns_html += '' + $(drugi_wiersz[j]).html() + ' | '
}
html += '' + columns_html + '
'
columns_html = ''
for (let j=1;j<12;j++) {
columns_html += '' + $(trzeci_wiersz[j]).html() + ' | '
}
html += 'wszystkie | ' + columns_html + '
'
}
$("#player_data_table").html(html)
let ilosc_off = 0
let ilosc_def = 0
let ilosc_mieszanych = 0
let ilosc_ofow_bez_maszyn = 0
let ilosc_full_ofow = 0
let ilosc_3_4_off = 0
$.each(villages,function(index,object) {
if (object.typ_wioski == 'OFF') {ilosc_off += 1}
if (object.typ_wioski == 'DEF') {ilosc_def += 1}
if (object.typ_wioski == 'OFF' && object.full_off == true) {ilosc_full_ofow += 1}
if (object.typ_wioski == 'OFF' && object.off < 19500 && object.off > 14500) {ilosc_3_4_off += 1}
})
let summary_html = `
Ilość wiosek off: ${ilosc_off}
Ilość full off: ${ilosc_full_ofow}
Ilość 3/4 off: ${ilosc_3_4_off}
Ilość wiosek def: ${ilosc_def}
`
$("#player_summary").html(summary_html)
console.log(villages)
}
}))
}}))
}
$(document.body).on('click','#clear_player_villages',function() {
$("#player_data").html('')
})
$(document.body).on('click','#export_table_for_def_analysis',function() {
html = 'Wioska | Piki | Miecze | CK |
'
$.each(villages,function(index,object) {
html += `${object.nazwa} | ${object.o_pik+object.p_pik} | ${object.o_miecz+object.p_miecz} | ${object.o_ciezka+object.p_ciezka} |
`
})
html += '
'
$("#player_data").html(html)
})
function get_player_def(player_id,player_name) {
$("#player_data").html('
'+player_name+'
')
let link1_s = `${link1}&player_id=${player_id}`
let link2_s = `${link3}&player_id=${player_id}`
let html = '
Wioska | Ataki | Piki | Miecze | Ciężka | Total def |
'
console.log(link1_s)
console.log(link2_s)
def_villages = []
$.ajax({
method:'GET',
url:link2_s,
success: function(data) {
def_data = $(data)
table = def_data.find('.table-responsive tr:not(:contains("Wioska"))')
for (i=1;i${village.village} | ${village.attacks} | ${village.spear} | ${village.sword} | ${village.heavy} | ${village.total_def} | `
})
html += '
'
$("#player_data_table").html(html)
}
})
}
function compareValues(key, order = 'asc') {
return function innerSort(a, b) {
if (!a.hasOwnProperty(key) || !b.hasOwnProperty(key)) {
// property doesn't exist on either object
return 0;
}
const varA = (typeof a[key] === 'string')
? a[key].toUpperCase() : a[key];
const varB = (typeof b[key] === 'string')
? b[key].toUpperCase() : b[key];
let comparison = 0;
if (varA > varB) {
comparison = 1;
} else if (varA < varB) {
comparison = -1;
}
return (
(order === 'desc') ? (comparison * -1) : comparison
);
};
}