From 8a95fb4df7082fa9f73ff2e8c042bd0d4e20960b Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Wed, 21 Jun 2017 12:12:08 -0500 Subject: [PATCH] Added unalias command. Updated to v0.22.0 --- src/Alias.js | 8 +++++++ src/Company.js | 2 +- src/Constants.js | 53 +++++++++++++++++++++++------------------------ src/SaveObject.js | 2 +- src/Terminal.js | 16 +++++++++++++- src/engine.js | 1 - 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/src/Alias.js b/src/Alias.js index 7d6ad52f3..071b50bef 100644 --- a/src/Alias.js +++ b/src/Alias.js @@ -30,6 +30,14 @@ function getAlias(name) { return null; } +function removeAlias(name) { + if (Aliases.hasOwnProperty(name)) { + delete Aliases[name]; + return true; + } + return false; +} + //Returns the original string with any aliases substituted in //Aliases only applied to "whole words", one level deep function substituteAliases(origCommand) { diff --git a/src/Company.js b/src/Company.js index 3dee532c0..8d9b8ca56 100644 --- a/src/Company.js +++ b/src/Company.js @@ -46,7 +46,7 @@ Company.prototype.hasPosition = function(pos) { Company.prototype.gainFavor = function() { if (this.favor == null || this.favor == undefined) {this.favor = 0;} - this.favor += (this.playerReputation / CONSTANTS.CompanyReputationToFavor); + this.favor += Math.max(0, (this.playerReputation-1) / CONSTANTS.CompanyReputationToFavor); } Company.prototype.toJSON = function() { diff --git a/src/Constants.js b/src/Constants.js index 99963145e..a1c630252 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ CONSTANTS = { - Version: "0.21.0", + Version: "0.22.0", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -183,7 +183,8 @@ CONSTANTS = { "sudov Shows whether or not you have root access on this computer
" + "tail [script] [args...] Display dynamic logs for the script with the specified name and arguments
" + "theme [preset] | bg txt hlgt Change the color scheme of the UI
" + - "top Display all running scripts and their RAM usage
", + "top Display all running scripts and their RAM usage
" + + 'unalias "[alias name]" Deletes the specified alias. Double quotation marks are required
', /* Tutorial related things */ TutorialGettingStartedText: "Todo...", @@ -673,7 +674,8 @@ CONSTANTS = { "-New favor system for companies and factions. Earning reputation at a company/faction will give you favor for that entity when you " + "reset after installing an Augmentation. This favor persists through the rest of the game. The more favor you have, the faster you will earn " + "reputation with that faction
" + - "-You can no longer donate to a faction for reputation until you have 150 favor with that faction

" + + "-You can no longer donate to a faction for reputation until you have 150 favor with that faction
" + + "-Added unalias Terminal command

" + "v0.21.1
" + "-IF YOUR GAME BREAKS, DO THE FOLLOWING: Options -> Soft Reset -> Save Game -> Reload Page. Sorry about that!
" + "-Autocompletion for aliases - courtesy of Github user LTCNugget

" + @@ -826,28 +828,25 @@ CONSTANTS = { "-You can now see what an Augmentation does and its price even while its locked

", LatestUpdate: - "v0.21.0
" + - "-All scripts automatically killed for the sake of update compatibility
" + - "-IF YOUR GAME BREAKS, DO THE FOLLOWING: Options -> Soft Reset -> Save Game -> Reload Page. Sorry about that!
" + - "-Autocompletion for aliases - courtesy of Github user LTCNugget

