bitburner-src/src/Faction.js

790 lines
31 KiB
JavaScript
Raw Normal View History

2016-11-03 22:36:01 +01:00
//Netburner Faction class
function Faction(name) {
this.name = name;
this.augmentations = []; //Name of augmentation only
2017-04-19 21:19:33 +02:00
this.info = ""; //Introductory/informational text about the faction
2016-11-03 22:36:01 +01:00
//Player-related properties for faction
this.isMember = false; //Whether player is member
this.isBanned = false; //Whether or not player is banned from joining this faction
2016-11-03 22:36:01 +01:00
this.playerReputation = 0; //"Reputation" within faction
//Multipliers for unlocking and purchasing augmentations
this.augmentationPriceMult = 1;
this.augmentationRepRequirementMult = 1;
2016-11-03 22:36:01 +01:00
};
Faction.prototype.setAugmentationMultipliers = function(price, rep) {
this.augmentationPriceMult = price;
this.augmentationRepRequirementMult = rep;
}
2017-04-19 21:19:33 +02:00
Faction.prototype.setInfo = function(inf) {
this.info = inf;
}
Faction.prototype.toJSON = function() {
return Generic_toJSON("Faction", this);
}
Faction.fromJSON = function(value) {
return Generic_fromJSON(Faction, value.data);
}
Reviver.constructors.Faction = Faction;
//Map of factions indexed by faction name
Factions = {}
AddToFactions = function(faction) {
var name = faction.name;
Factions[name] = faction;
}
//TODO Augmentation price and rep requirement mult are 1 for everything right now,
// This might change in the future for balance
initFactions = function() {
2016-11-03 22:36:01 +01:00
//Endgame
var Illuminati = new Faction("Illuminati");
2017-04-19 21:19:33 +02:00
Illuminati.setInfo(FactionInfo.IlluminatiInfo);
AddToFactions(Illuminati);
var Daedalus = new Faction("Daedalus");
2017-04-19 21:19:33 +02:00
Daedalus.setInfo(FactionInfo.DaedalusInfo);
AddToFactions(Daedalus);
var Covenant = new Faction("The Covenant");
2017-04-19 21:19:33 +02:00
Covenant.setInfo(FactionInfo.CovenantInfo);
AddToFactions(Covenant);
2016-11-03 22:36:01 +01:00
//Megacorporations, each forms its own faction
var ECorp = new Faction("ECorp");
2017-04-19 21:19:33 +02:00
ECorp.setInfo(FactionInfo.ECorpInfo);
AddToFactions(ECorp);
var MegaCorp = new Faction("MegaCorp");
2017-04-19 21:19:33 +02:00
MegaCorp.setInfo(FactionInfo.MegaCorpInfo);
AddToFactions(MegaCorp);
var BachmanAndAssociates = new Faction("Bachman & Associates");
2017-04-19 21:19:33 +02:00
BachmanAndAssociates.setInfo(FactionInfo.BachmanAndAssociatesInfo);
AddToFactions(BachmanAndAssociates);
var BladeIndustries = new Faction("Blade Industries");
2017-04-19 21:19:33 +02:00
BladeIndustries.setInfo(FactionInfo.BladeIndustriesInfo);
AddToFactions(BladeIndustries);
var NWO = new Faction("NWO");
2017-04-19 21:19:33 +02:00
NWO.setInfo(FactionInfo.NWOInfo);
AddToFactions(NWO);
var ClarkeIncorporated = new Faction("Clarke Incorporated");
2017-04-19 21:19:33 +02:00
ClarkeIncorporated.setInfo(FactionInfo.ClarkeIncorporatedInfo);
AddToFactions(ClarkeIncorporated);
var OmniTekIncorporated = new Faction("OmniTek Incorporated");
2017-04-19 21:19:33 +02:00
OmniTekIncorporated.setInfo(FactionInfo.OmniTekIncorporatedInfo);
AddToFactions(OmniTekIncorporated);
var FourSigma = new Faction("Four Sigma");
2017-04-19 21:19:33 +02:00
FourSigma.setInfo(FactionInfo.FourSigmaInfo);
AddToFactions(FourSigma);
var KuaiGongInternational = new Faction("KuaiGong International");
2017-04-19 21:19:33 +02:00
KuaiGongInternational.setInfo(FactionInfo.KuaiGongInternationalInfo);
AddToFactions(KuaiGongInternational);
2017-02-09 19:35:28 +01:00
//Other corporations
var FulcrumTechnologies = new Faction("Fulcrum Secret Technologies");
2017-04-19 21:19:33 +02:00
FulcrumTechnologies.setInfo(FactionInfo.FulcrumSecretTechnologiesInfo);
2017-02-09 19:35:28 +01:00
AddToFactions(FulcrumTechnologies);
2016-11-03 22:36:01 +01:00
//Hacker groups
var BitRunners = new Faction("BitRunners");
2017-04-19 21:19:33 +02:00
BitRunners.setInfo(FactionInfo.BitRunnersInfo);
AddToFactions(BitRunners);
var BlackHand = new Faction("The Black Hand");
2017-04-19 21:19:33 +02:00
BlackHand.setInfo(FactionInfo.BlackHandInfo);
AddToFactions(BlackHand);
var NiteSec = new Faction("NiteSec");
2017-04-19 21:19:33 +02:00
NiteSec.setInfo(FactionInfo.NiteSecInfo);
AddToFactions(NiteSec);
2016-11-03 22:36:01 +01:00
//City factions, essentially governments
var Chongqing = new Faction("Chongqing");
2017-04-19 21:19:33 +02:00
Chongqing.setInfo(FactionInfo.ChongqingInfo);
AddToFactions(Chongqing);
var Sector12 = new Faction("Sector-12");
2017-04-19 21:19:33 +02:00
Sector12.setInfo(FactionInfo.Sector12Info);
AddToFactions(Sector12);
var NewTokyo = new Faction("New Tokyo");
2017-04-19 21:19:33 +02:00
NewTokyo.setInfo(FactionInfo.NewTokyoInfo);
AddToFactions(NewTokyo);
var Aevum = new Faction("Aevum");
2017-04-19 21:19:33 +02:00
Aevum.setInfo(FactionInfo.AevumInfo);
AddToFactions(Aevum);
var Ishima = new Faction("Ishima");
2017-04-19 21:19:33 +02:00
Ishima.setInfo(FactionInfo.IshimaInfo);
AddToFactions(Ishima);
var Volhaven = new Faction("Volhaven");
2017-04-19 21:19:33 +02:00
Volhaven.setInfo(FactionInfo.VolhavenInfo);
AddToFactions(Volhaven);
2016-11-17 16:31:52 +01:00
//Criminal Organizations/Gangs
var SpeakersForTheDead = new Faction("Speakers for the Dead");
2017-04-19 21:19:33 +02:00
SpeakersForTheDead.setInfo(FactionInfo.SpeakersForTheDeadInfo);
2016-12-22 16:56:15 +01:00
AddToFactions(SpeakersForTheDead);
var DarkArmy = new Faction("The Dark Army");
2017-04-19 21:19:33 +02:00
DarkArmy.setInfo(FactionInfo.DarkArmyInfo);
2016-12-22 16:56:15 +01:00
AddToFactions(DarkArmy);
var TheSyndicate = new Faction("The Syndicate");
2017-04-19 21:19:33 +02:00
TheSyndicate.setInfo(FactionInfo.TheSyndicateInfo);
2016-12-22 16:56:15 +01:00
AddToFactions(TheSyndicate);
var Silhouette = new Faction("Silhouette");
Silhouette.setInfo(FactionInfo.SilhouetteInfo);
AddToFactions(Silhouette);
2016-11-17 16:31:52 +01:00
//Earlygame factions - factions the player will prestige with early on that don't
//belong in other categories
var Netburners = new Faction("Netburners");
Netburners.setInfo(FactionInfo.NetburnersInfo);
AddToFactions(Netburners);
2016-12-22 16:56:15 +01:00
var TianDiHui = new Faction("Tian Di Hui"); //Society of the Heaven and Earth
2017-04-19 21:19:33 +02:00
TianDiHui.setInfo(FactionInfo.TianDiHuiInfo);
2016-12-22 16:56:15 +01:00
AddToFactions(TianDiHui);
var CyberSec = new Faction("CyberSec");
2017-04-19 21:19:33 +02:00
CyberSec.setInfo(FactionInfo.CyberSecInfo);
AddToFactions(CyberSec);
}
2017-02-09 23:40:55 +01:00
//This function sets the requirements to join a Faction. It checks whether the Player meets
//those requirements and will return an array of all factions that the Player should
//receive an invitation to
PlayerObject.prototype.checkForFactionInvitations = function() {
if (Engine.Debug) {
console.log("checkForFactionInvitations() called");
}
invitedFactions = []; //Array which will hold all Factions th eplayer should be invited to
2017-02-09 23:40:55 +01:00
var company = Companies[this.companyName];
2017-04-19 07:02:40 +02:00
var companyRep = 0;
if (company != null) {
companyRep = company.playerReputation;
}
2017-02-09 23:40:55 +01:00
//Illuminati
var illuminatiFac = Factions["Illuminati"];
if (illuminatiFac.isBanned == false && illuminatiFac.isMember == false &&
this.numAugmentations >= 10 &&
this.money >= 10000000000 && this.total_money >= 20000000000 &&
this.hacking_skill >= 800 && this.total_hacking >= 7000 &&
this.strength >= 900 && this.total_strength >= 10000 &&
this.defense >= 900 && this.total_defense >= 10000 &&
this.dexterity >= 900 && this.total_dexterity >= 10000 &&
this.agility >= 900 && this.total_agility >= 10000) {
invitedFactions.push(illuminatiFac);
2017-02-09 23:40:55 +01:00
}
//Daedalus
var daedalusFac = Factions["Daedalus"];
if (daedalusFac.isBanned == false && daedalusFac.isMember == false &&
this.numAugmentations >= 15 &&
this.money >= 1000000000 && this.total_money >= 10000000000 &&
this.hacking_skill >= 1000 && this.total_hacking >= 10000 &&
this.strength >= 500 && this.total_strength >= 8000 &&
this.defense >= 500 && this.total_defense >= 8000 &&
this.dexterity >= 500 && this.total_dexterity >= 8000 &&
this.agility >= 500 && this.total_agility >= 8000) {
invitedFactions.push(daedalusFac);
2017-02-09 23:40:55 +01:00
}
//The Covenant
var covenantFac = Factions["The Covenant"];
if (covenantFac.isBanned == false && covenantFac.isMember == false &&
this.numAugmentations >= 12 &&
this.money >= 5000000000 && this.total_money >= 10000000000 &&
this.hacking_skill >= 850 && this.total_hack >= 5000 &&
this.strength >= 850 && this.total_strength >= 5000 &&
this.defense >= 850 && this.total_defense >= 5000 &&
this.dexterity >= 850 && this.total_dexterity >= 5000 &&
this.agility >= 850 && this.total_agility >= 5000) {
invitedFactions.push(covenantFac);
2017-02-09 23:40:55 +01:00
}
//ECorp
var ecorpFac = Factions["ECorp"];
if (ecorpFac.isBanned == false && ecorpFac.isMember == false &&
this.companyName == Locations.AevumECorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(ecorpFac);
2017-02-09 23:40:55 +01:00
}
//MegaCorp
var megacorpFac = Factions["MegaCorp"];
if (megacorpFac.isBanned == false && megacorpFac.isMember == false &&
this.companyName == Locations.Sector12MegaCorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(megacorpFac);
2017-02-09 23:40:55 +01:00
}
//Bachman & Associates
var bachmanandassociatesFac = Factions["Bachman & Associates"];
if (bachmanandassociatesFac.isBanned == false && bachmanandassociatesFac.isMember == false &&
this.companyName == Locations.AevumBachmanAndAssociates && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(bachmanandassociatesFac);
2017-02-09 23:40:55 +01:00
}
//Blade Industries
var bladeindustriesFac = Factions["Blade Industries"];
if (bladeindustriesFac.isBanned == false && bladeindustriesFac.isMember == false &&
this.companyName == Locations.Sector12BladeIndustries && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(bladeindustriesFac);
2017-02-09 23:40:55 +01:00
}
//NWO
var nwoFac = Factions["NWO"];
if (nwoFac.isBanned == false && nwoFac.isMember == false &&
this.companyName == Locations.VolhavenNWO && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(nwoFac);
2017-02-09 23:40:55 +01:00
}
//Clarke Incorporated
var clarkeincorporatedFac = Factions["Clarke Incorporated"];
if (clarkeincorporatedFac.isBanned == false && clarkeincorporatedFac.isMember == false &&
this.companyName == Locations.AevumClarkeIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(clarkeincorporatedFac);
2017-02-09 23:40:55 +01:00
}
//OmniTek Incorporated
var omnitekincorporatedFac = Factions["OmniTek Incorporated"];
if (omnitekincorporatedFac.isBanned == false && omnitekincorporatedFac.isMember == false &&
this.companyName == Locations.VolhavenOmniTekIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(omnitekincorporatedFac);
2017-02-09 23:40:55 +01:00
}
//Four Sigma
var foursigmaFac = Factions["Four Sigma"];
if (foursigmaFac.isBanned == false && foursigmaFac.isMember == false &&
this.companyName == Locations.Sector12FourSigma && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(foursigmaFac);
2017-02-09 23:40:55 +01:00
}
//KuaiGong International
var kuaigonginternationalFac = Factions["KuaiGong International"];
if (kuaigonginternationalFac.isBanned == false && kuaigonginternationalFac.isMember == false &&
this.companyName == Locations.ChongqingKuaiGongInternational && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(kuaigonginternationalFac);
2017-02-09 23:40:55 +01:00
}
//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"]];
2017-02-09 23:40:55 +01:00
if (fulcrumSecretServer == null) {
console.log("Error: Could not find Fulcrum Secret Technologies Server");
}
if (fulcrumsecrettechonologiesFac.isBanned == false && fulcrumsecrettechonologiesFac.isMember == false &&
fulcrumSecretServer.hasAdminRights &&
this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) {
invitedFactions.push(fulcrumsecrettechonologiesFac);
2017-02-09 23:40:55 +01:00
}
//BitRunners
var bitrunnersFac = Factions["BitRunners"];
var homeComp = Player.getHomeComputer();
2017-02-09 23:40:55 +01:00
if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false &&
this.hacking_skill >= 600 && homeComp.maxRam >= 32) {
invitedFactions.push(bitrunnersFac);
2017-02-09 23:40:55 +01:00
}
//The Black Hand
var theblackhandFac = Factions["The Black Hand"];
if (theblackhandFac.isBanned == false && theblackhandFac.isMember == false &&
this.hacking_skill >= 400 && this.strength >= 300 && this.defense >= 300 &&
this.agility >= 300 && this.dexterity >= 300 && homeComp.maxRam >= 16) {
invitedFactions.push(theblackhandFac);
2017-02-09 23:40:55 +01:00
}
//NiteSec
var nitesecFac = Factions["NiteSec"];
if (nitesecFac.isBanned == false && nitesecFac.isMember == false &&
this.hacking_skill >= 500 && homeComp.maxRam >= 32) {
invitedFactions.push(nitesecFac);
2017-02-09 23:40:55 +01:00
}
//Chongqing
var chongqingFac = Factions["Chongqing"];
if (chongqingFac.isBanned == false && chongqingFac.isMember == false &&
this.money >= 20000000 && this.location == Locations.Chongqing) {
invitedFactions.push(chongqingFac);
}
2017-02-09 23:40:55 +01:00
//Sector-12
var sector12Fac = Factions["Sector-12"];
if (sector12Fac.isBanned == false && sector12Fac.isMember == false &&
this.money >= 50000000 && this.location == Locations.Sector12) {
invitedFactions.push(sector12Fac);
}
2017-02-09 23:40:55 +01:00
//New Tokyo
var newtokyoFac = Factions["New Tokyo"];
if (newtokyoFac.isBanned == false && newtokyoFac.isMember == false &&
this.money >= 20000000 && this.location == Locations.NewTokyo) {
invitedFactions.push(newtokyoFac);
}
2017-02-09 23:40:55 +01:00
//Aevum
var aevumFac = Factions["Aevum"];
if (aevumFac.isBanned == false && aevumFac.isMember == false &&
this.money >= 40000000 && this.location == Locations.Aevum) {
invitedFactions.push(aevumFac);
}
2017-02-09 23:40:55 +01:00
//Ishima
var ishimaFac = Factions["Ishima"];
if (ishimaFac.isBanned == false && ishimaFac.isMember == false &&
this.money >= 30000000 && this.location == Locations.Ishima) {
invitedFactions.push(ishimaFac);
}
2017-02-09 23:40:55 +01:00
//Volhaven
var volhavenFac = Factions["Volhaven"];
if (volhavenFac.isBanned == false && volhavenFac.isMember == false &&
this.money >= 50000000 && this.location == Locations.Volhaven) {
invitedFactions.push(volhavenFac);
}
2017-02-09 23:40:55 +01:00
//Speakers for the Dead
var speakersforthedeadFac = Factions["Speakers for the Dead"];
if (speakersforthedeadFac.isBanned == false && speakersforthedeadFac.isMember == false &&
this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 &&
this.numPeopleKilledTotal >= 100 && this.karma <= -50 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) {
invitedFactions.push(speakersforthedeadFac);
}
2017-02-09 23:40:55 +01:00
//The Dark Army
var thedarkarmyFac = Factions["The Dark Army"];
if (thedarkarmyFac.isBanned == false && thedarkarmyFac.isMember == false &&
this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.location == Locations.Chongqing &&
this.numPeopleKilled >= 5 && this.karma <= -50 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thedarkarmyFac);
}
2017-02-09 23:40:55 +01:00
//The Syndicate
var thesyndicateFac = Factions["The Syndicate"];
if (thesyndicateFac.isBanned == false && thesyndicateFac.isMember == false &&
this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
this.dexterity >= 200 && this.agility >= 200 &&
(this.location == Locations.Aevum || this.location == Locations.Sector12) &&
this.money >= 10000000 && this.karma <= -100 &&
this.companyName != Locations.Sector12CIA && this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thesyndicateFac);
}
//Silhouette
var silhouetteFac = Factions["Silhouette"];
if (silhouetteFac.isBanned == false && silhouetteFac.isMember == false &&
(this.companyPosition.positionName == CompanyPositions.CTO.positionName ||
this.companyPosition.positionName == CompanyPositions.CFO.positionName ||
this.companyPosition.positionName == CompanyPositions.CEO.positionName) &&
this.money >= 15000000 && this.karma <= -25) {
invitedFactions.push(silhouetteFac);
}
//Netburners
var netburnersFac = Factions["Netburners"];
var totalHacknetRam = 0;
var totalHacknetCores = 0;
var totalHacknetLevels = 0;
for (var i = 0; i < Player.hacknetNodes.length; ++i) {
totalHacknetLevels += Player.hacknetNodes[i].level;
totalHacknetRam += Player.hacknetNodes[i].ram;
totalHacknetCores += Player.hacknetNodes[i].numCores;
}
if (netburnersFac.isBanned == false && netburnersFac.isMember == false &&
this.hacking_skill >= 100 && totalHacknetRam >= 10 &&
totalHacknetCores >= 5 && totalHacknetLevels >= 100) {
invitedFactions.push(netburnersFac);
2017-05-03 19:58:09 +02:00
}
2017-02-09 23:40:55 +01:00
//Tian Di Hui
var tiandihuiFac = Factions["Tian Di Hui"];
if (tiandihuiFac.isBanned == false && tiandihuiFac.isMember == false &&
this.money >= 1000000 && this.hacking_skill >= 50 &&
(this.location == Locations.Chongqing || this.location == Locations.NewTokyo ||
this.location == Locations.Ishima)) {
invitedFactions.push(tiandihuiFac);
}
2017-02-09 23:40:55 +01:00
//CyberSec
var cybersecFac = Factions["CyberSec"];
if (cybersecFac.isBanned == false && cybersecFac.isMember == false &&
2017-04-19 21:19:33 +02:00
this.hacking_skill >= 50) {
invitedFactions.push(cybersecFac);
}
return invitedFactions;
}
inviteToFaction = function(faction) {
if (Engine.Debug) {
console.log("inviteToFaction() called with faction: " + faction.name);
}
factionInvitationBoxCreate(faction);
2017-02-09 23:40:55 +01:00
}
joinFaction = function(faction) {
faction.isMember = true;
Player.factions.push(faction.name);
//Determine what factions you are banned from now that you have joined this faction
if (faction.name == "BitRunners") {
Factions["The Black Hand"].isBanned = true;
Factions["NiteSec"].isBanned = true;
} else if (faction.name == "The Black Hand") {
Factions["BitRunners"].isBanned = true;
Factions["NiteSec"].isBanned = true;
} else if (faction.name == "NiteSec") {
Factions["BitRunners"].isBanned = true;
Factions["The Black Hand"].isBanned = true;
} else if (faction.name == "Chongqing") {
Factions["Sector-12"].isBanned = true;
Factions["Aevum"].isBanned = true;
Factions["Volhaven"].isBanned = true;
} else if (faction.name == "Sector-12") {
Factions["Chongqing"].isBanned = true;
Factions["New Tokyo"].isBanned = true;
Factions["Ishima"].isBanned = true;
Factions["Volhaven"].isBanned = true;
} else if (faction.name == "New Tokyo") {
Factions["Sector-12"].isBanned = true;
Factions["Aevum"].isBanned = true;
Factions["Volhaven"].isBanned = true;
} else if (faction.name == "Aevum") {
Factions["Chongqing"].isBanned = true;
Factions["New Tokyo"].isBanned = true;
Factions["Ishima"].isBanned = true;
Factions["Volhaven"].isBanned = true;
} else if (faction.name == "Ishima") {
Factions["Sector-12"].isBanned = true;
Factions["Aevum"].isBanned = true;
Factions["Volhaven"].isBanned = true;
} else if (faction.name == "Volhaven") {
Factions["Chongqing"].isBanned = true;
Factions["Sector-12"].isBanned = true;
Factions["New Tokyo"].isBanned = true;
Factions["Aevum"].isBanned = true;
Factions["Ishima"].isBanned = true;
}
}
2017-04-21 22:56:44 +02:00
leaveFaction = function(faction) {
faction.isMember = false;
var i = Player.factions.indexOf(faction.name);
if (i > -1) {
Player.factions.splice(i, 1);
}
//Unban from faction
if (faction.name == "BitRunners") {
Factions["The Black Hand"].isBanned = false;
Factions["NiteSec"].isBanned = false;
} else if (faction.name == "The Black Hand") {
Factions["BitRunners"].isBanned = false;
Factions["NiteSec"].isBanned = false;
} else if (faction.name == "NiteSec") {
Factions["BitRunners"].isBanned = false;
Factions["The Black Hand"].isBanned = false;
} else if (faction.name == "Chongqing") {
Factions["Sector-12"].isBanned = false;
Factions["Aevum"].isBanned = false;
Factions["Volhaven"].isBanned = false;
} else if (faction.name == "Sector-12") {
Factions["Chongqing"].isBanned = false;
Factions["New Tokyo"].isBanned = false;
Factions["Ishima"].isBanned = false;
Factions["Volhaven"].isBanned = false;
} else if (faction.name == "New Tokyo") {
Factions["Sector-12"].isBanned = false;
Factions["Aevum"].isBanned = false;
Factions["Volhaven"].isBanned = false;
} else if (faction.name == "Aevum") {
Factions["Chongqing"].isBanned = false;
Factions["New Tokyo"].isBanned = false;
Factions["Ishima"].isBanned = false;
Factions["Volhaven"].isBanned = false;
} else if (faction.name == "Ishima") {
Factions["Sector-12"].isBanned = false;
Factions["Aevum"].isBanned = false;
Factions["Volhaven"].isBanned = false;
} else if (faction.name == "Volhaven") {
Factions["Chongqing"].isBanned = false;
Factions["Sector-12"].isBanned = false;
Factions["New Tokyo"].isBanned = false;
Factions["Aevum"].isBanned = false;
Factions["Ishima"].isBanned = false;
}
}
//Displays the HTML content for a specific faction
displayFactionContent = function(factionName) {
var faction = Factions[factionName];
2017-04-19 21:19:33 +02:00
document.getElementById("faction-name").innerHTML = factionName;
document.getElementById("faction-info").innerHTML = faction.info;
2017-04-19 23:39:25 +02:00
document.getElementById("faction-reputation").innerHTML = "Reputation: " + faction.playerReputation.toFixed(3);
var hackDiv = document.getElementById("faction-hack-div");
var fieldWorkDiv = document.getElementById("faction-fieldwork-div");
var securityWorkDiv = document.getElementById("faction-securitywork-div");
var hackButton = document.getElementById("faction-hack-button");
var fieldWorkButton = document.getElementById("faction-fieldwork-button");
var securityWorkButton = document.getElementById("faction-securitywork-button");
//Set new event listener for all of the work buttons
//The old buttons need to be replaced to clear the old event listeners
var newHackButton = hackButton.cloneNode(true);
var newFieldWorkButton = fieldWorkButton.cloneNode(true);
2017-04-17 14:26:54 +02:00
var newSecurityWorkButton = securityWorkButton.cloneNode(true);
hackButton.parentNode.replaceChild(newHackButton, hackButton);
fieldWorkButton.parentNode.replaceChild(newFieldWorkButton, fieldWorkButton);
securityWorkButton.parentNode.replaceChild(newSecurityWorkButton, securityWorkButton);
newHackButton.addEventListener("click", function() {
Player.startFactionHackWork(faction);
return false;
});
newFieldWorkButton.addEventListener("click", function() {
Player.startFactionFieldWork(faction);
return false;
});
2017-04-19 07:02:40 +02:00
newSecurityWorkButton.addEventListener("click", function() {
Player.startFactionSecurityWork(faction);
return false;
});
//Set new event listener for the purchase augmentation buttons
//The old button needs to be replaced to clear the old event listeners
var purchaseAugmentations = document.getElementById("faction-purchase-augmentations");
var newPurchaseAugmentationsButton = purchaseAugmentations.cloneNode(true);
purchaseAugmentations.parentNode.replaceChild(newPurchaseAugmentationsButton, purchaseAugmentations);
newPurchaseAugmentationsButton.addEventListener("click", function() {
Engine.hideAllContent();
2017-04-19 21:19:33 +02:00
Engine.Display.factionAugmentationsContent.style.visibility = "visible";
var backButton = document.getElementById("faction-augmentations-back-button");
var newBackButton = backButton.cloneNode(true);
backButton.parentNode.replaceChild(newBackButton, backButton);
newBackButton.addEventListener("click", function() {
Engine.loadFactionContent();
displayFactionContent(factionName);
return false;
});
displayFactionAugmentations(factionName);
return false;
});
if (faction.isMember) {
switch(faction.name) {
case "Illuminati":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "none";
break;
case "Daedalus":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "none";
break;
case "The Covenant":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "none";
break;
case "ECorp":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "MegaCorp":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Bachman & Associates":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Blade Industries":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "NWO":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Clarke Incorporated":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "OmniTek Incorporated":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Four Sigma":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "KuaiGong International":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "BitRunners":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "none";
securityWorkDiv.style.display = "none";
break;
case "The Black Hand":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "none";
break;
case "NiteSec":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "none";
securityWorkDiv.style.display = "none";
break;
case "Chongqing":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Sector-12":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "New Tokyo":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Aevum":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Ishima":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Volhaven":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Speakers for the Dead":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "The Dark Army":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "none";
break;
case "The Syndicate":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
securityWorkDiv.style.display = "inline";
break;
case "Silhouette":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "inline";
2017-05-03 19:58:09 +02:00
securityWorkDiv.style.display = "none";
case "Netburners":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "none";
securityWorkDiv.style.display = "none";
case "Tian Di Hui":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "none";
securityWorkDiv.style.display = "inline";
break;
case "CyberSec":
hackDiv.style.display = "inline";
fieldWorkDiv.style.display = "none";
securityWorkDiv.style.display = "none";
break;
default:
console.log("Faction does not exist");
break;
}
} else {
console.log("Not a member of this faction, cannot display faction information");
}
}
displayFactionAugmentations = function(factionName) {
2017-02-28 18:47:43 +01:00
document.getElementById("faction-augmentations-page-desc").innerHTML = "Lists all augmentations that are available to purchase from" + factionName;
var faction = Factions[factionName];
var augmentationsList = document.getElementById("faction-augmentations-list");
2017-04-19 23:39:25 +02:00
while (augmentationsList.firstChild) {
augmentationsList.removeChild(augmentationsList.firstChild);
}
2017-04-19 21:19:33 +02:00
for (var i = 0; i < faction.augmentations.length; ++i) {
(function () {
var aug = Augmentations[faction.augmentations[i]];
var item = document.createElement("li");
var span = document.createElement("span");
var aElem = document.createElement("a");
var pElem = document.createElement("p");
aElem.setAttribute("href", "#");
var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult;
if (faction.playerReputation >= req) {
aElem.setAttribute("class", "a-link-button");
pElem.innerHTML = "UNLOCKED - $" + aug.baseCost * faction.augmentationPriceMult;
//TODO Event listener for button to purchase augmentation
} else {
aElem.setAttribute("class", "a-link-button-inactive");
pElem.innerHTML = "LOCKED (Requires " + req + " faction reputation)";
pElem.style.color = "red";
}
aElem.style.display = "inline-block";
pElem.style.display = "inline-block";
aElem.innerHTML = aug.name;
aElem.addEventListener("click", function() {
console.log("here");
purchaseAugmentationBoxCreate(aug, faction);
});
span.appendChild(aElem);
span.appendChild(pElem);
item.appendChild(span);
augmentationsList.appendChild(item);
}()); //Immediate invocation closure
}
2017-05-04 07:05:48 +02:00
}
function processPassiveFactionRepGain(numCycles) {
var numTimesGain = numCycles / 600;
for (var name in Factions) {
if (Factions.hasOwnProperty(name)) {
var faction = Factions[name];
//TODO Get hard value of 1 rep per "rep gain cycle"" for now..
//maybe later make this based on
//a player's 'status' like how powerful they are and how much money they have
if (faction.isMember) {faction.playerReputation += numTimesGain;}
}
}
2016-11-03 22:36:01 +01:00
}