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
);
};
}
$(document.body).on('click','#attacks_check',function() {
members = $("table:contains('Ranking globalny')").find("a[href*='info_player&id=']:not([title])")
id = 1
$.each(members,function(index,element) {
link = $(element).attr('href')
player_id = link.substring(link.search("&id=")+4,link.length)
$.ajax({
method:'POST',
url:`https://${game_data.world}.plemiona.pl/game.php?screen=ally&mode=members_defense&player_id=${player_id}`,
async:false,
success: function(response) {
attacks = $(response).find("table.w100 th").last().text().trim().replace('(','').replace(')','')
console.log(link + " " + player_id + " " + attacks)
if (attacks == '0') {
$(element).closest('tr').find('td').last().html(attacks)
} else {
$(element).closest('tr').find('td').last().html(`${attacks}`)
}
}
})
})
window.Dialog.close()
//window.Dialog.show('test','Downloading data... ')
})
async function showDialog(id,length) {
window.Dialog.show('test',`Downloading data... ${id}/${length}`)
}