mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 12:45:45 +01:00
added favor related funtions
This commit is contained in:
parent
47134a9640
commit
142e141f6f
@ -31,6 +31,7 @@ let CONSTANTS = {
|
||||
HacknetNodeMaxCores: 16,
|
||||
|
||||
/* Faction and Company favor */
|
||||
BaseFavorToDonate: 150,
|
||||
FactionReputationToFavorBase: 500,
|
||||
FactionReputationToFavorMult: 1.02,
|
||||
CompanyReputationToFavorBase: 500,
|
||||
@ -78,6 +79,7 @@ let CONSTANTS = {
|
||||
ScriptArbScriptRamCost: 1.0, //Functions that apply to all scripts regardless of args
|
||||
ScriptGetScriptRamCost: 0.1,
|
||||
ScriptGetHackTimeRamCost: 0.05,
|
||||
ScriptGetFavorToDonate: 0.10,
|
||||
|
||||
ScriptSingularityFn1RamCost: 1,
|
||||
ScriptSingularityFn2RamCost: 2,
|
||||
|
@ -55,7 +55,7 @@ Faction.prototype.gainFavor = function() {
|
||||
this.rolloverRep = res[1];
|
||||
}
|
||||
|
||||
//Returns an array with [How much favor would be gained, how much favor would be left over]
|
||||
//Returns an array with [How much favor would be gained, how much rep would be left over]
|
||||
Faction.prototype.getFavorGain = function() {
|
||||
if (this.favor == null || this.favor == undefined) {this.favor = 0;}
|
||||
if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
|
||||
@ -432,7 +432,7 @@ function displayFactionContent(factionName) {
|
||||
throw new Error("Not a member of this faction, cannot display faction information");
|
||||
}
|
||||
|
||||
donateDiv.style.display = faction.favor >= (150 * BitNodeMultipliers.RepToDonateToFaction) ? "inline" : "none";
|
||||
donateDiv.style.display = faction.favor >= Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction) ? "inline" : "none";
|
||||
|
||||
hackMissionDiv.style.display = factionInfo.offerHackingMission ? "inline": "none";
|
||||
hackDiv.style.display = factionInfo.offerHackingWork ? "inline" : "none";
|
||||
|
@ -2110,6 +2110,13 @@ function NetscriptFunctions(workerScript) {
|
||||
yesNoBoxCreate(txt);
|
||||
});
|
||||
},
|
||||
getFavorToDonate: function() {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getFavorToDonate", CONSTANTS.ScriptGetFavorToDonate);
|
||||
}
|
||||
updateDynamicRam("getFavorToDonate", CONSTANTS.ScriptGetFavorToDonate);
|
||||
return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
||||
},
|
||||
|
||||
/* Singularity Functions */
|
||||
universityCourse : function(universityName, className) {
|
||||
@ -2745,6 +2752,27 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
return company.favor;
|
||||
},
|
||||
getCompanyFavorGain : function(companyName) {
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost / 4;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getCompanyFavorGain", ramCost);
|
||||
}
|
||||
updateDynamicRam("getCompanyFavorGain", ramCost);
|
||||
if (Player.bitNodeN != 4) {
|
||||
if (!(hasSingularitySF && singularitySFLvl >= 2)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot run getCompanyFavorGain(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
var company = Companies[companyName];
|
||||
if (company == null || !(company instanceof Company)) {
|
||||
workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyFavorGain(): " + companyName);
|
||||
return -1;
|
||||
}
|
||||
return company.getFavorGain()[0];
|
||||
},
|
||||
checkFactionInvitations : function() {
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
@ -2942,6 +2970,27 @@ function NetscriptFunctions(workerScript) {
|
||||
|
||||
return Factions[name].favor;
|
||||
},
|
||||
getFactionFavorGain: function(name){
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getFactionFavorGain", ramCost);
|
||||
}
|
||||
updateDynamicRam("getFactionFavorGain", ramCost);
|
||||
if (Player.bitNodeN != 4) {
|
||||
if (!(hasSingularitySF && singularitySFLvl >= 2)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot run getFactionFavorGain(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!factionExists(name)) {
|
||||
workerScript.scriptRef.log("ERROR: Faction specified in getFactionFavorGain() does not exist.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return Factions[name].getFavorGain()[0];
|
||||
},
|
||||
createProgram : function(name) {
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
|
Loading…
Reference in New Issue
Block a user