mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-27 03:25:44 +02:00
CONTRACTS: Proposal for Contract Progression System (#2230)
This commit is contained in:
@@ -70,17 +70,20 @@ export function tryGeneratingRandomContract(numberOfTries: number): void {
|
||||
}
|
||||
|
||||
export function generateRandomContract(): void {
|
||||
// First select a random problem type
|
||||
const problemType = getRandomProblemType();
|
||||
|
||||
// Then select a random reward type. 'Money' will always be the last reward type
|
||||
const reward = getRandomReward();
|
||||
|
||||
// Choose random server
|
||||
const randServer = getRandomServer();
|
||||
if (randServer === null) {
|
||||
return;
|
||||
}
|
||||
// Then select a random reward type. 'Money' will always be the last reward type
|
||||
const reward = getRandomReward();
|
||||
|
||||
// Finally select a random problem type.
|
||||
// Difficulty is capped to not overwhelm a new player.
|
||||
const totalSFs = [...Player.sourceFiles].reduce<number>((total, [__bn, lvl]) => (total += lvl), 0);
|
||||
const maxDif = 2 * totalSFs + 1;
|
||||
|
||||
const problemType = getRandomProblemType(maxDif);
|
||||
|
||||
const contractFn = getRandomFilename(randServer, reward);
|
||||
const contract = new CodingContract(contractFn, problemType, reward);
|
||||
@@ -179,8 +182,8 @@ function sanitizeRewardType(rewardType: CodingContractRewardType): CodingContrac
|
||||
return type;
|
||||
}
|
||||
|
||||
function getRandomProblemType(): CodingContractName {
|
||||
const problemTypes = Object.values(CodingContractName);
|
||||
function getRandomProblemType(maxDif = 10): CodingContractName {
|
||||
const problemTypes = Object.values(CodingContractName).filter((x) => CodingContractTypes[x].difficulty <= maxDif);
|
||||
const randIndex = getRandomIntInclusive(0, problemTypes.length - 1);
|
||||
|
||||
return problemTypes[randIndex];
|
||||
|
||||
@@ -96,7 +96,7 @@ export const algorithmicStockTrader: Pick<
|
||||
"If no profit can be made, then the answer should be 0.",
|
||||
].join(" ");
|
||||
},
|
||||
difficulty: 5,
|
||||
difficulty: 4,
|
||||
generate: (): number[] => {
|
||||
const len: number = getRandomIntInclusive(3, 50);
|
||||
const arr: number[] = [];
|
||||
|
||||
@@ -21,7 +21,7 @@ export const arrayJumpingGame: Pick<
|
||||
"Your answer should be submitted as 1 or 0, representing true and false respectively.",
|
||||
].join(" ");
|
||||
},
|
||||
difficulty: 2.5,
|
||||
difficulty: 2,
|
||||
generate: (): number[] => {
|
||||
const len: number = getRandomIntInclusive(3, 25);
|
||||
const arr: number[] = [];
|
||||
|
||||
@@ -8,7 +8,7 @@ export const hammingCode: Pick<
|
||||
CodingContractName.HammingCodesEncodedBinaryToInteger | CodingContractName.HammingCodesIntegerToEncodedBinary
|
||||
> = {
|
||||
[CodingContractName.HammingCodesIntegerToEncodedBinary]: {
|
||||
difficulty: 5,
|
||||
difficulty: 6,
|
||||
desc: (n: number): string => {
|
||||
return [
|
||||
"You are given the following decimal value: \n",
|
||||
@@ -43,7 +43,7 @@ export const hammingCode: Pick<
|
||||
validateAnswer: (ans): ans is string => typeof ans === "string",
|
||||
},
|
||||
[CodingContractName.HammingCodesEncodedBinaryToInteger]: {
|
||||
difficulty: 8,
|
||||
difficulty: 9,
|
||||
desc: (n: string): string => {
|
||||
return [
|
||||
"You are given the following encoded binary string: \n",
|
||||
|
||||
@@ -18,7 +18,7 @@ export const totalWaysToSum: Pick<
|
||||
"two positive integers?",
|
||||
].join(" ");
|
||||
},
|
||||
difficulty: 1.5,
|
||||
difficulty: 1,
|
||||
generate: (): number => {
|
||||
return getRandomIntInclusive(8, 100);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user