mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-11 15:57:33 +01:00
Merge pull request #396 from hydroflame/favor-gain
added favor related funtions
This commit is contained in:
commit
93bada0119
@ -31,6 +31,7 @@ let CONSTANTS = {
|
|||||||
HacknetNodeMaxCores: 16,
|
HacknetNodeMaxCores: 16,
|
||||||
|
|
||||||
/* Faction and Company favor */
|
/* Faction and Company favor */
|
||||||
|
BaseFavorToDonate: 150,
|
||||||
FactionReputationToFavorBase: 500,
|
FactionReputationToFavorBase: 500,
|
||||||
FactionReputationToFavorMult: 1.02,
|
FactionReputationToFavorMult: 1.02,
|
||||||
CompanyReputationToFavorBase: 500,
|
CompanyReputationToFavorBase: 500,
|
||||||
@ -79,6 +80,7 @@ let CONSTANTS = {
|
|||||||
ScriptArbScriptRamCost: 1.0, //Functions that apply to all scripts regardless of args
|
ScriptArbScriptRamCost: 1.0, //Functions that apply to all scripts regardless of args
|
||||||
ScriptGetScriptRamCost: 0.1,
|
ScriptGetScriptRamCost: 0.1,
|
||||||
ScriptGetHackTimeRamCost: 0.05,
|
ScriptGetHackTimeRamCost: 0.05,
|
||||||
|
ScriptGetFavorToDonate: 0.10,
|
||||||
|
|
||||||
ScriptSingularityFn1RamCost: 1,
|
ScriptSingularityFn1RamCost: 1,
|
||||||
ScriptSingularityFn2RamCost: 2,
|
ScriptSingularityFn2RamCost: 2,
|
||||||
|
@ -55,7 +55,7 @@ Faction.prototype.gainFavor = function() {
|
|||||||
this.rolloverRep = res[1];
|
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() {
|
Faction.prototype.getFavorGain = function() {
|
||||||
if (this.favor == null || this.favor == undefined) {this.favor = 0;}
|
if (this.favor == null || this.favor == undefined) {this.favor = 0;}
|
||||||
if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 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");
|
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";
|
hackMissionDiv.style.display = factionInfo.offerHackingMission ? "inline": "none";
|
||||||
hackDiv.style.display = factionInfo.offerHackingWork ? "inline" : "none";
|
hackDiv.style.display = factionInfo.offerHackingWork ? "inline" : "none";
|
||||||
|
@ -2142,6 +2142,13 @@ function NetscriptFunctions(workerScript) {
|
|||||||
yesNoBoxCreate(txt);
|
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 */
|
/* Singularity Functions */
|
||||||
universityCourse : function(universityName, className) {
|
universityCourse : function(universityName, className) {
|
||||||
@ -2777,6 +2784,27 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
return company.favor;
|
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() {
|
checkFactionInvitations : function() {
|
||||||
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
||||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||||
@ -2974,6 +3002,27 @@ function NetscriptFunctions(workerScript) {
|
|||||||
|
|
||||||
return Factions[name].favor;
|
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) {
|
createProgram : function(name) {
|
||||||
var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;
|
var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;
|
||||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||||
|
Loading…
Reference in New Issue
Block a user