mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 12:45:45 +01:00
fix contracts
This commit is contained in:
parent
894929efdb
commit
8312710b0d
@ -25,7 +25,7 @@ export function NetscriptCodingContract(player: IPlayer, workerScript: WorkerScr
|
|||||||
attempt:
|
attempt:
|
||||||
(ctx: NetscriptContext) =>
|
(ctx: NetscriptContext) =>
|
||||||
(
|
(
|
||||||
_answer: unknown,
|
answer: unknown,
|
||||||
_filename: unknown,
|
_filename: unknown,
|
||||||
_hostname: unknown = workerScript.hostname,
|
_hostname: unknown = workerScript.hostname,
|
||||||
{ returnReward }: CodingAttemptOptions = { returnReward: false },
|
{ returnReward }: CodingAttemptOptions = { returnReward: false },
|
||||||
@ -36,23 +36,23 @@ export function NetscriptCodingContract(player: IPlayer, workerScript: WorkerScr
|
|||||||
|
|
||||||
// Convert answer to string. If the answer is a 2D array, then we have to
|
// Convert answer to string. If the answer is a 2D array, then we have to
|
||||||
// manually add brackets for the inner arrays
|
// manually add brackets for the inner arrays
|
||||||
let answer = "";
|
let answerStr = "";
|
||||||
if (is2DArray(answer)) {
|
if (is2DArray(answer)) {
|
||||||
const answerComponents = [];
|
const answerComponents = [];
|
||||||
for (let i = 0; i < answer.length; ++i) {
|
for (let i = 0; i < answer.length; ++i) {
|
||||||
answerComponents.push(["[", String(answer[i]), "]"].join(""));
|
answerComponents.push(["[", String(answer[i]), "]"].join(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
answer = answerComponents.join(",");
|
answerStr = answerComponents.join(",");
|
||||||
} else {
|
} else {
|
||||||
answer = String(answer);
|
answerStr = String(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
const creward = contract.reward;
|
const creward = contract.reward;
|
||||||
if (creward === null) throw new Error("Somehow solved a contract that didn't have a reward");
|
if (creward === null) throw new Error("Somehow solved a contract that didn't have a reward");
|
||||||
|
|
||||||
const serv = ctx.helper.getServer(hostname);
|
const serv = ctx.helper.getServer(hostname);
|
||||||
if (contract.isSolution(answer)) {
|
if (contract.isSolution(answerStr)) {
|
||||||
const reward = player.gainCodingContractReward(creward, contract.getDifficulty());
|
const reward = player.gainCodingContractReward(creward, contract.getDifficulty());
|
||||||
ctx.log(() => `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`);
|
ctx.log(() => `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`);
|
||||||
serv.removeContract(filename);
|
serv.removeContract(filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user