Vanquished
Miliciano
- Puntuación de reacción
- 99
- Explicación de para qué sirve:
- Renombra tus órdenes de apoyo según las tropas que mandes, con los iconos BB propios del juego. Es decir, si el apoyo contiene 10 lanzas lo renombrará a [unit]spear[/unit] 10.
- Crea una tabla a modo resumen de apoyos enviados a ese pueblo. La tabla será únicamente creada a partir de las tropas visibles a través de las órdenes compartidas. Aparecerán el total de tropas enviadas al pueblo destino en forma de apoyos y un desglose por jugador.
- Como Hacerlo funcionar? Se puede ejecutar en cualquier página donde se vean órdenes de apoyos entrantes (Información del Pueblo si el pueblo no te pertenece, u Plaza de Reuniones / Visión General si te pertenece).
- Nombre de la entrada: Apoyos Entrantes
- URL de la imagen:
- URL de destino:
-
javascript:$.getScript('https://dl.dropbox.com/s/kogr1dqrq325ndb/farma.js?dl=0');
-
/*
plainte
*/
var supp_data;
var progress = 0;
var units = game_data.units;
var total_units = initializeUnits();
var players = {};
function initializeUnits() {
let base_units = {};
for (let key in units) {
let unit_type = units[key];
if (unit_type == "militia")
continue;
base_units[unit_type] = 0;
}
return base_units;
}
function createTable() {
let body = document.getElementById("content_value");
tbl = document.createElement('table');
tbl.className = "vis";
tbl.id = "incomings_summary";
tbl.style = "margin-left:auto; margin-right:auto;"
let keys = Object.keys(players);
for (let row = 0; row < keys.length + 2/*total+tags*/; ++row) {
let tr = tbl.insertRow();
for (let key = 0; key < Object.keys(total_units).length + 1/*player*/; ++key) {
let td = tr.insertCell();
td.style = "text-align:center";
let unitKey = key-1;
if (key == 0)
td.style.fontWeight = 'bold';
if (row == 0) { // First row
if (key == 0) {
td.appendChild(document.createTextNode("Player"));
} else {
let img = document.createElement('img');
img.src = "https://dshu.innogamescdn.com/asset/cf618eb/graphic/unit/unit_" + units[unitKey] + ".png";
td.appendChild(img);
}
} else {
if (row == 1) { // Second row
if (key == 0) {
td.appendChild(document.createTextNode("Total"));
} else {
td.appendChild(document.createTextNode(total_units[units[unitKey]]));
}
} else {
let player = keys[row-2];
if (key == 0) {
td.appendChild(document.createTextNode(player));
} else {
td.appendChild(document.createTextNode(players[player][units[unitKey]]));
}
}
}
}
}
body.prepend(tbl);
$("#incomings_summary").append(`<tr><td style = "text-align: right; font-weight: bold;" colspan = "${$("#incomings_summary").find("tr").eq(0).find("td").length}">Total: <img src = "https://dshu.innogamescdn.com/asset/4b16a6f/graphic/buildings/farm.png">${total_farm_capacity()} Granja</td></tr>`);
let inc = document.getElementById("incomings_summary");
inc.scrollIntoView(false);
}
//---->INCOMMING_SUPPORTS<----
function get_incomming_supports() {
if (progress == 0) {
supp_data = $("span[data-command-type='support']");
}
if (progress >= supp_data.length) {
createTable();
return;
}
$.ajax({
url: "https://" + document.location.host + "/game.php?village=" + game_data.village.id + "&screen=info_command&ajax=details&id=" + $(supp_data).eq(progress).attr("data-command-id"),
async: true,
success: function (result) {
console.log(result);
if (result != '{"no_authorization":true}') {
let data = result;
let sp_d_cont = $(supp_data[progress]).parent().siblings(".quickedit-label").eq(0);
let html = "";
for (let x = 0; x < units.length; x++) {
let unit_type = units[x];
if (unit_type == "militia")
continue;
let unit_count = data.units[units[x]].count;
if (unit_count == "0")
continue;
html += `<img src="https://dshu.innogamescdn.com/asset/cf618eb/graphic/unit/unit_${unit_type}.png">${unit_count} `;
total_units[unit_type] += parseInt(unit_count);
let maybePlayerName = sp_d_cont[0].innerText;
if (maybePlayerName.includes(":")) {
maybePlayerName = maybePlayerName.split(":")[0];
} else {
maybePlayerName = game_data.player.name;
}
if (!(maybePlayerName in players))
players[maybePlayerName] = initializeUnits();
players[maybePlayerName][unit_type] += parseInt(unit_count);
}
$(sp_d_cont).html(html);
}
++progress;
setTimeout(get_incomming_supports, 50);
}
})
}
function total_farm_capacity(){
var units_and_capacity = {"spear": 1, "sword": 1, "axe": 1, "archer": 1, "spy": 2, "light": 4, "heavy": 6, "marcher": 5, "ram": 5, "catapult": 8, "knight": 10, "snob": 100};
var total = 0;
for(var x = 0; x < game_data.units.length; x++){
if(game_data.units[x] == "militia")
continue;
total += total_units[game_data.units[x]] * units_and_capacity[game_data.units[x]];
}
return total;
}
function alw_check_commands() {
$("span").each(function () {
if ($(this).text().indexOf("0:00:1") > -1 || $(this).text().indexOf("0:00:0") > -1) {
$(this).parent().parent().remove();
}
});
setTimeout(alw_check_commands, 6000);
}
(() => {
initializeUnits(total_units);
alw_check_commands();
get_incomming_supports();
})();
-
Previamente aprobado en el ticket #t14716475.