2017-08-30 19:44:29 +02:00
|
|
|
import {Augmentations, Augmentation,
|
|
|
|
AugmentationNames} from "./Augmentations.js";
|
|
|
|
import {Programs} from "./CreateProgram.js";
|
|
|
|
import {Player} from "./Player.js";
|
|
|
|
import {GetServerByHostname} from "./Server.js";
|
|
|
|
import {Settings} from "./Settings.js";
|
2017-09-19 20:38:03 +02:00
|
|
|
import {dialogBoxCreate, dialogBoxOpened} from "../utils/DialogBox.js";
|
2017-08-30 19:44:29 +02:00
|
|
|
import {Reviver, Generic_toJSON,
|
|
|
|
Generic_fromJSON} from "../utils/JSONReviver.js";
|
|
|
|
|
2017-06-02 06:15:45 +02:00
|
|
|
/* Message.js */
|
2017-08-13 07:01:33 +02:00
|
|
|
function Message(filename="", msg="") {
|
2017-06-02 06:15:45 +02:00
|
|
|
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
|
2017-09-19 20:38:03 +02:00
|
|
|
function sendMessage(msg, forced=false) {
|
2017-06-02 06:15:45 +02:00
|
|
|
console.log("sending message: " + msg.filename);
|
|
|
|
msg.recvd = true;
|
2017-09-19 20:38:03 +02:00
|
|
|
if (forced || !Settings.SuppressMessages) {
|
2017-07-27 04:56:14 +02:00
|
|
|
showMessage(msg);
|
|
|
|
}
|
2017-06-02 06:15:45 +02:00
|
|
|
addMessageToServer(msg, "home");
|
|
|
|
}
|
|
|
|
|
|
|
|
function showMessage(msg) {
|
2017-07-27 04:56:14 +02:00
|
|
|
var txt = "Message received from unknown sender: <br><br>" +
|
|
|
|
"<i>" + msg.msg + "</i><br><br>" +
|
2017-06-02 06:15:45 +02:00
|
|
|
"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;
|
|
|
|
}
|
2017-09-19 20:38:03 +02:00
|
|
|
for (var i = 0; i < server.messages.length; ++i) {
|
|
|
|
if (server.messages[i].filename === msg.filename) {
|
|
|
|
return; //Already exists
|
|
|
|
}
|
|
|
|
}
|
2017-06-02 06:15:45 +02:00
|
|
|
server.messages.push(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Checks if any of the 'timed' messages should be sent
|
|
|
|
function checkForMessagesToSend() {
|
|
|
|
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 cybersecTest = Messages[MessageFilenames.CyberSecTest];
|
|
|
|
var nitesecTest = Messages[MessageFilenames.NiteSecTest];
|
|
|
|
var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
|
2017-07-22 00:54:55 +02:00
|
|
|
var redpill = Messages[MessageFilenames.RedPill];
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
var redpillOwned = false;
|
|
|
|
if (Augmentations[AugmentationNames.TheRedPill].owned) {
|
|
|
|
redpillOwned = true;
|
|
|
|
}
|
|
|
|
|
2017-09-19 20:38:03 +02:00
|
|
|
if (redpill && redpillOwned) {
|
|
|
|
if (!dialogBoxOpened) {
|
|
|
|
sendMessage(redpill, true);
|
|
|
|
}
|
|
|
|
} else if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) {
|
2017-06-02 06:15:45 +02:00
|
|
|
sendMessage(jumper0);
|
2017-09-13 16:22:22 +02:00
|
|
|
Player.getHomeComputer().programs.push(Programs.Flight);
|
2017-06-02 06:15:45 +02:00
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function AddToAllMessages(msg) {
|
|
|
|
Messages[msg.filename] = msg;
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
let Messages = {}
|
2017-06-02 06:15:45 +02:00
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function loadMessages(saveString) {
|
|
|
|
Messages = JSON.parse(saveString, Reviver);
|
|
|
|
}
|
|
|
|
|
|
|
|
let MessageFilenames = {
|
2017-06-02 06:15:45 +02:00
|
|
|
Jumper0: "j0.msg",
|
|
|
|
Jumper1: "j1.msg",
|
|
|
|
Jumper2: "j2.msg",
|
|
|
|
Jumper3: "j3.msg",
|
|
|
|
Jumper4: "j4.msg",
|
|
|
|
CyberSecTest: "csec-test.msg",
|
|
|
|
NiteSecTest: "nitesec-test.msg",
|
|
|
|
BitRunnersTest: "19dfj3l1nd.msg",
|
2017-07-22 00:54:55 +02:00
|
|
|
RedPill: "icarus.msg",
|
2017-06-02 06:15:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function initMessages() {
|
|
|
|
//Reset
|
|
|
|
Messages = {};
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-06-02 06:15:45 +02:00
|
|
|
//jump3R Messages
|
|
|
|
AddToAllMessages(new Message(MessageFilenames.Jumper0,
|
2017-07-27 04:56:14 +02:00
|
|
|
"I know you can sense it. I know you're searching for it. " +
|
|
|
|
"It's why you spend night after " +
|
|
|
|
"night at your computer. <br><br>It's real, I've seen it. And I can " +
|
2017-09-13 16:22:22 +02:00
|
|
|
"help you find it. But not right now. You're not ready yet.<br><br>" +
|
|
|
|
"Use this program to track your progress<br><br>" +
|
|
|
|
"The fl1ght.exe program was added to your home computer<br><br>" +
|
|
|
|
"-jump3R"));
|
2017-06-02 06:15:45 +02:00
|
|
|
AddToAllMessages(new Message(MessageFilenames.Jumper1,
|
|
|
|
"Soon you will be contacted by a hacking group known as CyberSec. " +
|
|
|
|
"They can help you with your search. <br><br>" +
|
2017-07-27 04:56:14 +02:00
|
|
|
"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.<br><br>" +
|
2017-06-02 06:15:45 +02:00
|
|
|
"-jump3R"));
|
|
|
|
AddToAllMessages(new Message(MessageFilenames.Jumper2,
|
2017-07-27 04:56:14 +02:00
|
|
|
"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. <br><br>Watch out for a hacking group known as NiteSec." +
|
2017-06-02 06:15:45 +02:00
|
|
|
"<br><br>-jump3R"));
|
|
|
|
AddToAllMessages(new Message(MessageFilenames.Jumper3,
|
2017-07-27 04:56:14 +02:00
|
|
|
"You must learn to walk before you can run. And you must " +
|
|
|
|
"run before you can fly. Look for the black hand. <br><br>" +
|
2017-06-02 06:15:45 +02:00
|
|
|
"I.I.I.I <br><br>-jump3R"));
|
|
|
|
AddToAllMessages(new Message(MessageFilenames.Jumper4,
|
2017-07-27 04:56:14 +02:00
|
|
|
"To find what you are searching for, you must understand the bits. " +
|
|
|
|
"The bits are all around us. The runners will help you.<br><br>" +
|
2017-06-02 06:15:45 +02:00
|
|
|
"-jump3R"));
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-06-02 06:15:45 +02:00
|
|
|
//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 " +
|
2017-07-27 04:56:14 +02:00
|
|
|
"the world for the better. If you join us, we can unlock your full potential. <br><br>" +
|
|
|
|
"But first, you must pass our test. Find and hack our server using the Terminal. <br><br>" +
|
2017-06-02 06:15:45 +02:00
|
|
|
"-CyberSec"));
|
|
|
|
AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
|
2017-07-27 04:56:14 +02:00
|
|
|
"People say that the corrupted governments and corporations rule the world. " +
|
|
|
|
"Yes, maybe they do. But do you know who everyone really fears? People " +
|
2017-06-02 06:15:45 +02:00
|
|
|
"like us. Because they can't hide from us. Because they can't fight shadows " +
|
2017-07-27 04:56:14 +02:00
|
|
|
"and ideas with bullets. <br><br>" +
|
|
|
|
"Join us, and people will fear you, too. <br><br>" +
|
|
|
|
"Find and hack our hidden server using the Terminal. Then, we will contact you again." +
|
2017-06-02 06:15:45 +02:00
|
|
|
"<br><br>-NiteSec"));
|
|
|
|
AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
|
2017-07-27 04:56:14 +02:00
|
|
|
"We know what you are doing. We know what drives you. We know " +
|
|
|
|
"what you are looking for. <br><br> " +
|
|
|
|
"We can help you find the answers.<br><br>" +
|
2017-06-02 06:15:45 +02:00
|
|
|
"run4theh111z"));
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
AddToAllMessages(new Message(MessageFilenames.RedPill,
|
2017-07-27 04:56:14 +02:00
|
|
|
"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" +
|
|
|
|
")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" +
|
|
|
|
"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" +
|
2017-07-22 00:54:55 +02:00
|
|
|
"DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)"));
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
export {Messages, checkForMessagesToSend, sendMessage, showMessage, loadMessages,
|
|
|
|
initMessages, Message};
|