2019-01-15 14:11:14 +01:00
|
|
|
import { dialogBoxCreate } from "./DialogBox";
|
|
|
|
import { clearEventListeners } from "./uiHelpers/clearEventListeners";
|
2021-05-08 03:24:16 +02:00
|
|
|
import { numeralWrapper } from "../src/ui/numeralFormat";
|
2019-01-15 14:11:14 +01:00
|
|
|
|
|
|
|
import { BitNodeMultipliers } from "../src/BitNode/BitNodeMultipliers";
|
2018-12-07 11:54:26 +01:00
|
|
|
import { CONSTANTS } from "../src/Constants";
|
|
|
|
import { Factions } from "../src/Faction/Factions";
|
|
|
|
import { Player } from "../src/Player";
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2018-06-28 05:34:57 +02:00
|
|
|
//Keep track of last faction
|
|
|
|
var lastFac = "";
|
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
/* InfiltrationBox.js */
|
2017-08-30 19:44:29 +02:00
|
|
|
function infiltrationBoxClose() {
|
2017-07-03 21:42:11 +02:00
|
|
|
var box = document.getElementById("infiltration-box-container");
|
|
|
|
box.style.display = "none";
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function infiltrationBoxOpen() {
|
2017-07-03 21:42:11 +02:00
|
|
|
var box = document.getElementById("infiltration-box-container");
|
2018-09-14 23:03:31 +02:00
|
|
|
box.style.display = "flex";
|
2017-07-03 21:42:11 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function infiltrationSetText(txt) {
|
2017-07-03 21:42:11 +02:00
|
|
|
var textBox = document.getElementById("infiltration-box-text");
|
|
|
|
textBox.innerHTML = txt;
|
|
|
|
}
|
|
|
|
|
|
|
|
//ram argument is in GB
|
2017-08-30 19:44:29 +02:00
|
|
|
function infiltrationBoxCreate(inst) {
|
2017-09-08 04:56:27 +02:00
|
|
|
//Gain exp
|
2019-03-23 19:27:11 +01:00
|
|
|
Player.gainHackingExp(inst.calcGainedHackingExp());
|
|
|
|
Player.gainStrengthExp(inst.calcGainedStrengthExp());
|
|
|
|
Player.gainDefenseExp(inst.calcGainedDefenseExp());
|
|
|
|
Player.gainDexterityExp(inst.calcGainedDexterityExp());
|
|
|
|
Player.gainAgilityExp(inst.calcGainedAgilityExp());
|
|
|
|
Player.gainCharismaExp(inst.calcGainedCharismaExp());
|
|
|
|
Player.gainIntelligenceExp(inst.calcGainedIntelligenceExp());
|
2017-09-15 16:06:59 +02:00
|
|
|
|
2018-09-29 20:58:32 +02:00
|
|
|
const expGainText = ["You gained:",
|
2021-05-08 03:24:16 +02:00
|
|
|
`${numeralWrapper.formatExp(inst.calcGainedHackingExp(), 3)} hacking exp`,
|
|
|
|
`${numeralWrapper.formatExp(inst.calcGainedStrengthExp(), 3)} str exp`,
|
|
|
|
`${numeralWrapper.formatExp(inst.calcGainedDefenseExp(), 3)} def exp`,
|
|
|
|
`${numeralWrapper.formatExp(inst.calcGainedDexterityExp(), 3)} dex exp`,
|
|
|
|
`${numeralWrapper.formatExp(inst.calcGainedAgilityExp(), 3)} agi exp`,
|
|
|
|
`${numeralWrapper.formatExp(inst.calcGainedCharismaExp(), 3)} cha exp`].join("\n");
|
2018-09-29 20:58:32 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
var totalValue = 0;
|
|
|
|
for (var i = 0; i < inst.secretsStolen.length; ++i) {
|
|
|
|
totalValue += inst.secretsStolen[i];
|
|
|
|
}
|
|
|
|
if (totalValue == 0) {
|
2017-08-30 19:44:29 +02:00
|
|
|
dialogBoxCreate("You successfully escaped the facility but you did not steal " +
|
2018-09-29 20:58:32 +02:00
|
|
|
"anything of worth when infiltrating.<br><br>" + expGainText);
|
2017-07-03 21:42:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-10-12 04:00:22 +02:00
|
|
|
var facValue = totalValue * Player.faction_rep_mult *
|
|
|
|
CONSTANTS.InfiltrationRepValue * BitNodeMultipliers.InfiltrationRep;
|
|
|
|
var moneyValue = totalValue * CONSTANTS.InfiltrationMoneyValue * BitNodeMultipliers.InfiltrationMoney;
|
2017-08-30 19:44:29 +02:00
|
|
|
infiltrationSetText("You can sell the classified documents and secrets " +
|
2021-05-08 03:24:16 +02:00
|
|
|
"you stole from " + inst.companyName + " for <span class='money-gold'>" +
|
|
|
|
numeralWrapper.formatMoney(moneyValue) + "</span> on the black market or you can give it " +
|
|
|
|
"to a faction to gain <span class='light-yellow'>" + numeralWrapper.formatReputation(facValue) + " reputation</span> with " +
|
2017-07-03 21:42:11 +02:00
|
|
|
"that faction.");
|
|
|
|
var selector = document.getElementById("infiltration-faction-select");
|
|
|
|
selector.innerHTML = "";
|
2018-06-28 05:34:57 +02:00
|
|
|
for (let i = 0; i < Player.factions.length; ++i) {
|
2018-10-23 20:55:42 +02:00
|
|
|
if (Player.factions[i] === "Bladeburners") { continue; }
|
|
|
|
if (Player.inGang() && Player.gang.facName === Player.factions[i]) { continue; }
|
2017-08-30 19:44:29 +02:00
|
|
|
selector.innerHTML += "<option value='" + Player.factions[i] +
|
2017-07-03 21:42:11 +02:00
|
|
|
"'>" + Player.factions[i] + "</option>";
|
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2018-06-28 05:34:57 +02:00
|
|
|
//Set initial value, if applicable
|
|
|
|
if (lastFac !== "") {
|
|
|
|
for (let i = 0; i < selector.options.length; ++i) {
|
|
|
|
if (selector.options[i].value === lastFac) {
|
|
|
|
selector.selectedIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
var sellButton = clearEventListeners("infiltration-box-sell");
|
|
|
|
setTimeout(function() {
|
2018-07-08 02:16:58 +02:00
|
|
|
sellButton.addEventListener("click", function(e) {
|
|
|
|
if (!e.isTrusted) {return false;}
|
2017-07-03 21:42:11 +02:00
|
|
|
Player.gainMoney(moneyValue);
|
2019-02-22 03:26:28 +01:00
|
|
|
Player.recordMoneySource(moneyValue, "infiltration");
|
2017-07-03 21:42:11 +02:00
|
|
|
dialogBoxCreate("You sold the classified information you stole from " + inst.companyName +
|
2021-05-08 03:24:16 +02:00
|
|
|
" for <span class='money-gold'>" + numeralWrapper.formatMoney(moneyValue) + "</span> on the black market!<br><br>" +
|
2018-09-29 20:58:32 +02:00
|
|
|
expGainText);
|
2017-07-03 21:42:11 +02:00
|
|
|
infiltrationBoxClose();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}, 750);
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
var factionButton = clearEventListeners("infiltration-box-faction");
|
|
|
|
setTimeout(function() {
|
2018-07-08 02:16:58 +02:00
|
|
|
factionButton.addEventListener("click", function(e) {
|
|
|
|
if (!e.isTrusted) {return false;}
|
2017-07-03 21:42:11 +02:00
|
|
|
var facName = selector.options[selector.selectedIndex].value;
|
2018-06-28 05:34:57 +02:00
|
|
|
lastFac = facName;
|
2017-07-03 21:42:11 +02:00
|
|
|
var faction = Factions[facName];
|
|
|
|
if (faction == null) {
|
|
|
|
dialogBoxCreate("Error finding faction. This is a bug please report to developer");
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-22 00:54:55 +02:00
|
|
|
faction.playerReputation += facValue;
|
2017-08-30 19:44:29 +02:00
|
|
|
dialogBoxCreate("You gave the classified information you stole from " + inst.companyName +
|
2021-05-08 03:24:16 +02:00
|
|
|
" to " + facName + " and gained <span class='light-yellow'>" + numeralWrapper.formatReputation(facValue) + " reputation</span> with the faction. <br><br>" +
|
2018-09-29 20:58:32 +02:00
|
|
|
expGainText);
|
2017-07-03 21:42:11 +02:00
|
|
|
infiltrationBoxClose();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}, 750);
|
|
|
|
infiltrationBoxOpen();
|
2017-08-30 19:44:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export {infiltrationBoxCreate};
|