// ==UserScript==
// @name TW Friends
// @name:el TW Friends
// @name:es TW Friends
// @name:fr TW Friends
// @name:it TW Friends
// @name:pl TW Friends
// @name:pt-PT TW Friends
// @name:tr TW Friends
// @version 0.31
// @license LGPLv3
// @description Friend Management for The West Events
// @description:el Διαχείριση Φίλων για τις Εκδηλώσεις του The West
// @description:es Gestión de Amigos para Eventos de The West
// @description:fr Gestion des Amis pour les Evénements de The West
// @description:it Gestione amici per gli eventi The West
// @description:pl Menadżer zarządzania Przyjaciółmi podczas eventów The West
// @description:pt-PT Gestão de amigos para eventos no The West
// @description:tr The West Etkinlikleri İçin Arkadaş Yöneticisi
// @author hiroaki
// @translation pepe100 (es_ES)
// @translation Jackssson (it_IT)
// @translation jccwest (pt_PT)
// @translation Bartosz86 (pl_PL)
// @translation Oğuzhan Ünal (tr_TR)
// @include http*://*.the-west.*/game.php*
// @include http*://*.tw.innogames.*/game.php*
// @grant none
// @namespace https://greasyfork.org/users/3197
// @icon https://cdn.rawgit.com/TWFriends/scripts/master/friends.png
// @downloadURL none
// ==/UserScript==
function hiroFriendsScript(fn) {
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = '(' + fn + ')();';
document.body.appendChild(script);
document.body.removeChild(script);
}
hiroFriendsScript(function() {
var VERSION = 0.31;
var URL_INSTALL = "https://greasyfork.org/scripts/2992-tw-friends";
var URL_CODE = "https://greasyfork.org/scripts/2992-tw-friends/code/TW%20Friends.user.js";
var URL_VERSION = "https://raw.githack.com/TWFriends/scripts/master/version.js";
var script = "HiroFriends";
var scriptName = "TW Friends";
var scriptAuthor = "hiroaki";
var scriptCredits = 'Bartosz86 ??, Jackssson ??, jccwest ??, pepe100 ??, Oğuzhan Ünal ??,
noolas, Pnevma, Revolver Ocelot, tzanetos22';
var refreshMinutes = 60; /* to be removed shortly */
var enableLog = true;
var enableInv = true;
var enableVersionCheck = true;
this[script] = {
api: TheWestApi.register(script, scriptName, '2.04', Game.version.toString(), scriptAuthor, URL_INSTALL),
locale: 'en_US',
timeLeft : 0,
helpers: {
/* Inno buildDateObject() function currently buggy */
buildDateObject: function(timeStr, isServerTime) {
var regEx, match, d = new Date(0), today = new Date();
regEx = /^(?:(3[01]|[012]?[0-9]|\*)\.(?:(1[012]|0?[1-9]|\*)\.((?:19|20)?\d\d|\*)))?(?: ?(2[0-3]|[01]?\d|\*)\:([0-5]?\d|\*)(?:\:([0-5]?\d|\*))?)?$/;
if(match = timeStr.match(regEx)) {
d.setFullYear(match[3] !== undefined ? (match[3] == '*' ? today.getFullYear() : parseInt(match[3], 10)) : today.getFullYear());
d.setMonth(match[2] !== undefined ? (match[2] == '*' ? today.getMonth() : parseInt(match[2], 10) - 1) : today.getMonth());
d.setDate(match[1] !== undefined ? (match[1] == '*' ? today.getDate() : parseInt(match[1], 10)) : today.getDate());
d.setHours(match[4] !== undefined ? (match[4] == '*' ? today.getHours() : match[4]) : 0);
d.setMinutes(match[5] !== undefined ? (match[5] == '*' ? today.getMinutes() : match[5]) : 0);
d.setSeconds(match[6] !== undefined ? (match[6] == '*' ? today.getSeconds() : match[6]) : 0);
d.setMilliseconds(0);
}
if(isServerTime) d = new Date(d - Game.serverTimeDifference);
return d;
},
buildTimeStamp: function (timeStr, isServerTime) {
return this.buildDateObject(timeStr, isServerTime).getTime();
},
debug: function(title = 'Debugger', data = '', icon = west.gui.Dialog.SYS_WARNING) {
var now = new Date(), date_str = now.toTimeString();
console.log('['+date_str+'|'+title+'] '+data);
// new west.gui.Dialog(title, msg, icon).addButton("ok").show();
},
escapeHtml: function(raw) {
return raw.replace(/[&<>"']/g, function onReplace(match) { return '' + match.charCodeAt(0) + ';'; });
},
},
eventManager: {
eventEnd: 0,
eventName: '',
eventInfo: {},
timeLeft: 0,
init: function(eventName) {
var eventEndStamp;
if(undefined === Game.sesData[eventName] || undefined === Game.sesData[eventName].friendsbar) return false;
this.eventName = eventName;
this.eventInfo = Game.sesData[eventName].friendsbar;
if(undefined === Game.sesData[this.eventName].meta.end) return false;
this.eventEnd = HiroFriends.helpers.buildTimeStamp(Game.sesData[this.eventName].meta.end) - Game.serverTimeDifference;
this.timeLeft = eventEndStamp - Game.getServerTime();
if(this.timeLeft < 0) return false;
if (HiroFriends.guiManager.init()) {
HiroFriends.tombolaManager.init();
HiroFriends.inventoryManager.init();
HiroFriends.logManager.init().done(function() {
HiroFriends.friendManager.init().done(function() {
HiroFriends.guiManager.divSend.show();
});
});
}
},
},
friendManager: {
loaded: false,
friends : {},
canSend: 0,
listeningSignals: [ 'friend_added', 'friend_removed', ],
totalFriends : 0,
pendingInvitations: 0,
refetch: 0,
timeout: false,
init: function() {
var that = this;
return this.fetch().done(function() {
that.loaded = true;
EventHandler.listen(that.listeningSignals, that.reload, that);
});
},
destroy: function() {
EventHandler.unlisten(this.listeningSignals, this.reload, this);
},
fetch: function() {
if(this.timeout !== false) clearInterval(this.timeout);
var event_times = {};
var friends = {}, total = 0, can_send = 0;
var server_time = Game.getServerTime(), activation_time, friend_time;
var that = this;
if(HiroFriends.eventManager.timeLeft < 0) {
$("#hiro_friends_container").slideUp(5000);
if(enableInv) HiroFriends.inventoryManager.bottomBarDiv.hide(5000);
throw "Event is over";
}
return $.post("/game.php?window=friendsbar&mode=search", { search_type: "friends" } , function(data) {
var now = Date.now()/1e3, timesSent = 0, activation_time, recv, firstSent, lastSent, freq, nextSend, nextFetch = HiroFriends.eventManager.eventInfo.cooldown;
$.each(data.eventActivations, function(key, val) {
if(val.event_name == HiroFriends.eventManager.eventName) event_times[val.friend_id] = val.activation_time;
});
$.each(data.players, function(key, val) {
if(val.name !== Character.name) {
activation_time = (event_times[val.player_id] !== undefined) ? event_times[val.player_id]: 0;
if(undefined === HiroFriends.logManager.friendLog[val.player_id]) {
recv = 0;
HiroFriends.logManager.friendLog[val.player_id] = { name: val.name, total: 0, dates: [] };
}
else {
recv = HiroFriends.logManager.friendLog[val.player_id].total;
}
if (undefined !== HiroFriends.logManager.friendLog[val.player_id].dates) {
timesSent = HiroFriends.logManager.friendLog[val.player_id].dates.length;
firstSent = Math.min.apply(null, HiroFriends.logManager.friendLog[val.player_id].dates);
lastSent = Math.max.apply(null, HiroFriends.logManager.friendLog[val.player_id].dates);
if (!timesSent) freq = Number.MAX_VALUE;
else if (timesSent == 1) freq = now - lastSent;
else freq = (now - firstSent) / (timesSent - 1);
}
else {
lastSent = 0;
freq = Number.MAX_VALUE;
}
friends[val.player_id] = { name: val.name, activation_time: activation_time, recv: recv, last: lastSent, freq: freq };
++ total;
nextSend = activation_time + HiroFriends.eventManager.eventInfo.cooldown - server_time;
if(nextSend <= 0) ++ can_send;
else nextFetch = Math.min(nextSend, nextFetch);
}
});
that.friends = friends;
that.canSend = can_send;
that.totalFriends = total;
HiroFriends.guiManager.updateCounters(can_send, total);
var should_fetch_again = nextFetch*1e3;
var will_fetch_again = Math.min(refreshMinutes*60*1e3, should_fetch_again); /* to be removed shortly */
that.refetch = now*1e3 + should_fetch_again;
that.timeout = setInterval(function() { HiroFriends.friendManager.fetch(); }, will_fetch_again);
});
},
getPendingInvitations: function() {
return $.post("/game.php?window=character&mode=get_open_requests", function(data) {
var openReq = 0;
$.each(data.open_friends, function(key, val) { if(val.inviter_id != Character.playerId) ++ openReq; });
HiroFriends.friendManager.pendingInvitations = openReq;
});
},
pendingInvitationsMsg: function() {
return this.pendingInvitations == 1 ? HiroFriends.localeMsg('pendingInvitation') : this.pendingInvitations+' '+HiroFriends.localeMsg('pendingInvitations');
},
reload: function() {
var that = this;
HiroFriends.guiManager.updateCounters(0, 0);
return this.fetch().done(function() {
HiroFriends.guiManager.updateCounters(that.canSend, that.totalFriends);
});
},
remove: function(charId) {
new west.gui.Dialog(HiroFriends.localeMsg('removeFriend'), HiroFriends.localeMsg('removeConfirm')).setIcon(west.gui.Dialog.SYS_QUESTION).addButton("yes", function() {
Ajax.remoteCall('character', 'cancel_friendship', { friend_id: charId }, function(json) {
if(json["result"]) {
new UserMessage(HiroFriends.localeMsg('removeSuccess'), UserMessage.TYPE_SUCCESS).show();
$("div.hiroFriendRow_" + charId).remove();
$("div.friendData_" + charId, FriendslistWindow.DOM).remove();
delete(HiroFriends.friendManager.friends[charId]);
if(HiroFriends.friendManager.canSend) -- HiroFriends.friendManager.canSend;
if(HiroFriends.friendManager.totalFriends) -- HiroFriends.friendManager.totalFriends;
HiroFriends.guiManager.updateCounters(HiroFriends.friendManager.canSend, HiroFriends.friendManager.totalFriends);
Chat.Friendslist.removeFriend(charId);
}
else new UserMessage(HiroFriends.localeMsg('removeFailed'), UserMessage.TYPE_ERROR).show();
})
}).addButton("no").show();
},
},
guiManager: {
loaded: false,
cdnBase: '',
currencyImage : '',
spanCounter: null,
spanFriendsAvail: null,
spanFriendsTotal: null,
spanInvitations: null,
spanRefresh: null,
divContainer: null,
divTombola: null,
divMain: null,
divSend: null,
divFriendsAvail: null,
imgFriendsAvail: null,
divInventoryAvail: null,
imgInventoryAvail: null,
init: function() {
this.cdnBase = Game.cdnURL || "https://westzzs.innogamescdn.com";
this.currencyImage = this.cdnBase+"/images/icons/"+HiroFriends.eventManager.eventName+".png";
if (this.addCss().addTopBar().addBottomBarFriendsIcon().addBottomBarInventoryIcon()) {
this.showInvitations();
this.loaded = true;
return true;
}
return false;
},
destroy: function() {
this.divMain.hide(5000);
this.divFriendsAvail.hide(5000);
this.divInventoryAvail.hide(5000);
this.loaded = false;
},
addCss: function() {
var my_css = "\n";
my_css += "\t.hf_idx { width: 24px; text-align: right; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n";
my_css += "\t.hf_player { width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n";
my_css += "\t.hf_action { width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }\n";
my_css += "\t.hf_log { width: 80px; text-align: right; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n";
my_css += "\t.hf_last { width: 140px; text-align: right; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n";
my_css += "\t.hf_freq { width: 80px; text-align: right; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n";
my_css += "\t.hf_delete { width: 24px; text-align: center; }\n";
my_css += "\t.hf_row { height: 16px; line-height: 16px; }\n";
my_css += "\tspan.hf_stat { display: inline-block; width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n";
my_css += "\tspan.hf_count { display: inline-block; width: 60px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; text-align: right; }\n";
my_css += "\t.hf_drill { white-space: nowrap; }\n";
my_css += "\tdiv.hiro_friends_maindiv div.tbody .hf_idx, div.hiro_friends_maindiv div.tbody .hf_delete { background: url('"+this.cdnBase+"/images/tw2gui/table/cell_shadow_y.png'); }\n";
$('').appendTo("head");
return this;
},
addBottomBarFriendsIcon: function() {
this.divFriendsAvail = $("
", { id: "hiro_friends_bottombar_friends", style: "position: absolute; top: 0px; right: 0px; z-index: 18; width: 20px; height: 18px;" }).hide();
this.imgFriendsAvail = $('
').click(function(e){ e.preventDefault(); HiroFriends.windowManager.open(); return false; });
this.imgFriendsAvail.appendTo(this.divFriendsAvail);
this.divFriendsAvail.appendTo("#ui_bottombar .ui_bottombar_wrapper .button:nth-child(3) .dock-image");
return this;
},
addBottomBarInventoryIcon: function() {
this.divInventoryAvail = $("", { id: "hiro_friends_inventory_container", style: "position: absolute; top: 0px; right: 0px; z-index: 18; width: 20px; height: 18px;" }).hide().appendTo("#ui_bottombar .ui_bottombar_wrapper .button:first .dock-image");
this.imgInventoryAvail = $('
').click(function(e){ e.preventDefault(); HiroFriends.inventoryManager.displayGenerators(); return false; }).appendTo(this.divInventoryAvail);
return this;
},
addTopBar: function() {
var that = this;
this.divContainer = $("", { id: "hiro_friends_container", style: "position: absolute; top: 32px; right: 50%; margin-right: 120px; z-index: 16; width: 180px; height: 36px; text-align: left; text-shadow: 1px 1px 1px #000; background: url('"+this.cdnBase+"/images/interface/custom_unit_counter_sprite.png?2') no-repeat scroll 50% 0px transparent;" })
var divRefresh = $("", { id: "hiro_friends_refresh", style: "width: 24px; height: 24px; position: absolute; left: 8px; top: 3px; z-index: 3; padding: 4px 0px 0px 4px;" });
this.divMain = $("", { id: "hiro_friends", style: "background: url('"+this.cdnBase+"/images/interface/custom_unit_counter_sprite.png?2') no-repeat scroll 0 -36px rgba(0, 0, 0, 0); height: 25px; left: 32px; line-height: 25px; padding: 0 5px; position: absolute; top: 3px; width: 105px; z-index: 1; text-shadow: 1px 1px 1px #000;" });
this.divTombola = $("", { id: "hiro_wof_container", style: "position: absolute; left: 2px; top: 4px; height: 16px;" });
this.divSend = $("", { title: HiroFriends.eventManager.eventInfo.label, class: "fbar-player-event-notif ses_"+HiroFriends.eventManager.eventName, style: "position: absolute; right: 0px; top: 2px; z-index: 3;" })
.click(function() { HiroFriends.windowManager.open(); return false; }).hide();
this.spanRefresh = $('', { title: HiroFriends.localeMsg('refresh'), style: "display: inline-block; width: 20px; height: 20px; cursor: pointer; background: url('"+this.cdnBase+"/images/tw2gui/window/window2_buttons.png?5') repeat scroll 0px -20px transparent;" })
.mouseenter(function() { that.refreshPopup(); $(this).css("background-position", ""); })
.mouseleave(function() { that.refreshPopup(); $(this).css("background-position", "0px -20px"); })
.click(function() {
HiroFriends.logManager.getLog();
HiroFriends.friendManager.reload();
HiroFriends.inventoryManager.check();
HiroFriends.tombolaManager.reload();
return false;
}).appendTo(divRefresh);
this.refreshPopup();
this.spanFriendsAvail = $("", { text: 0, title: HiroFriends.localeMsg('availFriends'), style: "color: #f8c57c; font-size: 13pt;" });
this.spanFriendsTotal = $("", { text: 0, title: HiroFriends.localeMsg('totalFriends') });
this.spanCounter = $("", { id: "hiro_friends_counter", style: "position: absolute; right: 5px; bottom: 0px; height: 25px; line-height: 25px; color: lightgray; font-size: 11px;" }).append(this.spanFriendsAvail, $(" / "), this.spanFriendsTotal);
this.divContainer.append(
divRefresh,
this.divMain.append(this.divTombola, this.spanCounter),
this.divSend,
).appendTo("#user-interface");
return this;
},
refreshPopup: function() {
var content = '', now = Date.now(), timers = { };
if (HiroFriends.tombolaManager.refetch) timers[HiroFriends.tombolaManager.wofStatus.title] = HiroFriends.tombolaManager.refetch;
if (HiroFriends.friendManager.refetch) timers[HiroFriends.eventManager.eventInfo.label] = HiroFriends.friendManager.refetch;
if (HiroFriends.inventoryManager.refetch) timers[HiroFriends.localeMsg('inventory')] = HiroFriends.inventoryManager.refetch;
content = '';
$.each(timers, function(key, val) {
var date_str = val < HiroFriends.eventManager.eventEnd ? new Date(val).toDateTimeStringNice() : HiroFriends.localeMsg('nextYear');
var diff_str = val < HiroFriends.eventManager.eventEnd ? ((val - now)/1e3).formatDurationBuffWay() : '';
content += ''+key+': | '+diff_str+' | '+date_str+' |
';
});
content += '';
this.spanRefresh.addMousePopup({'teaser': ''+HiroFriends.localeMsg('refresh')+'', 'content': content });
},
showInvitations: function() {
var that = this;
HiroFriends.friendManager.getPendingInvitations().done(function() {
if(HiroFriends.friendManager.pendingInvitations) {
that.spanCounter.css("right", "20px");
that.spanInvitations = $("", { id: "hiro_friends_invitations", title: HiroFriends.friendManager.pendingInvitationsMsg(), style: "position: absolute; right: 0px; width: 19px; height: 25px; background-image: url('"+that.cdnBase+"/images/interface/more.jpg'); background-repeat: no-repeat;" })
.hover(function() { $(this).css("background-position", "0px -25px"); }, function() { $(this).css("background-position", ""); })
.click(function() { $(this).hide(); that.spanCounter.css("right", "5px"); FriendslistWindow.open('openrequests'); return false; })
.appendTo(that.divMain).show();
}
});
},
updateBottomBarFriendsIcon: function(canSend, total) {
if (this.loaded) {
if(canSend) {
this.imgFriendsAvail.addMousePopup({'teaser': ''+scriptName+'', 'content': canSend+'/'+total });
this.divFriendsAvail.show(3000);
}
else this.divFriendsAvail.hide();
}
return this;
},
updateBottomBarInventoryIcon: function(coolDownComplete, wallet) {
this.imgInventoryAvail.attr('src', coolDownComplete ? HiroFriends.guiManager.cdnBase+'/images/icons/clock.png' : this.currencyImage);
this.imgInventoryAvail.attr('title', wallet ? wallet+'
' : '');
if(wallet) this.divInventoryAvail.show(3000);
else this.divInventoryAvail.hide(1000);
return this;
},
updateStatsInventory: function(wallet) {
var el = $(".hf_inv_row .hf_count"), from = "" != el.text() && deformat_number(el.text()) || 0;
west.common.countTo(el, wallet, from, function(val) { el.text(format_number(Math.ceil(val, 6))); });
return this;
},
updateFriendsAvail: function(n) {
west.common.countTo(this.spanFriendsAvail, parseInt(n));
return this;
},
updateFriendsTotal: function(n) {
west.common.countTo(this.spanFriendsTotal, parseInt(n));
return this;
},
updateCounters: function(canSend, totalFriends) {
this.updateFriendsAvail(canSend);
this.updateFriendsTotal(totalFriends);
this.updateBottomBarFriendsIcon(canSend, totalFriends);
return this;
},
},
logManager: {
deferred: null,
drillCollected: { admin: 0, adventures: 0, construction: 0, duels: 0, fortBattles: 0, itemUse: 0, jobs: 0, npcDuels: 0, quests: 0, other: 0 },
drillSpent: { admin: { times: 0, cost: 0 }, bribe: { times: 0, cost: 0 }, timer: { times: 0, cost: 0 }, other: { times: 0, cost: 0 } },
entries: [],
friendLog: {},
loaded: false,
locked: false,
refetch: 0,
signalReceived: null,
signalSent: null,
timeout: null,
totalCollected: 0,
totalFriends: 0,
totalReceived: 0,
totalSent: 0,
totalSpent: 0,
firstLog: Date.now()/1e3,
lastLog: 0,
newLastLog: 0,
init: function() {
var that = this;
this.signalSent = (Game.sesData[HiroFriends.eventManager.eventName].counter.key.replace('collected','sent'));
this.signalReceived = (Game.sesData[HiroFriends.eventManager.eventName].counter.key.replace('collected','received'));
EventHandler.listen(this.signalSent, this.updateTotalSent, this);
EventHandler.listen(this.signalReceived, this.updateTotalReceived, this);
return $.when(this.getLog()).done(function() {
that.loaded = true;
});
},
destroy: function() {
clearTimeout(this.timeout);
EventHandler.unlisten(this.signalSent, this.updateTotalSent, this);
EventHandler.unlisten(this.signalReceived, this.updateTotalReceived, this);
},
updateTotalReceived: function(data) {
var el = $(".hf_recv_row .hf_count"), new_value = parseInt(data);
if (this.totalReceived) {
var el2 = $(".hf_coll_row .hf_count"), from2 = "" != el2.text() && deformat_number(el2.text()) || 0;
diff = new_value - this.totalReceived;
if (from2 && diff) west.common.countTo(el2, from2+diff, from2, function(val) { el2.text(format_number(Math.ceil(val, 6))); });
}
$(".hf_recv_row").css({"visibility": "visible"});
west.common.countTo(el, new_value, this.totalReceived, function(val) { el.text(format_number(Math.ceil(val, 6))); });
this.totalReceived = new_value;
},
updateTotalSent: function(data) {
var el = $(".hf_sent_row .hf_count"), from = "" != el.text() && deformat_number(el.text()) || 0;
this.totalSent = parseInt(data);
$(".hf_sent_row").css({"visibility": "visible"});
west.common.countTo(el, this.totalSent, from, function(val) { el.text(format_number(Math.ceil(val, 6))); });
},
getLogPage: function(page, limit) {
var that = this;
return $.ajax({ type: "POST", url: "/game.php?window=ses&mode=log", data: { ses_id: HiroFriends.eventManager.eventName, page: page, limit: limit }, success: function(data) {
var details;
var hasNext = data.hasNext;
var count = 0;
var limit = data.limit;
page = data.page + 1;
$.each(data.entries, function(key, val) {
count = parseInt(val.value);
if(val.date < that.firstLog) that.firstLog = val.date;
if(val.date <= that.lastLog) {
hasNext = false;
return false;
}
that.entries.push(val);
if(val.date > that.newLastLog) that.newLastLog = val.date;
switch(val.type) {
case "friendDrop":
if(null !== val.details) {
details = JSON.parse(val.details);
if(undefined !== HiroFriends.friendManager.friends[details.player_id]) HiroFriends.friendManager.friends[details.player_id].recv += count;
if(undefined === that.friendLog[details.player_id]) that.friendLog[details.player_id] = { name: details.name, total: count, dates: [] };
else that.friendLog[details.player_id].total += count;
that.friendLog[details.player_id].dates.push(val.date);
}
that.totalFriends += count;
that.totalCollected += count;
break;
case "jobDrop": that.drillCollected.jobs += count; that.totalCollected += count; break;
case "buildDrop": that.drillCollected.construction += count; that.totalCollected += count; break;
case "duelDrop": that.drillCollected.duels += count; that.totalCollected += count; break;
case "duelNPCDrop": that.drillCollected.npcDuels += count; that.totalCollected += count; break;
case "battleDrop": that.drillCollected.fortBattles += count; that.totalCollected += count; break;
case "adventureDrop": that.drillCollected.mpi += count; that.totalCollected += count; break;
case "questDrop": that.drillCollected.quests += count; that.totalCollected += count; break;
case "itemUse": that.drillCollected.itemUse += count; that.totalCollected += count; break;
case "adminDrop":
if (count > 0) {
that.drillCollected.admin += count;
++ that.drillCollected.admin.times;
that.totalCollected += count;
}
else {
that.drillSpent.admin.cost += count;
++ that.drillSpent.admin.times;
that.totalSpent += count;
}
break;
case "wofPay":
that.totalSpent += count;
if(null !== val.details) {
if(val.details == "timerreset") {
that.drillSpent.timer.cost += count;
++ that.drillSpent.timer.times;
}
else if(val.details == "sneakyshot") {
that.drillSpent.bribe.cost += count;
++ that.drillSpent.bribe.times;
}
else {
that.drillSpent.other.cost += count;
++ that.drillSpent.other.times;
}
}
else {
if (undefined === that.drillSpent[count]) that.drillSpent[count] = { times: 1, cost: count };
else {
that.drillSpent[count].cost += count;
++ that.drillSpent[count].times;
}
}
break;
default:
if (count > 0) {
that.drillCollected.other += count;
that.totalCollected += count;
}
else {
that.drillSpent.other.cost += count;
++ that.drillSpent.other.times;
that.totalSpent += count;
}
}
});
if (hasNext) return that.getLogPage(page, limit, that.deferred);
else {
/* Done */
that.lastLog = that.newLastLog;
Chat.Request.Nop();
var now = Date.now(), will_fetch_again = refreshMinutes*60*1e3;
that.refetch = now + will_fetch_again;
that.timeout = setTimeout(function() { that.getLog(); }, will_fetch_again);
that.deferred.resolve();
}
} });
},
getLog: function() {
var limit = 100;
if(enableLog) {
if (!this.locked) {
clearTimeout(this.timeout);
this.deferred = new $.Deferred();
HiroFriends.logManager.newLastLog = HiroFriends.logManager.lastLog;
this.getLogPage(1, limit);
}
return this.deferred.promise();
}
},
},
inventoryManager: {
generatorsInventory: [],
generatorsAvailable: [],
listeningSignals: [],
loaded: false,
bottomBarDiv: null,
bottomBarImg: null,
wallet: 0,
invTimeout: null,
refetch: 0,
currencyGenerators: {
Hearts: {
2557000 : 1250, /* Small Heart Bag - 1250 hearts */
2558000 : 2500, /* Large Heart Bag - 2500 hearts */
2561000 : 100, /* Love Apple - 100 hearts */
2562000 : 500, /* Sugar hearts - 500 hearts */
2563000 : 650, /* 650 hearts */
2564000 : 1500, /* 1500 hearts */
2565000 : 3250, /* 3250 hearts */
2566000 : 9000, /* 9000 hearts */
2567000 : 16000, /* 16000 hearts */
},
Easter: {
2698000 : 2500, /* Efficient Easter egg container - 2500 eggs */
2590000 : 650, /* 650 Eggs */
2591000 : 1500, /* 1500 Eggs */
2592000 : 3250, /* 3250 Eggs */
2593000 : 9000, /* 9000 Eggs */
2594000 : 16000, /* 16000 Eggs */
},
Independence: {
2619000 : 650, /* 650 Fireworks */
2620000 : 1500, /* 1500 Fireworks */
2621000 : 3250, /* 3250 Fireworks */
2622000 : 9000, /* 9000 Fireworks */
2623000 : 16000, /* 16000 Fireworks */
},
Octoberfest: {
50691000 : 2500, /* Bag of Pretzels - 2500 Pretzels */
371000 : 650, /* 650 Pretzels */
973000 : 1500, /* 1500 Pretzels */
974000 : 3250, /* 3250 Pretzels */
975000 : 9000, /* 9000 Pretzels */
976000 : 16000, /* 16000 Pretzels */
},
DayOfDead: {
2665000 : 1250, /* Flower pot - 1250 Cempasúchil flowers */
2666000 : 2500, /* Big Flower pot - 2500 Cempasúchil flowers */
2675000 : 25, /* Cempasúchil Case - 25 Cempasúchil flowers */
2676000 : 650, /* 650 Cempasúchils */
2677000 : 1500, /* 1500 Cempasúchils */
2678000 : 3250, /* 3250 Cempasúchils */
2679000 : 9000, /* 9000 Cempasúchils */
2680000 : 16000, /* 16000 Cempasúchils*/
}
},
init: function() {
this.listeningSignals = [ 'inventory_loaded', 'inventory_changed', 'cooldown_changed', 'item_lifetime_changed' ];
this.loaded = true;
EventHandler.listen(this.listeningSignals, this.check, this);
return true;
},
destroy: function() {
EventHandler.unlisten(this.listeningSignals, this.check, this);
},
check: function () {
clearTimeout(this.invTimeout);
if(!this.loaded) return false;
var coolDownComplete = false, genAll = [], genNow = [], genTotal = 0, now = new ServerDate().getTime()/1e3;
var should_check_again = 86400, will_check_again;
$.each(this.currencyGenerators[HiroFriends.eventManager.eventName], function(itemId, amount) {
var invItem = Bag.getItemByItemId(itemId);
if(invItem) {
var coolDown = Bag.itemCooldown[itemId];
genAll.push(invItem);
if(!coolDown) {
genNow.push(invItem);
genTotal += invItem.count*amount;
}
else if(coolDown <= now) {
coolDownComplete = true;
genNow.push(invItem);
genTotal += amount;
}
else {
should_check_again = Math.min(should_check_again, coolDown - now);
}
}
});
this.generatorsInventory = genAll;
this.generatorsAvailable = genNow;
this.wallet = genTotal;
HiroFriends.guiManager.updateBottomBarInventoryIcon(coolDownComplete, this.wallet);
HiroFriends.guiManager.updateStatsInventory(this.wallet);
should_check_again = Math.max(1, should_check_again)*1e3;
will_check_again = Math.min(refreshMinutes*60*1e3, should_check_again); /* to be removed shortly */
this.refetch = now*1e3 + should_check_again;
var that = this;
this.invTimeout = setTimeout(function() { that.check(); }, will_check_again);
},
displayGenerators: function() {
try { this.check(); } catch(e) { }
if(this.generatorsInventory.length > 0) {
if(!Bag.loaded) {
var that = this;
EventHandler.listen('inventory_loaded', function () {
that.openInventory();
return EventHandler.ONE_TIME_EVENT;
});
}
else this.openInventory();
}
},
openInventory: function() {
Wear.open();
Inventory.showSearchResult(this.generatorsInventory);
},
},
tombolaManager: {
refetch: 0,
signalsPlayed: [ 'inventory_changed', 'char_nuggets_changed' ],
signalWallet: '',
loaded: false,
states: [],
wallet: 0,
wofId: undefined,
wofStatus: {},
wofTries: 0,
wofType: undefined,
wofPromise: undefined,
init: function() {
var wof_types = {
'Hearts' : 'heartswof',
'Easter' : 'easterwof',
'Independence' : 'independencewof',
'Octoberfest' : 'octoberwof',
'DayOfDead' : 'dayofdeadwof',
};
if (undefined == wof_types[HiroFriends.eventManager.eventName]) return false;
this.wofType = wof_types[HiroFriends.eventManager.eventName];
if ('Octoberfest' !== HiroFriends.eventManager.eventName) return false;
this.wallet = Character.ses_currency[HiroFriends.eventManager.eventName.toLowerCase()];
if (undefined == this.wofId) {
this.wofPromise = new $.Deferred();
var that = this;
$.when(this.wofPromise).done(function(wof_id) {
if (undefined !== wof_id) {
that.wofId = wof_id;
that.initGui();
that.initWofStatus().done(function() {
that.loaded = true;
that.signalWallet = Game.sesData[HiroFriends.eventManager.eventName].counter.key;
EventHandler.listen(that.signalWallet, that.signalWalletChanged, that);
EventHandler.listen(that.signalsPlayed, that.signalPlayedHandler, that);
});
}
});
this.getWofId();
}
},
initGui: function() {
for (var i = 0; i < 4; ++i)
$("", { id: "hiro_wof_"+i, style: "display: inline-block; width: 13px; height: 16px; background: url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat -2px -16px; opacity: 0.5; cursor: pointer;" }).appendTo(HiroFriends.guiManager.divTombola);
return this;
},
initWofStatus: function () {
var that = this;
if (this.loaded) return false;
this.wofStatus = west.wof.WofManager.wofs[this.wofType];
this.wallet = Character.ses_currency[HiroFriends.eventManager.eventName.toLowerCase()];
return $.ajax({ type: "POST", url: "/game.php?window=wheeloffortune&mode=init", data: { wofid: this.wofId }, success: function(data) {
data.prizes.enhancements.sort(function(a, b) { return a - b; });
west.wof.WofManager.wofs[that.wofType].mode = data.mode;
west.wof.WofManager.wofs[that.wofType].prizes = data.prizes;
west.wof.WofManager.wofs[that.wofType].title = data.title;
that.wofStatus = west.wof.WofManager.wofs[that.wofType];
that.displayWofStatus();
} });
},
destroy: function() {
EventHandler.unlisten(this.signalWallet, this.signalWalletChanged, this);
EventHandler.unlisten(this.signalsPlayed, this.signalPlayedHandler, this);
},
reload: function() {
for (var i = 3; i >= 0; --i)
$("#hiro_wof_"+i).css({ "background": "url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat 0 -16px", "opacity": "0.5" });
if (this.loaded) this.displayWofStatus();
},
getWofId: function() {
var wof_id = undefined;
try { wof_id = west.wof.WofManager.wofs[this.wofType].getId(); } catch (e) { }
if (undefined !== wof_id) this.wofPromise.resolve(wof_id);
else {
++ this.wofTries;
if (this.wofTries < 100) {
var that = this;
setTimeout(function() { that.getWofId(); }, this.wofTries*1e3);
}
else this.wofPromise.resolve();
}
},
signalPlayedHandler: function() {
var that = this;
if (!this.loaded) return false;
setTimeout(function() { that.displayWofStatus(); }, 1e3);
},
signalWalletChanged: function(data) {
var newAmount = parseInt(data), that = this;
if (!this.loaded) return false;
if (newAmount) this.wallet = newAmount;
setTimeout(function() { that.displayWofStatus(); }, 1e3);
},
constructionEnds: function(cost) {
var finishStamp = 0;
if (undefined !== this.wofStatus.window && undefined !== this.wofStatus.window.constructions && undefined !== this.wofStatus.window.constructions[cost]) {
finishStamp = this.wofStatus.window.constructions[cost].buildTime || 0;
return finishStamp;
}
if (undefined !== this.wofStatus.mode && undefined !== this.wofStatus.mode.states && undefined !== this.wofStatus.mode.states[cost]) {
finishStamp = this.wofStatus.mode.states[cost].finish_date || 0;
}
return finishStamp;
},
displayWofStatus: function() {
var cost_bribe = this.wofStatus.mode.cost.bribe * this.wofStatus.mode.conversion.ses, now = Date.now(), refetch = 0, that = this;
if (undefined === this.wofStatus.mode) return false;
$.fn.hiro_wof_status = function(cat, wof_state) {
var ar_title1 = HiroFriends.localeMsg('wofCat');
var ar_title2 = HiroFriends.localeMsg('wofState');
var ar_title3 = ar_title2[HiroFriends.eventManager.eventName];
switch(wof_state) {
case 0 : $(this).css({ "background": "url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat -98px 0", "opacity": "0.5" }); break;
case 1 : $(this).css({ "background": "url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat -82px -16px", "opacity": "1" }); break;
case 2 : $(this).css({ "background": "url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat -112px -16px", "opacity": "1" }); break;
case 3 : $(this).css({ "background": "url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat -98px -16px", "opacity": "1" }); break;
default : $(this).css({ "background": "url('"+HiroFriends.guiManager.cdnBase+"/images/tw2gui/iconset.png?14') no-repeat -2px -16px", "opacity": "0.5" });
}
$(this).addMousePopup({
'teaser' : '' + ar_title1[cat] + '',
'content': '' + ar_title3[wof_state] + '
'
});
$(this).off("click");
if (wof_state > 1) $(this).click(function() { return that.wofWindowOpen(); });
return $(this);
};
$.each(this.wofStatus.prizes.enhancements, function(key, cost) {
var currencyCost = cost * that.wofStatus.mode.conversion.ses, state = 0, finish = that.constructionEnds(cost)*1e3;
if (finish < now) {
if (that.wallet < currencyCost) state = 1;
else if (that.wallet < currencyCost + cost_bribe) state = 2;
else state = 3;
}
else if (finish) {
refetch = refetch ? Math.min(refetch, finish) : finish;
}
$("#hiro_wof_"+key).hiro_wof_status(key, state);
});
this.refetch = refetch;
return true;
},
wofWindowOpen: function() {
west.wof.WofManager.wofs[this.wofType].window.show();
return false;
},
},
updateManager: {
lastChecked: 0,
latestVersion: undefined,
storageLastChecked: script+".lastChecked",
storageVersion: script+".version",
updated: false,
init: function() {
var now = Date.now();
if("undefined" !== typeof(Storage)) {
var previousVersion = localStorage.getItem(this.storageVersion) === null ? 0 : parseFloat(localStorage.getItem(this.storageVersion));
this.lastChecked = localStorage.getItem(this.storageLastChecked) == null ? 0 : parseInt(localStorage.getItem(this.storageLastChecked));
localStorage.setItem(this.storageVersion, VERSION);
this.updated = previousVersion && VERSION > previousVersion;
}
if (now - this.lastChecked > 8 * 3600 * 1e3) this.check(false);
},
check: function(user_initiated = true) {
var that = this;
$.getScript(URL_VERSION).done(function() {
that.lastChecked = Date.now();
localStorage.setItem(that.storageLastChecked, that.lastChecked);
if(that.latestVersion && that.latestVersion > VERSION) {
var upgradeDialog = new west.gui.Dialog(scriptName + ' ' + HiroFriends.localeMsg('version')+' ' + that.latestVersion.toFixed(2), HiroFriends.localeMsg('version_upgrade'), west.gui.Dialog.SYS_WARNING).addButton('ok', function() {
try { upgradeDialog.hide(); location.href = URL_CODE; } catch(e) {}
}).addButton('cancel').show();
}
else if (user_initiated) new west.gui.Dialog(scriptName + ' ' + HiroFriends.localeMsg('version')+' ' + VERSION.toFixed(2), HiroFriends.localeMsg('version_ok'), west.gui.Dialog.SYS_OK).addButton("ok").show();
}).fail(function() {
new west.gui.Dialog(scriptName, HiroFriends.localeMsg('version_checkFailed'), west.gui.Dialog.SYS_WARNING).addButton(HiroFriends.localeMsg('version_checkManual'), function() { window.open(URL_INSTALL, '_blank'); }).addButton("cancel").show();
});
},
},
windowManager: {
sortByName: function(a, b) { return a.name.toLowerCase().localeCompare(b.name.toLowerCase()); },
sortByRecv: function(a, b) { return b.recv - a.recv; },
sortByTime: function(a, b) { return a.activation_time - b.activation_time; },
sortByFreq: function(a, b) { return a.freq - b.freq; },
sortByLast: function(a, b) { return b.last - a.last; },
display: function(sort) {
var friend_time, server_time = Game.getServerTime();
var maindiv = $('');
var friends = [];
for(var key in HiroFriends.friendManager.friends) if(HiroFriends.friendManager.friends.hasOwnProperty(key)) friends.push({
id: key,
name: HiroFriends.friendManager.friends[key].name,
activation_time: HiroFriends.friendManager.friends[key].activation_time,
recv: HiroFriends.friendManager.friends[key].recv,
last: HiroFriends.friendManager.friends[key].last,
freq: HiroFriends.friendManager.friends[key].freq,
});
if(!friends.length) $(''+HiroFriends.localeMsg('noFriends')+'
').appendTo(maindiv);
else {
var hiroTable;
switch(sort) {
case "name" : friends.sort(this.sortByName); break;
case "name_desc": friends.sort(this.sortByName).reverse(); break;
case "recv" : friends.sort(this.sortByRecv); break;
case "recv_asc" : friends.sort(this.sortByRecv).reverse(); break;
case "time_asc" : friends.sort(this.sortByTime).reverse(); break;
case "freq" : friends.sort(this.sortByFreq); break;
case "freq_desc": friends.sort(this.sortByFreq).reverse(); break;
case "last" : friends.sort(this.sortByLast); break;
case "last_asc": friends.sort(this.sortByLast).reverse(); break;
case "time" :
default : sort = "time"; friends.sort(this.sortByTime);
}
var thName = $(''+HiroFriends.localeMsg('name')+'').click(function(){ HiroFriends.windowManager.display(sort == 'name' ? 'name_desc' : 'name'); return false; });
var thAction = $(''+HiroFriends.eventManager.eventInfo.label+'').click(function(){ HiroFriends.windowManager.display(sort == 'time' ? 'time_asc' : 'time'); return false; });
var thRecv = enableLog ? $(''+HiroFriends.localeMsg('received')+'').click(function(){ HiroFriends.windowManager.display(sort == 'recv' ? 'recv_asc' : 'recv'); return false; }) : '';
var thFreq = enableLog ? $(''+HiroFriends.localeMsg('frequency')+'').click(function(){ HiroFriends.windowManager.display(sort == 'freq' ? 'freq_desc' : 'freq'); return false; }) : '';
var thLast = enableLog ? $(''+HiroFriends.localeMsg('lastReceived')+'').click(function(){ HiroFriends.windowManager.display(sort == 'last' ? 'last_asc' : 'last'); return false; }) : '';
hiroTable = new west.gui.Table().appendTo(maindiv)
.addColumn("hf_idx")
.addColumn("hf_player")
.addColumn("hf_action")
.addColumn("hf_log")
.addColumn("hf_last")
.addColumn("hf_freq")
.addColumn("hf_delete")
.appendToCell("head", "hf_idx", ' ')
.appendToCell("head", "hf_player", thName)
.appendToCell("head", "hf_action", thAction)
.appendToCell("head", "hf_log", thRecv)
.appendToCell("head", "hf_last", thLast)
.appendToCell("head", "hf_freq", thFreq)
.appendToCell("head", "hf_delete", ' ');
var idx = 1;
var now = Date.now()/1e3;
$.each(friends, function(key, val) {
var actionCell, recvCell = '', lastCell = '', freqCell = '', freqColor = '';
friend_time = val.activation_time + HiroFriends.eventManager.eventInfo.cooldown - server_time;
if(friend_time > HiroFriends.eventManager.timeLeft) actionCell = '('+HiroFriends.localeMsg('nextYear')+')';
else if(friend_time > 0) actionCell = '('+friend_time.formatDurationBuffWay()+')';
else {
actionCell = $(''+HiroFriends.eventManager.eventInfo.label+'').click({ id: val.id, ev: HiroFriends.eventManager.eventName }, function(e) {
$(this).parent().parent().remove();
Ajax.remoteCall("friendsbar", "event", { player_id: val.id, event: HiroFriends.eventManager.eventName }, function(response) {
if(response.error) return MessageError(response.msg).show();
// MessageSuccess(response.msg).show();
HiroFriends.friendManager.friends[val.id].activation_time = Date.now()/1e3;
if(HiroFriends.friendManager.canSend) -- HiroFriends.friendManager.canSend;
HiroFriends.guiManager.updateCounters(HiroFriends.friendManager.canSend, HiroFriends.friendManager.totalFriends);
if(WestUi.FriendsBar.friendsBarUi !== null)
WestUi.FriendsBar.friendsBarUi.friendsBar.eventActivations[val.id][HiroFriends.eventManager.eventName] = response.activationTime;
});
return false;
});
}
if(enableLog) {
if(val.recv) {
var recv_list = '', lastDate;
HiroFriends.logManager.friendLog[val.id].dates.sort(function(a, b){ return new Date(a)-new Date(b); });
recv_list += '';
$.each(HiroFriends.logManager.friendLog[val.id].dates, function(dkey, dval) {
recv_list += '- ' + new Date(dval * 1e3).toDateTimeStringNice() + '
';
});
recv_list += '';
recvCell = ''+val.recv+'';
if (now - val.last < 129600) freqColor = "#006600";
else if (now - val.last < 172800) freqColor = "#996600";
else freqColor = "#990000";
lastDate = new Date(val.last*1e3);
lastCell = ''+lastDate.toDateTimeString()+'';
if (val.freq < 129600) freqColor = "#006600";
else if (val.freq < 172800) freqColor = "#996600";
else freqColor = "#990000";
freqCell = val.freq > HiroFriends.eventManager.eventInfo.cooldown ? ''+val.freq.formatDuration()+'' : '';
}
else {
recvCell = '0';
lastCell = ''+HiroFriends.localeMsg('neverReceived')+'';
freqCell = '∞';
}
}
hiroTable.appendRow(null, 'hiroFriendRow_'+val.id)
.appendToCell(-1, "hf_idx", idx)
.appendToCell(-1, "hf_player", '' + val.name + '')
.appendToCell(-1, "hf_action", actionCell)
.appendToCell(-1, "hf_log", recvCell)
.appendToCell(-1, "hf_last", lastCell)
.appendToCell(-1, "hf_freq", freqCell)
.appendToCell(-1, "hf_delete", '
');
++ idx;
});
hiroTable.appendToCell('foot', 'hf_idx', '');
hiroTable.appendToCell('foot', 'hf_player', ''+scriptName+'');
hiroTable.appendToCell('foot', 'hf_action', HiroFriends.localeMsg('version')+' ' + VERSION.toFixed(2));
if('https://gr1.the-west.gr' == Game.gameURL || 'https://gr4.the-west.gr' == Game.gameURL || 'https://gr5.the-west.gr' == Game.gameURL) hiroTable.appendToCell('foot', 'hf_log', 'by '+scriptAuthor+'');
else if('https://zz1.beta.the-west.net' == Game.gameURL) hiroTable.appendToCell('foot', 'hf_log', 'by '+scriptAuthor+'');
else hiroTable.appendToCell('foot', 'hf_log', 'by '+scriptAuthor);
if(HiroFriends.friendManager.pendingInvitations) hiroTable.appendToCell('foot', 'hf_delete', '
');
if(enableLog) hiroTable.appendToCell('foot', 'hf_freq', $(''+HiroFriends.localeMsg('exporter')+'').click(function() {
HiroFriends.logManager.entries.sort(function(a,b) { return a.date - b.date; });
var tsv_friends = "id\t"+HiroFriends.localeMsg('name')+"\t"+HiroFriends.localeMsg('received')+"\r\n";
$.each(HiroFriends.logManager.friendLog, function(key,val) { tsv_friends += key+"\t"+val.name+"\t"+val.total+"\r\n"; });
new west.gui.Dialog(HiroFriends.localeMsg('exporter'),''+HiroFriends.localeMsg('friends')+' (TSV):
'+HiroFriends.localeMsg('everything')+':
').setModal(true,true,{bg:HiroFriends.guiManager.cdnBase+'/images/curtain_bg.png',opacity:0.7}).addButton("ok").show();
return false;
}) );
}
if(enableLog || HiroFriends.inventoryManager.generatorsInventory.length) {
var drills = [], details = '', extended = '';
details += '
';
details += '
';
details += '
'+HiroFriends.localeMsg('youSent')+''+format_number(HiroFriends.logManager.totalSent)+'
';
details += '
'+HiroFriends.localeMsg('received')+''+format_number(HiroFriends.logManager.totalReceived)+'
';
details += '
'+HiroFriends.localeMsg('collected')+''+format_number(HiroFriends.logManager.totalCollected)+'
';
details += '
'+HiroFriends.localeMsg('used')+''+format_number(HiroFriends.logManager.totalSpent)+'
';
details += '
';
details += '
';
details += '
';
details += '
'+HiroFriends.localeMsg('stats')+' ('+HiroFriends.localeMsg('since')+' '+new Date(HiroFriends.logManager.firstLog*1e3).toDateTimeString()+')
';
extended = '
'+HiroFriends.localeMsg('friends')+': | '+format_number(HiroFriends.logManager.totalFriends)+' |
';
drills.push(''+HiroFriends.localeMsg('friends')+': '+format_number(HiroFriends.logManager.totalFriends)+'');
$.each(Object.keys(HiroFriends.logManager.drillCollected), function(key, type) {
var drill_count = HiroFriends.logManager.drillCollected[type];
var locale = HiroFriends.localeMsg('statDetails') || { };
var drill_name = locale[type] || type;
extended += ''+drill_name+': | '+format_number(drill_count)+' |
';
if(drill_count) drills.push(''+drill_name+': '+format_number(drill_count)+'');
});
extended += '
';
details += '
'+drills.join(", ")+'';
drills = [];
$.each(Object.keys(HiroFriends.logManager.drillSpent), function(key, type) {
var drill = HiroFriends.logManager.drillSpent[type];
if(isNaN(parseInt(type))) {
var locale = HiroFriends.localeMsg('statDetails') || { };
var drill_name = locale[type] || type;
if (drill.times) drills.push('
'+drill_name+': '+drill.cost+' ('+drill.times+'×)');
}
else {
drills.push('
'+drill.times+'×'+format_number(type)+'');
}
});
details += '
'+drills.join(", ")+'';
details += '
';
details += '
';
details += '
';
$(details).appendTo(maindiv);
}
var hiroPane = new west.gui.Scrollpane();
hiroPane.appendContent(maindiv);
var hiroWindow = wman.open("HiroFriends_"+HiroFriends.eventManager.eventName, null, "noreload").setMiniTitle(HiroFriends.eventManager.eventInfo.label).setTitle(HiroFriends.eventManager.eventInfo.label).appendToContentPane(hiroPane.getMainDiv());
},
open: function() {
if(!WestUi.FriendsBar.hidden) WestUi.FriendsBar.toggle();
$.when(HiroFriends.logManager.getLog()).done(function() {
HiroFriends.friendManager.fetch().done(function() {
HiroFriends.friendManager.getPendingInvitations().done(function() {
HiroFriends.windowManager.display('time');
});
});
});
},
},
localeMsg: function(msg) {
if(undefined !== this.messages[this.locale][msg]) return this.messages[this.locale][msg];
if(undefined !== this.messages['en_US'][msg]) return this.messages['en_US'][msg];
return '';
},
scriptInit: function(tries, maxTries) {
var ev, eventName;
if(tries >= maxTries) return false;
if(Game && Game.loaded && Character.playerId) {
this.locale = (undefined === Game.locale || undefined == this.messages[Game.locale]) ? "en_US" : Game.locale;
this.api.setGui(this.localeMsg('description'));
if (enableVersionCheck) this.updateManager.init();
for(eventName in Game.sesData) {
if(!Game.sesData.hasOwnProperty(eventName)) continue;
var ev = Game.sesData[eventName];
if(!ev.friendsbar) continue;
if('Hearts' == eventName || 'Easter' == eventName || 'Independence' == eventName || 'DayOfDead' == eventName || 'Octoberfest' == eventName) {
this.eventManager.init(eventName);
return false;
}
}
return true;
}
++ tries;
setTimeout(function() { HiroFriends.scriptInit(tries, maxTries); }, tries * 1e3);
},
messages: {
el_GR: {
description: 'Διαχείριση Φίλων για τις Εκδηλώσεις του The West
Μην κλικάρετε πολύ γρήγορα, για να αποφύγετε ένα σερί κακής τύχης :)
Υποστηριζόμενες Εκδηλώσεις:
- Άγιος Βαλεντίνος
- Πάσχα
- Οκτόμπερφεστ
- Ημέρα Ανεξαρτησίας
- Ημέρα των Νεκρών
Συζήτηση στο Φόρουμ | Feedback: Αναφορά Bugs, Ιδέες, Μεταφράσεις.
Ευχαριστίες: '+scriptCredits+'
',
version: 'έκδοση',
version_checkFailed: 'Ο αυτόματος έλεγχος για ενημερώσεις απέτυχε',
version_checkManual: 'Μη αυτόματος έλεγχος',
version_ok: 'Έχεις ήδη την τελευταία έκδοση',
version_upgrade: 'Μια νέα έκδοση είναι διαθέσιμη. Θες να την εγκαταστήσεις;',
refresh: 'Ανανέωση',
timeLeft: 'Χρόνος που υπολείπεται μέχρι το τέλος της εκδήλωσης',
serverTime: 'ώρα διακομιστή',
availFriends: 'Αριθμός Φιλων στους οποίους μπορείς να στείλεις τώρα',
totalFriends: 'Αριθμός Φίλων',
pendingInvitation: 'Μία εκκρεμής πρόσκληση',
pendingInvitations: 'εκκρεμείς πρoσκλήσεις',
noFriends: 'Δεν έχεις φίλους',
name: 'Όνομα',
received: 'Έλαβες',
lastReceived: 'Τελευταία φορά',
neverReceived: 'Ποτέ',
frequency: 'Συχνότητα',
removeFriend: 'Αφαίρεση φίλου',
removeConfirm: 'Θέλεις πραγματικά να διαγράψεις αυτόν τον παίχτη από τη λίστα;',
removeSuccess: 'Ο φίλος αφαιρέθηκε από τη λίστα.',
removeFailed: 'Ο φίλος δεν μπόρεσε να αφαιρεθεί',
exporter: 'Εξαγωγή',
everything: 'Όλα',
stats: 'Στατιστικά',
since: 'από',
collected: 'Έχεις συλλέξει',
youSent: 'Έστειλες',
friends: 'Φίλοι',
used: 'Έχεις χρησιμοποιήσει',
statDetails: {
admin: 'Παρέμβαση Διαχειριστών',
adventures: 'Περιπέτειες',
bribe: 'Δωροδοκίες',
construction: 'Χτίσιμο',
duels: 'Μονομαχίες',
fortBattles: 'Μάχες Οχυρών',
itemUse: 'Χρήση Αντικειμένων',
jobs: 'Εργασίες',
npcDuels: 'Μονομαχίες με Ληστές',
quests: 'Αποστολές',
timer: 'Μείωση Χρόνου',
other: 'Άλλα',
},
inventory: 'Αποθέματα',
wofCat: [ 'Συνηθισμένα', 'Ασυνήθιστα', 'Σπάνια', 'Πολύ Σπάνια' ],
wofState: {
Octoberfest: [ 'Περιμένεις να σερβιριστεί το επόμενο πιάτο', 'Δεν διαθέτεις αρκετά πρέτσελ', 'Διαθέτεις αρκετά πρέτσελ για να φας', 'Διαθέτεις αρκετά πρέτσελ για να φας και να δωροδοκήσεις!' ]
},
nextYear: 'Του χρόνου',
theEnd: 'Τετέλεσται',
},
en_US: {
description: 'Friend Management for The West Events
Don't click too fast, to avoid a streak of bad luck upon you :)
Supported Events:
- Valentine's Day
- Easter
- Independence Day
- Oktoberfest
- Day of the Dead
Feedback: Bug Reports, Ideas, Translations (in English).
Credits: '+scriptCredits+'
',
version: 'version',
version_checkFailed: 'Unable to check for updates',
version_checkManual: 'Check manually',
version_ok: 'You already have the latest version',
version_upgrade: 'A new version is available. Do you want to upgrade now?',
refresh: 'Refresh',
timeLeft: 'Time Left until the event ends',
serverTime: 'server time',
availFriends: 'Number of Friends you can send now',
totalFriends: 'Number of Friends',
pendingInvitation: 'One pending invitation',
pendingInvitations: 'pending invitations',
noFriends: 'No Friends',
name: 'Name',
received: 'Received',
frequency: 'Frequency',
lastReceived: 'Last Time',
neverReceived: 'Never',
removeFriend: 'Remove friend',
removeConfirm: 'Do you really want to delete this player from the list?',
removeSuccess: 'Friend removed from your list.',
removeFailed: 'Friend could not be removed',
exporter: 'Export',
everything: 'Everything',
stats: 'Stats',
since: 'since',
collected: 'Collected',
youSent: 'Sent',
friends: 'Friends',
used: 'Used',
statDetails: {
admin: 'Admin Intervention',
adventures: 'Adventures',
bribe: 'Bribe',
construction: 'Construction',
duels: 'Duels',
fortBattles: 'Fort Battles',
itemUse: 'Item Use',
jobs: 'Jobs',
npcDuels: 'Bandit Duels',
quests: 'Quests',
timer: 'Shorten service time',
other: 'Other',
},
inventory: 'Inventory',
wofCat: [ 'Common', 'Uncommon', 'Rare', 'Very Rare' ],
wofState: {
Octoberfest: [ 'Waiting for the next dish to be served', 'Not enough pretzels to pay for a serving', 'Enough pretzels to pay for a serving', 'Enough pretzels to pay for a serving and bribe the waiting staff' ]
},
nextYear: 'Next Year',
theEnd: 'The End',
},
es_ES: {
description: 'Gestión de Amigos para Eventos de The West
No haga clic demasiado rápido, para evitar una racha de mala suerte :)
Eventos soportados:
- Día de San Valentín
- Pascua
- Día de la Independencia
- Oktoberfest
- Día de los Muertos
Comentarios: Bug Reports, Ideas, Translations (in English).
Créditos: '+scriptCredits+'
',
version: 'versión',
version_checkFailed: 'No se puede comprobar actualizaciones',
version_checkManual: 'Compruebe manualmente',
version_ok: 'Ya tienes la última versión',
version_upgrade: 'Una nueva versión está disponible. ¿Quieres instalarla ahora?',
refresh: 'Actualizar',
timeLeft: 'Tiempo que queda hasta el final del evento',
serverTime: 'hora del servidor',
availFriends: 'Número de Amigos que se puede enviar ahora',
totalFriends: 'Número de Amigos',
pendingInvitation: 'Una invitación pendiente',
pendingInvitations: 'invitaciones pendientes',
noFriends: 'Sin Amigos',
name: 'Nombre',
received: 'Recibidos',
lastReceived: 'Ultima vez',
neverReceived: 'Jamás',
frequency: 'Frecuencia',
removeFriend: 'Remover amigo',
removeConfirm: '¿Estas seguro que quieres eliminar a este jugador de tu lista?',
removeSuccess: 'Amigo removido de tu lista',
removeFailed: 'El amigo no ha podido ser eliminado',
exporter: 'Exportar',
everything: 'Todo',
stats: 'Estadísticas',
since: 'desde',
collected: 'Conseguidos',
youSent: 'Enviados',
friends: 'Amigos',
used: 'Usados',
statDetails: {
adventures: 'Aventuras',
bribe: 'Soborno',
construction: 'Ampliación',
duels: 'Duelos',
fortBattles: 'Batallas de fuertes',
itemUse: 'Objetos usados',
jobs: 'Trabajos',
npcDuels: 'Duelos NPC',
quests: 'Busquedas',
timer: 'Reiniciar temporizadores',
other: 'Otros',
},
inventory: 'Inventario',
wofCat: [ 'Común', 'No común', 'Raro', 'Muy raro' ],
wofState: {
Octoberfest: [ 'Esperando para ser servido', 'No tienes suficientes pretzels', 'Tienes suficientes pretzels para pagar', 'Tienes suficientes pretzels para pagar y sobornar' ]
},
nextYear: 'El próximo año',
theEnd: 'Final',
},
fr_FR: {
description: 'Gestion des Amis pour les Evénements de The West
Ne cliquez pas trop vite, pour éviter une série de malchance sur vous :)
Evénements:
- Saint Valentin
- Pâques
- Jour De L'Indépendance
- Oktoberfest
- Jour des Morts
Commentaires: Bug Reports, Ideas, Translations (in English).
Credits: '+scriptCredits+'
',
version: 'version',
version_checkFailed: 'Impossible de vérifier les mises à jour',
version_checkManual: 'Vérifier manuellement',
version_ok: 'Tu as déjà la dernière version',
version_upgrade: 'Une nouvelle version est disponible. Installer maintenant?',
refresh: 'Rafraîchir',
timeLeft: "Temps restant jusqu'à la fin de l'événement",
serverTime: 'horaire du serveur',
availFriends: 'Nombre des amis que tu peux envoyer maintenant',
totalFriends: 'Nombre des Amis',
pendingInvitation: 'Une invitation en attente',
pendingInvitations: 'invitations en attentes',
noFriends: "Pas d'Amis",
name: 'Nom',
received: 'Tu as reçu',
lastReceived: 'Dernière fois',
neverReceived: 'Jamais',
frequency: 'Fréquence',
removeFriend: "Supprimer l'ami(e)",
removeConfirm: 'Veux-tu vraiment supprimer ce joueur de la liste?',
removeSuccess: 'Ami supprimé de la liste',
removeFailed: "L'ami n'a pas pu être supprimé",
exporter: 'Exportation',
everything: 'Tout',
stats: 'Statistiques',
since: 'à partir de',
collected: 'Collectés',
youSent: 'Tu as envoyé',
friends: 'Amis',
used: 'Utilisés',
statDetails: {
adventures: 'Aventures',
bribe: 'Soudoyer',
construction: 'Agrandissement',
duels: 'Duels',
fortBattles: 'Batailles',
itemUse: 'Objets utilisés',
jobs: 'Travaux',
npcDuels: 'Duels PNJ',
quests: 'Quêtes',
timer: 'Réduire la durée de construction',
other: 'Autres',
},
inventory: 'Inventaire',
wofCat: [ 'Commun', 'Non commun', 'Rare', 'Très rare' ],
wofState: {
Octoberfest: [ "En attendant d'être servi", "Tu n'as pas assez de Bretzels", 'Tu as assez de Bretzels pour payer', 'Tu as assez de Bretzels pour payer et soudoyer' ]
},
nextYear: "L'année prochaine",
theEnd: 'La Fin',
},
it_IT: {
description: 'Gestione amici per gli eventi The West
Non clickare tropo veloce, per non essere bloccato :)
Eventi supportati:
- Giorno San Valentino
- Pasqua
- Giorno dell'Independenza
- Oktoberfest
- Il giorno dei morti
Feedback: Bug Report, Ideee, Traduzioni (in English).
Credits: '+scriptCredits+'
',
version: 'versione',
version_checkFailed: 'Impossibile verificare gli aggiornamenti',
version_checkManual: 'Controllare manualmente',
version_ok: "Hai già l'ultima versione",
version_upgrade: 'Nuova versione disponibile. Vuoi aggiornare adesso?',
refresh: 'Aggiorna',
timeLeft: 'Tempo rimanente fino alla fine dell'evento',
serverTime: 'server time',
availFriends: 'Totale amici che puoi inviare adesso',
totalFriends: 'Amici totale',
pendingInvitation: 'Invito in attesa',
pendingInvitations: 'inviti in attesa',
noFriends: 'Non ci sono amici',
name: 'Nome',
received: 'Ricevuti',
lastReceived: 'Ultima volta',
neverReceived: 'Mai',
frequency: 'Freqvenza',
removeFriend: 'Rimuovi amico',
removeConfirm: 'Sei sicuro di voler cancellare l'amico dalla lista?',
removeSuccess: 'Amico rimosso dalla tua lista.',
removeFailed: 'Impossibile rimuovere l'amico',
exporter: 'Esporta',
everything: 'Tutto',
stats: 'Statistiche',
since: 'dal',
collected: 'Collezionate',
youSent: 'Inviati',
friends: 'Amici',
used: 'Usato',
statDetails: {
adventures: 'Avventure',
bribe: 'Corruzione',
construction: 'Costruzione',
duels: 'Duelli',
fortBattles: 'Battaglie forti',
itemUse: 'Oggetti usati',
jobs: 'Lavori',
npcDuels: 'Duelli con NPC',
quests: 'Missioni',
timer: 'Reseta Timer',
other: 'Altro',
},
inventory: 'Inventario',
wofCat: [ 'Molto comune', 'Comune', 'Raro', 'Molto raro' ],
wofState: {
Octoberfest: [ 'In attesa di essere servita', 'Non hai abbastanza pretzel', 'Hai abbastanza pretzel per pagare', 'Hai abbastanza pretzel per pagare e corrompere' ]
},
nextYear: 'Anno prossimo',
theEnd: 'Fine',
},
pl_PL: {
description: 'Menadżer zarządzania Przyjaciółmi podczas eventów The West
Nie klikaj zbyt szybko, bo to będzie bardzo niemiłe dla Ciebie :)
Obsługiwane Eventy:
- Walentynki
- Wielkanoc
- Dzień Niepodległości
- Oktoberfest
- Dia de los Muertos
Forum | Opinie: Zgłaszanie błędów, pomysłów, propozycji zmian (w języku angielskim).
Uznanie dla: '+scriptCredits+'
',
version: 'wersja',
version_checkFailed: 'Nie można sprawdzić aktualizacji',
version_checkManual: 'Sprawdź ręcznie',
version_ok: 'Masz już najnowszą wersję',
version_upgrade: 'Dostępna jest nowa wersja. Czy chcesz dokonać aktualizacji?',
refresh: 'Odśwież',
timeLeft: 'Czas pozostały do zakończenia eventu',
serverTime: 'czasu serwera',
availFriends: 'Liczba przyjaciół do których można wysłać prezent',
totalFriends: 'Łączna liczba przyjaciół',
pendingInvitation: 'jedno oczekujące zaproszenie',
pendingInvitations: 'oczekujących zaproszeń',
noFriends: 'Brak przyjaciół',
name: 'Nazwa gracza',
received: 'Otrzymano',
lastReceived: 'Ostatni raz',
neverReceived: 'Nigdy',
frequency: 'Częstotliwość',
removeFriend: 'Usuń przyjaciela',
removeConfirm: 'Czy na pewno chcesz usunąć tego gracza z listy przyjaciół?',
removeSuccess: 'Przyjaciel usunięty z Twojej listy.',
removeFailed: 'Nie można usunąć przyjaciela',
exporter: 'Eksport',
everything: 'Wszystko',
stats: 'Statystyka',
since: 'od',
collected: 'Uzbierano',
youSent: 'Wysłano',
friends: 'Znajomi',
used: 'Użyto',
statDetails: {
adventures: 'Przygody',
bribe: 'Przekup',
construction: 'Rozbudowa',
duels: 'Pojedynki',
fortBattles: 'Bitwy fortowe',
itemUse: 'Użycie przedmiotów',
jobs: 'Prace',
npcDuels: 'Pojedynki z NPC',
quests: 'Zadania',
timer: 'Zresetuj liczniki',
other: 'Inne',
},
inventory: 'Ekwipunek',
wofCat: [ 'Bardzo powszechny', 'Powszechny', 'Rzadki', 'Bardzo rzadki' ],
nextYear: 'W przyszłym roku',
theEnd: 'Koniec',
},
pt_PT: {
description: 'Gestão de amigos para eventos no The West
não clique rápido demais, para evitar uma maré de azar :)
Eventos suportados:
- Dia dos namorados
- Páscoa
- Dia da independência
- Oktoberfest
- Dia de los Muertos
Comentários: Bug Reports, Ideas, Translations (in English).
Créditos: '+scriptCredits+'
',
version: 'versão',
version_checkFailed: 'Não é possível verificar atualizações',
version_checkManual: 'Verifique manualmente',
version_ok: 'Você já possui a versão mais recente',
version_upgrade: 'A nova versão está disponível. Atualize agora?',
refresh: 'Actualizar',
timeLeft: 'Tempo restante até ao final do evento',
serverTime: 'hora do servidor',
availFriends: 'Número de amigos a quem pode enviar agora',
totalFriends: 'Número de Amigos',
pendingInvitation: 'Um convite pendente',
pendingInvitations: 'convites pendentes',
noFriends: 'Sem Amigos',
name: 'Nome',
received: 'Recebidos',
lastReceived: 'Última vez',
neverReceived: 'Nunca',
frequency: 'Freqüência',
removeFriend: 'Remover amigo',
removeConfirm: 'Queres mesmo remover amigo da lista ?',
removeSuccess: 'Amigo removido da lista',
removeFailed: 'Amigo não pode ser removido',
exporter: 'Exportar',
everything: 'Tudo',
stats: 'Estatísticas',
since: 'desde',
collected: 'Recolhidos',
youSent: 'Enviados',
friends: 'Amigos',
used: 'Usados',
statDetails: {
adventures: 'Aventuras MPI',
bribe: 'Suborno',
construction: 'Construção',
duels: 'Duelos',
fortBattles: 'Batalhas de Forte',
itemUse: 'Itens usados',
jobs: 'Trabalhos',
npcDuels: 'Duelos NPC',
quests: 'Aventuras',
timer: 'Reiniciar temporizadores',
other: 'Outros',
},
inventory: 'Inventário',
wofCat: [ 'Comum', 'Fora do Comum', 'Raro', 'Muito Raro' ],
nextYear: 'Próximo Ano',
theEnd: 'Final',
},
tr_TR: {
description: 'The West Etkinlikleri İçin Arkadaş Yöneticisi
Üzerinde kara bulutların dolaşmasını istemiyorsan çok hızlı tıklama :)
Desteklenen Etkinlikler:
- Sevgililer Günü
- Paskalya
- Bağımsızlık Günü
- Ekim Festivali
- Ölülerin Günü
Geri Bildirim: Açık Raporları, Fikirler, Çeviriler (İngilizce).
Yapımcılar: '+scriptCredits+'
',
version: 'versiyon',
version_checkFailed: 'Güncellemeleri kontrol edilemiyor',
version_checkManual: 'Elle kontrol et',
version_ok: 'En son sürümünüz var',
version_upgrade: 'Yeni versiyon mevcut. Şimdi yükseltmek istiyor musun?',
refresh: 'Yenile',
timeLeft: 'Etkinliğin bitmesine kalan süre',
serverTime: 'sunucu süresi',
availFriends: 'Şimdi gönderebileceğin arkadaş sayısı',
totalFriends: 'Arkadaş Sayısı',
pendingInvitation: 'Bir davetiye bekliyor',
pendingInvitations: 'bekleyen davetiyeler',
noFriends: 'Arkadaş Yok',
name: 'İsim',
received: 'Alınan',
lastReceived: 'Son kez',
neverReceived: 'Asla',
frequency: 'Sıklık',
removeFriend: 'Arkadaşı Sil',
removeConfirm: 'Bu oyuncuyu gerçekten listeden silmek istiyor musun?',
removeSuccess: 'Arkadaşın listeden silindi.',
removeFailed: 'Arkadaş silinemedi',
exporter: 'Çıkar',
everything: 'Her şey',
stats: 'İstatistikler',
since: 'başlangıç',
collected: 'Toplanan',
youSent: 'Gönderilen',
friends: 'Arkadaşlar',
used: 'Kullanılan',
statDetails: {
adventures: 'Maceralar',
bribe: 'Rüşvet',
construction: 'Kurma',
duels: 'Düellolar',
fortBattles: 'Kale Savaşları',
itemUse: 'Kullanılan Ürünler',
jobs: 'Çalışmalar',
npcDuels: 'Haydut Düelloları',
quests: 'Görevler',
timer: 'Zamanlayıcıyı Sıfırla',
other: 'Diğer',
},
inventory: 'Envanter',
wofCat: [ 'Sıradan', 'Sıradan olmayan', 'Nadir', 'Çok nadir' ],
wofState: {
Octoberfest: [ 'Bir sonraki tabak bekleniyor', 'Bu tabağa ödeme yapmak için yeterli tuzlu kraker yok', 'Bu tabağa ödeme yapmak için yeterli tuzlu kraker var', 'Bu tabağa ödeme yapmak ve bekleyen personele rüşvet vermek için yeterli tuzlu kraker var' ]
},
nextYear: 'Gelecek Yıl',
theEnd: 'Son',
},
},
}
try { HiroFriends.scriptInit(0, 100); } catch(e) { }
});