mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 19:14:32 +02:00
REFACTOR: Remove duplicate random alphanumeric string functions (#2601)
This commit is contained in:
@@ -11,6 +11,7 @@ import { BaseServer } from "../Server/BaseServer";
|
||||
import { getRandomIntInclusive } from "../utils/helpers/getRandomIntInclusive";
|
||||
import { ContractFilePath, resolveContractFilePath } from "../Paths/ContractFilePath";
|
||||
import { clampNumber } from "../utils/helpers/clampNumber";
|
||||
import { getRandomAlphanumericString } from "../utils/StringHelperFunctions";
|
||||
|
||||
export function tryGeneratingRandomContract(numberOfTries: number): void {
|
||||
/**
|
||||
@@ -213,15 +214,6 @@ function getRandomServer(): BaseServer | null {
|
||||
return randServer;
|
||||
}
|
||||
|
||||
function getRandomAlphanumericString(length: number) {
|
||||
const alphanumericChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
let result = "";
|
||||
for (let i = 0; i < length; ++i) {
|
||||
result += alphanumericChars.charAt(Math.random() * alphanumericChars.length);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return null if the randomized name collides with another contract's name on the specified server.
|
||||
* Callers of this function must return early and not generate a contract when it happens. It likely happens when there
|
||||
|
||||
Reference in New Issue
Block a user