mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
Fixed bug with contract generation when player doesn't have a job. Added bladeburner.getActionRepGain() function
This commit is contained in:
parent
593087d55f
commit
81c1655a30
2
dist/engine.bundle.js
vendored
2
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -33,6 +33,32 @@ Interacting through Scripts
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
See :ref:`netscriptcodingcontractapi`.
|
||||
|
||||
Submitting Solutions
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
Different contract problem types will require different types of
|
||||
solutions. Some may be numbers, others may be strings or arrays.
|
||||
If a contract asks for a specific solution format, then
|
||||
use that. Otherwise, follow these rules when submitting solutions:
|
||||
|
||||
* String-type solutions should not have quotation marks surrounding
|
||||
the string (unless specifically asked for). Only quotation
|
||||
marks that are part of the actual string solution should be included.
|
||||
* Array-type solutions should be submitted with each element
|
||||
in the array separated by commas. Brackets are optional. For example,
|
||||
both of the following are valid solution formats::
|
||||
|
||||
1,2,3
|
||||
[1,2,3]
|
||||
|
||||
However, if the solution is a multidimensional array, then
|
||||
all arrays that are not the outer-most array DO require the brackets.
|
||||
For example, an array of arrays can be submitted as one of the following::
|
||||
|
||||
[1,2],[3,4]
|
||||
[[1,2],[3,4]]
|
||||
|
||||
* Numeric solutions should be submitted normally, as expected
|
||||
|
||||
Rewards
|
||||
^^^^^^^
|
||||
There are currently four possible rewards for solving a Coding Contract:
|
||||
@ -45,3 +71,8 @@ There are currently four possible rewards for solving a Coding Contract:
|
||||
The 'amount' of reward varies based on the difficulty of the problem
|
||||
posed by the Coding Contract. There is no way to know what a
|
||||
Coding Contract's exact reward will be until it is solved.
|
||||
|
||||
Notes
|
||||
^^^^^
|
||||
|
||||
* The *scp* Terminal command does not work on Coding Contracts
|
||||
|
@ -146,6 +146,19 @@ getActionEstimatedSuccessChance
|
||||
is returned as a decimal value, NOT a percentage (e.g. if you have an estimated
|
||||
success chance of 80%, then this function will return 0.80, NOT 80).
|
||||
|
||||
getActionRepGain
|
||||
----------------
|
||||
|
||||
.. js:function:: getActionRepGain(type, name[, level=current level])
|
||||
|
||||
:param string type: Type of action. See :ref:`bladeburner_action_types`
|
||||
:param string name: Name of action. Must be an exact match
|
||||
:param number level: Optional action level at which to calculate the gain
|
||||
|
||||
Returns the average Bladeburner reputation gain for successfully completing
|
||||
the specified action. Note that this value is an 'average' and the real
|
||||
reputation gain may vary slightly from this value.
|
||||
|
||||
getActionCountRemaining
|
||||
-----------------------
|
||||
|
||||
|
@ -105,7 +105,7 @@ let NetscriptFunctions =
|
||||
"getGeneralActionNames|getSkillNames|startAction|stopBladeburnerAction|" +
|
||||
"getActionTime|getActionEstimatedSuccessChance|getActionCountRemaining|" +
|
||||
"getActionMaxLevel|getActionCurrentLevel|getActionAutolevel|" +
|
||||
"setActionAutolevel|setActionLevel|" +
|
||||
"getActionRepGain|setActionAutolevel|setActionLevel|" +
|
||||
"getRank|getSkillPoints|getSkillLevel|getSkillUpgradeCost|" +
|
||||
"upgradeSkill|getTeamSize|getCity|" +
|
||||
"setTeamSize|getCityEstimatedPopulation|getCityEstimatedCommunities|" +
|
||||
|
@ -509,6 +509,7 @@ let CONSTANTS = {
|
||||
v0.40.4<br>
|
||||
* Added new Coding Contracts mechanic. Solve programming problems to earn rewards
|
||||
* (TODO NEEDS DOCUMENTATION) The write() and read() Netscript functions now work on scripts
|
||||
* Added bladeburner.getActionRepGain() function to the Netscript Bladeburner API
|
||||
* It is now possible to use freely use angled bracket (<, >) and create DOM elements using tprint()
|
||||
* The game's theme colors can now be set through the Terminal configuration (.fconf).
|
||||
* You can now switch to the old left-hand main menu bar through the Terminal configuration (.fconf)
|
||||
|
@ -3617,6 +3617,37 @@ function NetscriptFunctions(workerScript) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "getActionEstimatedSuccessChance() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
|
||||
"at the Bladeburner division or because you do not have Source-File 7");
|
||||
},
|
||||
getActionRepGain: function(type="", name="", level) {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getActionRepGain", CONSTANTS.ScriptBladeburnerApiBaseRamCost);
|
||||
}
|
||||
updateDynamicRam("getActionRepGain", CONSTANTS.ScriptBladeburnerApiBaseRamCost);
|
||||
checkBladeburnerAccess(workerScript, "getActionRepGain");
|
||||
|
||||
try {
|
||||
var errorLogText = unknownBladeburnerActionErrorMessage("getActionAutolevel", type, name);
|
||||
const actionId = Player.bladeburner.getActionIdFromTypeAndName(type, name);
|
||||
if (actionId == null) {
|
||||
workerScript.log(errorLogText);
|
||||
return -1;
|
||||
}
|
||||
const actionObj = Player.bladeburner.getActionObject(actionId);
|
||||
if (actionObj == null) {
|
||||
workerScript.log(errorLogText);
|
||||
return -1;
|
||||
}
|
||||
var rewardMultiplier;
|
||||
if (level == null || isNaN(level)) {
|
||||
rewardMultiplier = Math.pow(actionObj.rewardFac, actionObj.level - 1);
|
||||
} else {
|
||||
rewardMultiplier = Math.pow(actionObj.rewardFac, level - 1);
|
||||
}
|
||||
|
||||
return actionObj.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank;
|
||||
} catch(err) {
|
||||
throw makeRuntimeRejectMsg(workerScript, unknownBladeburnerExceptionMessage("getActionAutolevel", err));
|
||||
}
|
||||
},
|
||||
getActionCountRemaining : function(type="", name="") {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getActionCountRemaining", CONSTANTS.ScriptBladeburnerApiBaseRamCost);
|
||||
|
@ -211,7 +211,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
||||
if (++l > r) { break; }
|
||||
}
|
||||
|
||||
const sanitizedPlayerAns: string = removeBracketsFromArrayString(ans);
|
||||
const sanitizedPlayerAns: string = removeBracketsFromArrayString(ans).replace(/\s/g, "");
|
||||
const playerAns: any[] = sanitizedPlayerAns.split(",");
|
||||
for (let i: number = 0; i < playerAns.length; ++i) {
|
||||
playerAns[i] = parseInt(playerAns[i], 10);
|
||||
@ -310,7 +310,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
||||
const sanitizedResult: string = convert2DArrayToString(result);
|
||||
const sanitizedAns: string = ans.replace(/\s/g, "");
|
||||
|
||||
return (sanitizedResult === sanitizedAns ||
|
||||
return (sanitizedResult === sanitizedAns ||
|
||||
sanitizedResult === removeBracketsFromArrayString(sanitizedAns));
|
||||
},
|
||||
},
|
||||
@ -362,11 +362,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
||||
}
|
||||
}
|
||||
|
||||
let sanitizedAns: string = ans.replace(/\s/g, "");
|
||||
if (sanitizedAns.length === 0 || sanitizedAns[0] !== "[" || sanitizedAns[sanitizedAns.length - 1] !== "]") {
|
||||
return false;
|
||||
}
|
||||
sanitizedAns = sanitizedAns.slice(1, -1); // Remove []
|
||||
let sanitizedAns: string = removeBracketsFromArrayString(ans).replace(/\s/g, "");
|
||||
const ansArr: string[] = sanitizedAns.split(",");
|
||||
if (ansArr.length !== ret.length) { return false; }
|
||||
for (const ipInAns of ansArr) {
|
||||
|
@ -1154,8 +1154,8 @@ const Engine = {
|
||||
}
|
||||
|
||||
if (Engine.Counters.contractGeneration <= 0) {
|
||||
// 20% chance of a contract being generated
|
||||
if (Math.random() < 0.2) {
|
||||
// X% chance of a contract being generated
|
||||
if (Math.random() < 0.23) {
|
||||
// First select a random problem type
|
||||
const problemTypes = Object.keys(CodingContractTypes);
|
||||
let randIndex = getRandomInt(0, problemTypes.length - 1);
|
||||
@ -1166,8 +1166,15 @@ const Engine = {
|
||||
reward.type = getRandomInt(0, CodingContractRewardType.Money);
|
||||
|
||||
// Change type based on certain conditions
|
||||
if (Player.factions.length === 0) { reward.type = CodingContractRewardType.CompanyReputation; }
|
||||
if (Player.companyName === "") { reward.type = CodingContractRewardType.Money; }
|
||||
if (reward.type === CodingContractRewardType.FactionReputation && Player.factions.length === 0) {
|
||||
reward.type = CodingContractRewardType.CompanyReputation;
|
||||
}
|
||||
if (reward.type === CodingContractRewardType.FactionReputationAll && Player.factions.length === 0) {
|
||||
reward.type = CodingContractRewardType.CompanyReputation;
|
||||
}
|
||||
if (reward.type === CodingContractRewardType.CompanyReputation && Player.companyName === "") {
|
||||
reward.type = CodingContractRewardType.Money;
|
||||
}
|
||||
|
||||
// Add additional information based on the reward type
|
||||
switch (reward.type) {
|
||||
|
Loading…
Reference in New Issue
Block a user