Began implementing Singularity functions

This commit is contained in:
danielyxie
2017-08-21 11:59:06 -05:00
parent 99c220514f
commit e2d0477203
3 changed files with 69 additions and 5 deletions

View File

@ -34,7 +34,7 @@ BitNodes = {
"Level 3: 35%"),
BitNode3: new BitNode(3, "The Price of Civilization", "COMING SOON"), //Corporate Warfare, Run own company
BitNode4: new BitNode(4, "The Singularity", "COMING SOON"), //Everything automatable
BitNode5: new BitNode(5, "2084", "COMING SOON"), //Big Brother
BitNode5: new BitNode(5, "Artificial Intelligence", "COMING SOON"), //Big Brother
BitNode6: new BitNode(6, "Hacktocracy", "COMING SOON"), //Healthy Hacknet balancing mechanic
BitNode7: new BitNode(7, "Do Androids Dream?", "COMING SOON"), //Build androids for automation
BitNode8: new BitNode(8, "Ghost of Wall Street", "COMING SOON"), //Trading only viable strategy

View File

@ -1,3 +1,10 @@
function initSingularitySFFlags() {
//TODO
}
var hasSingularitySF = false;
var singularitySFLvl = 1;
function NetscriptFunctions(workerScript) {
return {
hacknetnodes : Player.hacknetNodes,
@ -864,7 +871,39 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
}
return scriptCalculateWeakenTime(server) / 1000; //Returns seconds
}
},
/* Singularity Functions */
universityCourse(universityName, courseName) {
if (Player.isWorking) {
var txt = Player.singularityStopWork();
workerScript.scriptRef.log(txt);
}
},
//gymWorkout(gymName, stat);
//travelToCity(cityname);
//purchaseTor();
//homeComp.upgradeRam();
//homeComp.getUpgradeRamCost();
//workForCompany();
//applyToCompany(companyName, field);
//getCompanyRep(companyName);
//checkFactionInvitations();
//joinFaction(name);
//workForFaction(facName, type);
//getFactionRep(name);
//createProgram();
//getAugmentationCost(name);
//purchaseAugmentation(faction, name);
//installAugmentations();
}
}

View File

@ -1064,7 +1064,9 @@ PlayerObject.prototype.takeClass = function(numCycles) {
"You may cancel at any time";
}
PlayerObject.prototype.finishClass = function() {
//The 'sing' argument defines whether or not this function was called
//through a Singularity Netscript function
PlayerObject.prototype.finishClass = function(sing=false) {
this.gainWorkExp();
if (this.workMoneyGained > 0) {
@ -1082,8 +1084,7 @@ PlayerObject.prototype.finishClass = function() {
formatNumber(this.workDexExpGained, 4) + " dexterity exp <br>" +
formatNumber(this.workAgiExpGained, 4) + " agility exp <br>" +
formatNumber(this.workChaExpGained, 4) + " charisma exp<br>";
dialogBoxCreate(txt);
if (!sing) {dialogBoxCreate(txt);}
var mainMenu = document.getElementById("mainmenu-container");
mainMenu.style.visibility = "visible";
@ -1091,6 +1092,16 @@ PlayerObject.prototype.finishClass = function() {
this.isWorking = false;
Engine.loadLocationContent();
if (sing) {return = "After " + this.className + " for " + convertTimeMsToTimeElapsedString(this.timeWorked) + ", " +
"you spent a total of $" + formatNumber(this.workMoneyGained * -1, 2) + ". " +
"You earned a total of: " +
formatNumber(this.workHackExpGained, 3) + " hacking exp, " +
formatNumber(this.workStrExpGained, 3) + " strength exp, " +
formatNumber(this.workDefExpGained, 3) + " defense exp, " +
formatNumber(this.workDexExpGained, 3) + " dexterity exp, " +
formatNumber(this.workAgiExpGained, 3) + " agility exp, and " +
formatNumber(this.workChaExpGained, 3) + " charisma exp";}
}
//The EXP and $ gains are hardcoded. Time is in ms
@ -1232,6 +1243,20 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
Engine.loadLocationContent();
}
//Cancels the player's current "work" assignment and gives the proper rewards
//Used only for Singularity functions, so no popups are created
PlayerObject.prototype.singularityStopWork = function() {
if (!this.isWorking) {return null;}
switch (this.workType) {
case CONSTANTS.WorkTypeStudyClass:
return Player.finishClass(true);
break;
default:
console.log("ERROR: Unrecognized work type");
return;
}
}
//Returns true if hospitalized, false otherwise
PlayerObject.prototype.takeDamage = function(amt) {