// ==UserScript==
// @name The West - tw-db.info Cloth Calc [sk]
// @version 0.49 Rev. 6
// @description The West Script: Cloth Calculation for game version 1.34 or higher
// @author Bluep, scoobydoo, Dun, Petee [tw-db.info]
// @namespace http://tw-db.info
// @grant none
// @website http://tw-db.info
// @include http://*.the-west.*/game.php*
// @include https://*.the-west.*/game.php*
// @include http://*.tw.innogames.*/game.php*
// @include https://*.tw.innogames.*/game.php*
// @downloadURL https://update.greasyfork.icu/scripts/513323/The%20West%20-%20tw-dbinfo%20Cloth%20Calc%20%5Bsk%5D.user.js
// @updateURL https://update.greasyfork.icu/scripts/513323/The%20West%20-%20tw-dbinfo%20Cloth%20Calc%20%5Bsk%5D.meta.js
// ==/UserScript==
(function (f) {
var d = document,
s = d.createElement("script");
s.setAttribute("type", "application/javascript");
s.textContent = "(" + f.toString() + ")()";
(d.body || d.head || d.documentElement).appendChild(s);
s.parentNode.removeChild(s);
})(function () {
if (isDefined(window.TWDB)) {
new west.gui.Dialog(
TWDB.script.name,
'
Používateľský skript ClothCalc je nainštalovaný dvakrát, s rôznymi jazykovými verziami. Jednu z nich je nutné odinštalovať, aby skript fungoval správne!
');
var o = new west.gui.Dialog(s + "Vlastné atribúty", o);
o.addButton("ok", function () {
return n.editConfig(e, true);
});
o.addButton("cancel");
o.show();
} else {
var u = function (e) {
new UserMessage("Zadané údaje sú nesprávne: " + e, UserMessage.TYPE_ERROR).show();
return false;
};
if (this.parent.gui.custom.name.getValue() == "") {
return u("prázdne Meno");
}
if (this.parent.gui.custom.code.getValue() == "") {
return u("prázdne Kód [1]");
}
if (this.parent.gui.custom.name.getValue() == this.tmp.name && this.parent.gui.custom.code.getValue() == this.tmp.code) {
return true;
}
try {
var i = JSON.parse(this.parent.gui.custom.code.getValue());
} catch (a) {
return u("Nesprávne Kód [2]");
}
if (typeof i.type == "undefined" || typeof i.para == "undefined") {
return u("Nesprávne Kód [3]");
}
var f = 0;
for (var l in i.para) {
f++;
}
switch (i.type) {
case "speed":
case "regen":
if (f !== 0) {
return u("Nesprávne Kód [4]");
}
break;
case "fort":
if (typeof i.para.type == "undefined" || typeof i.para.att == "undefined" || typeof i.para.def == "undefined" || typeof i.para.health == "undefined") {
return u("Nesprávne Kód [5]");
}
if (i.para.type !== 1 && i.para.type !== 0) {
return u("Nesprávne Kód [6]");
}
if (!jQuery.isNumeric(i.para.att) || i.para.att < 0) {
return u("Nesprávne Kód [7]");
}
if (!jQuery.isNumeric(i.para.def) || i.para.def < 0) {
return u("Nesprávne Kód [8]");
}
if (!jQuery.isNumeric(i.para.health) || i.para.health < 0) {
return u("Nesprávne Kód [9]");
}
break;
case "duel":
case "custom":
if (f <= 0) {
return u("Nesprávne Kód [10]");
}
break;
default:
return u("Nesprávne Kód [11]");
}
delete this.tmp;
this.parent.data.custom[e] = { id: Number(e), type: i.type, para: i.para, name: this.htmlEscape(this.parent.gui.custom.name.getValue()) };
this.parent.gui.custom.config.hide();
this.showConfig();
TWDB.Settings.set("custom", this.parent.data.custom);
}
},
deleteConfig: function (e, t) {
if (typeof t == "undefined") {
var n = this;
var r = new west.gui.Dialog("Zmazať - Vlastné atribúty", "Zmazať: " + this.parent.data.custom[e].name + "?");
r.addButton("ok", function () {
n.deleteConfig(e, true);
});
r.addButton("cancel");
r.show();
} else {
var i = this.parent.data.custom;
delete i[e];
this.parent.data.custom = {};
var s = 0;
for (var e in i) {
s++;
this.parent.data.custom[s] = i[e];
this.parent.data.custom[s].id = s;
}
this.parent.gui.custom.config.hide();
this.showConfig();
TWDB.Settings.set("custom", this.parent.data.custom);
}
},
},
getSkillImg: function (e, t) {
var n = 1;
var r = 1;
var i = 0;
switch (e) {
case "build":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
r = 2;
break;
case "punch":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 1;
r = 2;
break;
case "tough":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 2;
r = 2;
break;
case "endurance":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 3;
r = 2;
break;
case "health":
var s = Game.cdnURL + "/images/skill/skills_strength.png";
i = 4;
r = 2;
break;
case "ride":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
r = 2;
break;
case "reflex":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 1;
r = 2;
break;
case "dodge":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 2;
r = 2;
break;
case "hide":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 3;
r = 2;
break;
case "swim":
var s = Game.cdnURL + "/images/skill/skills_flexibility.png";
i = 4;
r = 2;
break;
case "aim":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
r = 2;
break;
case "shot":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 1;
r = 2;
break;
case "pitfall":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 2;
r = 2;
break;
case "finger_dexterity":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 3;
r = 2;
break;
case "repair":
var s = Game.cdnURL + "/images/skill/skills_dexterity.png";
i = 4;
r = 2;
break;
case "leadership":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
r = 2;
break;
case "tactic":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 1;
r = 2;
break;
case "trade":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 2;
r = 2;
break;
case "animal":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 3;
r = 2;
break;
case "appearance":
var s = Game.cdnURL + "/images/skill/skills_charisma.png";
i = 4;
r = 2;
break;
case "strength":
var s = Game.cdnURL + "/images/window/skills/circle_strength.png";
break;
case "flexibility":
var s = Game.cdnURL + "/images/window/skills/circle_flexibility.png";
break;
case "dexterity":
var s = Game.cdnURL + "/images/window/skills/circle_dexterity.png";
break;
case "charisma":
var s = Game.cdnURL + "/images/window/skills/circle_charisma.png";
break;
case "attacker":
var s = TWDB.images.attacker;
break;
case "defender":
var s = TWDB.images.defender;
break;
default:
return jQuery("");
}
var o = "";
if (typeof CharacterSkills.skills[e] !== "undefined") {
var o = CharacterSkills.skills[e].name;
} else if (typeof CharacterSkills.attributes[e] !== "undefined") {
var o = CharacterSkills.attributes[e].name;
}
s = '';
s = jQuery(s);
var u = '';
u = jQuery(u);
return u.append(s);
},
bag: {
stack: {},
interval: false,
setParent: function (e) {
this.parent = e;
},
showItems: function (e, t) {
this.parent.gui.bag.children().remove();
this.items = {};
var n = this,
r = false,
i = function (e) {
var r = new tw2widget.InventoryItem(ItemManager.get(e)).setCharacter(Character);
var i = r.getMainDiv();
var s = (function (e) {
return function () {
n.click(r, e, t);
};
})(e);
jQuery(i).removeAttr("id").children(".TWDBbuyTip, .TWDBsellTip, .TWDBcollector").remove().end().children("img:first-child").removeAttr("id").end().click(s).appendTo(n.parent.gui.bag);
n.items[e] = jQuery(i);
},
s,
o;
for (s in e) {
if (typeof s === "function") {
break;
}
o = e[s].id;
i(o);
r = r || ItemManager.get(o).type === "animal";
}
this.parent.gui.bag.append(jQuery(new west.gui.Button(Inventory.guiElements.instantWearButton.caption.text, n.autoEquip, n, null).getMainDiv()).css({ position: "absolute", right: "8px", bottom: "5px" }));
var u = TWDB.DataManager.getAnimals();
if (!r && u.length > 0) {
i(u[0]["id"]);
}
this.wear();
},
autoEquip: function () {
var e;
for (e in this.items) {
if (this.items.hasOwnProperty(e)) {
jQuery(this.items[e]).click();
}
}
},
click: function (e, t, n) {
if (Bag.getItemByItemId(t) === undefined) {
return false;
}
Wear.carry(e);
this.stack[t] = e;
var r = this,
i;
if (this.interval === false) {
switch (n) {
case "jobs":
i = function () {
r.wear();
r.parent.jobs.update();
r.parent.joblist.update();
};
break;
case "custom":
i = function () {
r.wear();
r.parent.customs.showSkill();
};
break;
}
TWDB.Eventer.set("carryChecker", i, 1);
this.interval = setInterval(function () {
r.carry();
}, 100);
}
},
carry: function () {
var e = 0,
t,
n;
for (t in this.stack) {
n = this.stack[t];
if (n === undefined || n.getImgEl().css("opacity") === "1") {
delete this.stack[t];
} else {
e++;
}
}
if (e === 0) {
clearInterval(this.interval);
this.interval = false;
TWDB.Eventer.trigger("carryChecker");
}
},
wear: function () {
var e, t;
for (e in Wear.wear) {
t = Wear.wear[e].getId();
if (typeof this.items[t] !== "undefined") {
this.items[t].css("opacity", "0.5");
}
}
},
},
setUsedItems: function () {
for (var e in this.calcdata.jobs) {
for (var t in this.calcdata.jobs[e].cloth) {
var n = this.calcdata.jobs[e].cloth[t].id;
if (typeof (this.calcdata.used[n] == "undefined")) {
this.calcdata.used[n] = 1;
} else {
this.calcdata.used[n]++;
}
}
}
for (var r in this.calcdata.custom) {
for (var t in this.calcdata.custom[r].cloth) {
var n = this.calcdata.custom[r].cloth[t].id;
if (typeof (this.calcdata.used[n] == "undefined")) {
this.calcdata.used[n] = 1;
} else {
this.calcdata.used[n]++;
}
}
}
},
jobSearch: function () {
var e = this;
if (this.jobs.selected == 0) {
return;
}
if (this.gui.job.searchDiv.parent().length) {
this.jobs.switchJob(this.jobs.selected);
return;
}
this.gui.bag.children().remove();
var t = TWDB.Map.getNearestJob(this.jobs.selected);
var n = 4;
var r = jQuery("
");
for (var i = 0; i < t.length; i++) {
if (i === n) {
break;
}
var s = t[i];
var o = "rotate(" + s.angle + "deg);";
var u = jQuery("
");
u.append('
' + s.time.formatDuration() + "
");
u.append(
jQuery('
').append(
jQuery(
''
).click(
(function (e, t) {
return function () {
GameMap.center(e, t);
};
})(s.x, s.y)
)
)
);
var a = jQuery("
");
var f = new west.gui.Button(
"Otvoriť",
(function (e, t, n) {
return function () {
TWDB.Jobs.openJob(e, t, n);
};
})(e.jobs.selected, s.x, s.y)
);
jQuery(f.divMain).css({ "min-width": "50px", "max-width": "80px" });
jQuery(f.divMain).find(".textart_title").css({ overflow: "hidden" });
f.appendTo(a);
u.append(a);
if (Premium.hasBonus("automation")) {
var a = jQuery("
");
var f = new west.gui.Button(
"default",
(function (t, n, r) {
return function () {
TWDB.Jobs.startJob(t, n, r, Number(e.jobs.basetime));
};
})(e.jobs.selected, s.x, s.y)
);
jQuery(f.divMain).css({ "min-width": "50px", "max-width": "80px" });
jQuery(f.divMain).find(".textart_title").css({ overflow: "hidden" });
f.appendTo(a);
u.append(a);
}
r.append(u);
}
this.gui.job.searchDiv.children().remove();
this.gui.job.searchDiv.append(r);
this.gui.bag.append(this.gui.job.searchDiv);
},
isUsedItem: function (e) {
if (this.calcdata.used[e]) {
return true;
} else {
return false;
}
},
getClothForJob: function (e) {
if (!isDefined(this.calcdata.jobs[e]) || !isDefined(this.calcdata.jobs[e].cloth)) {
return null;
}
return this.calcdata.jobs[e].cloth;
},
getLPForJob: function (e) {
if (!isDefined(this.calcdata.jobs[e]) || !isDefined(this.calcdata.jobs[e].laborpoints)) {
return null;
}
return this.calcdata.jobs[e].laborpoints;
},
getSelectedJob: function () {
return this.jobs.selected;
},
isLoaded: function () {
if (isDefined(this.calcdata.loaded)) {
return this.calcdata.loaded;
}
return false;
},
};
(function ($) {
var _base = TWDB;
var w = window;
var Images = _base.images;
var Script = _base.script;
var ClothCalc = _base.ClothCalc;
var Debugger = (function (e) {
var t = {};
return t;
})($);
_base.Debugger = Debugger;
var Error = (function (e) {
var t = {};
var n = "twdb_error";
var r = [];
var i = true;
t.report = function (e, t) {
if (!isDefined(e.message)) {
r.push({ msg: "failed to add error", e: t });
} else {
r.push({ msg: t + " " + ((e.stack && (e.stack.match(/:\d+:\d+/) || [])[0]) || ""), e: e.message });
}
if (i) {
i = false;
WestUi.NotiBar.add(
new OnGoingPermanentEntry(
function () {
s();
},
"tw-db.info: an error occured",
"tip"
)
);
}
};
var s = function () {
var t = new west.gui.Scrollpane();
e(t.getMainDiv()).css("height", "370px");
e(t.getMainDiv()).find(".tw2gui_scrollpane_clipper_contentpane").addClass("selectable");
var i = '
';
for (var s = r.length - 1; s >= 0; s--) {
i += "
" + s + "
" + r[s].msg + "
" + r[s].e + "
";
}
i += "
";
t.appendContent(i);
var o = wman.open(n, null, "noreload").setMiniTitle("TWDB Errorlog").setTitle("tw-db.info Errorlog").appendToContentPane(t.getMainDiv());
};
return t;
})($);
_base.Error = Error;
Debugger.Error = Error;
var Loader = (function (e) {
var t = {};
var n = [];
var r = {};
var i = {};
var s;
var o = false;
var u = false;
var a = false;
var f = 0;
t.add = function (e, t, r, i) {
var s = { ready: false };
n.push({ key: e, txt: t, call: r, dep: i || {}, ready: s, count: 0 });
return s;
};
t.init = function () {
if (s) {
return;
}
s = w.setInterval(function () {
l();
}, 500);
};
var l = function () {
if (u) {
return;
}
u = true;
if (o === false) {
if (!c()) {
u = false;
return;
}
TWDB.Cache.init();
r.Cache = true;
try {
Updater.query();
h();
} catch (e) {
Error.report(e, "");
new UserMessage("registrácia tw-db.info scriptu na TheWestApi zlyhala", UserMessage.TYPE_FATAL).show();
return d();
}
if (TWDB.Util.isNewIDsystem()) {
TWDB.Util.wrapBetaGetItem();
}
if (TWDB.Util.isNewIDsystem() && window.location.href.indexOf(".beta.the-west.net") === -1 && !TWDB.Util.idMigrationDone()) {
try {
TWDB.Util.backupData();
} catch (e) {}
try {
TWDB.Util.idMigrator();
new UserMessage("Converting TW-DB data to new item ID system successful.", UserMessage.TYPE_SUCCESS).show();
TWDB.Util.simpleRestore(true);
} catch (e) {
Error.report(e, "Item ID conversion failed.");
new UserMessage("Item ID conversion failed. Do not use the ANALYSERS if you want to save your data!", UserMessage.TYPE_FATAL).show();
TWDB.Util.simpleRestore();
}
}
return p();
}
if (isDefined(i[o.key])) {
return p();
}
if (o.ready.ready) {
r[o.key] = true;
a = false;
return p();
}
u = false;
};
var c = function () {
if (!isDefined(w.jQuery) || !isDefined(w.TheWestApi) || !isDefined(w.TheWestApi.version) || w.ItemManager.get(2e3) === undefined || !isDefined(w.Character) || w.Character.playerId === 0 || !w.Bag.loaded) {
return false;
} else {
return true;
}
};
var h = function () {
var t = w.TheWestApi.register("twdb_clothcalc", "tw-db.info Cloth Calc", "2.04", String(Script.gameversion), "scoobydoo, Dun, Petee, Bluep, Tom Robert, xShteff [tw-db.info]", "https://tw-db.info");
var n =
'
';
var r = e("").append(
"Script ClothCalc je pomôcka vytvorená týmom TW-DB.info. Ponúka mnoho funkcií a rozšírení, ktoré vám poskytnú lepší zážitok z hry. Ušetrí čas a zjednoduší niektoré činnosti.",
n,
"Ďakujeme!"
);
t.setGui(r);
if (t.isOutdated()) {
w.TheWestApi.displayOutdated();
}
};
var p = function () {
if (n.length === 0) {
return d();
}
o = n.shift();
o.count++;
if (o.count > f) {
if (a) {
Error.report({ message: "deadlock detected" }, "failed to load module: " + o.key);
i[o.key] = true;
return p();
}
f++;
a = true;
}
for (var e in o.dep) {
if (!isDefined(r[e])) {
if (TWDB.script.isDev()) {
console.log(o.key, "needs ", e);
}
n.push(o);
return p();
}
}
try {
o.call();
} catch (t) {
Error.report(t, "failed to load module: " + o.key);
i[o.key] = true;
return p();
}
u = false;
l();
};
var d = function () {
w.clearInterval(s);
w.setTimeout(function () {
delete t;
}, 1e3);
};
t.stack = n;
t.loaded = r;
t.failed = i;
t.current = o;
return t;
})($);
Debugger.Loader = Loader;
var Cache = (function (e) {
var t = {};
var n = {};
var r = "";
var i = {};
var s = function (e) {
if (!i[e]) {
i[e] = true;
t.save("keys", i);
}
};
var o = function () {
if (n.ready) {
return;
}
r = "twdb_0_";
i = t.load("keys");
if (!i) {
i = { keys: true };
}
n.ready = true;
};
t.load = function (e) {
s(e);
try {
return JSON.parse(decodeURIComponent(localStorage.getItem(r + e)));
} catch (n) {
Error.report(n, "load " + e + " from cache");
t.save(e, null);
return null;
}
};
t.save = function (e, n) {
s(e);
try {
localStorage.setItem(r + e, encodeURIComponent(JSON.stringify(n)));
return true;
} catch (i) {
Error.report(i, "save " + e + " to cache");
t.save(e, null);
return false;
}
};
t.reset = function (n, s) {
try {
if (n) {
if (isDefined(s)) {
localStorage.removeItem(s);
} else {
for (var o in i) {
localStorage.removeItem(r + o);
}
}
new UserMessage("Reset Done, page will now be reloaded", UserMessage.TYPE_SUCCESS).show();
location.href = location.href.replace(location.hash || "#", "");
} else {
var u = e("
Určite chceš vymazať celú Cache pamäť scriptu tw-db?
");
var a = new west.gui.Textfield("twdb_cache_key").setSize(40).setLabel("Key:");
u.append(a.getMainDiv());
var f = new west.gui.Checkbox("all Keys").setSelected(true);
f.setCallback(function (e) {
if (e) {
a.setValue("");
}
});
e(a.getMainDiv()).find("span").css("font-size", "12px");
e(a.getMainDiv())
.find("input")
.keyup(function () {
f.setSelected(false);
});
u.append(e('').append(f.getMainDiv()));
new west.gui.Dialog("tw-db Cache Reset", u, west.gui.Dialog.SYS_QUESTION)
.addButton("ok", function () {
if (f.isSelected()) {
t.reset(true);
} else {
t.reset(true, a.getValue());
}
})
.addButton("cancel")
.show();
}
} catch (l) {
Error.report(l, "cache reset");
}
};
t.init = o;
return t;
})($);
_base.Cache = Cache;
Debugger.Cache = Cache;
var Worker = (function (e) {
var t = {};
var n = [];
var r = false;
var i = false;
t.add = function (e) {
n.push(e);
if (r) {
return;
}
r = w.setInterval(function () {
s();
}, 100);
};
var s = function () {
if (i) {
return;
}
i = true;
var e = n.shift();
try {
e();
} catch (t) {
Error.report(t, "Worker");
}
if (n.length == 0) {
w.clearInterval(r);
r = false;
}
i = false;
};
return t;
})($);
Debugger.Worker = Worker;
var Jobs = (function (e) {
var t = {};
var n = {};
var r = [];
var i = {};
var s = {};
var o = [1828e3, 1829e3, 183e4, 2e6, 2003e3, 2006e3, 2009e3];
var u;
var a = {};
var f = function () {
if (n.ready) {
return;
}
var t = 0;
var f = 0;
var c = {};
while (true) {
t++;
var h = w.JobList.getJobById(t);
if (!h) {
f++;
if (f > 5) {
break;
}
continue;
}
f = 0;
r.push(h.id);
i[h.name.toLowerCase()] = h.id;
s[h.shortname.toLowerCase()] = h.id;
for (var p in h.yields) {
if (isNaN(p) || c[p]) {
continue;
}
c[p] = true;
o.push(Number(p));
}
}
u = (function (e) {
var t = {
description: "",
duration: 1800,
energy: 6,
groupid: null,
id: 255,
malus: 0,
name: "Výstavba",
randomyields: [],
shortname: "construction",
skills: { build: 3, repair: 1, leadership: 1 },
yields: {},
calcJobPoints: function () {
return 0;
},
canDo: function () {
return true;
},
};
return t;
})(e);
r.push(255);
i[u.name.toLowerCase()] = 255;
s[u.shortname.toLowerCase()] = 255;
var d = function (e, t) {
var n = e === 255 ? u : w.JobList.getJobById(e);
var r = t === 255 ? u : w.JobList.getJobById(t);
return n.name > r.name;
};
r.sort(d);
o.sort();
a = Cache.load("jobdata");
if (a === null || typeof a !== "object") {
a = {};
}
Eventer.set("TWDBdataLoaded", function () {
l();
});
n.ready = true;
};
n = Loader.add("Jobs", "tw-db Jobsystem", f, { Cache: true });
var l = function () {
a = {};
Cache.save("jobdata", a);
};
t.getJobByName = function (n) {
n = e.trim(n).toLowerCase();
if (!isDefined(i[n])) {
return null;
}
return t.getJobById(i[n]);
};
t.getJobByShortname = function (n) {
n = e.trim(n).toLowerCase();
if (!isDefined(s[n])) {
return null;
}
return t.getJobById(s[n]);
};
t.getJobById = function (t) {
var n;
if (t === 255) {
n = u;
} else {
n = w.JobList.getJobById(t);
if (!n) {
return n;
}
}
var r = e.extend(true, {}, n);
var i = 1;
if (w.Character.charClass == "adventurer") {
if (w.Premium.hasBonus("character")) {
i *= 1.2;
} else {
i *= 1.1;
}
}
if (w.Premium.hasBonus("money")) {
i *= 1.5;
}
for (var s = 0; s < r.randomyields.length; s++) {
r.randomyields[s] = (r.randomyields[s] * i).round(2);
}
if (typeof r.yields.length == "undefined") {
for (var o in r.yields) {
r.yields[o].prop = (r.yields[o].prop * i).round(2);
}
}
return r;
};
t.openJob = function (e, t, n) {
w.JobWindow.open(e, t, n);
};
t.startJob = function (e, t, n, r) {
w.JobWindow.startJob(e, t, n, Number(r) || 3600);
};
t.getAllJobs = function () {
return r;
};
t.isProduct = function (t) {
return e.inArray(Number(t), o);
};
t.getPopup = function (e, n) {
var r = '
';
var i = t.getJobById(e);
if (isDefined(i)) {
r +=
'' +
i.name +
"" +
'
' +
"" +
'' +
"
";
}
return (r += "
");
};
return t;
})($);
_base.Jobs = Jobs;
Debugger.Jobs = Jobs;
var Window = (function (e) {
var t = {};
var n = "twdb_window";
var r = null;
var i = null;
var s = {};
var o = {};
var u = function () {
if (o.ready) {
return;
}
var t = e('')
.css("background-image", "url(" + Images.button + ")")
.mouseenter(function () {
e(this).css("background-position", "-25px 0px");
})
.mouseleave(function () {
e(this).css("background-position", "0px 0px");
})
.click(function () {
a();
});
e("#ui_menubar").append(e('').append(t).append(''));
ready = true;
o.ready = true;
};
o = Loader.add("Window", "tw-db Scriptwindow", u);
t.open = function (e) {
a(e);
};
var a = function (t) {
r = wman.open(n, null).setMiniTitle("tw-db.info").setTitle("tw-db.info");
r.appendToContentPane(
e(
'
"
)
);
r.appendToContentPane(
e('')
.append('')
.click(function () {
Support.open();
})
);
var o;
for (var u in s) {
if (!isDefined(o)) {
o = u;
}
if (t == u) {
o = u;
}
r.addTab(s[u].name, u, function (e, t) {
f(t);
});
s[u].gui.children().remove();
r.appendToContentPane(s[u].gui);
}
if (isDefined(o)) {
i = s[o].gui;
f(o);
}
};
var f = function (e) {
i.hide();
r.showLoader();
r.activateTab(e);
if (!isDefined(s[e])) {
return;
}
if (s[e].title !== "") {
r.setTitle("tw-db.info " + s[e].title);
} else {
r.setTitle("");
}
i = s[e].gui;
i.show();
w.setTimeout(s[e].callback, 10);
};
t.addTab = function (t, n, r, i) {
s[t] = { title: r, name: n, callback: i, gui: null };
s[t].gui = e('').hide();
return s[t].gui;
};
t.hideLoader = function () {
r.hideLoader();
};
return t;
})($);
Debugger.Window = Window;
var Support = (function (e) {
var t = {};
var n = "twdb_support";
var r = {};
t.addKey = function (e, t) {
r[e] = t;
};
t.open = function () {
var t = e(
'
Please include the text displayed below in a bug report sent using our contact form and also try to describe how to reproduce this error (what did you do when it occured). Thanks!
'
);
var i = e('');
var s = "[CODE]";
for (var o in r) {
s += String(o) + "\n";
s += String(r[o]) + "\n";
s += "----------" + "\n";
}
s += "[/CODE]";
i.append(new west.gui.Textarea().setContent(s).setWidth(600).setHeight(250).setReadonly().getMainDiv());
wman.open(n, null).setMiniTitle("tw-db.info Support").setTitle("tw-db.info Support").appendToContentPane(t).appendToContentPane(i);
};
return t;
})($);
Debugger.Support = Support;
var Timer = (function (e) {
var t = {};
var n = 0;
var r = 0;
var i = 0;
t.getTimeout = function () {
var e = new Date().getTime();
if (e - n < 2e3) {
r++;
} else {
r = 0;
}
if (e - n < 6e4) {
i++;
} else {
i = 0;
}
n = e;
var t = 0;
if (i > 50) {
t = 6e4;
}
if (r < 20) {
return t + 200;
}
return t + 2e3;
};
return t;
})($);
Debugger.Timer = Timer;
var Eventer = (function (e) {
var t = {};
var n = {};
t.set = function (e, t, r) {
if (!isDefined(n[e])) {
n[e] = {};
}
if (!isDefined(r)) {
var r = false;
}
var i = Number(new Date().getTime());
while (n[e][i]) i++;
n[e][i] = { id: i, call: t, count: r };
return i;
};
t.trigger = function (e) {
if (!isDefined(n[e])) {
return;
}
var t = 0;
for (var r in n[e]) {
if (!isDefined(n[e][r].id)) {
continue;
}
w.setTimeout(n[e][r].call, 10);
if (n[e][r].count == false) {
t++;
continue;
}
n[e][r].count--;
if (n[e][r].count > 0) {
t++;
continue;
}
}
if (t == 0) {
delete n[e];
}
};
t.remove = function (e, t) {
if (!isDefined(n[e]) || !isDefined(n[e][t])) {
return false;
}
delete n[e][t];
};
return t;
})($);
_base.Eventer = Eventer;
Debugger.Eventer = Eventer;
var Calc = (function (e) {
var t = {};
var n = false;
var r = { sets: {} };
var i = { sets: {}, items: {} };
var s = {};
var o = function (e) {
for (set in e) {
var t = e[set];
var n = {};
var i = {},
s = {},
o = {};
var u = 0;
for (level in t.bonus) {
if (!t.bonus.hasOwnProperty(level)) continue;
n[level] = { jobs: {}, attributes: [], skills: [] };
if (u > 0) {
for (var a = parseInt(u, 10) + 1; a <= level; ++a) {
n[a] = JSON.parse(JSON.stringify(n[u]));
}
}
for (bonus in t.bonus[level]) {
if (!t.bonus[level].hasOwnProperty(bonus)) continue;
var f = t.bonus[level][bonus];
var l = TWDB.ClothCalc._skill2id[f.name];
switch (f.type) {
case "job":
if (!isDefined(n[level]["jobs"][f.job])) n[level]["jobs"][f.job] = 0;
n[level]["jobs"][f.job] += f.value;
break;
case "attribute":
if (!isDefined(i[l])) i[l] = 0;
i[l] += f.value;
n[level]["attributes"][l] = i[l];
for (iT = 0; iT < TWDB.ClothCalc._sk4attr[f.name].length; iT++) {
var c = TWDB.ClothCalc._sk4attr[f.name][iT];
if (!isDefined(s[c])) s[c] = 0;
s[c] += f.value;
n[level]["skills"][c] = s[c];
}
break;
case "skill":
if (!isDefined(s[l])) s[l] = 0;
s[l] += f.value;
n[level]["skills"][l] = s[l];
break;
case "character":
if (f.bonus && f.key === "level") {
var h = f.roundingMethod;
if (f.bonus.type === "skill") {
var p = TWDB.ClothCalc._skill2id[f.bonus.name];
if (!isDefined(s[p])) s[p] = 0;
s[p] += Math[h](Character.level * f.bonus.value);
n[level]["skills"][p] = s[p];
} else if (f.bonus.type == "attribute") {
for (iT = 0; iT < TWDB.ClothCalc._sk4attr[f.bonus.name].length; iT++) {
var c = TWDB.ClothCalc._sk4attr[f.bonus.name][iT];
if (!isDefined(s[c])) s[c] = 0;
s[c] += Math[h](Character.level * f.bonus.value);
n[level]["skills"][c] = s[c];
}
} else if (f.bonus.type == "job") {
if (!isDefined(n[level]["jobs"][f.bonus.job])) n[level]["jobs"][f.bonus.job] = 0;
n[level]["jobs"][f.bonus.job] += Math[h](Character.level * f.bonus.value);
}
}
break;
default:
break;
}
}
u = level;
}
r.sets[set] = n;
}
return r.sets;
};
var u = function () {
if (s.ready) {
return;
}
Worker.add(
(function () {
return function () {
r = o(west.storage.ItemSetManager._setList);
s.ready = true;
n = true;
};
})()
);
};
s = Loader.add("Calc", "tw-db Calculator", u, {});
t.getCcCache = function () {
return i;
};
t.getSetCache = function () {
return r;
};
t.getSetBonusForJob = function (e, t, n) {
if (isDefined(i.sets[e]) && isDefined(i.sets[e][t]) && isDefined(i.sets[e][t][n])) {
return i.sets[e][t][n];
}
try {
return a(e, t, n);
} catch (r) {
Error.report(r, "calcSetBonusForJob (" + e + " " + t + " " + n + ")");
}
return 0;
};
t.getItemBonusForJob = function (e, t) {
try {
if (isDefined(i) && isDefined(i.items) && isDefined(i.items[e]) && isDefined(i.items[e][t])) {
return i.items[e][t];
}
return f(e, t);
} catch (n) {
Error.report(n, "calcItemBonusForJob (" + e + " " + t + ")");
}
return 0;
};
t.isCached = function (e, t) {
if (isDefined(i.items[e]) && isDefined(i.items[e][t])) {
return true;
} else {
return false;
}
};
var a = function (e, t, n) {
if (!isDefined(r[e])) {
console.log({ message: "unknown set " + e }, "calcSetBonusForJob");
return 0;
}
if (!isDefined(r[e][t])) {
return 0;
}
var s = r[e][t];
var o = Jobs.getJobById(n);
if (!o) {
return 0;
}
var u = 0;
if (isDefined(s.jobs["all"])) {
u += s.jobs["all"];
}
if (isDefined(s.jobs[n])) {
u += s.jobs[n];
}
for (var a in o.skills) {
var f = o.skills[a];
if (isDefined(s.skills[TWDB.ClothCalc._skill2id[a]])) {
u += s.skills[TWDB.ClothCalc._skill2id[a]] * f;
}
}
if (!isDefined(i.sets[e])) {
i.sets[e] = {};
}
if (!isDefined(i.sets[e][t])) {
i.sets[e][t] = {};
}
i.sets[e][t][n] = u;
return u;
};
var f = function (e, t) {
var n = ItemManager.get(e);
if (!n) {
return 0;
}
var r = Jobs.getJobById(t);
if (!r) {
return 0;
}
var s = n.getValue(r.skills, t);
if (!isDefined(i.items[e])) {
i.items[e] = {};
}
i.items[e][t] = s;
return s;
};
return t;
})($);
_base.Calc = Calc;
Debugger.Calc = Calc;
var Importer = (function (e) {
var t = {};
var n = {};
t.div = null;
var r = function () {
if (n.ready) {
return;
}
t.div = Window.addTab("importer", "Importer", "", function () {
i();
});
n.ready = true;
};
n = Loader.add("Importer", "tw-db Importersystem", r, { Window: true });
var i = function () {
t.div.children().remove();
Window.hideLoader();
e.getScript(Script.protocol + "://" + Script.url + "/cache/js/sDoImport_" + Script.lang + ".js");
};
return t;
})($);
_base.Importer = Importer;
Debugger.Importer = Importer;
var Settings = (function (e) {
var t = {};
var n = {};
var r = null;
var i = {};
var s = function () {
if (i.ready) {
return;
}
var e = Cache.load("settings");
if (typeof e === "object" && e !== null) {
n = e;
} else {
n = {};
}
TWDB.Util.addCss("span.twdb_sett_capt { font-size: 115%; font-weight: bold; font-style: italic; display: inline-block; margin-top: 8px; text-shadow: 2px 1px 2px #643; }");
r = Window.addTab("settings", "Nastavenia", "Nastavenia", o);
i.ready = true;
};
i = Loader.add("Settings", "tw-db Settingssystem", s, { Cache: true, Window: true });
var o = function () {
r.children().remove();
var i = new west.gui.Scrollpane();
e(i.getMainDiv()).css("height", "300px");
r.append(i.getMainDiv());
var s = [
[9, "", "Inventár", false],
[0, "jobBoniTooltip", "Pre zvolenú prácu zobraziť v inventári info o pracovných bodoch", false],
[0, "collector", "Označiť veci u obchodníka a na trhu, ktoré nemáš v inventári", false],
[0, "buyTip", "Zobraziť v obchodoch tipy pre kúpu", false],
[0, "sellTip", "Zobraziť v inventári info pri nepotrebných veciach (na predaj)", false],
[0, "sellTip1", "Predávať predmety ktoré máš viackrát", "Nastavenia tipov pri predaji"],
[0, "sellTip2", "Predávať predmety nevyužité na žiadnej práci", "Nastavenia tipov pri predaji"],
[0, "sellTip3", "Nepredávať pomenované predmety", "Nastavenia tipov pri predaji"],
[0, "sellTip4", "Nepredávať predmety, ktoré sa dajú len nájsť", "Nastavenia tipov pri predaji"],
[0, "sellTip5", "Nepredávať predmety zo súprav", "Nastavenia tipov pri predaji"],
[0, "pinitems", "Zapnúť pripínanie vecí v sekcii prednedávnom použitých vecí Inventára", false],
[0, "collectorsell", "Pridať možnosť predaja všetkých duplikátov vybranej veci u obchodníka", false],
[9, "", "Úlohy", false],
[0, "questwiki", "Pridať do okien úloh odkaz na tw-db a ClothCalc", false],
[0, "questcancle", "Pri rušení úlohy dostaneš upozornenie či to chceš naozaj spraviť", false],
[0, "qbswitch", "Pridať možnosť prepnutia medzi úvodným a záverečným textom v Knihe úloh", false],
[0, "qfulltext", "Vždy zobraz plný text príbehu úlohy", false],
[9, "", "Trh", false],
[0, "marketmap", "Použiť mapu trhu", false],
[0, "marketreminder", "Pridať možnosť pripomenutia aukcie", false],
[0, "marketselldialog", "Vylepšiť okno predaja na trhu", false],
[9, "", "Práce", false],
[0, "jobwin_ccbutton", "Pridať ClothCalc do okna práce", false],
[0, "jobwin_showlp", "Zobraziť pracovné body v okne práce", false],
[9, "", "Zoznam činností", false],
[0, "tasklistpoints", "Zobraziť rozšírené informácie o PB v zozname činností", false],
[9, "", "GUI", false],
[0, "duelmotivation", "Pridať indikátor duelovej motivácie pod ukazovateľ energie", false],
[0, "directsleep", "Pridať tlačidlo na priame použitie Hotela alebo Kasární", false],
[0, "deposit", "Pridať tlačítko na uloženie peňazí", false],
[0, "noshopsale", "Zrušiť notifikáciu o zľavách v obchode", false],
[0, "expbarvalues", "Zobraziť hodnoty v lište skúseností; Zásluhy a poďakovanie: Leones/Slygoxx", false],
[0, "mini_chatgui", "Povoliť minimalizáciu zoznamu chatovacích miestností", false],
[0, "customcounterpos", "Premiestniť ukazatele udalostí na širších obrazovkách (mena udalosti, Hirov skript)", false],
[0, "noscrollbars", "Zakázať scrollbary na malých obrazovkách alebo pri posúvaní okien príliš ďaleko", false],
[9, "", "Minimapa", false],
[0, "showbonusjobs", "Zobraziť na mape bonusové práce", false],
[0, "showscrollto", "Pridať do minimapy možnosť posunu na zadané súradnice", false],
[9, "", "Pevnosť", false],
[0, "fortrecruitment", "Sprístupniť rozšírené možnosti verbovania", false],
[0, "enhancedfortrecruitment", "Zobraziť hráčov pri pevnosti", false],
[9, "", "Rôzne", false],
[0, "chat", "Použiť rozšírenie chatu", false],
[0, "notes", "Zapnúť poznámky", false],
[0, "forumlastpage", "Pridať do fóra odkaz na posledný príspevok v téme", false],
[0, "fastskillchange", "Zapnúť rýchly presun schopností (podržaním tlačítka myši)", false],
[0, "autodeposit", "Dostávať upozornenia pri príchode do mesta s peniazmi", false],
[0, "chestanalyser", "Vytvoriť štatistiky tebou otvorených truhiel", false],
[0, "weeklycrafting", "Upozorniť po vypršaní čakacej doby na výrobu", false],
[0, "noworkqueuepa", "Zrušiť upozornenia na kúpu prémia", "Nastavenia prémia"],
[0, "nofetchallpa", "Odstrániť prémiové okno pri výbere všetkých vecí z trhu", "Nastavenia prémia"],
[0, "nowofnuggets", "Nepoužívať nuggety ako predvolený spôsob platby v udalostiach (keď možné)", "Nastavenia prémia"],
[0, "instanthotel", "Pridať tlačidlo hotela k názvom miest", false],
[0, "telegramsource", "Pridať tlačidlo na zmenu telegramov do neformátovanej podoby", false],
[8, "clothPos"],
[0, "wear_openmin", "Otvoriť inventár minimalizovaný pri otváraní kalkulátora", false],
];
var o = {};
var a = e("
");
var f = {};
for (var l = 0; l < s.length; l++) {
var c = s[l][1];
o[c] = t.get(c);
var h = e("
");
if (s[l][0] === 9) {
h.append(e('
').append(e('').text((s[l][2] + "").twdb_twiceHTMLUnescape())));
a.append(h);
continue;
}
if (s[l][0] === 8) {
h.addClass("placeholder_" + s[l][1]);
a.append(h);
continue;
}
switch (s[l][0]) {
case 0:
var p = (function (e) {
return function () {
o[e] = !o[e];
};
})(c);
var d = new west.gui.Checkbox("", !o[c] ? "" : "tw2gui_checkbox_checked", p);
h.append(e('
').append(d.getMainDiv()));
break;
}
h.append(e("
").text((s[l][2] + "").twdb_twiceHTMLUnescape()));
if (s[l][3]) {
var v = s[l][3];
if (!isDefined(f[v])) {
f[v] = e("
"));
var g = new west.gui.Button("Uložiť", function () {
switch (m.getValue()) {
case "left":
n["clothPos"] = "left";
break;
case "right":
n["clothPos"] = "right";
break;
default:
n["clothPos"] = "custom";
break;
}
u(o);
});
var y = e('').append(
e('').click(function () {
Cache.reset();
})
);
i.appendContent(a);
r.append(g.getMainDiv()).append(y);
Window.hideLoader();
};
t.get = function (e, r) {
if (!isDefined(n[e])) {
t.set(e, r);
return r;
}
return n[e];
};
t.set = function (e, t) {
n[e] = t;
Cache.save("settings", n);
};
var u = function (e) {
for (var t in e) {
n[t] = e[t];
}
if (Cache.save("settings", n)) {
new UserMessage("Uloženie úspešné", UserMessage.TYPE_SUCCESS).show();
} else {
new UserMessage("?save_error", UserMessage.TYPE_ERROR).show();
}
};
return t;
})($);
_base.Settings = Settings;
Debugger.Settings = Settings;
var JobWindowCC = (function (e) {
var t = {};
var n = {};
var r = function () {
if (n.ready) {
return;
}
if (Settings.get("jobwin_ccbutton", true)) {
i();
}
if (Settings.get("jobwin_showlp", true)) {
s();
}
n.ready = true;
};
var i = function () {
try {
JobWindow.prototype.__twdb__getBestWearButton = JobWindow.prototype.__twdb__getBestWearButton || JobWindow.prototype.getBestWearButton;
JobWindow.prototype.getBestWearButton = function () {
var t = JobWindow.prototype.__twdb__getBestWearButton.apply(this, arguments);
var n = this;
return t.append(
e('
').click(function (e) {
e.stopImmediatePropagation();
TWDB.ClothCalc.open(n.job.id, "job");
})
);
};
var t =
"div.job_bestwearbutton {left: 15px!important; width: 210px;}\n" +
"div.twdb_bestwear {background: url('" +
TWDB.images.bestwear +
"') no-repeat top; " +
"height: 55px; width: 55px; position: relative; left: 195px; top: -15px;}\n" +
"div.job_bestwearbutton:hover .twdb_bestwear {background-position: bottom;}";
TWDB.Util.addCss(t, "bestwear");
} catch (n) {
Error.report(n, "manipulate JobWindow.prototype.getBestWearButton");
}
};
var s = function () {
try {
JobWindow.prototype.__twdb__initView = JobWindow.prototype.__twdb__initView || JobWindow.prototype.initView;
JobWindow.prototype.initView = function () {
var t = JobWindow.prototype.__twdb__initView.apply(this, arguments);
var n = " (" + (this.currSkillpoints - this.job.workpoints) + " PB)";
e("div.tw2gui_inner_window_title > .textart_title", this.window.divMain).append(n);
return t;
};
} catch (t) {
Error.report(t, "manipulate JobWindow.prototype.initView");
}
};
n = Loader.add("JobWindowCC", "tw-db Job window", r, { Settings: true, ClothCalc: true });
return t;
})($);
var Tools = (function (e) {
var t = {};
var n = {};
var r;
var i = function () {
if (n.ready) {
return;
}
r = Window.addTab("tools", "Tools", "", function () {
s();
});
n.ready = true;
};
n = Loader.add("Tools", "tw-db Toolsystem", i, { Window: true });
var s = function () {
r.children().remove();
new west.gui.Button("open Tool", function () {
w.open("https://" + Script.url + "/?strana=politic_map&world=" + location.hostname.split(".")[0]);
}).appendTo(r);
var t = new west.gui.Button();
t.setCaption("Alliance Import".escapeHTML())
.click(function () {
t.disable();
e.getScript(Script.protocol + "://" + Script.url + "/js/sDoAllianceImport.js");
})
.appendTo(r);
Window.hideLoader();
};
return t;
})($);
Debugger.Tools = Tools;
var Updater = (function (e) {
var t = {};
var n = {};
var r;
var i = false;
var s = function () {
if (n.ready) {
return;
}
r = Window.addTab("notes", "Release Notes", "Release Notes", function () {
u();
});
if (!Cache.load("version")) Cache.save("version", Script.version + " " + Script.revision);
else if (Script.version + " " + Script.revision !== Cache.load("version")) {
Cache.save("version", Script.version + " " + Script.revision);
i = true;
var e = "Script bol aktualizovaný";
var t = '
Script =1= bol aktualizovaný. Chceš sa pozrieť na zoznam zmien?
';
t = t.replace("=1=", "" + Script.name + "");
new west.gui.Dialog(e, t, "warning")
.addButton("no")
.addButton("yes", function () {
Window.open("notes");
})
.show();
}
n.ready = true;
};
n = Loader.add("Updater", "tw-db Updater", s, { Cache: true, Window: true });
var o = function (e, t) {
var n = "Script potrebuje aktualizáciu";
var r = '
Pre script =1= je dostupná nová verzia, prosím zvoľ ok pre aktualizovanie scriptu.
';
r = r.replace("=1=", "" + Script.name + "");
r += "
current version: " + Script.version / 100 + " revision " + Script.revision + " new version: " + e / 100 + " revision " + t + "
";
var i = Script.protocol + "://" + Script.update;
var s = function () {
window.open(i);
new west.gui.Dialog(Script.name, "Prosím znovu načítajte hru po inštalácii.", "warning").setModal(true, false, true).show();
};
new west.gui.Dialog(n, r, west.gui.Dialog.SYS_WARNING).addButton("Teraz nie").addButton("ok", s).show();
};
t.wasUpdated = function () {
return i;
};
var u = function () {
r.children().remove();
var t = new west.gui.Scrollpane();
e(t.getMainDiv()).css("height", "335px");
var n = false;
for (var i = 0; i < Script.notes.length; i++) {
var s = e("
")
.css("border-bottom", "1px solid black")
.click(function () {
e(this).next().toggle();
});
var o = e("
" + Script.notes[i].notes + "
");
t.appendContent(s).appendContent(o);
if (n) {
o.hide();
}
n = true;
}
r.append(t.getMainDiv());
Window.hideLoader();
};
t.query = function () {
setTimeout(function () {
e.getScript(Script.protocol + "://" + Script.check + "?" + new Date().getTime());
}, 500);
};
t.check = function (e, t, n) {
if (Script.version !== e || Script.revision !== t) {
o(e, t);
}
};
return t;
})($);
_base.Updater = Updater;
Debugger.Updater = Updater;
var Sleep = (function (e) {
var t = {};
var n = null;
var r = [];
var i = [];
var s = {};
var o = 1;
var u = false;
var a = {};
var f;
var l = false;
var c = 0;
var h = [];
var p = ["", "cubby", "bedroom", "hotel_room", "apartment", "luxurious_apartment"];
var d = function () {
if (a.ready) {
return;
}
if (Settings.get("directsleep", true)) {
var e =
"ul.tw2gui_selectbox_content.twdb_sleepmenu {max-width: 320px!important; white-space: nowrap; overflow-y: auto; overflow-x: hidden;}" +
"ul.tw2gui_selectbox_content.twdb_sleepmenu > div.tw2gui_scrollpane {width: 320px!important}" +
"ul.tw2gui_selectbox_content.twdb_sleepmenu > li {padding-right: 20px!important;}";
TWDB.Util.addCss(e);
s = Cache.load("barracks");
if (s == null || typeof s !== "object") {
s = {};
}
v();
if (Character.homeTown.town_id !== 0) x();
else S();
}
a.ready = true;
};
a = Loader.add("Sleep", "tw-db DirectSleep", d, { Cache: true, Settings: true });
var v = function () {
n = GameInject.CharacterButton.add(Images.buttonSleep);
n.addMousePopup("spánok").click(function (e) {
if (w.Character.homeTown.town_id !== 0 && r.length == 0) b();
else y(e);
});
};
var m = function (t, n, r) {
var i = new west.gui.Selectbox(true).addListener(function (e) {
switch (e) {
case "home":
b();
break;
default:
E(e);
break;
}
});
if (w.Character.homeTown.town_id !== 0) i.addItem("home", "Hotel " + w.GameMap.calcWayTime(f, w.Character.homeTown).formatDuration());
for (var s = 0; s < r; s++) if (t[s].stage !== 0) i.addItem(s, "Stupeň " + t[s].stage + " " + t[s].distance.formatDuration() + " | " + t[s].name);
e(i.elContent).addClass("twdb_sleepmenu");
i.show(n);
l = false;
};
var g = function (e, t, n) {
Ajax.remoteCallMode("building_hotel", "get_data", { town_id: h[e].town_id }, function (r) {
if (r.error) return new UserMessage(r.msg).show();
h[e].stage = r.hotel_level;
if (++c == t) m(h, n, t);
});
};
var y = function (e) {
if (l) return;
l = true;
f = Map.getLastPosition();
if (w.Character.homeTown.town_id === 0) {
for (var t = 0; t < h.length; t++) h[t].distance = w.GameMap.calcWayTime(f, h[t]);
h.sort(function (e, t) {
return e.distance - t.distance;
});
var n = h.length > 5 ? 5 : h.length;
c = 0;
for (var i = 0; i < n; i++) {
if (h[i].hasOwnProperty("stage")) {
if (++c == n) m(h, e, n);
} else g(i, n, e);
}
} else {
for (var t = 0; t < r.length; t++) r[t].distance = w.GameMap.calcWayTime(f, r[t]);
r.sort(function (e, t) {
return e.distance - t.distance;
});
m(r, e, r.length);
}
};
var b = function () {
Ajax.remoteCallMode("building_hotel", "get_data", { town_id: w.Character.homeTown.town_id }, function (e) {
if (e.error) return new UserMessage(e.msg).show();
var t = p[e.hotel_level];
w.TaskQueue.add(new TaskSleep(w.Character.homeTown.town_id, t));
});
};
var E = function (e) {
if (isDefined(h[e])) w.TaskQueue.add(new TaskSleep(h[e].town_id, p[h[e].stage]));
else if (isDefined(r[e])) w.TaskQueue.add(new TaskFortSleep(r[e].id, r[e].x, r[e].y));
};
var S = function () {
Ajax.get("map", "get_minimap", {}, function (e) {
if (e.error) return new UserMessage(e.msg).show();
for (var t in e.towns) if (e.towns[t].member_count) h.push(e.towns[t]);
});
};
var x = function () {
if (w.Character.homeTown.alliance_id == 0)
Ajax.remoteCall("fort_overview", "", {}, function (e) {
for (var t in e.js) {
var n = e.js[t],
r = e.page.match(new RegExp('
'));
if (r) i.push({ fort_id: n[0], x: n[1], y: n[2], name: r[1] });
}
if (i.length > 0)
w.setTimeout(function () {
T();
}, Timer.getTimeout());
});
else
Ajax.remoteCallMode("alliance", "get_data", { alliance_id: w.Character.homeTown.alliance_id }, function (e) {
if (e.error) return new UserMessage(e.error).show();
i = e.data.forts;
if (i.length > 0)
w.setTimeout(function () {
T();
}, Timer.getTimeout());
});
};
var T = function () {
try {
if (i.length <= 0) {
return;
}
var t = i.pop();
var n = t.fort_id;
if (!isDefined(s[n])) {
s[n] = { time: 0, stage: 0 };
}
e.extend(s[n], { id: n, x: t.x, y: t.y, name: t.name });
if (s[n].stage !== 5 && s[n].time + o * 86400 > new Date().getTime() / 1e3) {
r.push(s[n]);
if (i.length > 0) {
w.setTimeout(function () {
T();
}, Timer.getTimeout());
} else {
Cache.save("barracks", s);
}
return;
}
Ajax.remoteCallMode("fort_building_barracks", "index", { fort_id: n }, function (e) {
if (e.error) {
new UserMessage(e.error).show();
} else {
s[n].time = Number(new Date().getTime() / 1e3).round(0);
if (isDefined(e.barrackStage)) {
s[n].stage = e.barrackStage;
}
}
r.push(s[n]);
if (i.length > 0) {
w.setTimeout(function () {
T();
}, Timer.getTimeout());
} else {
Cache.save("barracks", s);
}
});
} catch (u) {
Error.report(u, "getFortData");
}
};
return t;
})($);
Debugger.Sleep = Sleep;
var Analyser = (function (e) {
var t = {};
var n = false;
var r = null;
var s = null;
var o = false;
var u = [];
var a = [];
var f = 0;
var l = {};
var c = {};
t.extra = false;
var h = {};
var p = function () {
if (h.ready) {
return;
}
TWDB.Util.addCss(
".messages-analyser-job .item img.tw_item { width: 30px; height: 27px; }" +
".messages-analyser-job .item .count { bottom: -4px; }" +
".messages-analyser-job .item span.usable { display: none; }" +
"div.tw2gui_window .messages-analyser-job div.fancytable .row > div { display: none; vertical-align: top; }" +
".messages-analyser-job.view-rewards div.fancytable .row > div.view-rewards { display: inline-block; }" +
".messages-analyser-job.view-items div.fancytable .row > div.view-items { display: inline-block; }" +
"div.tw2gui_window .messages-analyser-job div.fancytable div.trows div.tbody div.row { height: auto; }"
);
var t = Cache.load("statistic");
if (typeof t == "object" && t !== null) {
r = t;
} else {
d("all", true);
}
if (!r.ver) {
d("all", true);
}
switch (r.ver) {
case 1:
d("job", true, 1);
d("duel", true, 1);
r.ver = 2;
case 2:
d("job", true, 1);
d("duel", true, 1);
r.ver = 3;
case 3:
d("chest", true, 1);
r.ver = 4;
}
s = e.extend(true, {}, r);
GameInject.addTabOnMessagesWindow("Analýza prác", "analyser-job", function () {
T("job");
});
if (Settings.get("chestanalyser", true)) {
GameInject.ItemUse(v.add);
GameInject.addTabOnMessagesWindow("Analýza truhiel", "analyser-chest", function () {
v.show();
});
}
h.ready = true;
};
h = Loader.add("Analyser", "tw-db Job-Analyser", p, { Cache: true, Settings: true, Jobs: true });
t.restore = function () {
r = e.extend(true, {}, s);
};
t.debug = function () {
console.log(r);
console.log(c);
};
var d = function (t, n, i) {
if (n == true) {
if (!i) {
var i = 0;
} else {
var s = /\[report=([0-9]+)([A-Fa-f0-9]{10})\]/;
var o = String(i).match(s);
if (o) {
var i = o[1];
}
}
if (isNaN(parseInt(i, 10))) {
var u = 0;
} else {
var u = parseInt(i, 10) - 1;
}
switch (t) {
case "job":
r[t] = { last: u, items: { last: 0 } };
break;
case "duel":
r[t] = { last: u };
break;
case "chest":
r[t] = {};
break;
case "all":
r = { ver: 4 };
d("job", true, u + 1);
d("duel", true, u + 1);
d("chest", true, u + 1);
break;
}
} else {
var a = e('
Do you really want to reset the ReportAnalyser statistics?
Give Report-Link of first Report which should be read after Reset
');
var f = new west.gui.Textfield("twdb_analyser_last").setSize(40);
f.setLabel("Report-Link:");
a.append(f.getMainDiv());
var l = new west.gui.Checkbox("or use all reports ");
var c = new west.gui.Checkbox("or use only future reports");
l.setCallback(function (e) {
if (e) {
c.setSelected(false);
f.setValue("");
}
});
c.setCallback(function (e) {
if (e) {
l.setSelected(false);
f.setValue("");
}
});
e(f.getMainDiv()).find("span").css("font-size", "12px");
e(f.getMainDiv())
.find("input")
.keyup(function () {
l.setSelected(false);
c.setSelected(false);
});
a.append(e('').append(l.getMainDiv()).append(c.getMainDiv()));
var h = new west.gui.Dialog("ReportAnalyser - Vynulovať", a);
h.addButton("ok", function () {
if (l.isSelected()) {
d(t, true);
} else if (c.isSelected()) {
d(t, true, r[t].last + 1);
} else {
d(t, true, f.getValue());
}
h.hide();
MessagesWindow.open("analyser-" + t);
});
h.addButton("cancel");
h.show();
}
};
var v = (function (e) {
var t = {};
t.add = function (e, t) {
var n = false;
for (i = 0; i < t.msg.effects.length; i += 1) {
var s = t.msg.effects[i];
if (s.type == "lottery" || s.type == "content") {
if (!isDefined(r.chest[e])) {
r.chest[e] = { count: 0, items: {} };
}
var o = r.chest[e];
if (!n) {
o.count++;
n = true;
}
s.items.each(function (e) {
if (!isDefined(o.items[e.item_id])) {
o.items[e.item_id] = 0;
}
o.items[e.item_id] += e.count;
});
} else if (s.type == "learn_recipe") TWDB.ClothCalc.recipes[s.recipe] = 1;
}
Cache.save("statistic", r);
};
t.show = function () {
if (!MessagesWindow.window) {
return;
}
var t = e(MessagesWindow.window.getContentPane()).find(".messages-analyser-chest");
MessagesWindow.window.showLoader();
t.children().remove();
var n = new west.gui.Scrollpane();
e(n.getMainDiv()).css("height", "385px");
t.append(n.getMainDiv());
for (var i in r.chest) {
var s = r.chest[i];
var o = new tw2widget.Item(ItemManager.get(i), "item_inventory").setCount(s.count);
o.getImgEl().addClass("item_inventory_img");
n.appendContent(e('').append(o.getMainDiv()));
var u = 0;
var a = e('');
for (var f in s.items) {
u++;
var o = new tw2widget.Item(ItemManager.get(f), "item_inventory").setCount(s.items[f]);
o.getImgEl().addClass("item_inventory_img");
a.append(o.getMainDiv());
}
n.appendContent('')
.appendContent(a)
.appendContent('');
}
MessagesWindow.window.hideLoader();
};
return t;
})(e);
var m = function (e) {
if (o) {
return;
}
o = true;
u = [];
g(e);
};
var g = function (e, t) {
if (!t) {
t = 1;
}
f = t;
Ajax.remoteCall("reports", "get_reports", { page: t, folder: e }, function (t) {
y(e, t);
});
};
var y = function (e, t) {
var n = true;
if (typeof t.reports !== "object") {
t.reports = [];
n = false;
}
if (typeof t.page == "undefined" || f !== t.page) {
t.reports = [];
n = false;
}
for (var i = 0; i < t.reports.length; i++) {
var s = t.reports[i];
if (s.report_id <= r[e].last) {
n = false;
break;
}
u.push({ id: s.report_id, hash: s.hash, type: e });
}
l.bar.setMaxValue(u.length);
if (n) {
window.setTimeout(function () {
g(e, f + 1);
}, Timer.getTimeout());
} else {
b(e);
}
};
var b = function (e) {
if (u.length > 0) {
l.bar.setValue(l.bar.getValue() + 1);
w(u.pop());
} else {
Cache.save("statistic", r);
o = false;
T(e, true);
}
};
var w = function (t) {
e.post(
"game.php?window=reports&mode=show_report",
{ flash: null, hash: t.hash, report_id: t.id },
function (e) {
E(t.type, e);
},
"json"
);
};
var E = function (e, t) {
if (!t || !t.report_id || !t.publishHash) {
new UserMessage("empty Server Response", UserMessage.TYPE_ERROR).show();
return false;
}
if (typeof t.page !== "string" || typeof t.title !== "string" || typeof t.js !== "string") {
a.push(t.report_id);
} else {
switch (e) {
case "job":
x(t);
break;
case "duel":
S(t);
break;
}
r[e].last = t.report_id;
}
window.setTimeout(function () {
b(e);
}, Timer.getTimeout());
};
var S = function (e) {};
var x = function (n) {
try {
data = { id: null, hash: null, job: null, motivation: null, duration: null, wage: null, bond: null, experience: null, injury: 0, killed: false, date_received: null, items: {} };
data.id = n.report_id;
data.hash = n.publishHash;
var i = Jobs.getJobByName(n.title.slice(n.title.indexOf(":") + 1));
if (!i) {
a.push(data.id);
return false;
}
data.job = i.id;
data.date_received = n.date_received;
var s = e(n.page);
s.find(".rp_row_jobdata").each(function (t) {
var n = e.trim(e(this).children("span:last-child").html());
n = n.split(" ").join(" ");
switch (t) {
case 0:
data.motivation = parseInt(n.slice(0, n.indexOf(" ")), 10);
break;
case 1:
var r = parseFloat(n);
data.duration = r == 1 ? 3600 : r == 10 ? 600 : r == 15 ? 15 : null;
if (!data.duration) Error.report({ message: "Unrecognized time on report:" + n }, "Job-Analyser");
break;
case 2:
data.wage = parseInt(n.slice(n.indexOf(" ") + 1), 10);
break;
case 3:
data.bond = parseInt(n, 10);
break;
case 4:
data.experience = parseInt(n.slice(0, n.indexOf(" ")), 10);
break;
}
});
s.find(".rp_hurtmessage_text").each(function () {
var t = new RegExp("[0-9]+");
data.injury = Number(t.exec(e(this).html()));
});
s.find(".rp_row_killmessage").each(function () {
data.killed = true;
});
var s = n.js.split(";");
e(s).each(function () {
var e = new RegExp(/\s*ItemManager\.get\(([0-9]+)\)\s*\)\.setCount\(([0-9]+)\)/m);
var t = e.exec(this);
if (t) {
data.items[Number(t[1])] = Number(t[2]);
}
});
if (!r.job[data.job]) {
r.job[data.job] = { count: 0, products: {} };
}
var o = r.job[data.job];
o.count++;
if (!o[data.motivation]) {
o[data.motivation] = { count: 0, duration: 0, wage: 0, bond: 0, experience: 0, injury: {}, killed: 0, items: {}, extraitems: {} };
}
var u = o[data.motivation];
if (!isDefined(u.duration)) {
u.duration = 0;
}
u.count++;
u.duration += data.duration;
u.wage += data.wage;
u.bond += data.bond;
u.experience += data.experience;
if (!u.injury[data.injury]) {
u.injury[data.injury] = 0;
}
u.injury[data.injury]++;
if (data.killed) {
u.killed++;
}
for (var f in data.items) {
var l = Number(f);
var c = 138e3;
if (l === c) {
if (!isDefined(r.extra)) {
r.extra = { count: 0 };
t.extra = true;
}
r.extra.count++;
r.extra[r.extra.count] = data;
}
var h = data.items[l];
var p = ItemManager.get(l);
if (Jobs.isProduct(l) !== -1) {
if (!o.products[l]) {
o.products[l] = { last: 0 };
}
var s = o.products[l];
for (var d = 0; d < h; d++) {
var v = o.count - s.last;
s.last = o.count;
if (!s[v]) {
s[v] = 0;
}
s[v]++;
}
} else if (p.price == 0) {
if (!u.extraitems[l]) {
u.extraitems[l] = 0;
}
u.extraitems[l]++;
} else {
luck = true;
if (!u.items[l]) {
u.items[l] = 0;
}
u.items[l]++;
}
}
} catch (m) {
a.push(data.id);
return false;
}
};
var T = function (t, n) {
if (!MessagesWindow.window) {
return;
}
l.window = e(MessagesWindow.window.getContentPane()).find(".messages-analyser-" + t);
if (typeof n == "undefined") {
MessagesWindow.window.showLoader();
l.bar = new west.gui.Progressbar(0, u.length);
l.window.children().remove();
l.window.append(l.bar.getMainDiv());
m(t);
} else {
switch (t) {
case "job":
var r = k();
break;
case "duel":
var r = showDuels();
break;
}
l.window.children().remove();
l.window.append(r);
N();
C();
N();
MessagesWindow.window.hideLoader();
}
};
var N = function (t) {
try {
if (typeof t != "undefined") {
if (c.type == t) {
c.ord *= -1;
} else {
c.ord = 1;
c.type = t;
}
} else {
var t = c.type;
}
var n = c.ord;
var r = function (r, i) {
var s = e(r)
.find(".cell_" + t)
.html();
var o = e(i)
.find(".cell_" + t)
.html();
if (Number(s) == s) {
return s * 1 > o * 1 ? n : -n;
} else {
return s > o ? n : -n;
}
};
l.rows.sort(r);
for (var i = 0; i < l.rows.length; i++) {
l.bodyscroll.appendContent(l.rows[i]);
}
} catch (s) {
Error.report(s, "Analyser sort");
}
};
var C = function () {
switch (c.avg) {
case "avg":
c.avg = "sum";
break;
case "sum":
c.avg = "avg";
break;
}
e(l.window)
.find("div.row div")
.each(function (t) {
var n = e(this).data(String(c.avg));
var r = e(this).data(String(c.avg) + "-t");
e(this).html(n).attr("title", r);
});
};
var k = function () {
l.window.addClass("view-rewards");
c = { ord: 1, type: 0, avg: "avg" };
var t = e(
'
' +
'' +
'' +
'' +
'' +
'
' +
'
' +
'
' +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
'
' +
'' +
'' +
"" +
"
" +
"
" +
"
" +
'
' +
'' +
'' +
"
" +
'
' +
'' +
"
" +
"
" +
"
"
);
t.find(".row_head > div").each(function () {
var t = e(this)
.attr("class")
.match(/cell_(\d+|reset)/)[1],
n = e(this).find("img");
if (t == "reset") {
e(this).click(function () {
d("job");
});
} else {
e(this).click(
(function (e) {
return function () {
N(e);
};
})(t * 1)
);
}
});
t.find(".row_head").find("img").css("cursor", "pointer");
var n = 0;
var i = { jobs: 0, count: 0, duration: 0, experience: 0, wage: 0, bond: 0, motivation: 0, injury: 0, killed: 0, products: 0, items: 0, luck: 0 };
var s = r.job;
var o = e();
l.rows = [];
for (var u in s) {
var a = Jobs.getJobById(u);
if (!a) {
continue;
}
var f = { count: 0, duration: 0, experience: 0, wage: 0, bond: 0, motivation: 0, injury: 0, killed: 0, products: 0, items: 0, luck: 0, all_products: {}, all_items: {} };
var h = s[u];
f.count = h.count;
var p = 0;
for (var n = 0; n < a.randomyields.length; n++) {
p += a.randomyields[n];
}
if (typeof a.yields.length == "undefined") {
for (var v in a.yields) {
p += a.yields[v].prop;
}
}
for (var v in h.products) {
for (var m in h.products[v]) {
if (m == "last") {
continue;
}
var g = ItemManager.get(v);
f.products += Number(h.products[v][m]);
f.luck += Number(g.price * h.products[v][m]);
f.all_products[v] = (f.all_products[v] || 0) + h.products[v][m];
}
}
for (var y in h) {
if (y == "count" || y == "products") {
continue;
}
var m = h[y];
f.motivation += y * m.count;
f.bond += m.bond;
f.duration += m.duration || 0;
f.experience += m.experience;
for (var b in m.injury) {
f.injury += b * m.injury[b];
}
for (var v in m.items) {
var g = ItemManager.get(v);
f.items += Number(m.items[v]);
f.luck += Number(g.price * m.items[v]);
f.all_items[v] = (f.all_items[v] || 0) + m.items[v];
}
f.killed += m.killed;
f.wage += m.wage;
}
var w = e('');
var m = e('');
m.data("sum", a.name);
m.data("sum-t", a.name);
m.data("avg", a.name);
m.data("avg-t", a.name);
w.append(m);
i.jobs++;
var m = e('');
m.data("sum", f.count);
m.data("sum-t", f.count);
m.data("avg", f.count);
m.data("avg-t", f.count);
w.append(m);
i.count += f.count;
var m = e('');
m.data("sum", (f.duration / 3600).round(2));
m.data("sum-t", String((f.duration / 3600).round(2)) + " hodín");
m.data("avg", (f.duration / (3600 * f.count)).round(2));
m.data("avg-t", "Ø " + String((f.duration / (3600 * f.count)).round(2)) + " hodín");
w.append(m);
i.duration += f.duration;
var m = e('');
m.data("sum", f.experience);
m.data("sum-t", String(f.experience));
m.data("avg", (f.experience / f.count).round(2));
m.data("avg-t", "Ø " + String((f.experience / f.count).round(2)));
w.append(m);
i.experience += f.experience;
var m = e('');
m.data("sum", f.wage);
m.data("sum-t", "$" + String(f.wage));
m.data("avg", (f.wage / f.count).round(2));
m.data("avg-t", "Ø $" + String((f.wage / f.count).round(2)));
w.append(m);
i.wage += f.wage;
var m = e('');
m.data("sum", f.bond);
m.data("sum-t", String(f.bond));
m.data("avg", ((f.bond / f.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((f.bond / f.count) * 100).round(2)) + "%");
w.append(m);
i.bond += f.bond;
var m = e('');
m.data("sum", f.motivation);
m.data("sum-t", String(f.motivation) + "%");
m.data("avg", (f.motivation / f.count).round(2));
m.data("avg-t", "Ø " + String((f.motivation / f.count).round(2)) + "%");
w.append(m);
i.motivation += f.motivation;
var m = e('');
m.data("sum", f.injury);
m.data("sum-t", String(f.injury));
m.data("avg", (f.injury / f.count).round(2));
m.data("avg-t", "Ø " + String((f.injury / f.count).round(2)));
w.append(m);
i.injury += f.injury;
var m = e('');
m.data("sum", f.killed);
m.data("sum-t", String(f.killed));
m.data("avg", ((f.killed / f.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((f.killed / f.count) * 100).round(2)) + "%");
w.append(m);
i.killed += f.killed;
var m = e('');
m.data("sum", f.products);
m.data("sum-t", String(f.products));
m.data("avg", ((f.products / f.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((f.products / f.count) * 100).round(2)) + "% [" + p * 100 + "%]");
w.append(m);
i.products += f.products;
var m = e('');
var E = e.map(f.all_products, function (e, t) {
return new tw2widget.Item(ItemManager.get(t)).setCount(e).getMainDiv();
});
m.data("sum", E);
m.data("avg", E);
w.append(m);
var m = e('');
m.data("sum", f.items);
m.data("sum-t", String(f.items));
m.data("avg", ((f.items / f.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((f.items / f.count) * 100).round(2)) + "%");
w.append(m);
i.items += f.items;
var m = e('');
var E = e.map(f.all_items, function (e, t) {
return new tw2widget.Item(ItemManager.get(t)).setCount(e).getMainDiv();
});
m.data("sum", E);
m.data("avg", E);
w.append(m);
var m = e('');
m.data("sum", f.luck);
m.data("sum-t", "$" + String(f.luck));
m.data("avg", (f.luck / f.count).round(2));
m.data("avg-t", "Ø $" + String((f.luck / f.count).round(2)));
w.append(m);
i.luck += f.luck;
l.rows.push(w);
w.click(function () {
L(e(this).children(".cell_0").html());
});
n++;
}
l.bodyscroll = new west.gui.Scrollpane();
e(l.bodyscroll.getMainDiv()).css("height", "300px");
t.find(".tbody").append(l.bodyscroll.getMainDiv());
l.footer = t.find(".row_foot");
var m = e('');
m.data("sum", i.jobs);
m.data("sum-t", i.jobs + " práce");
m.data("avg", i.jobs);
m.data("avg-t", i.jobs + " práce");
l.footer.append(m);
var m = e('');
m.mouseenter(function () {
e(this).css("color", "#888");
}).mouseleave(function () {
e(this).css("color", "#444");
});
m.click(function () {
C();
});
m.data("sum", "∑");
m.data("sum-t", "prepnúť na Ø");
m.data("avg", "Ø");
m.data("avg-t", "prepnúť na ∑");
l.footer.append(m);
var m = e('');
m.data("sum", i.count);
m.data("sum-t", i.count);
m.data("avg", i.count);
m.data("avg-t", i.count);
l.footer.append(m);
var m = e('');
m.data("sum", (i.duration / 3600).round(2));
m.data("sum-t", String((i.duration / 3600).round(2)) + "hodín");
m.data("avg", (i.duration / (3600 * i.count)).round(2));
m.data("avg-t", "Ø " + String((i.duration / (3600 * i.count)).round(2)) + "hodín");
l.footer.append(m);
var m = e('');
m.data("sum", i.experience);
m.data("sum-t", String(i.experience));
m.data("avg", (i.experience / i.count).round(2));
m.data("avg-t", "Ø " + String((i.experience / i.count).round(2)));
l.footer.append(m);
var m = e('');
m.data("sum", i.wage);
m.data("sum-t", "$" + String(i.wage));
m.data("avg", (i.wage / i.count).round(2));
m.data("avg-t", "Ø $" + String((i.wage / i.count).round(2)));
l.footer.append(m);
var m = e('');
m.data("sum", i.bond);
m.data("sum-t", String(i.bond));
m.data("avg", ((i.bond / i.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((i.bond / i.count) * 100).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.motivation);
m.data("sum-t", String(i.motivation) + "%");
m.data("avg", (i.motivation / i.count).round(2));
m.data("avg-t", "Ø " + String((i.motivation / i.count).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.injury);
m.data("sum-t", String(i.injury));
m.data("avg", (i.injury / i.count).round(2));
m.data("avg-t", "Ø " + String((i.injury / i.count).round(2)));
l.footer.append(m);
var m = e('');
m.data("sum", i.killed);
m.data("sum-t", String(i.killed));
m.data("avg", ((i.killed / i.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((i.killed / i.count) * 100).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.products);
m.data("sum-t", String(i.products));
m.data("avg", ((i.products / i.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((i.products / i.count) * 100).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.products);
m.data("sum-t", String(i.products));
m.data("avg", ((i.products / i.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((i.products / i.count) * 100).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.items);
m.data("sum-t", String(i.items));
m.data("avg", ((i.items / i.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((i.items / i.count) * 100).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.items);
m.data("sum-t", String(i.items));
m.data("avg", ((i.items / i.count) * 100).round(2));
m.data("avg-t", "Ø " + String(((i.items / i.count) * 100).round(2)) + "%");
l.footer.append(m);
var m = e('');
m.data("sum", i.luck);
m.data("sum-t", "$" + String(i.luck));
m.data("avg", (i.luck / i.count).round(2));
m.data("avg-t", "Ø $" + String((i.luck / i.count).round(2)));
l.footer.append(m);
var o = e('')
.append(
e('Prepnúť medzi odmenami a nájdenými vecami')
.css({ marginTop: "-8px", display: "block", textAlign: "center" })
.click(function () {
e(".messages-analyser-job").toggleClass("view-rewards view-items");
})
)
.append(t);
return o;
};
var L = function (e) {};
t.getExtra = function () {
if (isDefined(r.extra)) {
return r.extra;
}
return null;
};
return t;
})($);
Debugger.Analyser = Analyser;
var Notes = (function (e) {
var t = {};
var n = null;
var r = {};
var i = function () {
if (r.ready) {
return;
}
if (r.ready) {
return;
}
if (Settings.get("notes", true)) {
GameInject.addTabOnMessagesWindow("Poznámky", "notes", function () {
s();
});
}
r.ready = true;
};
r = Loader.add("Notes", "tw-db Notes", i, { Cache: true, Settings: true });
var s = function () {
if (!w.MessagesWindow.window) {
return;
}
n = e(w.MessagesWindow.window.getContentPane()).find(".messages-notes");
n.css("width", "680px").css("margin", "0 auto").css("position", "relative").css("top", "0");
a(Cache.load("notes"));
};
var o = function (e) {
Cache.save("notes", e);
new UserMessage("Uloženie úspešné", UserMessage.TYPE_SUCCESS).show();
};
var u = function (t) {
n.children().remove();
w.MessagesWindow.window.showLoader();
var r = new west.gui.Textarea().setWidth(660).setHeight(300).setContent(t);
n.append(e('').append(new west.gui.Bbcodes(r).getMainDiv()))
.append(r.getMainDiv())
.append(
e('')
.append(
new west.gui.Button("Uložiť".escapeHTML(), function () {
o(r.getContent());
a(r.getContent());
}).getMainDiv()
)
.append(
new west.gui.Button("Náhľad".escapeHTML(), function () {
a(r.getContent());
}).getMainDiv()
)
);
w.MessagesWindow.window.hideLoader();
};
var a = function (t) {
n.children().remove();
var r = new west.gui.Scrollpane();
e(r.getMainDiv()).css("height", "324px");
e(r.getMainDiv()).find(".tw2gui_scrollpane_clipper_contentpane").addClass("selectable");
n.append(e('').append(r.getMainDiv())).append(
e('')
.append(
new west.gui.Button("Uložiť".escapeHTML(), function () {
o(t);
}).getMainDiv()
)
.append(
new west.gui.Button("Upraviť".escapeHTML(), function () {
u(t);
}).getMainDiv()
)
);
if (t) {
w.MessagesWindow.window.showLoader();
Ajax.remoteCall("settings", "get_parsed_text", { text: t }, function (e) {
r.appendContent(w.Game.TextHandler.parse(e.parsed_text));
w.MessagesWindow.window.hideLoader();
});
}
};
return t;
})($);
Debugger.Notes = Notes;
var Map = (function (e) {
var t = {};
var n = false;
var r = 181;
var i = 79;
var s = 0;
var o = 0;
var u = {};
var a = {};
var f = null;
var l = null;
var c = {};
var h = function () {
if (c.ready) {
return;
}
if (Settings.get("showscrollto", true)) {
d();
}
Ajax.get("map", "get_minimap", {}, function (e) {
if (e.error) {
c.failed = true;
return new UserMessage(e.msg).show();
}
u = e.job_groups;
c.ready = true;
});
};
c = Loader.add("Map", "tw-db Map", h, { Settings: true });
t.getNearestJob = function (e) {
var n = JobList.getJobById(e);
var r = u[n.groupid];
if (!r) {
return [];
}
var i = [];
var s = t.getLastPosition();
for (var o = 0; o < r.length; o++) {
var a = r[o][0] - s.x;
var f = r[o][1] - s.y;
var l = Math.sqrt(a * a + f * f);
var c = window.GameMap.calcWayTime({ x: r[o][0], y: r[o][1] }, s);
var h = Number((Math.atan(f / a) * 180) / Math.PI).round(0);
if (a < 0) {
h -= 180;
}
i.push({ dist: l, time: c, x: r[o][0], y: r[o][1], angle: h });
}
var p = function (e, t) {
return e.dist * 1 > t.dist * 1 ? 1 : -1;
};
i.sort(p);
return i;
};
t.getLastPosition = function () {
var e = { x: Character.position.x, y: Character.position.y };
var t = TaskQueue.queue;
for (var n = 0; n < t.length; n++) {
var r = t[n].wayData;
if (r.x) {
e.x = r.x;
e.y = r.y;
}
}
return e;
};
t.setMinimapJob = function (t) {
if (f) {
window.clearInterval(l);
window.clearInterval(f);
}
var n = function (t) {
if (!MinimapWindow.window || e(MinimapWindow.window.divMain).find(".tw2gui_jobsearch_string").length == 0 || !e(MinimapWindow.window.divMain).find(".tw2gui_jobsearch_string").is(":visible")) {
return;
}
window.clearInterval(f);
window.clearInterval(l);
f = null;
l = null;
MinimapWindow.resetSearchContext();
e("input.tw2gui_jobsearch_string", MinimapWindow.DOM).val(t).keyup();
};
l = setInterval(function () {
window.clearInterval(f);
window.clearInterval(l);
f = null;
l = null;
}, 3e5);
f = setInterval(function () {
n(t);
}, 200);
};
var p = function (e) {
var n = false;
var u = 0;
var e = [];
var a = s;
var f = o;
for (var a = s; a <= r; a++) {
for (var f = o; f <= i; f++) {
u++;
e.push([a, f]);
if (u > 299) {
n = true;
break;
}
}
if (n) {
break;
}
o = 0;
}
s = a;
o = f + 1;
if (e.length > 0) {
window.GameMap.Data.Loader.load(e, function () {
setTimeout(function () {
t.loadMap();
}, Timer.getTimeout());
});
}
};
t.loadMap = function () {
p();
};
var d = function () {
var t = "div#mmap_twdb_coords {position: absolute; bottom: 35px; left: 1px; display: block;}\n" + "div#mmap_twdb_coords > img {cursor:pointer; opacity:0.5; position:relative;}";
TWDB.Util.addCss(t, "minimap");
var n = function () {
var t = e('');
var n = new west.gui.Textfield();
var r = new west.gui.Textfield();
var i = "";
var s = "";
n.setWidth(45);
r.setWidth(45).setMaxLength(5);
var o = function () {
var e = Number(n.getValue());
var t = Number(r.getValue());
window.GameMap.center(e, t);
n.setValue("");
r.setValue("");
};
e(n.getMainDiv())
.find("input")
.keyup(function (t) {
window.setTimeout(function () {
var u;
if (t.ctrlKey && t.keyCode === 86 && !t.altKey) {
u = new RegExp("^([0-9]{1,5})([^0-9]+)([0-9]{1,5})$").exec(e.trim(n.getValue()));
if (u) {
n.setValue(u[1]);
r.setValue(u[3]);
e(r.getMainDiv()).find("input").focus();
i = n.getValue();
s = r.getValue();
return;
}
u = new RegExp("^([0-9]{1,5})$").exec(e.trim(n.getValue()));
if (u) {
n.setValue(u[1]);
e(r.getMainDiv()).find("input").focus();
i = n.getValue();
return;
}
n.setValue(i);
}
if (t.keyCode === 13) {
return o();
}
if (String(e.trim(n.getValue())).length === 0) {
i = n.getValue();
return;
}
u = new RegExp("^([0-9]{1,5})$").exec(e.trim(n.getValue()));
if (u) {
n.setValue(u[1]);
if (String(u[1]).length === 5) {
e(r.getMainDiv()).find("input").focus();
}
i = n.getValue();
return;
}
n.setValue(i);
}, 100);
});
e(r.getMainDiv())
.find("input")
.keyup(function (t) {
window.setTimeout(function () {
if (t.ctrlKey && t.keyCode == 86 && !t.altKey) {
var n = new RegExp("^([0-9]{1,5})$").exec(e.trim(r.getValue()));
if (n) {
r.setValue(n[1]);
e(r.getMainDiv()).find("input").focus();
s = r.getValue();
return;
}
r.setValue(s);
}
if (t.keyCode == 13) {
o();
return;
}
if (String(e.trim(r.getValue())).length == 0) {
s = r.getValue();
return;
}
var n = new RegExp("^([0-9]{1,5})$").exec(e.trim(r.getValue()));
if (n) {
r.setValue(n[1]);
if (String(n[1]).length == 5) {
e(r.getMainDiv()).find("input").focus();
}
s = r.getValue();
return;
}
r.setValue(s);
}, 100);
});
var u = new west.gui.Button(
"Ok",
function () {
o();
},
null,
null,
"Posunúť mapu na dané súradnice"
).setWidth("48");
var a = e('').click(function () {
if (e(this).css("opacity") === 1) {
e(this).css("opacity", "0.5");
window.GameMap.hideCoords();
} else {
e(this).css("opacity", "1");
window.GameMap.showCoords();
}
});
t.append(a, n.getMainDiv(), "|", r.getMainDiv(), e(u.getMainDiv()).css("top", "6px"));
e(".minimap-right", MinimapWindow.window.divMain).append(t);
};
GameInject.injectMinimap(function () {
n();
});
};
return t;
})($);
_base.Map = Map;
Debugger.Map = Map;
var BonusJobs = (function (e) {
var t = {},
n,
r = {},
i = { gold: false, silver: false },
s = function () {
if (r.ready) {
return;
}
if (!Settings.get("showbonusjobs", true)) {
r.ready = true;
return;
}
var e,
t,
s,
a,
f = get_server_date(),
l = 1,
c = new Date();
c.setUTCHours(l);
c.setMinutes(15);
c.setSeconds(0);
c.setMilliseconds(0);
var h = c.getTime();
if (f.getUTCHours() < l || (f.getUTCHours() == l && f.getMinutes() < 15)) h -= 24 * 60 * 60 * 1e3;
n = Cache.load("bonusjobs") || {};
i = Cache.load("bonusdisplay") || { gold: false, silver: false };
for (e in n) {
if (!n.hasOwnProperty(e)) {
continue;
}
t = n[e];
s = 0;
for (a in t) {
if (!t.hasOwnProperty(a)) {
continue;
}
if (t[a].gold) {
s++;
continue;
}
if (t[a].time > h) {
s++;
} else {
delete t[a];
}
}
if (s == 0) {
delete n[e];
}
}
u();
o();
r.ready = true;
};
r = Loader.add("BonusJobs", "tw-db BonusJobs", s, { Settings: true, Cache: true, Jobs: true });
var o = function () {
var e = function (e) {
var t = window.GameMap.Helper.getPosition(e.parent);
if (!isDefined(t) || !isDefined(t.x) || !isDefined(t.y)) {
return;
}
if (!isDefined(window.GameMap.JobHandler.Featured[t.x + "-" + t.y])) {
if (isDefined(n[t.x + "-" + t.y])) {
delete n[t.x + "-" + t.y];
Cache.save("bonusjobs", n);
}
return;
}
var r = window.GameMap.JobHandler.Featured[t.x + "-" + t.y],
i;
n[t.x + "-" + t.y] = {};
for (i in r) {
if (!r.hasOwnProperty(i)) {
continue;
}
n[t.x + "-" + t.y][i] = r[i];
n[t.x + "-" + t.y][i]["time"] = new Date().getTime();
}
Cache.save("bonusjobs", n);
};
GameInject.injectRadialmenu(function (t) {
e(t);
});
};
var u = function () {
var t =
"div#mmap_twdb_bonusjobs {position:absolute; top:40px; right:10px;}\n" +
'div#mmap_twdb_bonusjobs > input[type="checkbox"] {margin-left:6px; cursor:pointer;}\n' +
"div#mmap_twdb_bonusjobs > div {position:relative; display:inline-block; height:9px; width:9px; margin:1px;}\n" +
"div#mmap_twdb_bonusjobs > img {margin-left:3px; cursor:pointer; position:relative; display:inline-block; height:16px; width:16px; top:-4px;}";
TWDB.Util.addCss(t, "minimap");
var n = function () {
var t = e('')
.append(
e('").change(function () {
i.gold = e(this).is(":checked");
a();
})
)
.append('')
.append(
e('").change(function () {
i.silver = e(this).is(":checked");
a();
})
)
.append('')
.append(
e('').click(function () {
f();
})
)
.append(
e('').click(function () {
l();
})
)
.append(
e('').click(function () {
c();
})
);
e(MinimapWindow.window.divMain).find(".minimap-right").append(t);
a();
};
GameInject.injectMinimap(function () {
n();
});
};
var a = function () {
Cache.save("bonusdisplay", i);
e("#minimap_worldmap > div.TWDBbonusjob", MinimapWindow.window.divMain).remove();
var t = function (t, n, r, i, s) {
var o = 0.00513;
var u = parseInt(t * o, 10) - 3;
var a = parseInt(n * o, 10) + 2;
var f = "";
if (i > 1) {
f = "-moz-transform:rotate(45deg);-webkit-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);";
}
var l = e(
''
)
.click(
(function (e, t) {
return function () {
window.GameMap.center(e, t);
};
})(t, n)
)
.addMousePopup('
' + s.join('') + "
");
e(MinimapWindow.window.divMain).find("#minimap_worldmap").append(l);
};
var r = n;
for (key in r) {
if (!r.hasOwnProperty(key)) {
continue;
}
var s = r[key];
var o = false;
var u = 0;
var a = [];
for (var f in s) {
if (!s.hasOwnProperty(f)) {
continue;
}
if (s[f].gold) {
if (!i.gold) {
continue;
}
o = true;
u++;
}
if (s[f].silver) {
if (!i.silver) {
continue;
}
u++;
}
var l = s[f].x;
var c = s[f].y;
job = JobList.getJobById(s[f].job_id);
a.push(Jobs.getPopup(s[f].job_id, s[f].gold ? "gold" : "silver"));
}
if (u > 0) {
t(l, c, o, u, a);
}
}
};
var f = function () {
var t = [];
for (var r in n) {
if (!n.hasOwnProperty(r)) {
continue;
}
var i = n[r];
for (var s in i) {
if (!i.hasOwnProperty(s)) {
continue;
}
var o = Jobs.getJobById(s);
var u = Math.ceil(i[s].x / 6635) + (i[s].y > 10176 ? 7 : 0);
t.push({ name: o.name, bonus: i[s].gold ? "gold" : "silver", country: u, x: i[s].x, y: i[s].y, id: s });
}
}
var a = e("")
.css({ width: "500px", height: "200px", "background-color": "transparent", "border-width": "0px" })
.click(function () {
this.select();
});
var f = "";
var l = 1;
var c = function (e) {
if (f !== e) {
f = e;
l = 1;
} else {
l *= -1;
}
var n = function (e, t) {
return e[f] > t[f] ? l : -1 * l;
};
t.sort(n);
var r = "";
var i = "";
for (var s = 0; s < t.length; s++) {
var o = t[s];
if (f == "country" && i !== o.country) {
i = o.country;
r += "-- ?country " + i + " --" + "\n";
}
r += o.name + "; " + o.bonus + "; " + o.x + "-" + o.y + "; " + o.id + "\n";
}
a.val(r);
};
c("name");
var h = e("")
.css({ width: "500px", height: "22px", position: "relative", display: "block" })
.append(
e('').click(function () {
c("name");
})
)
.append(
e('').click(function () {
c("country");
})
);
new west.gui.Dialog("Bonusové práce Export", e("").append(h).append(a)).addButton("ok").show();
};
var l = function () {
var t = e("").css({ width: "400px", height: "100px" });
var r = function () {
var r = t.val(),
i = r.split(/[\n,\r,\r\n]/),
s,
o,
u,
f,
l,
c;
for (s = 0; s < i.length; s++) {
o = i[s].split(";", 4);
if (o.length !== 4 || !e.isNumeric(o[3]) || !Jobs.getJobById(Number(o[3]))) {
continue;
}
u = String(o[2]).split("-", 2);
if (u.length !== 2 || !e.isNumeric(u[0]) || !e.isNumeric(u[1])) {
continue;
}
f = Number(o[3]);
l = { gold: e.trim(o[1]) == "gold" ? true : false, group_id: Jobs.getJobById(f).groupid, job_id: f, silver: e.trim(o[1]) == "gold" ? false : true, x: Number(u[0]), y: Number(u[1]), time: new Date().getTime() };
c = Number(u[0]) + "-" + Number(u[1]);
if (!isDefined(n[c])) {
n[c] = {};
}
n[c][f] = l;
}
Cache.save("bonusjobs", n);
a();
};
new west.gui.Dialog("Bonusové práce Import", t).addButton("ok", r).addButton("cancel").show();
};
var c = function (e) {
try {
if (e) {
for (var t in n) {
if (!n.hasOwnProperty(t)) {
continue;
}
var r = n[t];
var i = 0;
for (var s in r) {
if (!r.hasOwnProperty(s)) {
continue;
}
if (e == "gold" && r[s].gold) {
i++;
continue;
}
if (e == "silver" && r[s].silver) {
i++;
continue;
}
delete r[s];
}
if (i == 0) {
delete n[t];
}
}
Cache.save("bonusjobs", n);
a();
new UserMessage("Bonusové práce Vynulovať", UserMessage.TYPE_SUCCESS).show();
} else {
var o = "tw-db Bonusové práce Vynulovať";
var u = '
Bonusové práce Vynulovať
';
new west.gui.Dialog(o, u, west.gui.Dialog.SYS_QUESTION)
.addButton("Všetky", function () {
c("all");
})
.addButton("Zlaté práce", function () {
c("silver");
})
.addButton("Strieborné práce", function () {
c("gold");
})
.addButton("cancel")
.show();
}
} catch (f) {
Error.report(f, "bonusjob reset");
}
};
return t;
})($);
Debugger.BonusJobs = BonusJobs;
var Chat = (function (e) {
var t = {};
var n = false;
var i = {
":/": "sore",
"=:)": "invader",
">:(": "angry",
":'(": "cry",
":)": "smile",
":D": "grin",
":(": "frown",
";)": "smirk",
":P": "tongue",
":o": "ohmy",
":x": "muted",
":|": "silent",
">.<": "palm",
"-.-": "nc",
"o.O": "oo",
"O.o": "oo",
"^_^": "happy",
o_O: "oo",
"x.x": "xx",
"T.T": "cry",
"el pollo diablo!": "elpollodiablo",
"!el pollo diablo": "elpollodiablo_mirror",
"el pollo diablo?!": "elpollodiablo_front",
"add me": "sheep.gif",
"add me!": "sheep_rainbow.gif",
};
var s = [];
var o = {};
var u = function () {
if (o.ready) {
return;
}
if (Settings.get("chat", true)) {
GameInject.ChatLayout(function (e) {
f(e);
});
GameInject.ChatSend(function (e) {
a(e);
});
var e = Cache.load("chathistory");
if (typeof e == "object" && e !== null) {
if (e.color) {
e = e.color;
Cache.save("chathistory", e);
}
s = e;
}
if ($("div.tw2gui_window.chat.nominimize div.tw2gui_window_buttons_close").click().length > 0) {
ChatWindow.open();
}
}
o.ready = true;
};
o = Loader.add("Chat", "tw-db Chat Enhancement", u, { Settings: true, Cache: true });
var a = function (e) {
var t = e.input.val();
if (!t) {
return;
}
var n = function (t) {
if (e._caps) {
t = t.toUpperCase();
}
if (e._bold) {
t = t.replace(/\*/g, "~");
t = "*" + t + "*";
}
return t;
};
if (t.substr(0, 1) == "/") {
r = new RegExp("^\\/(tell|msg)\\s+([^:]+):(.+)$");
v = t.match(r);
if (v) {
if (e._color) {
t = "/tell " + v[2] + ":/" + e._color + n(v[3]);
} else {
t = "/tell " + v[2] + ":" + n(v[3]);
}
}
e.input.val(t);
return;
}
t = n(t);
if (e._color) {
t = "/" + e._color + t;
}
e.input.val(t);
return;
};
var f = function (e) {
var t = e.mainDiv.find(".TWDBchat");
if (t.length == 0) {
e.mainDiv.find(".chat_input").find(".cbg").css("left", "38px").addClass(".TWDBchat");
e._color = null;
e._bold = false;
e._caps = false;
l(e);
m(e);
}
};
var l = function (t) {
var n;
var r = e('');
for (var s in i) {
n = i[s].indexOf(".gif") === -1 ? i[s] + ".png" : i[s];
r.append(
e('').click(
(function (e) {
return function () {
t.input.val(t.input.val() + " " + e + " ");
t.input.focus();
r.hide();
};
})(s)
)
);
}
var o = false;
t.mainDiv.find(".chat_input").append(
e('')
.append(e(''))
.append(r)
.hover(
function () {
o = true;
r.show();
},
function () {
o = false;
setTimeout(function () {
if (!o) {
r.hide();
}
}, 200);
}
)
);
};
var c = function (e) {
var t = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if (t) {
return String(parseInt((t[1] * 9) / 255 + 0.5, 10)) + String(parseInt((t[2] * 9) / 255 + 0.5, 10)) + String(parseInt((t[3] * 9) / 255 + 0.5, 10));
} else {
return "000";
}
};
var h = function (e) {
return "rgb(" + parseInt((e[0] * 255) / 9, 10) + "," + parseInt((e[1] * 255) / 9, 10) + "," + parseInt((e[2] * 255) / 9, 10) + ")";
};
var p = function (e, t) {
if (isDefined(t.color)) {
var n = c(t.color);
var r = s.length;
for (var i = 0; i < r; i++) {
var o = s.shift();
if (o !== n) {
s.push(o);
}
}
s.push(n);
if (s.length > 5) {
s.shift();
}
Cache.save("chathistory", s);
e._color = n;
}
if (t.color === null) {
e._color = null;
}
if (isDefined(t.bold)) {
e._bold = t.bold;
}
if (isDefined(t.caps)) {
e._caps = t.caps;
}
if (e._bold) {
e.mainDiv.find(".TWDBtext").css("font-weight", "bold");
} else {
e.mainDiv.find(".TWDBtext").css("font-weight", "normal");
}
if (e._caps) {
e.mainDiv.find(".TWDBtext").html("A");
} else {
e.mainDiv.find(".TWDBtext").html("a");
}
if (e._color) {
e.mainDiv.find(".TWDBcolor").children("div").children("div").css("background-color", h(e._color));
if (e._color[1] >= 4) {
e.mainDiv.find(".TWDBtext").css("color", "#000");
} else {
e.mainDiv.find(".TWDBtext").css("color", "#fff");
}
} else {
e.mainDiv.find(".TWDBcolor").children("div").children("div").css("background-color", "#e0e2e0");
e.mainDiv.find(".TWDBtext").css("color", "#000");
}
e.input.focus();
};
var d = function (t) {
return e('')
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''))
.append(e(''));
};
var m = function (t) {
try {
var n = e('');
n.append('');
var r = ["black", "red", "blue", "yellow", "green", "brown", "magenta", "gray"];
n.append(
e('')
.append(d("#e0e2e0"))
.append(
e(
'
'
)
)
.append(n)
.hover(
function () {
s = true;
n.show();
},
function () {
s = false;
setTimeout(function () {
if (!s) {
n.hide();
}
}, 200);
}
)
);
} catch (o) {
Error.report(o, "injectColor");
}
};
var g = function (t) {
var n = t.mainDiv.find(".TWDBcolor").children("div").children("div");
var r = c(n.css("background-color"));
var i = {};
i.customColor = e('');
i.customColor.css("background-color", h(c(n.css("background-color"))));
var o = function (e, t) {
if ((t && r[e] == 9) || (!t && r[e] == 0)) {
return;
}
var n = [Number(r[0]), Number(r[1]), Number(r[2])];
n[e] += t ? 1 : -1;
r = String(n[0]) + String(n[1]) + String(n[2]);
i.input.val(r);
if (r[e] == 0) {
i.plusminus[e].children(".butMinus").css("opacity", 0.3);
} else {
i.plusminus[e].children(".butMinus").css("opacity", 1);
}
if (r[e] == 9) {
i.plusminus[e].children(".butPlus").css("opacity", 0.3);
} else {
i.plusminus[e].children(".butPlus").css("opacity", 1);
}
i.customColor.css("background-color", h(r));
};
var u = e('');
i.plusminus = [];
for (var a = 0; a < 3; a++) {
switch (a) {
case 0:
var f = "#f00";
break;
case 1:
var f = "#0f0";
break;
case 2:
var f = "#00f";
break;
}
i.plusminus[a] = e(
'
'
);
i.plusminus[a].children(".butMinus").click(
(function (e) {
return function () {
o(e, false);
};
})(a)
);
i.plusminus[a].children(".butPlus").click(
(function (e) {
return function () {
o(e, true);
};
})(a)
);
if (r[a] == 0) {
i.plusminus[a].children(".butMinus").css("opacity", 0.3);
}
if (r[a] == 9) {
i.plusminus[a].children(".butPlus").css("opacity", 0.3);
}
u.append(i.plusminus[a]);
}
u.append(i.plusminus[0]).append(i.plusminus[1]).append(i.plusminus[2]);
i.input = e(
''
);
i.input.keyup(function () {
var e = i.input.val();
if (e.length < 3) {
return;
}
if (!e.match(/(\d){3}/)) {
i.input.val(r);
return;
}
r = e;
for (var t = 0; t < 3; t++) {
if (r[t] == 0) {
i.plusminus[t].children(".butMinus").css("opacity", 0.3);
} else {
i.plusminus[t].children(".butMinus").css("opacity", 1);
}
if (r[t] == 9) {
i.plusminus[t].children(".butPlus").css("opacity", 0.3);
} else {
i.plusminus[t].children(".butPlus").css("opacity", 1);
}
}
i.customColor.css("background-color", h(r));
i.input.attr("value", r);
});
u.append(i.input);
var l = { bold: t._bold, caps: t._caps };
var d = e('');
var v = new west.gui.Checkbox("*tučne*", l.bold ? "tw2gui_checkbox_checked" : "", function () {
l.bold = l.bold ? false : true;
});
e(v.getMainDiv()).css("display", "block").css("margin-bottom", "5px");
d.append(v.getMainDiv());
var v = new west.gui.Checkbox("CAPS LOCK", l.caps ? "tw2gui_checkbox_checked" : "", function () {
l.caps = l.caps ? false : true;
});
d.append(v.getMainDiv());
var m = e('');
m.append('História');
for (var a = 0; a < s.length; a++) {
var g = e('');
g.click(function () {
p(t, { color: e(this).css("background-color"), bold: l.bold, caps: l.caps });
i.colorBox.hide();
});
m.append(g);
}
var y = e("").append(i.customColor).append(u).append(d).append(m);
i.colorBox = new west.gui.Dialog("Farba", y);
i.colorBox.addButton("ok", function () {
p(t, { color: e(i.customColor).css("background-color"), bold: l.bold, caps: l.caps });
});
i.colorBox.addButton("cancel");
i.colorBox.show();
};
return t;
})(jQuery);
Debugger.Chat = Chat;
var SellTip = (function (e) {
var t = {};
var n = false;
var r = {};
var i = function () {
if (r.ready) {
return;
}
if (Settings.get("sellTip", true)) {
GameInject.injectItem("Inventory", "sellTip", function (e) {
setTimeout(function () {
return s(e);
}, 0);
});
}
r.ready = true;
};
r = Loader.add("sellTip", "tw-db sellTip", i, { Settings: true, ClothCalc: true });
var s = function (e) {
var t = e.obj.item_id;
var n = w.ItemManager.get(t);
var r = false;
var i = "";
if (!n.sellable && !n.auctionable) {
return;
}
if (Settings.get("sellTip1", true)) {
var s = w.Bag.getItemByItemId(n.item_id);
var o = w.Wear.wear[n.type];
if (s || (o && o.obj.item_id == n.item_id)) {
var u = (s !== undefined ? s.count : 0) + (o !== undefined && o.obj.item_id == n.item_id ? 1 : 0);
if (u > 1) {
r = true;
i = "Tento predmet máš viackrát".escapeHTML();
}
}
}
if (Settings.get("sellTip2", true) && ClothCalc.isLoaded()) {
if (!ClothCalc.isUsedItem(n.item_id)) {
r = true;
i = "Táto vec nie je užitočná pre žiadnu prácu, alebo vlastné atribúty (ClothCalc)".escapeHTML();
}
}
if (Settings.get("sellTip3", true)) {
if (n.named) {
r = false;
}
}
if (Settings.get("sellTip4", true)) {
if (n.traderlevel === null || n.traderlevel > 20) {
r = false;
}
}
if (Settings.get("sellTip5", true)) {
if (n.set) {
r = false;
}
}
e.divMain.find(".TWDBsellTip").remove();
if (r) {
e.divMain.append(
''
);
}
};
return t;
})($);
Debugger.SellTip = SellTip;
var Collector = (function (e) {
var t = {};
var n = false;
var r = {};
var i = function () {
if (r.ready) {
return;
}
if (Settings.get("collector", true)) {
GameInject.injectItem("Trader", "collector", function (e) {
return s(e);
});
GameInject.injectTrader("collector", function (e) {
if (t.isNewItem(e.item_id)) {
var n = '';
return n;
}
return "";
});
GameInject.injectMarket("collector", function (e) {
return o(e);
});
GameInject.injectGetBids();
}
r.ready = true;
};
r = Loader.add("Collector", "tw-db Collector", i, { Settings: true });
t.isNewItem = function (e) {
var t = w.ItemManager.get(e);
var n = w.Bag.getItemsIdsByBaseItemId(t.item_base_id);
var r = w.Wear.wear[t.type];
var i = r && r.obj.item_base_id == t.item_base_id;
var s = TWDB.ClothCalc.bids[t.item_id];
var o = TWDB.ClothCalc.recipes[t.item_id];
if (n.length || i || s || o) {
return false;
} else {
return true;
}
};
var s = function (e) {
e.divMain.find(".TWDBcollector").remove();
if (t.isNewItem(e.obj.item_id)) {
e.divMain.append('');
}
};
var o = function (e) {
if (t.isNewItem(e)) {
return '';
} else {
return "";
}
};
return t;
})($);
Debugger.Collector = Collector;
var BuyTip = (function (e) {
var t = {};
var n = false;
var r = {};
var i = 0;
var s = {};
var o = {};
var u = function () {
if (o.ready) {
return;
}
if (Settings.get("buyTip", true)) {
GameInject.injectItem("Trader", "buytip", function (e) {
return f(e, "trader");
});
GameInject.injectTrader("buytip", function (e) {
return a(e);
});
GameInject.injectMarket("buytip", function (e) {
return f(e, "market");
});
}
Eventer.set("TWDBdataLoaded", function () {
t.reset();
});
if (!Updater.wasUpdated()) {
r = Cache.load("betteritems");
if (r == null || typeof r !== "object") {
r = {};
}
}
o.ready = true;
};
o = Loader.add("BuyTip", "tw-db BuyTip", u, { Settings: true, Cache: true, Collector: true, ClothCalc: true, Calc: true });
t.reset = function () {
r = {};
Cache.save("betteritems", r);
};
var a = function (e) {
n = e.item_id;
if (!Collector.isNewItem(n) || (isDefined(r[n]) && r[n].length == 0)) {
return "";
}
if (isDefined(r[n])) {
var t = h(n);
if (isDefined(t)) {
t.css({ bottom: "45px", right: "11px" });
}
return t;
}
l(n);
var t = h(n);
if (isDefined(t)) {
t.css({ bottom: "45px", right: "11px" });
}
return t;
};
var f = function (e, t) {
if (t == "shop") {
n = e.item_id;
} else {
n = t == "market" ? e : e.obj.item_id;
}
if (!Collector.isNewItem(n) || (isDefined(r[n]) && r[n].length == 0)) {
return "";
}
if (t == "market") {
if (isDefined(r[n])) {
return c(n);
}
i++;
Worker.add(
(function (e, t) {
return function () {
l(t);
var n = w.MarketWindow.DOM.find("#TWDBbuyTip" + e);
n.after(c(t));
n.remove();
};
})(i, n)
);
return '';
}
if (isDefined(r[n])) {
if (t == "shop") {
var s = h(n);
s.css({ bottom: "45px", right: "11px" });
return s;
} else {
e.divMain.find(".TWDBbuyTip").remove();
e.divMain.append(h(n));
}
return;
}
if (isDefined(e.divMain)) {
e.divMain.find(".TWDBbuyTip").remove();
}
e.divMain.append(
''
);
Worker.add(
(function (e, t) {
return function () {
l(t);
if (t == "shop") {
var n = h(t);
n.css({ bottom: "45px", right: "11px" });
return n;
} else {
e.divMain.find(".TWDBbuyTip").remove();
e.divMain.append(h(t));
}
};
})(e, n)
);
};
var l = function (e) {
if (!ClothCalc.isLoaded()) {
return;
}
if (!ClothCalc.isItemUsable(e, true)) {
return;
}
if (isDefined(r[e])) {
return;
}
r[e] = [];
var t = ItemManager.get(e);
var n = Jobs.getAllJobs();
for (var i = 0; i < n.length; i++) {
var s = n[i];
var o = ClothCalc.getClothForJob(s);
if (!isDefined(o)) {
continue;
}
var u = 0;
var a = Calc.getItemBonusForJob(e, s);
if (isDefined(o[TWDB.ClothCalc._type2id[t.type]])) {
var f = ItemManager.get(o[TWDB.ClothCalc._type2id[t.type]].id);
u += Calc.getItemBonusForJob(f.item_id, s);
}
if ((isDefined(f) && isDefined(f.set)) || isDefined(t.set)) {
var l = isDefined(f) && isDefined(f.set) ? f.set : null;
var c = isDefined(t.set) ? t.set : null;
var h = {};
h[l] = 0;
h[c] = 0;
for (var p in o) {
var d = ItemManager.get(o[p].id);
if (!isDefined(d)) {
continue;
}
if (d.set) {
if (d.set == l) {
h[l]++;
}
if (d.set == c && l !== c) {
h[c]++;
}
}
}
if (l) {
u += Calc.getSetBonusForJob(l, h[l], s);
u -= Calc.getSetBonusForJob(l, h[l] - 1, s);
}
if (c) {
a += Calc.getSetBonusForJob(c, h[c] + 1, s);
a -= Calc.getSetBonusForJob(c, h[c], s);
}
}
if (a > u) {
var v = ClothCalc.getLPForJob(s);
if (isDefined(v)) {
var m = v.sum - u + a;
r[e].push({ job: s, newlp: m, more: m - v.sum });
} else {
r[e].push({ job: s, newlp: a, more: a });
}
}
}
Cache.save("betteritems", r);
};
var c = function (e) {
if (!isDefined(r[e])) {
return "";
}
if (r[e].length == 0) {
return "";
}
s[e] = false;
var t = p(e).escapeHTML();
return (
"'
);
};
var h = function (t) {
if (!isDefined(r[t])) {
return;
}
if (r[t].length == 0) {
return;
}
s[t] = false;
var n = p(t);
return e(
''
);
};
var p = function (e) {
if (!isDefined(r[e])) {
return "";
}
var t = '
';
if (!ClothCalc.isItemUsable(e)) {
var n = ItemManager.get(e);
t += '
Úroveň ' + n.level + "
";
}
for (var i = 0; i < r[e].length; i++) {
var o = r[e][i];
var u = Jobs.getJobById(o.job);
var a = " +" + o.more + " " + u.name.escapeHTML() + " [" + o.newlp + "]";
if (o.job == ClothCalc.getSelectedJob()) {
a = "" + a + "";
s[e] = true;
}
if (o.newlp < 0) {
var f = "#FF0000";
} else {
if (o.newlp - o.more < 0) {
var f = "#0000FF";
} else {
var f = "#008000";
}
}
t += '
' + a + "
";
if (i % 2) {
t += "
";
}
}
if (i % 2) {
t += "
";
} else {
t = t.substring(0, t.length - 4);
}
t += "
";
return t;
};
return t;
})($);
Debugger.BuyTip = BuyTip;
var LpInfo = (function (e) {
var t = {};
var n = false;
var r = {};
var i = function () {
if (r.ready) {
return;
}
if (Settings.get("jobBoniTooltip", true)) {
GameInject.injectItem("Inventory", "lpInfo", function (e) {
return s(e);
});
}
r.ready = true;
};
r = Loader.add("LpInfo", "tw-db LpInfo", i, { Settings: true, Jobs: true, Calc: true });
var s = function (e) {
e.divMain.find(".TWDBlpInfo").remove();
var t = ClothCalc.getSelectedJob();
if (!isDefined(t)) {
return;
}
var n = e.obj.item_id;
e.divMain.find(".TWDBlpInfo").remove();
if (Calc.isCached(n, t)) {
e.divMain.append(o(n, t));
} else {
Worker.add(
(function (e, t, n) {
return function () {
e.divMain.find(".TWDBlpInfo").remove();
e.divMain.append(o(t, n));
};
})(e, n, t)
);
}
};
var o = function (e, t) {
var n = Calc.getItemBonusForJob(e, t);
if (isNaN(n) || n <= 0) {
return;
}
var t = Jobs.getJobById(t);
return (
''
);
};
return t;
})($);
Debugger.LpInfo = LpInfo;
var Snippets = (function ($) {
var _self = {};
var timeout = null;
var interval = null;
var loader = {};
var init = function () {
if (loader.ready) {
return;
}
trustTWDB();
if (Settings.get("collectorsell", true)) {
GameInject.injectWanderingTraderSellDialog();
}
if (Settings.get("customcounterpos", true)) {
repositionEventCounters();
}
if (Settings.get("noscrollbars", false)) {
disableScrollbars();
}
if (Settings.get("instanthotel", true)) {
InstantHotel();
}
if (Settings.get("qbswitch", true)) {
QuestbookSwitch();
}
if (Settings.get("qfulltext", false)) {
QuestFullText();
}
if (Settings.get("fastskillchange", true)) {
fastSkillChange();
}
if (Settings.get("fortrecruitment", true)) {
activateFortRecruitment();
}
if (Settings.get("noworkqueuepa", true)) {
removeWorkQueuePA();
}
if (Settings.get("nofetchallpa", false)) {
removeVariousPA();
}
if (Settings.get("nowofnuggets", false)) {
changeWofNuggets();
}
if (Settings.get("marketselldialog", true)) {
enhanceMarketSellDialog();
}
if (Settings.get("weeklycrafting", false)) {
weeklyCrafting();
}
if (Settings.get("pinitems", true)) {
GameInject.injectInventoryAddItemsPinItems();
GameInject.injectInventoryAddItemDivToInvPinItems();
}
if (Settings.get("telegramsource", true)) GameInject.injectTelegramWindowAppendTelegramDisplaySource();
if (Settings.get("noshopsale", false)) {
supressOnGoingEntries();
}
if (Settings.get("expbarvalues", true)) {
expBarValues();
}
if (Settings.get("mini_chatgui", true)) {
allowChatGuiMinimize();
}
if (Settings.get("tasklistpoints", true)) {
addTaskJobsHints();
GameInject.injectTaskJobs();
}
var e = new ServerDate().date;
loader.ready = true;
};
loader = Loader.add("Snippets", "tw-db code Snippets", init, { Settings: true });
var trustTWDB = function () {
try {
var str = showlink.toString();
str = str.replace("the-west", "tw-db|the-west");
str = str.replace("|com|", "|com|info|");
eval("showlink = " + str);
} catch (e) {}
};
var repositionEventCounters = function () {
TWDB.Util.addCss("@media (min-width: 1320px) { .custom_unit_counter {top: -1px!important; margin-left: 310px!important;} #hiro_friends_container {top: -1px!important; margin-right: 304px!important;} }");
};
var disableScrollbars = function () {
$("body").css({ overflow: "hidden" });
};
var allowChatGuiMinimize = function () {
TWDB.Util.addCss(
"div#ui_bottomleft { width: auto; overflow: hidden; }" +
"div#ui_chat { margin-top: 12px; }" +
"div#ui_chat div#toggleMinChat { position: absolute; top: -14px; left: 5px; width: 27px; display: block; background-size: 108px 42px; border: 0px solid rgba(0, 0, 0, 0); background-clip: content-box; }" +
"div#ui_chat.minchat div#toggleMinChat { background-position: 0px 0px; border-width: 0px 8px 34px 0px; }" +
"div#ui_chat.minchat div#servertime { display: none; }" +
"div#ui_chat.minchat > div.tabs div { display: none; }" +
"div#ui_chat.minchat div.container div.friend { display: none!important; }" +
"div#ui_chat.minchat div.container div.general { display: block!important; }" +
"div#ui_chat.minchat div.container div.vertical_divider { display: none; }" +
"div#ui_chat.minchat img.leave_channel { display: none!important; }" +
"div#ui_chat div.minchat_tabr { display: none; }" +
'div#ui_chat.minchat div.minchat_tabr { display: block; position: absolute; left: 32px; top: 0px; width: 8px; height: 34px; background: url("' +
to_cdn("images/interface/chat/chat-top.png?1") +
'") top right; }' +
"div#ui_chat.minchat { position: relative; left: -10px; top: 4px; width: 39px; }" +
'div#ui_chat.minchat > div.tabs { width: 32px; background: url("' +
to_cdn("images/interface/chat/chat-top.png?1") +
'"); }' +
"div#ui_chat.minchat div.chat_channel { width: 24px; }" +
"div#ui_chat.minchat div.chat_channel .new_message { left: 2px; top: 0px; }" +
"div#ui_chat.minchat div.chat_channel div.online_count { background: none; position: absolute; right: 0px; top: -1px; width: auto; height: auto; line-height: normal; padding: 0px; font-size: 8pt; font-weight: bold; text-align: right; text-shadow: -1px 1px 1px #FFF, 0px 0px 2px #FFF; cursor: default; }" +
"div#ui_chat.minchat div.container { width: 40px; background-position-x: right; }" +
"div#ui_chat.minchat div.row_title { left: 5px; width: 32px; opacity: 0; }" +
"div#ui_chat.minchat div.tw2gui_scrollpane { width: 50px; }",
"minchat"
);
$("div#ui_chat")
.append('')
.toggleClass("minchat", Settings.get("mini_chatgui_min", true))
.children(".tabs")
.first()
.append(
$('').on("click", function (e) {
e.stopPropagation();
Settings.set("mini_chatgui_min", $("div#ui_chat").toggleClass("minchat").hasClass("minchat"));
return false;
})
);
};
var addTaskJobsHints = function () {
var e =
"div#ui_workcontainer div.twdb_lp_hint { position: absolute; left: 2px; width: 18px; height: 18px; background-color: #432; border: 2px ridge #976; border-radius: 11px; background-blend-mode: soft-light; }" +
"div.twdb_lp_hint > img { position: absolute; left: 1px; top: 1px; }";
TWDB.Util.addCss(e);
var t = function () {
if (TaskQueue.queue.length) {
var e,
t = $("div#ui_workcontainer"),
n,
r;
for (e = 0; e < TaskQueue.queue.length; e++) {
if (TaskQueue.queue[e].type === "job") {
n = null;
r = TWDB.ClothCalc.calcdata.loaded && TaskQueue.queue[e].data.job_points < TWDB.ClothCalc.calcdata.jobs[TaskQueue.queue[e].data.job.id].laborpoints.sum - 5;
if (TaskQueue.queue[e].data.job_points < 0) {
n = west.gui.Icon.get("exclamation-priority-3", "záporné pracovné body");
} else if (TaskQueue.queue[e].data.job_points < TaskQueue.queue[e].data.job.malus / 5) {
n = west.gui.Icon.get("exclamation-priority-2", "málo pracovných bodov");
} else if (r) {
n = west.gui.Icon.get("exclamation-priority-1", "PB nie sú optimálne");
}
if (n !== null) {
$(".task-queuePos-" + e + " > div.icon", t)
.children(".twdb_lp_hint")
.remove()
.end()
.append($('').toggleClass("tw2gui-iconset tw2gui-icon-star", !r).append(n));
}
}
}
}
};
EventHandler.listen(["taskqueue-updated", "taskqueue-ready"], t);
};
var expBarValues = function () {
if (isDefined(w.SlySuite)) {
TWDB.Settings.set("expbarvalues", false);
return;
}
TWDB.Util.addCss("div#ui_experience_bar .label {text-shadow: 3px 1px 1px #000, 3px -1px 1px #000, -2px 1px 1px #000, -2px 0px 0px #000;}");
var e = function (e) {
if (Math.abs(e) >= 1e4) {
return Math.round(e / 1e3) + "k";
} else {
return e;
}
};
var t = function () {
var t = $("#ui_experience_bar"),
n = undefined === Character.getTrackingAchievement() ? WestUi.updateTrackXp(t) : WestUi.updateTrackAchievement(t);
$(".label", t).off("mouseenter mouseleave");
$(".label span", t).show();
var r = "";
if (Character.level < 150) {
r = n.percent + "% - " + e(n.current) + " / " + e(n.required);
r += " (" + e(n.required - n.current) + ")";
} else r = Character.experience.toLocaleString();
$(".label span", t).html(r);
};
EventHandler.listen("character_exp_changed", t);
EventHandler.listen("character_tracking_achievement_changed", t);
t();
};
var supressOnGoingEntries = function () {
var e = ["shop_sale"];
var t = function (e) {
if ($.isArray(e)) {
for (var n = 0; n < e.length; n++) {
t(e[n]);
}
} else if (typeof e === "string") {
var r = WestUi.NotiBar.main.list;
for (var n = 0; n < r.length; n++) {
if (
$(r[n].element)
.children()
.is("div.image." + e)
) {
WestUi.NotiBar.remove(r[n]);
}
}
}
};
var n = function (e) {
try {
WestUi.NotiBar.__twdb__add = WestUi.NotiBar.__twdb__add || WestUi.NotiBar.add;
WestUi.NotiBar.add = function (t) {
var n = $(".image", t.element);
for (var r = 0; r < e.length; r++) {
if (n.hasClass(e[r])) {
return;
}
}
WestUi.NotiBar.__twdb__add.apply(this, arguments);
};
} catch (t) {
Error.report(t, "manipulate WestUi.NotiBar.add");
}
};
n(e);
t(e);
};
var InstantHotel = function () {
try {
w.GameMap.Component.Town.prototype.__twdb__getContent = w.GameMap.Component.Town.prototype.__twdb__getContent || w.GameMap.Component.Town.prototype.getContent;
w.GameMap.Component.Town.prototype.getContent = function () {
var e = this.__twdb__getContent();
if (e === "") {
return e;
} else {
return e.replace(/\<\/div\>$/, "
");
}
};
w.GameMap.Draw.__twdb__checkDouble = w.GameMap.Draw.__twdb__checkDouble || w.GameMap.Draw.checkDouble;
w.GameMap.Draw.checkDouble = function () {
$("#map div.instanthotel.needslistener").each(function (e, t) {
var n = $(t);
var r = parseInt(n.attr("tid"), 10);
n.click(function (e) {
e.stopPropagation();
HotelWindow.open(r);
return false;
})
.removeClass("needslistener")
.removeAttr("tid");
});
return w.GameMap.Draw.__twdb__checkDouble();
};
var e =
"div.instanthotel { background-image: url('" +
TWDB.images.instanthotel +
"'); width: 20px; height: 20px; " +
"position: absolute; right: 10px; top: -8px; cursor: pointer; display: none; }\n" +
"div.townname:hover .instanthotel { z-index: 2; display: block; }";
TWDB.Util.addCss(e);
w.GameMap.refresh(true);
} catch (t) {
Error.report(t, "manipulate town signs");
}
};
var fastSkillChange = function () {
try {
west.gui.Plusminusfield.prototype.__twdb__init = west.gui.Plusminusfield.prototype.init;
west.gui.Plusminusfield.prototype.init = function (e, t, n, r, i, s, o, u) {
this.__twdb__init.apply(this, arguments);
var a = this;
var f = { minus: $("span.butMinus", a.divMain), plus: $("span.butPlus", a.divMain) };
$(this.divMain)
.off("mousewheel")
.on("mousewheel", function (e, t) {
f[t < 0 ? "minus" : "plus"].click();
e.stopPropagation();
return false;
});
$.each(f, function (e, t) {
var n = 400,
r = -1,
i = function () {
n = Math.max(Math.round((n * (n / 200 + 1)) / (n / 133 + 1)), 5);
t.click();
r = setTimeout(i, n);
},
s = function () {
r = setTimeout(i, n);
},
o = function (e) {
if (r !== -1) {
clearTimeout(r);
r = -1;
}
n = 400;
};
t.css("cursor", "pointer").mousedown(s).mouseup(o).mouseout(o);
});
};
} catch (e) {
Error.report(e, "manipulate Plusminusfield");
}
};
var QuestbookSwitch = function () {
try {
QuestGroupWindowView.cc_showSolvedQuest = QuestGroupWindowView.showSolvedQuest;
QuestGroupWindowView.showSolvedQuest = function (e) {
QuestGroupWindowView.cc_showSolvedQuest(e);
var t = $("div.window-quest_group div.quest_description_container span").slice(1).hide();
var n = $(" " + e.description + "");
$("div.window-quest_group div.quest_description_container").append(n);
var r = $(' Zobraziť záverečný text ')
.addClass("introshown")
.click(function () {
var e = $(this),
r = e.hasClass("introshown");
t.toggle(r);
n.toggle(!r);
e.text(r ? " Zobraziť úvodný text " : " Zobraziť záverečný text ");
e.toggleClass("introshown");
});
$("div.window-quest_group div.solved_text_container").append($("
").append(r));
};
} catch (e) {
Error.report(e, "manipulate showSolvedQuest");
}
};
var QuestFullText = function () {
try {
QuestWindowView.cc_showQuest = QuestWindowView.showQuest;
QuestWindowView.showQuest = function (e) {
QuestWindowView.cc_showQuest(e);
$("div.quest_description_container div#quest_shortd").hide();
$("div.quest_description_container div#quest_fulld").show();
};
QuestEmployerView.cc_showQuest = QuestEmployerView.showQuest;
QuestEmployerView.showQuest = function (e) {
QuestEmployerView.cc_showQuest(e);
$("div.quest_description_container div#quest_shortd").hide();
$("div.quest_description_container div#quest_fulld").show();
};
} catch (e) {
Error.report(e, "manipulate showQuest");
}
};
var removeWorkQueuePA = function () {
try {
TWDB.Util.addCss("#queuedTasks .buyPremiumTask {background: none!important}");
Premium.checkForAutomationPremium = function (e, t) {
if (typeof t !== "undefined") return t();
};
} catch (e) {
Error.report(e, "manipulate removeWorkQueuePA");
}
};
var changeWofNuggets = function () {
try {
west.gui.payHandler.prototype.__twdb__addPayOption = west.gui.payHandler.prototype.addPayOption;
west.gui.payHandler.prototype.addPayOption = function (e) {
this.__twdb__addPayOption.apply(this, arguments);
if (false === e || "nugget" === e || 2 == e || 2 == e.id) {
return this;
}
this.setSelectedPayId(e.id || e);
return this;
};
} catch (e) {
Error.report(e, "manipulate changeWofNuggets");
}
};
var removeVariousPA = function () {
var e = [],
t;
if (Settings.get("nofetchallpa", false)) e.push("marketdelivery all");
if (!e.length) return;
t = new RegExp(e.join("|"));
try {
Premium.twdb_confirmUse = Premium.confirmUse;
Premium.confirmUse = function (e, n, r, i, s, o, u, a) {
if (t.test(e)) {
if (typeof u !== "undefined") return u();
} else {
return Premium.twdb_confirmUse(e, n, r, i, s, o, u, a);
}
};
} catch (n) {
Error.report(n, "manipulate removeVariousPA");
}
};
var activateFortRecruitment = function () {
try {
FortBattleWindow.__twdb__getInfoArea = FortBattleWindow.__twdb__getInfoArea || FortBattleWindow.getInfoArea;
FortBattleWindow.getInfoArea = function () {
this.preBattle.battleData.canSetPrivilege = true;
return FortBattleWindow.__twdb__getInfoArea.apply(this, arguments);
};
} catch (e) {
Error.report(e, "manipulate FortBattleWindow.getInfoArea");
}
};
var enhanceMarketSellDialog = function () {
var e;
var t = TWDB.Cache.load("msdsettings");
if (typeof t !== "object" || t == null) {
t = { cb: {} };
} else if (typeof t.cb !== "object" || t.cb == null) {
t.cb = {};
}
try {
if (!isDefined(west.gui.Dialog.prototype.__twdb__show)) {
west.gui.Dialog.prototype.__twdb__show = west.gui.Dialog.prototype.show;
}
if (TWDB.script.isDev()) {
west.gui.Dialog.prototype.show = function () {
if (this.divMain.attr("id") === "market_createoffer_window") {
var e = this.__twdb__show();
w.setTimeout(function () {
MarketWindow.TWDB_touchUpSellDialog(e);
}, 25);
return e;
}
var t = ["div#equip_manager_list", "span.twdb_banking"].join(", ");
if ($(this.divMain).find(t).addBack().is(t)) {
return this.setModal(false).setBlockGame(false).setDraggable(true).__twdb__show();
}
return this.__twdb__show();
};
} else {
west.gui.Dialog.prototype.show = function () {
if (this.divMain.attr("id") === "market_createoffer_window") {
var e = this.__twdb__show();
w.setTimeout(function () {
MarketWindow.TWDB_touchUpSellDialog(e);
}, 25);
return e;
}
return this.__twdb__show();
};
}
if (!isDefined(MarketWindow.TWDB_createMarketOffer)) {
MarketWindow.TWDB_createMarketOffer = MarketWindow.createMarketOffer;
}
MarketWindow.createMarketOffer = function (t) {
var n = typeof t == "number" ? t : $(t).data("itemId");
if (n === undefined) {
var r = $(this).data("dnd_droppedObj");
n = r.data("itemId");
}
e = w.ItemManager.get(n);
return MarketWindow.TWDB_createMarketOffer(n);
};
} catch (n) {
Error.report(n, "manipulate market sell dialog");
}
MarketWindow.TWDB_touchUpSellDialog = function (n) {
if (n.divMain.attr("id") !== "market_createoffer_window") {
return;
}
var r = $("div.tw2gui_dialog_content", n.divMain);
if (r.find("#auction_item_slot", r).html() == "")
return w.setTimeout(function () {
MarketWindow.TWDB_touchUpSellDialog(n);
}, 25);
$("div.tw2gui_dialog_framefix").css({ left: "50%", top: "50%", width: "1px", height: "1px" });
$("textarea#auction_description", r).css("width", "270px").closest("tr").append("
");
var i = $("table:nth-child(2)", r);
$("tr:first-child", i).after($("
').click(function () {
u("description", "");
$("textarea#auction_description", r).val("");
})
);
$("#twdb_msd_bid_btn_cc", r).append(
/*$('').click(function () {
$("div.tw2gui_checkbox", r).each(function () {
const checkbox = $(this).guiElement(); // Get the checkbox element
if (checkbox) {
const groupClass = checkbox.groupClass; // Assuming groupClass is used to identify checkboxes
const value = checkbox.getValue(); // Get the current value of the checkbox
t.cb[groupClass] = value;
TWDB.Cache.save("msdsettings", t);
new UserMessage("Uloženie úspešné", UserMessage.TYPE_SUCCESS).show();
}
});
}),*/
$('').click(function () {
$("div.tw2gui_checkbox.twdb_msd_bid_fix", r).each(function () {
const checkbox = $(this).guiElement(); // Get the checkbox element
if (checkbox && checkbox.isSelected()) {
checkbox.setSelected(false, true); // Unset selected state
o.call(checkbox); // Call the `o` function in the context of the checkbox
}
});
//$("#market_max_price", r).val("").keyup();
$("#market_min_bid", r).val("").keyup();
})
);
$("#twdb_msd_buy_btn_cc", r).append(
$('').click(function () {
$("div.tw2gui_checkbox.twdb_msd_buy_fix", r).each(function () {
const checkbox = $(this).guiElement(); // Get the checkbox element
if (checkbox && checkbox.isSelected()) {
checkbox.setSelected(false, true); // Unset selected state
o.call(checkbox); // Call the `o` function in the context of the checkbox
}
});
$("#market_max_price", r).val("").keyup();
})
);
$("#twdb_msd_buy_cc", r)
.append(new west.gui.Checkbox("", "twdb_msd_buy_fix", o).setTitle("Použiť ako predvolenú cenu").setValue(2).divMain)
.append(
$('
Hallo ' +
Character.name +
", der Bondumtausch konnte bei dir leider nicht korrekt ausgeführt werden, da du keine 5.000 Bonds besitzt. Eine weitere Verwendung des Bonuscode ist nun leider nicht mehr möglich.
",
animated: 0,
},
{ upbs: Character.upb },
])
);
Character.addUpb(-Character.upb);
Character.setToRead("reports", true);
});
} else this.twdb_activateRedeem.apply(this, arguments);
};
} catch (n) {
Error.report(n, "manipulate OptionsButler.activateRedeem");
}
try {
Date.prototype.toReportTime = function () {
var e = new Date(),
t = this;
if (t.getDate() === e.getDate() && t.getMonth() === e.getMonth() && t.getFullYear() === e.getFullYear()) return this.toTime().substring(0, 5) + " Uhr";
return this.toDateString().replace("-04-20", ". Apr ");
};
MessagesWindow.Report.twdb__initContent = MessagesWindow.Report.twdb__initContent || MessagesWindow.Report._initContent;
MessagesWindow.Report._initContent = function (e) {
var n = t();
var r = e.reports;
var i = r.length;
if (n && (e.type == "all" || e.type == "other")) {
var s = n[0];
s.date_received = new Date(s.date).toReportTime();
if (i === 0) r.push(s);
else
for (var o = 0; o < i; o++)
if ((e.page > 1 ? r[Math.max(0, o - 1)].data_id > s.data_id : true) && r[o].data_id < s.data_id) {
r.splice(o, 0, s);
r.pop();
break;
} else if (o == i - 1 && i < 10 && r[o].data_id > s.data_id) r.push(s);
}
this.twdb__initContent.call(this, e);
};
} catch (n) {
Error.report(n, "manipulate MessagesWindow.Report._initContent");
}
try {
ReportWindow.twdb_init = ReportWindow.twdb_init || ReportWindow.init;
ReportWindow.init = function (n, r) {
if (this.reportId == "01042017") {
var i = t();
if (!i[0].read) {
i[0].read = true;
localStorage.setItem(e, JSON.stringify(i));
}
i[1].date_received = new Date(i[1].date).toDateTimeStringNice();
i[1].publishData = ReportPublish.publishData;
ReportWindow.init_content(i[1]);
} else this.twdb_init.apply(this, arguments);
};
} catch (n) {
Error.report(n, "manipulate ReportWindow.init");
}
var r = t();
if (r) Character.addUpb(-r[2].upbs);
};
return _self;
})($);
Debugger.GameInject = GameInject;
var DataManager = (function (e) {
var t = {};
var n = false;
var r = {};
var i = {};
var s = {};
var o = [];
var u = 0;
var a = { items: {}, skills: {} };
var f = { items: true, skills: true };
var l = null;
var c = {};
var h = function () {
if (c.ready) {
return;
}
var e = window.addEventListener ? "addEventListener" : "attachEvent";
var t = window[e];
var n = e == "attachEvent" ? "onmessage" : "message";
t(
n,
function (e) {
if (e.origin !== Script.protocol + "://" + Script.url) {
return;
}
try {
var t = JSON.parse(e.data);
if (isDefined(t.error)) {
new UserMessage(Script.url + ": " + t.error, UserMessage.TYPE_ERROR).show();
} else {
new UserMessage(Script.url + ": " + t.message, UserMessage.TYPE_SUCCESS).show();
r = t.data;
a.skills = s;
a.items = i;
Cache.save("datamanager", a);
f = { items: true, skills: true };
u++;
Eventer.trigger("TWDBdataLoaded");
}
} catch (e) {
console.log(Script.url + ": empty or corrupt data recieved");
}
},
false
);
var o = Cache.load("datamanager");
if (isDefined(o) && isDefined(o.skills) && isDefined(o.items)) {
a = o;
}
if (!window.Bag.loaded && window.Bag.loadItems) {
window.Bag.loadItems();
}
var l = window.setInterval(function () {
if (window.Bag.loaded) {
window.clearInterval(l);
c.ready = true;
}
}, 100);
};
c = Loader.add("DataManager", "tw-db DataManager", h, { Cache: true });
t.getData = function (e) {
if (isDefined(r[e])) {
return r[e];
}
return r;
};
t.getSkills = function () {
return s;
};
t.getItems = function () {
return i;
};
t.getAnimals = function () {
return o;
};
t.getVersion = function () {
return u;
};
t.getUp2Date = function () {
return f;
};
var p = function () {
try {
var t = e.extend(true, {}, a.skills);
s = {};
for (var n in CharacterSkills.skills) {
var r = TWDB.ClothCalc._skill2id[n];
var i = CharacterSkills.skills[n].points;
s[r] = i;
if (isDefined(t[r])) {
if (t[r] !== i) {
f.skills = false;
}
delete t[r];
} else {
f.skills = false;
}
}
if (!e.isEmptyObject(t)) {
f.skills = false;
}
} catch (o) {
Error.report(o, "DataManager loadSkill");
}
};
var d = function () {
try {
var t = e.extend(true, {}, a.items);
i = {};
o = [];
for (var n in Bag.items_by_id) {
var r = Bag.items_by_id[n].obj;
if (ClothCalc.isItemUsable(r.item_id)) {
i[r.item_id] = true;
if (r.type === "animal") {
o.push({ id: r.item_id, speed: r.speed });
}
if (isDefined(t[r.item_id])) {
delete t[r.item_id];
} else {
f.items = false;
}
}
}
for (var s in Wear.wear) {
var u = Number(Wear.wear[s].getId());
if (isDefined(i[u])) {
continue;
}
if (ClothCalc.isItemUsable(u)) {
i[u] = true;
if (s == "animal") {
o.push({ id: u, speed: Wear.wear[s].obj.speed });
}
if (isDefined(t[u])) {
delete t[u];
} else {
f.items = false;
}
}
}
if (!e.isEmptyObject(t)) {
f.items = false;
}
var l = function (e, t) {
return e["speed"] > t["speed"] ? true : false;
};
o.sort(l);
} catch (c) {
Error.report(c, "DataManager loadItems");
}
};
t.loadData = function (e) {
p();
d();
if (e === true) {
v();
}
};
var v = function () {
try {
var t = {};
var n = {};
for (var r in i) {
var o = ItemManager.get(r);
var u = Number(TWDB.ClothCalc._type2id[o.type]);
if (!isDefined(t[u])) {
t[u] = [];
}
t[u].push(r);
if (isDefined(o.set)) {
if (!isDefined(n[u])) {
n[u] = [];
}
n[u].push(r);
}
}
var a = { 0: Number(Premium.hasBonus("regen")), 1: Number(Premium.hasBonus("automation")), 2: Number(Premium.hasBonus("money")), 3: Number(Premium.hasBonus("character")) };
var f = '";
f += '';
f += "