Skip to content
Snippets Groups Projects
Commit 7a9d29ea authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'buy-all-hero' into 'pregmod-master'

Buy all hero slaves

Closes #1542

See merge request !7588
parents 43405030 181ae8cc
Branches
Tags
1 merge request!7588Buy all hero slaves
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
App.Markets.specialSlave = function() { App.Markets.specialSlave = function() {
const el = document.createElement("p"); const el = document.createElement("p");
let p; let p;
const heroSlaves = App.Utils.buildHeroArray(); let heroSlaves = App.Utils.buildHeroArray();
let slave; let slave;
let selectedID; let selectedID;
...@@ -75,11 +75,55 @@ App.Markets.specialSlave = function() { ...@@ -75,11 +75,55 @@ App.Markets.specialSlave = function() {
} }
App.UI.DOM.appendNewElement("p", el, App.UI.DOM.generateLinksStrip(linkArray)); App.UI.DOM.appendNewElement("p", el, App.UI.DOM.generateLinksStrip(linkArray));
if (V.cheatMode) {
let oneSlaveCost = (s) => { let cost = slaveCost(s); return cost + (10 * Math.trunc((cost / 10) * 2)); };
let allHeroSlaves = App.Utils.buildHeroArray().map(
(hs) => {
const slave = App.Utils.getHeroSlave(hs);
return {slave: slave, cost: oneSlaveCost(slave), ID: hs.ID};
}
);
let totalCost = allHeroSlaves.reduce((acc, s) => acc += s.cost, 0);
if (V.cash > totalCost) {
App.UI.DOM.appendNewElement(
"div",
el,
App.UI.DOM.link(
`Buy all of them for ${cashFormat(totalCost)}`,
() => {
for (const hero of allHeroSlaves) {
cashX(forceNeg(hero.cost), "slaveTransfer", hero.slave);
newSlave(hero.slave);
V.heroSlavesPurchased.push(hero.ID);
}
refresh();
}
)
);
} else {
App.UI.DOM.appendNewElement(
"div",
el,
App.UI.DOM.disabledLink(
`Buy all of them for ${cashFormat(totalCost)}`,
[`Cannot afford`]
)
);
}
}
return el; return el;
function refresh() { function refresh() {
jQuery("#complete-catalog").empty().append(catalog()); heroSlaves = App.Utils.buildHeroArray();
jQuery("#show-slave").empty().append(showSlave()); if (heroSlaves.length === 0) {
jQuery("#complete-catalog").empty().append(`There are no longer any special slaves available.`);
jQuery("#show-slave").empty();
} else {
jQuery("#complete-catalog").empty().append(catalog());
jQuery("#show-slave").empty().append(showSlave());
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment