mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 19:14:32 +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];
|
||||
|
||||
Reference in New Issue
Block a user