From 94dd4395becaba03b3822be465bb374b23a0e6d9 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Thu, 1 Jun 2017 23:15:45 -0500 Subject: [PATCH] Adding messages. Changed hacking factions to rely on hacking their specific servers to get the invite. Made Augmentations more expensive --- index.html | 1 + src/Augmentations.js | 2 +- src/Constants.js | 4 +- src/CreateProgram.js | 1 + src/Faction.js | 33 +++++--- src/Message.js | 153 ++++++++++++++++++++++++++++++++++++++ src/NetscriptEvaluator.js | 7 -- src/SaveObject.js | 12 ++- src/Server.js | 45 ++++++++--- src/SpecialServerIps.js | 11 ++- src/Terminal.js | 48 +++++++++--- src/engine.js | 10 ++- utils/HelperFunctions.js | 4 + 13 files changed, 287 insertions(+), 44 deletions(-) create mode 100644 src/Message.js diff --git a/index.html b/index.html index b548e2270..3582addb8 100644 --- a/index.html +++ b/index.html @@ -57,6 +57,7 @@ + diff --git a/src/Augmentations.js b/src/Augmentations.js index 7f2ca824a..d23ebfb53 100644 --- a/src/Augmentations.js +++ b/src/Augmentations.js @@ -18,7 +18,7 @@ Augmentation.prototype.setInfo = function(inf) { } Augmentation.prototype.setRequirements = function(rep, cost) { - this.baseRepRequirement = rep; + this.baseRepRequirement = rep * CONSTANTS.AugmentationRepMultiplier; this.baseCost = cost * CONSTANTS.AugmentationCostMultiplier; } diff --git a/src/Constants.js b/src/Constants.js index 1f21a026a..e0334e283 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -70,7 +70,8 @@ CONSTANTS = { ServerWeakenAmount: 0.1, //Amount by which server's security decreases when weakened //Augmentation Constants - AugmentationCostMultiplier: 3, //Used for balancing costs without having to readjust every Augmentation cost + AugmentationCostMultiplier: 4, //Used for balancing costs without having to readjust every Augmentation cost + AugmentationRepMultiplier: 1.2, //Used for balancing rep cost without having to readjust every value //Maximum number of log entries for a script MaxLogCapacity: 40, @@ -147,6 +148,7 @@ CONSTANTS = { //Text that is displayed when the 'help' command is ran in Terminal HelpText: 'alias [name="value"] Create aliases for Terminal commands, or list existing aliases
' + "analyze Get statistics and information about current machine
" + + "cat [message] Display a .msg file
" + "clear Clear all text on the terminal
" + "cls See 'clear' command
" + "connect [ip/hostname] Connects to the machine given by its IP or hostname
" + diff --git a/src/CreateProgram.js b/src/CreateProgram.js index e8026f0c6..e2ec91e3b 100644 --- a/src/CreateProgram.js +++ b/src/CreateProgram.js @@ -8,6 +8,7 @@ Programs = { SQLInjectProgram: "SQLInject.exe", DeepscanV1: "DeepscanV1.exe", DeepscanV2: "DeepscanV2.exe", + Flight: "fl1ght.exe", } //TODO Right now the times needed to complete work are hard-coded... diff --git a/src/Faction.js b/src/Faction.js index c46e13401..eb8f775b0 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -290,12 +290,12 @@ PlayerObject.prototype.checkForFactionInvitations = function() { //Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company var fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"]; - var fulcrumSecretServer = AllServers[SpecialServerIps["Fulcrum Secret Technologies Server"]]; + var fulcrumSecretServer = AllServers[SpecialServerIps[SpecialServerNames.FulcrumSecretTechnologies]]; if (fulcrumSecretServer == null) { - console.log("Error: Could not find Fulcrum Secret Technologies Server"); + console.log("ERROR: Could not find Fulcrum Secret Technologies Server"); } else { if (fulcrumsecrettechonologiesFac.isBanned == false && fulcrumsecrettechonologiesFac.isMember == false && - fulcrumSecretServer.hasAdminRights && + fulcrumSecretServer.manuallyHacked && this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) { invitedFactions.push(fulcrumsecrettechonologiesFac); } @@ -303,23 +303,31 @@ PlayerObject.prototype.checkForFactionInvitations = function() { //BitRunners var bitrunnersFac = Factions["BitRunners"]; - var homeComp = Player.getHomeComputer(); - if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false && - this.hacking_skill >= 500 && homeComp.maxRam >= 128) { + var homeComp = this.getHomeComputer(); + var bitrunnersServer = AllServers[SpecialServerIps[SpecialServerNames.BitRunnersServer]]; + if (bitrunnersServer == null) { + console.log("ERROR: Could not find BitRunners Server"); + } else if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false && bitrunnersServer.manuallyHacked && + this.hacking_skill >= 500 && homeComp.maxRam >= 128) { invitedFactions.push(bitrunnersFac); } //The Black Hand var theblackhandFac = Factions["The Black Hand"]; - if (theblackhandFac.isBanned == false && theblackhandFac.isMember == false && - this.hacking_skill >= 300 && this.strength >= 100 && this.defense >= 100 && - this.agility >= 100 && this.dexterity >= 100 && homeComp.maxRam >= 64) { + var blackhandServer = AllServers[SpecialServerIps[SpecialServerNames.TheBlackHandServer]]; + if (blackhandServer == null) { + console.log("ERROR: Could not find The Black Hand Server"); + } else if (!theblackhandFac.isBanned && !theblackhandFac.isMember && blackhandServer.manuallyHacked && + this.hacking_skill >= 350 && homeComp.maxRam >= 64) { invitedFactions.push(theblackhandFac); } //NiteSec var nitesecFac = Factions["NiteSec"]; - if (nitesecFac.isBanned == false && nitesecFac.isMember == false && + var nitesecServer = AllServers[SpecialServerIps[SpecialServerNames.NiteSecServer]]; + if (nitesecServer == null) { + console.log("ERROR: Could not find NiteSec Server"); + } else if (!nitesecFac.isBanned && !nitesecFac.isMember && nitesecServer.manuallyHacked && this.hacking_skill >= 200 && homeComp.maxRam >= 32) { invitedFactions.push(nitesecFac); } @@ -451,7 +459,10 @@ PlayerObject.prototype.checkForFactionInvitations = function() { //CyberSec var cybersecFac = Factions["CyberSec"]; - if (cybersecFac.isBanned == false && cybersecFac.isMember == false && + var cybersecServer = AllServers[SpecialServerIps[SpecialServerNames.CyberSecServer]]; + if (cybersecServer == null) { + console.log("ERROR: Could not find CyberSec Server"); + } else if (!cybersecFac.isBanned && !cybersecFac.isMember && cybersecServer.manuallyHacked && this.hacking_skill >= 50) { invitedFactions.push(cybersecFac); } diff --git a/src/Message.js b/src/Message.js new file mode 100644 index 000000000..f0a7e1182 --- /dev/null +++ b/src/Message.js @@ -0,0 +1,153 @@ +/* Message.js */ +function Message(filename, msg) { + this.filename = filename; + this.msg = msg; + this.recvd = false; +} + +Message.prototype.toJSON = function() { + return Generic_toJSON("Message", this); +} + + +Message.fromJSON = function(value) { + return Generic_fromJSON(Message, value.data); +} + +Reviver.constructors.Message = Message; + +//Sends message to player, including a pop up +function sendMessage(msg) { + console.log("sending message: " + msg.filename); + msg.recvd = true; + showMessage(msg); + addMessageToServer(msg, "home"); +} + +function showMessage(msg) { + var txt = "Message received from unknown sender:

" + + "" + msg.msg + "

" + + "This message was saved as " + msg.filename + " onto your home computer."; + dialogBoxCreate(txt); +} + +//Adds a message to a server +function addMessageToServer(msg, serverHostname) { + var server = GetServerByHostname(serverHostname); + if (server == null) { + console.log("WARNING: Did not locate " + serverHostname); + return; + } + server.messages.push(msg); +} + +//Checks if any of the 'timed' messages should be sent +function checkForMessagesToSend() { + console.log("checkForMessagesToSend() called"); + var jumper0 = Messages[MessageFilenames.Jumper0]; + var jumper1 = Messages[MessageFilenames.Jumper1]; + var jumper2 = Messages[MessageFilenames.Jumper2]; + var jumper3 = Messages[MessageFilenames.Jumper3]; + var jumper4 = Messages[MessageFilenames.Jumper4]; + var jumper5 = Messages[MessageFilenames.Jumper5]; + var cybersecTest = Messages[MessageFilenames.CyberSecTest]; + var nitesecTest = Messages[MessageFilenames.NiteSecTest]; + var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest]; + + if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) { + sendMessage(jumper0); + } else if (jumper1 && !jumper1.recvd && Player.hacking_skill >= 40) { + sendMessage(jumper1); + } else if (cybersecTest && !cybersecTest.recvd && Player.hacking_skill >= 50) { + sendMessage(cybersecTest); + } else if (jumper2 && !jumper2.recvd && Player.hacking_skill >= 175) { + sendMessage(jumper2); + } else if (nitesecTest && !nitesecTest.recvd && Player.hacking_skill >= 200) { + sendMessage(nitesecTest); + } else if (jumper3 && !jumper3.recvd && Player.hacking_skill >= 350) { + sendMessage(jumper3); + } else if (jumper4 && !jumper4.recvd && Player.hacking_skill >= 490) { + sendMessage(jumper4); + } else if (bitrunnersTest && !bitrunnersTest.recvd && Player.hacking_skill >= 500) { + sendMessage(bitrunnersTest); + Player.getHomeComputer.programs.push(Programs.Flight); + } if (!jumper5 && !jumper5.recvd && Player.hacking_skill >= 900) { + sendMessage(jumper5); + } +} + +function AddToAllMessages(msg) { + Messages[msg.filename] = msg; +} + +Messages = {} + +MessageFilenames = { + Jumper0: "j0.msg", + Jumper1: "j1.msg", + Jumper2: "j2.msg", + Jumper3: "j3.msg", + Jumper4: "j4.msg", + Jumper5: "j4.msg", + CyberSecTest: "csec-test.msg", + NiteSecTest: "nitesec-test.msg", + BitRunnersTest: "19dfj3l1nd.msg", +} + +function initMessages() { + //Reset + Messages = {}; + + //jump3R Messages + AddToAllMessages(new Message(MessageFilenames.Jumper0, + "I know you can sense it. I know you're searching for it. " + + "It's why you spend night after " + + "night at your computer.

It's real, I've seen it. And I can " + + "help you find it. But not right now. You're not ready yet. Keep searching, " + + "but don't fly too close to the sun.

-jump3R")); + AddToAllMessages(new Message(MessageFilenames.Jumper1, + "Soon you will be contacted by a hacking group known as CyberSec. " + + "They can help you with your search.

" + + "You should join them, garner their favor, and " + + "exploit them for their Augmentations. But do not trust them. " + + "They are not what they seem. No one is.

" + + "-jump3R")); + AddToAllMessages(new Message(MessageFilenames.Jumper2, + "Do not try to save the world. There is no world to save. If " + + "you want to find the truth, worry only about yourself. Ethics and " + + "morals will get you killed.

Watch out for a hacking group known as NiteSec." + + "

-jump3R")); + AddToAllMessages(new Message(MessageFilenames.Jumper3, + "You must learn to walk before you can run. And you must " + + "run before you can fly. Look for the black hand.

" + + "I.I.I.I

-jump3R")); + AddToAllMessages(new Message(MessageFilenames.Jumper4, + "To find what you are searching for, you must understand the bits. " + + "The bits are all around us. The runners will help you.

" + + "-jump3R")); + AddToAllMessages(new Message(MessageFilenames.Jumper5, + "Build your wings and fly

-jump3R

" + + "The fl1ght.exe program was added to your home computer")); + + //Messages from hacking factions + AddToAllMessages(new Message(MessageFilenames.CyberSecTest, + "We've been watching you. Your skills are very impressive. But you're wasting " + + "your talents. If you join us, you can put your skills to good use and change " + + "the world for the better. If you join us, we can unlock your full potential.

" + + "But first, you must pass our test. Find and hack our server using the Terminal.

" + + "-CyberSec")); + AddToAllMessages(new Message(MessageFilenames.NiteSecTest, + "People say that the corrupted governments and corporations rule the world. " + + "Yes, maybe they do. But do you know who everyone really fears? People " + + "like us. Because they can't hide from us. Because they can't fight shadows " + + "and ideas with bullets.

" + + "Join us, and people will fear you, too.

" + + "Find and hack our hidden server using the Terminal. Then, we will contact you again." + + "

-NiteSec")); + AddToAllMessages(new Message(MessageFilenames.BitRunnersTest, + "We know what you are doing. We know what drives you. We know " + + "what you are looking for.

" + + "We can help you find the answers.

" + + "run4theh111z")); + +} \ No newline at end of file diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 39715be5b..2bb27c7a3 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -120,7 +120,6 @@ function evaluate(exp, workerScript) { var numConds = exp.cond.length; var numThens = exp.then.length; if (numConds == 0 || numThens == 0 || numConds != numThens) { - console.log("Number of ifs and conds dont match. Rejecting"); reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Number of conds and thens in if structure don't match (or there are none)"); } @@ -128,20 +127,17 @@ function evaluate(exp, workerScript) { evalIfPromise.then(function(res) { if (res) { //One of the if/elif statements evaluated to true - console.log("done with if"); resolve("if statement done"); } else { //None of the if/elif statements were true. Evaluate else if there is one if (exp.else) { var elseEval = evaluate(exp.else, workerScript); elseEval.then(function(res) { - console.log("if statement done with else"); resolve("if statement done with else"); }, function(e) { reject(e); }); } else { - console.log("no else statement, resolving"); resolve("if statement done"); } } @@ -960,12 +956,9 @@ function evaluateIf(exp, workerScript, i) { } else { var cond = evaluate(exp.cond[i], workerScript); cond.then(function(condRes) { - console.log("cond evaluated to: " + condRes); if (condRes) { - console.log("Evaluating then: " + exp.then[i]); var evalThen = evaluate(exp.then[i], workerScript); evalThen.then(function(res) { - console.log("If statement done"); resolve(true); }, function(e) { reject(e); diff --git a/src/SaveObject.js b/src/SaveObject.js index b22dfecb5..998c4d809 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -11,6 +11,7 @@ function BitburnerSaveObject() { this.SpecialServerIpsSave = ""; this.AugmentationsSave = ""; this.AliasesSave = ""; + this.MessagesSave = ""; } BitburnerSaveObject.prototype.saveGame = function() { @@ -21,6 +22,7 @@ BitburnerSaveObject.prototype.saveGame = function() { this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps); this.AugmentationsSave = JSON.stringify(Augmentations); this.AliasesSave = JSON.stringify(Aliases); + this.MessagesSave = JSON.stringify(Messages); var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this)))); window.localStorage.setItem("bitburnerSave", saveString); @@ -52,7 +54,15 @@ loadGame = function(saveObj) { } else { Aliases = {}; } - + if (saveObj.hasOwnProperty("MessagesSave")) { + try { + Messages = JSON.parse(saveObj.MessagesSave, Reviver); + } catch(e) { + initMessages(); + } + } else { + initMessages(); + } return true; } diff --git a/src/Server.js b/src/Server.js index 780212254..afc02c305 100644 --- a/src/Server.js +++ b/src/Server.js @@ -13,6 +13,7 @@ function Server() { //Access information this.hasAdminRights = false; //Whether player has admin rights this.purchasedByPlayer = false; + this.manuallyHacked = false; //Flag that tracks whether or not the server has been hacked at least once //RAM, CPU speed and Scripts this.maxRam = 1; //GB @@ -131,8 +132,6 @@ Server.fromJSON = function(value) { Reviver.constructors.Server = Server; -//world_daemon: new Server(), //Final server for 2nd tier prestige. Discover that the world is a simulation - initForeignServers = function() { //MegaCorporations var ECorpServer = new Server(); @@ -201,8 +200,7 @@ initForeignServers = function() { FulcrumSecretTechnologiesServer.setHackingParameters(999, 1000000, 99, 1); FulcrumSecretTechnologiesServer.setPortProperties(5); AddToAllServers(FulcrumSecretTechnologiesServer); - - SpecialServerIps.addIp("Fulcrum Secret Technologies Server", FulcrumSecretTechnologiesServer.ip); + SpecialServerIps.addIp(SpecialServerNames.FulcrumSecretTechnologies, FulcrumSecretTechnologiesServer.ip); var StormTechnologiesServer = new Server(); StormTechnologiesServer.init(createRandomIp(), "stormtech", "Storm Technologies", true, false, false, false, 0); @@ -519,47 +517,72 @@ initForeignServers = function() { //Faction servers, cannot hack money from these var BitRunnersServer = new Server(); BitRunnersServer.init(createRandomIp(), "run4theh111z", "The Runners", true, false, false, false, 0); + BitRunnersServer.setHackingParameters(getRandomInt(505, 550), 0, 0, 0); BitRunnersServer.setPortProperties(4); AddToAllServers(BitRunnersServer); + SpecialServerIps.addIp(SpecialServerNames.BitRunnersServer, BitRunnersServer.ip); var TheBlackHandServer = new Server(); TheBlackHandServer.init(createRandomIp(), "I.I.I.I", "I.I.I.I", true, false, false, false, false, 0); + TheBlackHandServer.setHackingParameters(getRandomInt(305, 350), 0, 0, 0); TheBlackHandServer.setPortProperties(3); AddToAllServers(TheBlackHandServer); + SpecialServerIps.addIp(SpecialServerNames.TheBlackHandServer, TheBlackHandServer.ip); var NiteSecServer = new Server(); NiteSecServer.init(createRandomIp(), "avmnite-02h", "NiteSec", true, false, false, false, 0); + NiteSecServer.setHackingParameters(getRandomInt(202, 230), 0, 0, 0); NiteSecServer.setPortProperties(2); AddToAllServers(NiteSecServer); + SpecialServerIps.addIp(SpecialServerNames.NiteSecServer, NiteSecServer.ip); var DarkArmyServer = new Server(); DarkArmyServer.init(createRandomIp(), ".", ".", true, false, false, false, 0); - DarkArmyServer.setPortProperties(5); + DarkArmyServer.setHackingParameters(getRandomInt(505, 550), 0, 0, 0); + DarkArmyServer.setPortProperties(4); AddToAllServers(DarkArmyServer); + SpecialServerIps.addIp(SpecialServerNames.TheDarkArmyServer, DarkArmyServer.ip); var CyberSecServer = new Server(); CyberSecServer.init(createRandomIp(), "CSEC", "CyberSec", true, false, false, false, 0); - CyberSecServer.setPortProperties(2); + CyberSecServer.setHackingParameters(getRandomInt(51, 60), 0, 0, 0); + CyberSecServer.setPortProperties(1); AddToAllServers(CyberSecServer); + SpecialServerIps.addIp(SpecialServerNames.CyberSecServer, CyberSecServer.ip); + + var DaedalusServer = new Server(); + DaedalusServer.init(createRandomIp(), "Icarus", "Icarus", true, false, false, false, 0); + DaedalusServer.setHackingParameters(925, 0, 0, 0); + DaedalusServer.setPortProperties(5); + AddToAllServers(DaedalusServer); + SpecialServerIps.addIp(SpecialServerNames.DaedalusServer, DaedalusServer.ip); + + //Super special Servers + var WorldDaemon = new Server(); + WorldDaemon.init(createRandomIp(), SpecialServerNames.WorldDaemon, SpecialServerNames.WorldDaemon, true, false, false, false, 0); + WorldDaemon.setHackingParameters(950, 0, 0, 0); + WorldDaemon.setPortProperties(5); + AddToAllServers(WorldDaemon); + SpecialServerIps.addIp(SpecialServerNames.WorldDaemon, WorldDaemon.ip); /* Create a randomized network for all the foreign servers */ //Groupings for creating a randomized network var NetworkGroup1 = [IronGymServer, FoodNStuffServer, SigmaCosmeticsServer, JoesGunsServer, HongFangTeaHouseServer, HaraKiriSushiBarServer]; - var NetworkGroup2 = [MaxHardwareServer, NectarNightclubServer, Zer0NightclubServer]; + var NetworkGroup2 = [MaxHardwareServer, NectarNightclubServer, Zer0NightclubServer, CyberSecServer]; var NetworkGroup3 = [OmegaSoftwareServer, PhantasyServer, SilverHelixServer, NeoNightclubServer]; - var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer]; - var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer]; + var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer, NiteSecServer]; + var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer, TheBlackHandServer]; var NetworkGroup6 = [LexoCorpServer, RhoConstructionServer, AlphaEnterprisesServer, AevumPoliceServer, MilleniumFitnessGymServer, CyberSecServer, NiteSecServer]; var NetworkGroup7 = [GlobalPharmaceuticalsServer, AeroCorpServer, GalacticCyberSystemsServer, SnapFitnessGymServer]; - var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer]; + var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer, BitRunnersServer]; var NetworkGroup9 = [ZeusMedicalServer, SolarisSpaceSystemsServer, UniversalEnergyServer, IcarusMicrosystemsServer, DefCommServer]; var NetworkGroup10 = [NovaMedicalServer, ZBDefenseServer, TaiYangDigitalServer, InfoCommServer]; var NetworkGroup11 = [AppliedEnergeticsServer, MicrodyneTechnologiesServer, TitanLabsServer, BitRunnersServer]; var NetworkGroup12 = [VitaLifeServer, HeliosLabsServer, StormTechnologiesServer, FulcrumTechnologiesServer]; var NetworkGroup13 = [KuaiGongInternationalServer, FourSigmaServer, OmniTekIncorporatedServer, DarkArmyServer]; var NetworkGroup14 = [PowerhouseGymServer, ClarkeIncorporatedServer, NWOServer, BladeIndustriesServer, BachmanAndAssociatesServer]; - var NetworkGroup15 = [FulcrumSecretTechnologiesServer, MegaCorpServer, ECorpServer]; + var NetworkGroup15 = [FulcrumSecretTechnologiesServer, MegaCorpServer, ECorpServer, DaedalusServer]; for (var i = 0; i < NetworkGroup2.length; i++) { var randomServerFromPrevGroup = NetworkGroup1[Math.floor(Math.random() * NetworkGroup1.length)]; diff --git a/src/SpecialServerIps.js b/src/SpecialServerIps.js index 01f5f02e2..c5d760d04 100644 --- a/src/SpecialServerIps.js +++ b/src/SpecialServerIps.js @@ -1,6 +1,15 @@ /* Holds IP of Special Servers */ -function SpecialServerIpsMap() { +SpecialServerNames = { + FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server", + CyberSecServer: "CyberSec Server", + NiteSecServer: "NiteSec Server", + TheBlackHandServer: "The Black Hand Server", + BitRunnersServer: "BitRunners Server", + TheDarkArmyServer: "The Dark Army Server", + DaedalusServer: "Daedalus Server", + WorldDaemon: "w0r1d_d43m0n", } +function SpecialServerIpsMap() {} SpecialServerIpsMap.prototype.addIp = function(name, ip) { this[name] = ip; diff --git a/src/Terminal.js b/src/Terminal.js index ef9cb7d84..a0ac0cdde 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -250,6 +250,13 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) { } return allPos; } + + if (input.startsWith("cat ")) { + for (var i = 0; i < currServ.messages.length; ++i) { + allPos.push(currServ.messages[i].filename); + } + return allPos; + } return allPos; } @@ -272,7 +279,8 @@ var Terminal = { //Complete the hack/analyze command finishHack: function(cancelled = false) { if (cancelled == false) { - console.log("Hack done. Determining success/failure of hack. Re-enabling terminal and changing the id of the hack progress bar"); + var server = Player.getCurrentServer(); + server.manuallyHacked = true; //Calculate whether hack was successful var hackChance = Player.calculateHackingChance(); @@ -282,23 +290,23 @@ var Terminal = { var expGainedOnFailure = (expGainedOnSuccess / 4); if (rand < hackChance) { //Success! var moneyGained = Player.calculatePercentMoneyHacked(); - moneyGained = Math.floor(Player.getCurrentServer().moneyAvailable * moneyGained); + moneyGained = Math.floor(server.moneyAvailable * moneyGained); //Safety check if (moneyGained <= 0) {moneyGained = 0;} - Player.getCurrentServer().moneyAvailable -= moneyGained; + server.moneyAvailable -= moneyGained; Player.gainMoney(moneyGained); Player.gainHackingExp(expGainedOnSuccess) - Player.getCurrentServer().fortify(CONSTANTS.ServerFortifyAmount); + server.fortify(CONSTANTS.ServerFortifyAmount); post("Hack successful! Gained $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " hacking EXP"); } else { //Failure //Player only gains 25% exp for failure? TODO Can change this later to balance Player.gainHackingExp(expGainedOnFailure) - post("Failed to hack " + Player.getCurrentServer().hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " hacking EXP"); + post("Failed to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " hacking EXP"); } } @@ -550,6 +558,24 @@ var Terminal = { break; case "buy": executeDarkwebTerminalCommand(commandArray); + break; + case "cat": + if (commandArray.length != 2) { + post("Incorrect usage of cat command. Usage: cat [message]"); return; + } + var filename = commandArray[1]; + //Can only edit script files + if (filename.endsWith(".msg") == false) { + post("Error: Only .msg files are viewable with cat (filename must end with .msg)"); return; + } + var s = Player.getCurrentServer(); + for (var i = 0; i < s.messages.length; ++i) { + if (s.messages[i].filename == filename) { + showMessage(s.messages[i]); + return; + } + } + post("Error: No such file " + filename); break; case "clear": case "cls": @@ -877,11 +903,15 @@ var Terminal = { var allFiles = []; //Get all of the programs and scripts on the machine into one temporary array - for (var i = 0; i < Player.getCurrentServer().programs.length; i++) { - allFiles.push(Player.getCurrentServer().programs[i]); + var s = Player.getCurrentServer(); + for (var i = 0; i < s.programs.length; i++) { + allFiles.push(s.programs[i]); } - for (var i = 0; i < Player.getCurrentServer().scripts.length; i++) { - allFiles.push(Player.getCurrentServer().scripts[i].filename); + for (var i = 0; i < s.scripts.length; i++) { + allFiles.push(s.scripts[i].filename); + } + for (var i = 0; i < s.messages.length; i++) { + allFiles.push(s.messages[i].filename); } //Sort the files alphabetically then print each diff --git a/src/engine.js b/src/engine.js index 2b09572e9..e011efdaa 100644 --- a/src/engine.js +++ b/src/engine.js @@ -602,8 +602,9 @@ var Engine = { updateDisplays: 3, //Update displays such as Active Scripts display and character display createProgramNotifications: 10, //Checks whether any programs can be created and notifies serverGrowth: 450, //Process server growth every minute and a half - checkFactionInvitations: 1000, //Check whether you qualify for any faction invitations every 5 minutes + checkFactionInvitations: 250, //Check whether you qualify for any faction invitations every 5 minutes passiveFactionGrowth: 600, + messages: 300, }, decrementAllCounters: function(numCycles = 1) { @@ -667,7 +668,7 @@ var Engine = { var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)]; inviteToFaction(randFaction); } - Engine.Counters.checkFactionInvitations = 1000; + Engine.Counters.checkFactionInvitations = 250; } if (Engine.Counters.passiveFactionGrowth <= 0) { @@ -675,6 +676,11 @@ var Engine = { processPassiveFactionRepGain(adjustedCycles); Engine.Counters.passiveFactionGrowth = 600; } + + if (Engine.Counters.messages <= 0) { + checkForMessagesToSend(); + Engine.Counters.messages = 300; + } }, /* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */ diff --git a/utils/HelperFunctions.js b/utils/HelperFunctions.js index 8470dfc9d..09fdee6b3 100644 --- a/utils/HelperFunctions.js +++ b/utils/HelperFunctions.js @@ -28,4 +28,8 @@ function clearEventListeners(elemId) { var newElem = elem.cloneNode(true); elem.parentNode.replaceChild(newElem, elem); return newElem; +} + +function getRandomInt(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; } \ No newline at end of file