2017-08-30 19:44:29 +02:00
|
|
|
import {CONSTANTS} from "../src/Constants.js";
|
|
|
|
import {Factions, Faction} from "../src/Faction.js";
|
|
|
|
import {Player} from "../src/Player.js";
|
|
|
|
import {dialogBoxCreate} from "./DialogBox.js";
|
|
|
|
import {clearEventListeners} from "./HelperFunctions.js";
|
|
|
|
import {formatNumber} from "./StringHelperFunctions.js";
|
|
|
|
|
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");
|
|
|
|
box.style.display = "block";
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
Player.gainHackingExp(inst.hackingExpGained);
|
|
|
|
Player.gainStrengthExp(inst.strExpGained);
|
|
|
|
Player.gainDefenseExp(inst.defExpGained);
|
|
|
|
Player.gainDexterityExp(inst.dexExpGained);
|
|
|
|
Player.gainAgilityExp(inst.agiExpGained);
|
|
|
|
Player.gainCharismaExp(inst.chaExpGained);
|
|
|
|
|
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 " +
|
|
|
|
"anything of worth when infiltrating.<br><br>" +
|
|
|
|
"You gained:<br>" +
|
|
|
|
formatNumber(inst.hackingExpGained, 3) + " hacking exp<br>" +
|
|
|
|
formatNumber(inst.strExpGained, 3) + " str exp<br>" +
|
|
|
|
formatNumber(inst.defExpGained, 3) + " def exp<br>" +
|
|
|
|
formatNumber(inst.dexExpGained, 3) + " dex exp<br>" +
|
|
|
|
formatNumber(inst.agiExpGained, 3) + " agi exp<br>" +
|
2017-07-03 21:42:11 +02:00
|
|
|
formatNumber(inst.chaExpGained, 3) + " cha exp<br>");
|
|
|
|
return;
|
|
|
|
}
|
2017-07-22 00:54:55 +02:00
|
|
|
var facValue = totalValue * Player.faction_rep_mult * 1.2
|
2017-07-03 21:42:11 +02:00
|
|
|
var moneyValue = totalValue * CONSTANTS.InfiltrationMoneyValue;
|
2017-08-30 19:44:29 +02:00
|
|
|
infiltrationSetText("You can sell the classified documents and secrets " +
|
|
|
|
"you stole from " + inst.companyName + " for $" +
|
|
|
|
formatNumber(moneyValue, 2) + " on the black market or you can give it " +
|
|
|
|
"to a faction to gain " + formatNumber(facValue, 3) + " reputation with " +
|
2017-07-03 21:42:11 +02:00
|
|
|
"that faction.");
|
|
|
|
var selector = document.getElementById("infiltration-faction-select");
|
|
|
|
selector.innerHTML = "";
|
|
|
|
for (var i = 0; i < Player.factions.length; ++i) {
|
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
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
var sellButton = clearEventListeners("infiltration-box-sell");
|
|
|
|
setTimeout(function() {
|
|
|
|
sellButton.addEventListener("click", function() {
|
|
|
|
Player.gainMoney(moneyValue);
|
|
|
|
dialogBoxCreate("You sold the classified information you stole from " + inst.companyName +
|
2017-08-30 19:44:29 +02:00
|
|
|
" for $" + moneyValue + " on the black market!<br><br>" +
|
|
|
|
"You gained:<br>" +
|
|
|
|
formatNumber(inst.hackingExpGained, 3) + " hacking exp<br>" +
|
|
|
|
formatNumber(inst.strExpGained, 3) + " str exp<br>" +
|
|
|
|
formatNumber(inst.defExpGained, 3) + " def exp<br>" +
|
|
|
|
formatNumber(inst.dexExpGained, 3) + " dex exp<br>" +
|
|
|
|
formatNumber(inst.agiExpGained, 3) + " agi exp<br>" +
|
2017-07-03 21:42:11 +02:00
|
|
|
formatNumber(inst.chaExpGained, 3) + " cha exp<br>");
|
|
|
|
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() {
|
|
|
|
factionButton.addEventListener("click", function() {
|
|
|
|
var facName = selector.options[selector.selectedIndex].value;
|
|
|
|
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 +
|
|
|
|
" to " + facName + " and gained " + formatNumber(facValue, 3) + " reputation with the faction. <br><br>" +
|
|
|
|
"You gained:<br>" +
|
|
|
|
formatNumber(inst.hackingExpGained, 3) + " hacking exp<br>" +
|
|
|
|
formatNumber(inst.strExpGained, 3) + " str exp<br>" +
|
|
|
|
formatNumber(inst.defExpGained, 3) + " def exp<br>" +
|
|
|
|
formatNumber(inst.dexExpGained, 3) + " dex exp<br>" +
|
|
|
|
formatNumber(inst.agiExpGained, 3) + " agi exp<br>" +
|
2017-07-03 21:42:11 +02:00
|
|
|
formatNumber(inst.chaExpGained, 3) + " cha exp<br>");
|
|
|
|
infiltrationBoxClose();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}, 750);
|
|
|
|
infiltrationBoxOpen();
|
2017-08-30 19:44:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export {infiltrationBoxCreate};
|