Fixed bug with creating gangs

This commit is contained in:
danielyxie 2017-09-01 11:59:11 -05:00
parent a8e28e3d71
commit 9b96e2537d
7 changed files with 841 additions and 772 deletions

1491
dist/bundle.js vendored

File diff suppressed because it is too large Load Diff

@ -134,6 +134,7 @@ function getNumAvailableCreateProgram() {
if (!Player.hasProgram(Programs.AutoLink) && Player.hacking_skill >= 25) {
++count;
}
if (count > 0) {Player.firstProgramAvailable = true;}
return count;
}

@ -2,10 +2,12 @@ import {Augmentations, AugmentationNames,
PlayerOwnedAugmentation} from "./Augmentations.js";
import {BitNodeMultipliers} from "./BitNode.js";
import {CONSTANTS} from "./Constants.js";
import {Player} from "./Player.js";
import {Engine} from "./engine.js";
import {FactionInfo} from "./FactionInfo.js";
import {Locations} from "./Location.js";
import {Player} from "./Player.js";
import {Settings} from "./Settings.js";
import {dialogBoxCreate} from "../utils/DialogBox.js";
import {factionInvitationBoxCreate} from "../utils/FactionInvitationBox.js";
import {clearEventListeners} from "../utils/HelperFunctions.js";
@ -568,8 +570,8 @@ function displayFactionContent(factionName) {
noBtn.innerHTML = "Cancel";
yesBtn.addEventListener("click", () => {
var hacking = false;
if (factionName == "NiteSec" || factionName == "The Black Hand") {hacking = true;}
Player.gang = new Gang(factionName, hacking);
if (factionName === "NiteSec" || factionName === "The Black Hand") {hacking = true;}
Player.startGang(factionName, hacking);
Engine.loadGangContent();
yesNoBoxClose();
});
@ -906,6 +908,8 @@ function purchaseAugmentation(aug, fac, sing=false) {
var txt = "You must first install the Bionic Arms augmentation before installing this upgrade";
if (sing) {return txt;} else {dialogBoxCreate(txt);}
} else if (Player.money.gte(aug.baseCost * fac.augmentationPriceMult)) {
Player.firstAugPurchased = true;
var queuedAugmentation = new PlayerOwnedAugmentation(aug.name);
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
queuedAugmentation.level = getNextNeurofluxLevel();

@ -1840,6 +1840,7 @@ function initLocationButtons() {
}
function travelToCity(destCityName, cost) {
Player.firstTimeTraveled = true;
if (Player.money.lt(cost)) {
dialogBoxCreate("You cannot afford to travel to " + destCityName);
return;

@ -105,15 +105,8 @@ function PlayerObject() {
this.sourceFiles = [];
//Crime statistics
this.karma = 0;
this.numTimesShoplifted = 0;
this.numPeopleMugged = 0;
this.numTimesDealtDrugs = 0;
this.numTimesTraffickArms = 0;
this.numPeopleKilled = 0;
this.numTimesGrandTheftAuto = 0;
this.numTimesKidnapped = 0;
this.numTimesHeist = 0;
this.karma = 0;
this.crime_money_mult = 1;
this.crime_success_mult = 1;
@ -172,11 +165,18 @@ function PlayerObject() {
this.hasTixApiAccess = false;
//Gang
this.gang = null;
this.gang = 0;
//bitnode
this.bitNodeN = 1;
//Flags for determining whether certain "thresholds" have been achieved
this.firstFacInvRecvd = false;
this.firstAugPurchased = false;
this.firstJobRecvd = false;
this.firstTimeTraveled = false;
this.firstProgramAvailable = false;
//Used to store the last update time.
this.lastUpdate = 0;
this.totalPlaytime = 0;
@ -207,16 +207,7 @@ PlayerObject.prototype.prestigeAugmentation = function() {
this.currentServer = homeComp.ip;
this.homeComputer = homeComp.ip;
//Crime statistics
this.numTimesShoplifted = 0;
this.numPeopleMugged = 0;
this.numTimesDealtDrugs = 0;
this.numTimesTraffickArms = 0;
this.numPeopleKilled = 0;
this.numTimesGrandTheftAuto = 0;
this.numTimesKidnapped = 0;
this.numTimesHeist = 0;
this.karma = 0;
//Reset stats
@ -295,15 +286,7 @@ PlayerObject.prototype.prestigeSourceFile = function() {
this.currentServer = homeComp.ip;
this.homeComputer = homeComp.ip;
this.numTimesShoplifted = 0;
this.numPeopleMugged = 0;
this.numTimesDealtDrugs = 0;
this.numTimesTraffickArms = 0;
this.numPeopleKilled = 0;
this.numTimesGrandTheftAuto = 0;
this.numTimesKidnapped = 0;
this.numTimesHeist = 0;
this.karma = 0;
//Reset stats
@ -1425,24 +1408,20 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
switch(this.crimeType) {
case CONSTANTS.CrimeShoplift:
this.karma -= 0.1;
++this.numTimesShoplifted;
break;
case CONSTANTS.CrimeRobStore:
this.karma -= 0.5;
break;
case CONSTANTS.CrimeMug:
this.karma -= 0.25;
++this.numPeopleMugged;
break;
case CONSTANTS.CrimeLarceny:
this.karma -= 1.5;
break;
case CONSTANTS.CrimeDrugs:
++this.numTimesDealtDrugs;
this.karma -= 0.5;
break;
case CONSTANTS.CrimeTraffickArms:
++this.numTimesTraffickArms;
this.karma -= 1;
break;
case CONSTANTS.CrimeHomicide:
@ -1450,11 +1429,9 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
this.karma -= 3;
break;
case CONSTANTS.CrimeGrandTheftAuto:
++this.numTimesGrandTheftAuto;
this.karma -= 5;
break;
case CONSTANTS.CrimeKidnap:
++this.numTimesKidnapped;
this.karma -= 6;
break;
case CONSTANTS.CrimeAssassination:
@ -1462,7 +1439,6 @@ PlayerObject.prototype.finishCrime = function(cancelled) {
this.karma -= 10;
break;
case CONSTANTS.CrimeHeist:
++this.numTimesHeist;
this.karma -= 15;
break;
default:
@ -1638,6 +1614,8 @@ PlayerObject.prototype.applyForJob = function(entryPosType, sing=false) {
this.companyName = company.companyName;
this.companyPosition = pos;
Player.firstJobRecvd = true;
if (leaveCompany) {
if (sing) {return true;}
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " +
@ -1740,6 +1718,7 @@ PlayerObject.prototype.applyForAgentJob = function(sing=false) {
PlayerObject.prototype.applyForEmployeeJob = function(sing=false) {
var company = Companies[this.location]; //Company being applied to
if (this.isQualified(company, CompanyPositions.Employee)) {
Player.firstJobRecvd = true;
this.companyName = company.companyName;
this.companyPosition = CompanyPositions.Employee;
if (sing) {return true;}
@ -1754,6 +1733,7 @@ PlayerObject.prototype.applyForEmployeeJob = function(sing=false) {
PlayerObject.prototype.applyForPartTimeEmployeeJob = function(sing=false) {
var company = Companies[this.location]; //Company being applied to
if (this.isQualified(company, CompanyPositions.PartTimeEmployee)) {
Player.firstJobRecvd = true;
this.companyName = company.companyName;
this.companyPosition = CompanyPositions.PartTimeEmployee;
if (sing) {return true;}
@ -1768,6 +1748,7 @@ PlayerObject.prototype.applyForPartTimeEmployeeJob = function(sing=false) {
PlayerObject.prototype.applyForWaiterJob = function(sing=false) {
var company = Companies[this.location]; //Company being applied to
if (this.isQualified(company, CompanyPositions.Waiter)) {
Player.firstJobRecvd = true;
this.companyName = company.companyName;
this.companyPosition = CompanyPositions.Waiter;
if (sing) {return true;}
@ -1782,6 +1763,7 @@ PlayerObject.prototype.applyForWaiterJob = function(sing=false) {
PlayerObject.prototype.applyForPartTimeWaiterJob = function(sing=false) {
var company = Companies[this.location]; //Company being applied to
if (this.isQualified(company, CompanyPositions.PartTimeWaiter)) {
Player.firstJobRecvd = true;
this.companyName = company.companyName;
this.companyPosition = CompanyPositions.PartTimeWaiter;
if (sing) {return true;}
@ -2171,6 +2153,10 @@ PlayerObject.prototype.inGang = function() {
return (this.gang instanceof Gang);
}
PlayerObject.prototype.startGang = function(factionName, hacking) {
this.gang = new Gang(factionName, hacking);
}
/************* BitNodes **************/
PlayerObject.prototype.setBitNodeNumber = function(n) {
this.bitNodeN = n;

@ -142,10 +142,30 @@ function loadGame(saveObj) {
if (saveObj.hasOwnProperty("VersionSave")) {
try {
var ver = JSON.parse(saveObj.VersionSave, Reviver);
if (Player.bitNodeN === null || Player.bitNodeN === 0) {
Player.setBitNodeNumber(1);
}
if (ver.startsWith("0.27.") || ver.startsWith("0.28.")) {
console.log("Evaluating changes needed for version compatibility");
if (Player.bitNodeN == null || Player.bitNodeN == 0) {
Player.setBitNodeNumber(1);
if (Player.augmentations.length > 0 || Player.queuedAugmentations.length > 0 ||
Player.sourceFiles.length > 0) {
//If you have already purchased an Aug...you are far enough in the game
//that everything should be available
Player.firstFacInvRecvd = true;
Player.firstAugPurchased = true;
Player.firstJobRecvd = true;
Player.firstTimeTraveled = true;
Player.firstProgramAvailable = true;
} else {
if (Player.factions.length > 0 || Player.factionInvitations.length > 0) {
Player.firstFacInvRecvd = true;
}
if (Player.companyName !== "" || Player.companyPosition !== "") {
Player.firstJobRecvd = true;
}
if (Player.hacking_skill >= 25) {
Player.firstScriptAvailable = true;
}
}
}
if (ver != CONSTANTS.Version) {
@ -329,10 +349,31 @@ function loadImportedGame(saveObj, saveString) {
if (saveObj.hasOwnProperty("VersionSave")) {
try {
var ver = JSON.parse(saveObj.VersionSave, Reviver);
if (ver.startsWith("0.27.")) {
console.log("Evaluating changes needed for version compatibility");
if (Player.bitNodeN == null || Player.bitNodeN == 0) {
Player.setBitNodeNumber(1);
}
if (ver.startsWith("0.27.") || ver.startsWith("0.28.")) {
console.log("Evaluating changes needed for version compatibility");
if (Player.augmentations.length > 0 || Player.queuedAugmentations.length > 0 ||
Player.sourceFiles.length > 0) {
//If you have already purchased an Aug...you are far enough in the game
//that everything should be available
Player.firstFacInvRecvd = true;
Player.firstAugPurchased = true;
Player.firstJobRecvd = true;
Player.firstTimeTraveled = true;
Player.firstProgramAvailable = true;
} else {
if (Player.factions.length > 0 || Player.factionInvitations.length > 0) {
Player.firstFacInvRecvd = true;
}
if (Player.companyName !== "" || Player.companyPosition !== "") {
Player.firstJobRecvd = true;
}
if (Player.hacking_skill >= 25) {
Player.firstScriptAvailable = true;
}
}
}
if (ver != CONSTANTS.Version) {

@ -27,14 +27,14 @@ import {Programs, displayCreateProgramContent,
import {displayFactionContent, joinFaction,
processPassiveFactionRepGain, Factions,
inviteToFaction, initFactions} from "./Faction.js";
import {Locations, displayLocationContent,
initLocationButtons} from "./Location.js";
import {displayGangContent, updateGangContent,
Gang} from "./Gang.js";
import {displayHacknetNodesContent, processAllHacknetNodeEarnings,
updateHacknetNodesContent} from "./HacknetNode.js";
import {iTutorialStart} from "./InteractiveTutorial.js";
import {initLiterature} from "./Literature.js";
import {Locations, displayLocationContent,
initLocationButtons} from "./Location.js";
import {checkForMessagesToSend, initMessages} from "./Message.js";
import {initSingularitySFFlags,
hasSingularitySF} from "./NetscriptFunctions.js";
@ -915,6 +915,7 @@ let Engine = {
if (Engine.Counters.checkFactionInvitations <= 0) {
var invitedFactions = Player.checkForFactionInvitations();
if (invitedFactions.length > 0) {
Player.firstFacInvRecvd = true;
var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
inviteToFaction(randFaction);
}