mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
BUGFIX: Properly deep copy array data for coding contracts (#1064)
This commit is contained in:
parent
5277db2c65
commit
011d5e8fd6
@ -67,17 +67,8 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
|
|||||||
const contract = getCodingContract(ctx, hostname, filename);
|
const contract = getCodingContract(ctx, hostname, filename);
|
||||||
const data = contract.getData();
|
const data = contract.getData();
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
// For two dimensional arrays, we have to copy the internal arrays using
|
// For multi-dimensional arrays, we have to copy the internal arrays as well
|
||||||
// slice() as well. As of right now, no contract has arrays that have
|
return JSON.parse(JSON.stringify(data));
|
||||||
// more than two dimensions
|
|
||||||
const copy = data.slice();
|
|
||||||
for (let i = 0; i < copy.length; ++i) {
|
|
||||||
if (data[i].constructor === Array) {
|
|
||||||
copy[i] = data[i].slice();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return copy;
|
|
||||||
} else return data;
|
} else return data;
|
||||||
},
|
},
|
||||||
getDescription: (ctx) => (_filename, _hostname?) => {
|
getDescription: (ctx) => (_filename, _hostname?) => {
|
||||||
|
@ -1198,9 +1198,9 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
|
|||||||
`"1+01" is not a valid expression`,
|
`"1+01" is not a valid expression`,
|
||||||
"Examples:\n\n",
|
"Examples:\n\n",
|
||||||
`Input: digits = "123", target = 6\n`,
|
`Input: digits = "123", target = 6\n`,
|
||||||
`Output: [1+2+3, 1*2*3]\n\n`,
|
`Output: ["1+2+3", "1*2*3"]\n\n`,
|
||||||
`Input: digits = "105", target = 5\n`,
|
`Input: digits = "105", target = 5\n`,
|
||||||
`Output: [1*0+5, 10-5]`,
|
`Output: ["1*0+5", "10-5"]`,
|
||||||
].join(" ");
|
].join(" ");
|
||||||
},
|
},
|
||||||
difficulty: 10,
|
difficulty: 10,
|
||||||
|
Loading…
Reference in New Issue
Block a user