Copying a NetscriptJS script with scp now properly clears its 'module'.

This commit is contained in:
danielyxie 2018-06-29 00:39:05 -05:00
parent e621cac0a8
commit c8421168b6
5 changed files with 60 additions and 41 deletions

83
dist/engine.bundle.js vendored

@ -2860,13 +2860,13 @@ function convertTimeMsToTimeElapsedString(time) {
const secTruncMinutes = secTruncHours % secondPerMinute; const secTruncMinutes = secTruncHours % secondPerMinute;
const seconds = secTruncMinutes; const seconds = secTruncMinutes;
let res = ""; let res = "";
if (days) { if (days > 0) {
res += `${days} days `; res += `${days} days `;
} }
if (hours) { if (hours > 0) {
res += `${hours} hours `; res += `${hours} hours `;
} }
if (minutes) { if (minutes > 0) {
res += `${minutes} minutes `; res += `${minutes} minutes `;
} }
res += `${seconds} seconds `; res += `${seconds} seconds `;
@ -2878,7 +2878,7 @@ function longestCommonStart(strings) {
if (!containsAllStrings(strings)) { if (!containsAllStrings(strings)) {
return ""; return "";
} }
if (strings.length == 0) { if (strings.length === 0) {
return ""; return "";
} }
const A = strings.concat().sort(); const A = strings.concat().sort();
@ -2886,7 +2886,8 @@ function longestCommonStart(strings) {
const a2 = A[A.length - 1]; const a2 = A[A.length - 1];
const L = a1.length; const L = a1.length;
let i = 0; let i = 0;
while (i < L && a1.charAt(i).toLowerCase() === a2.charAt(i).toLowerCase()) { const areEqualCaseInsensitive = (a, b) => a.toUpperCase() === b.toUpperCase();
while (i < L && areEqualCaseInsensitive(a1.charAt(i), a2.charAt(i))) {
i++; i++;
} }
return a1.substring(0, i); return a1.substring(0, i);
@ -2912,16 +2913,16 @@ function formatNumber(num, numFractionDigits) {
exports.formatNumber = formatNumber; exports.formatNumber = formatNumber;
// Count the number of times a substring occurs in a string // Count the number of times a substring occurs in a string
function numOccurrences(text, subString) { function numOccurrences(text, subString) {
text += ""; const input = `${text}`;
subString += ""; const search = `${subString}`;
if (subString.length <= 0) { if (search.length <= 0) {
return (text.length + 1); return (input.length + 1);
} }
let n = 0; let n = 0;
let pos = 0; let pos = 0;
const step = subString.length; const step = search.length;
while (true) { while (true) {
pos = text.indexOf(subString, pos); pos = input.indexOf(search, pos);
if (pos >= 0) { if (pos >= 0) {
++n; ++n;
pos += step; pos += step;
@ -2949,6 +2950,7 @@ function numNetscriptOperators(text) {
numOccurrences(text, "==") + numOccurrences(text, "==") +
numOccurrences(text, "!="); numOccurrences(text, "!=");
if (isNaN(total)) { if (isNaN(total)) {
// tslint:disable-next-line:max-line-length
const message = "ERROR in counting number of operators in script. This is a bug, please report to game developer"; const message = "ERROR in counting number of operators in script. This is a bug, please report to game developer";
DialogBox_1.dialogBoxCreate(message, false); DialogBox_1.dialogBoxCreate(message, false);
return 0; return 0;
@ -2958,11 +2960,11 @@ function numNetscriptOperators(text) {
exports.numNetscriptOperators = numNetscriptOperators; exports.numNetscriptOperators = numNetscriptOperators;
// Checks if a string contains HTML elements // Checks if a string contains HTML elements
function isHTML(str) { function isHTML(str) {
const a = document.createElement("div"); const element = document.createElement("div");
a.innerHTML = str; element.innerHTML = str;
const c = a.childNodes; const c = element.childNodes;
for (let i = c.length; i--;) { for (let i = c.length - 1; i >= 0; i--) {
if (c[i].nodeType == 1) { if (c[i].nodeType === 1) {
return true; return true;
} }
} }
@ -3491,7 +3493,12 @@ let CONSTANTS = {
"at levels 1, 2, and 3, respectively (increased from 8%, 12%, 14%)<br>" + "at levels 1, 2, and 3, respectively (increased from 8%, 12%, 14%)<br>" +
"* The effect of Source-File 12 is now additive with itself, rather than multiplicative. This means " + "* The effect of Source-File 12 is now additive with itself, rather than multiplicative. This means " +
"that level N of Source-File 12 now increases all multipliers by N%<br>" + "that level N of Source-File 12 now increases all multipliers by N%<br>" +
"* The setting to suppress the confirmation box when purchasing Augmentations was moved into the main Options menu (by Github user hydroflame)<br>" "* The setting to suppress the confirmation box when purchasing Augmentations was moved into the main Options menu (by Github user hydroflame)<br>" +
"* Bug Fix: Crime Success rates were being calculated incorrectly (by Github user hydroflame)<br>" +
"* When an Infiltration is finished, you will now return back to the company's page, rather than the city<br>" +
"* Infiltration faction reputation selector now remembers your last choice<br>" +
"* Bug Fix: Copying a NetscriptJS script to another server using scp now properly takes into account " +
"the script's changes.<br>"
} }
@ -12436,14 +12443,14 @@ function initBitNodeMultipliers() {
BitNodeMultipliers.CorporationValuation = 0.01; BitNodeMultipliers.CorporationValuation = 0.01;
break; break;
case 12: //The Recursion case 12: //The Recursion
let sf12Lvl = 0; var sf12Lvl = 0;
for (let i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].sourceFiles.length; i++) { for (var i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].sourceFiles.length; i++) {
if (_Player__WEBPACK_IMPORTED_MODULE_0__["Player"].sourceFiles[i].n === 12) { if (_Player__WEBPACK_IMPORTED_MODULE_0__["Player"].sourceFiles[i].n === 12) {
sf12Lvl = _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].sourceFiles[i].lvl; sf12Lvl = _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].sourceFiles[i].lvl;
} }
} }
const inc = Math.pow(1.01, sf12Lvl); var inc = Math.pow(1.01, sf12Lvl);
const dec = Math.pow(0.99, sf12Lvl); var dec = Math.pow(0.99, sf12Lvl);
BitNodeMultipliers.HackingLevelMultiplier = dec; BitNodeMultipliers.HackingLevelMultiplier = dec;
BitNodeMultipliers.ServerMaxMoney = dec; BitNodeMultipliers.ServerMaxMoney = dec;
@ -15842,8 +15849,8 @@ function initSettings() {
Settings.MaxPortCapacity = 50; Settings.MaxPortCapacity = 50;
Settings.SuppressMessages = false; Settings.SuppressMessages = false;
Settings.SuppressFactionInvites = false; Settings.SuppressFactionInvites = false;
Settings.SuppressTravelConfirmation = false, Settings.SuppressTravelConfirmation = false;
Settings.SuppressBuyAugmentationConfirmation = false, Settings.SuppressBuyAugmentationConfirmation = false;
Settings.AutosaveInterval = 60; Settings.AutosaveInterval = 60;
Settings.DisableHotkeys = false; Settings.DisableHotkeys = false;
} }
@ -17664,7 +17671,7 @@ $(document).keyup(function(e) {
}) })
//Implements a tab completion feature for terminal //Implements a tab completion feature for terminal
// command - Command (first arg only) // command - Terminal command except for the last incomplete argument
// arg - Incomplete argument string that the function will try to complete, or will display // arg - Incomplete argument string that the function will try to complete, or will display
// a series of possible options for // a series of possible options for
// allPossibilities - Array of strings containing all possibilities that the // allPossibilities - Array of strings containing all possibilities that the
@ -18826,6 +18833,7 @@ let Terminal = {
var oldScript = destServer.scripts[i]; var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code; oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage; oldScript.ramUsage = sourceScript.ramUsage;
oldScript.module = "";
post(scriptname + " overwriten on " + destServer.hostname); post(scriptname + " overwriten on " + destServer.hostname);
return; return;
} }
@ -30122,7 +30130,7 @@ const Crimes = {
dexterity_exp: 60, dexterity_exp: 60,
agility_exp: 60, agility_exp: 60,
hacking_skill_success_weight: 0.5, hacking_success_weight: 0.5,
dexterity_success_weight: 1, dexterity_success_weight: 1,
agility_success_weight: 1, agility_success_weight: 1,
@ -30144,7 +30152,7 @@ const Crimes = {
dexterity_exp: 150, dexterity_exp: 150,
charisma_exp: 15, charisma_exp: 15,
hacking_skill_success_weight: 0.05, hacking_success_weight: 0.05,
dexterity_success_weight: 1.25, dexterity_success_weight: 1.25,
intelligence_exp: 2 * _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain, intelligence_exp: 2 * _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
@ -30185,7 +30193,7 @@ const Crimes = {
agility_exp: 80, agility_exp: 80,
charisma_exp: 40, charisma_exp: 40,
hacking_skill_success_weight: 1, hacking_success_weight: 1,
strength_success_weight: 1, strength_success_weight: 1,
dexterity_success_weight: 4, dexterity_success_weight: 4,
agility_success_weight: 2, agility_success_weight: 2,
@ -30232,7 +30240,7 @@ const Crimes = {
agility_exp: 450, agility_exp: 450,
charisma_exp: 450, charisma_exp: 450,
hacking_skill_success_weight: 1, hacking_success_weight: 1,
strength_success_weight: 1, strength_success_weight: 1,
defense_success_weight: 1, defense_success_weight: 1,
dexterity_success_weight: 1, dexterity_success_weight: 1,
@ -31568,6 +31576,7 @@ function NetscriptFunctions(workerScript) {
var oldScript = destServer.scripts[i]; var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code; oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage; oldScript.ramUsage = sourceScript.ramUsage;
oldScript.module = "";
return true; return true;
} }
} }
@ -53348,8 +53357,8 @@ function applySourceFile(srcFile) {
_Player__WEBPACK_IMPORTED_MODULE_0__["Player"].company_rep_mult *= incMult; _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].company_rep_mult *= incMult;
break; break;
case 12: //The testing ground case 12: //The testing ground
const inc = 1 + (srcFile.level/100); var inc = 1 + (srcFile.level/100);
const dec = 1 - (srcFile.level/100); var dec = 1 - (srcFile.level/100);
_Player__WEBPACK_IMPORTED_MODULE_0__["Player"].hacking_chance_mult *= inc; _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].hacking_chance_mult *= inc;
_Player__WEBPACK_IMPORTED_MODULE_0__["Player"].hacking_speed_mult *= inc; _Player__WEBPACK_IMPORTED_MODULE_0__["Player"].hacking_speed_mult *= inc;
@ -69587,7 +69596,9 @@ function purchaseRamForHomeComputer(cost) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
// Contains the "information" property for all the Factions, which is just a description of each faction /**
* Contains the "information" property for all the Factions, which is just a description of each faction
*/
class FactionInfo { class FactionInfo {
constructor(infoText, enemies, offerHackingMission, offerHackingWork, offerFieldWork, offerSecurityWork) { constructor(infoText, enemies, offerHackingMission, offerHackingWork, offerFieldWork, offerSecurityWork) {
this.infoText = infoText; this.infoText = infoText;
@ -69601,7 +69612,11 @@ class FactionInfo {
this.augmentationRepRequirementMult = 1; this.augmentationRepRequirementMult = 1;
} }
} }
const FactionInfos = { /**
* A map of all factions and associated info to them.
*/
// tslint:disable-next-line:variable-name
exports.FactionInfos = {
// Endgame // Endgame
Illuminati: new FactionInfo("Humanity never changes. No matter how civilized society becomes, it will eventually" + Illuminati: new FactionInfo("Humanity never changes. No matter how civilized society becomes, it will eventually" +
"fall back into chaos. And from this chaos, we are the Invisible hand that guides them to order. ", [], true, true, true, false), "fall back into chaos. And from this chaos, we are the Invisible hand that guides them to order. ", [], true, true, true, false),
@ -69713,7 +69728,6 @@ const FactionInfos = {
"faction, reputation can only be gained through Bladeburner actions. Completing " + "faction, reputation can only be gained through Bladeburner actions. Completing " +
"Bladeburner contracts/operations will increase your reputation.", [], false, false, false, false), "Bladeburner contracts/operations will increase your reputation.", [], false, false, false, false),
}; };
exports.FactionInfos = FactionInfos;
/***/ }), /***/ }),
@ -99962,8 +99976,7 @@ let NetscriptFunctions =
"getActionTime|getActionEstimatedSuccessChance|getActionCountRemaining|" + "getActionTime|getActionEstimatedSuccessChance|getActionCountRemaining|" +
"getRank|getSkillPoints|getSkillLevel|upgradeSkill|getTeamSize|" + "getRank|getSkillPoints|getSkillLevel|upgradeSkill|getTeamSize|" +
"setTeamSize|getCityEstimatedPopulation|getCityEstimatedCommunities|" + "setTeamSize|getCityEstimatedPopulation|getCityEstimatedCommunities|" +
"getCityChaos|switchCity|getStamina|joinBladeburnerFaction" "getCityChaos|switchCity|getStamina|joinBladeburnerFaction";
;
var NetscriptHighlightRules = function(options) { var NetscriptHighlightRules = function(options) {
var keywordMapper = this.createKeywordMapper({ var keywordMapper = this.createKeywordMapper({

@ -498,7 +498,12 @@ let CONSTANTS = {
"at levels 1, 2, and 3, respectively (increased from 8%, 12%, 14%)<br>" + "at levels 1, 2, and 3, respectively (increased from 8%, 12%, 14%)<br>" +
"* The effect of Source-File 12 is now additive with itself, rather than multiplicative. This means " + "* The effect of Source-File 12 is now additive with itself, rather than multiplicative. This means " +
"that level N of Source-File 12 now increases all multipliers by N%<br>" + "that level N of Source-File 12 now increases all multipliers by N%<br>" +
"* The setting to suppress the confirmation box when purchasing Augmentations was moved into the main Options menu (by Github user hydroflame)<br>" "* The setting to suppress the confirmation box when purchasing Augmentations was moved into the main Options menu (by Github user hydroflame)<br>" +
"* Bug Fix: Crime Success rates were being calculated incorrectly (by Github user hydroflame)<br>" +
"* When an Infiltration is finished, you will now return back to the company's page, rather than the city<br>" +
"* Infiltration faction reputation selector now remembers your last choice<br>" +
"* Bug Fix: Copying a NetscriptJS script to another server using scp now properly takes into account " +
"the script's changes.<br>"
} }

@ -877,6 +877,7 @@ function NetscriptFunctions(workerScript) {
var oldScript = destServer.scripts[i]; var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code; oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage; oldScript.ramUsage = sourceScript.ramUsage;
oldScript.module = "";
return true; return true;
} }
} }

@ -304,7 +304,7 @@ $(document).keyup(function(e) {
}) })
//Implements a tab completion feature for terminal //Implements a tab completion feature for terminal
// command - Command (first arg only) // command - Terminal command except for the last incomplete argument
// arg - Incomplete argument string that the function will try to complete, or will display // arg - Incomplete argument string that the function will try to complete, or will display
// a series of possible options for // a series of possible options for
// allPossibilities - Array of strings containing all possibilities that the // allPossibilities - Array of strings containing all possibilities that the
@ -1466,6 +1466,7 @@ let Terminal = {
var oldScript = destServer.scripts[i]; var oldScript = destServer.scripts[i];
oldScript.code = sourceScript.code; oldScript.code = sourceScript.code;
oldScript.ramUsage = sourceScript.ramUsage; oldScript.ramUsage = sourceScript.ramUsage;
oldScript.module = "";
post(scriptname + " overwriten on " + destServer.hostname); post(scriptname + " overwriten on " + destServer.hostname);
return; return;
} }

@ -49,14 +49,13 @@ function longestCommonStart(strings: string[]): string {
if (!containsAllStrings(strings)) {return ""; } if (!containsAllStrings(strings)) {return ""; }
if (strings.length === 0) {return ""; } if (strings.length === 0) {return ""; }
const A: string[] = strings.concat() const A: string[] = strings.concat().sort();
.sort();
const a1: string = A[0]; const a1: string = A[0];
const a2: string = A[A.length - 1]; const a2: string = A[A.length - 1];
const L: number = a1.length; const L: number = a1.length;
let i: number = 0; let i: number = 0;
const areEqualCaseInsensitive: EqualityFunc<string> = (a: string, b: string) => a.toUpperCase() === b.toUpperCase(); const areEqualCaseInsensitive: EqualityFunc<string> = (a: string, b: string) => a.toUpperCase() === b.toUpperCase();
while (i < L && areEqualCaseInsensitive(a1, a2)) { while (i < L && areEqualCaseInsensitive(a1.charAt(i), a2.charAt(i))) {
i++; i++;
} }
@ -133,7 +132,7 @@ function isHTML(str: string): boolean {
const element: HTMLDivElement = document.createElement("div"); const element: HTMLDivElement = document.createElement("div");
element.innerHTML = str; element.innerHTML = str;
const c: NodeListOf<Node & ChildNode> = element.childNodes; const c: NodeListOf<Node & ChildNode> = element.childNodes;
for (let i: number = c.length; i >= 0; i--) { for (let i: number = c.length-1; i >= 0; i--) {
if (c[i].nodeType === 1) { if (c[i].nodeType === 1) {
return true; return true;
} }