" + - "-Added dynamic arrays. See Netscript documentation
" + - "-Added ability to pass arguments into scripts. See documentation
" + - "-The implementation/function signature of functions that deal with scripts have changed. Therefore, some old scripts might not " + - "work anymore. Some of these functions include run(), exec(), isRunning(), kill(), and some others I may have forgot about. " + - "Please check the updated Netscript documentation if you run into issues." + - "-Note that scripts are now uniquely identified by the script name and their arguments. For example, you can run " + - "a script using
run foodnstuff.script 1
and you can also run the same script with a different argument " + - "
run foodnstuff.script 2
These will be considered two different scripts. To kill the first script you must " + - "run
kill foodnstuff.script 1
and to kill the second you must run
kill foodnstuff.script 2
Similar concepts " + - "apply for Terminal Commands such as tail, and Netscript commands such as run(), exec(), kill(), isRunning(), etc.
" + - "-Added basic theme functionality using the 'theme' Terminal command - All credit goes to /u/0x726564646974 who implemented the awesome feature
" + - "-Optimized Script objects, which were causing save errors when the player had too many scripts
" + - "-Formula for determining exp gained from hacking was changed
" + - "-Fixed bug where you could purchase Darkweb items without TOR router
" + - "-Slightly increased cost multiplier for Home Computer RAM
" + - "-Fixed bug where you could hack too much money from a server (and bring its money available below zero)
" + - "-Changed tail command so that it brings up a display box with dynamic log contents. To get " + - "old functionality where the logs are printed to the Terminal, use the new 'check' command
" + - "-As a result of the change above, you can no longer call tail/check on scripts that are not running
" + - "-Added autocompletion for buying Programs in Darkweb
", + "v0.22.0 - Major rebalancing, optimization, and favor system
" + + "-Significantly nerfed most augmentations
" + + "-Almost every server with a required hacking level of 200 or more now has slightly randomized server parameters. This means that after every Augmentation " + + "purchase, the required hacking level, base security level, and growth factor of these servers will all be slightly different
" + + "-The hacking speed multiplier now increases rather than decreases. The hacking time is now divided by your hacking speed " + + "multiplier rather than multiplied. In other words, a higher hacking speed multiplier is better
" + + "-Servers now have a minimum server security, which is approximately one third of their starting ('base') server security
" + + "-If you do not steal any money from a server, then you gain hacking experience equal to the amount you would have gained " + + "had you failed the hack
" + + "-The effects of grow() were increased by 50%
" + + "-grow() and weaken() now give hacking experience based on the server's base security level, rather than a flat exp amount
" + + "-Slightly reduced amount of exp gained from hack(), weaken(), and grow()
" + + "-Rebalanced formulas that determine crime success
" + + "-Reduced RAM cost for multithreading a script. The RAM multiplier for each thread was reduced from 1.02 to 1.005
" + + "-Optimized Script objects so they take less space in the save file
" + + "-Added getServerBaseSecurityLevel() Netscript function
" + + "-New favor system for companies and factions. Earning reputation at a company/faction will give you favor for that entity when you " + + "reset after installing an Augmentation. This favor persists through the rest of the game. The more favor you have, the faster you will earn " + + "reputation with that faction
" + + "-You can no longer donate to a faction for reputation until you have 150 favor with that faction
" + + "-Added unalias Terminal command

", } diff --git a/src/SaveObject.js b/src/SaveObject.js index e2d600d82..9fd3f99fc 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -83,7 +83,7 @@ loadGame = function(saveObj) { try { var ver = JSON.parse(saveObj.VersionSave, Reviver); if (ver != CONSTANTS.Version) { - if (CONSTANTS.Version == "0.21.0") { + if (CONSTANTS.Version == "0.21.0" || CONSTANTS.Version == "0.22.0") { dialogBoxCreate("All scripts automatically killed for the sake of compatibility " + "with new version. If the game is still broken, try the following: " + "Options -> Soft Reset -> Save Game -> Reload page. If that STILL " + diff --git a/src/Terminal.js b/src/Terminal.js index 6d1c56dc4..490e34bab 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -585,7 +585,6 @@ var Terminal = { } else { post('Incorrect usage of alias command. Usage: alias [aliasname="value"]'); return; } - break; case "analyze": if (commandArray.length != 1) { @@ -1041,6 +1040,21 @@ var Terminal = { //TODO List each's script RAM usage post("Not yet implemented"); break; + case "unalias": + if (commandArray.length != 2) { + post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); + return; + } else if (!(commandArray[1].startsWith('"') && commandArray[1].endsWith('"'))) { + post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); + } else { + var alias = commandArray[1].slice(1, -1); + if (removeAlias(alias)) { + post("Removed alias " + alias); + } else { + post("No such alias exists"); + } + } + break; default: post("Command not found"); } diff --git a/src/engine.js b/src/engine.js index 117cd03ce..92b7cf255 100644 --- a/src/engine.js +++ b/src/engine.js @@ -357,7 +357,6 @@ var Engine = { aElem.setAttribute("class", "a-link-button"); aElem.innerHTML = factionName; aElem.addEventListener("click", function() { - console.log("factionName:" + factionName) Engine.loadFactionContent(); displayFactionContent(factionName); return false;