- Code: Select all
plugins.worldmorale = { // calculates traveltimes on the map
'enhance_game_map': function() {
$("#info_content #info_extra_info").after("<tr><td>Morale</td><td id=\"info_morale\"></td></tr>");
var old_map_popup = unsafeWindow.map_popup;
setFunc("map_popup", function map_popup(title, bonus_image, bonus_text, points, owner, ally, village_groups, moral, village_id, source_id) {
old_map_popup(title, bonus_image, bonus_text, points, owner, ally, village_groups, moral, village_id, source_id);
window.setTimeout(function() {
if (owner == null) {
$("#info_morale").html("100%");
} else {
var MyPoints = (xpathGetFirst("/html/body/table[1]/tbody/tr/td[6]").innerHTML).replace('<span class="grey">.</span>',"").match(/\|(\d+) P\)/)[1];
var HisPoints = owner.match(/\(([\d.]+) Points\)/)[1].replace(".","");
var Target_Coords = title.match(/\((-?\d+)\|(-?\d+)\)/);
$("#info_morale").html(((t = ((t = Math.round(30+(300/(MyPoints/HisPoints)))) > 100 ? 100 : t)) < 30 ? 30 : t) + "%");
}
}, 0);
});
},
'info' : {
'mandatory' : false,
'name' : "Morale",
'desc' : "Adds morale to the world map",
'version' : "0.1",
'dev' : "JohnDoe"
}
};
