mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 15:50:42 -05:00
Update Bot Generation to use ProgressWriter
- The ProgressWriter class now resets it's cursor position to the beginning of the current line so that any log inbetween increments overwrites the current progress bar. - Bot generation will now display a progress bar.
This commit is contained in:
parent
a9d76021bc
commit
bc1d0c5fb4
@ -25,6 +25,7 @@ import { DatabaseService } from "@spt/services/DatabaseService";
|
|||||||
import { LocalisationService } from "@spt/services/LocalisationService";
|
import { LocalisationService } from "@spt/services/LocalisationService";
|
||||||
import { MatchBotDetailsCacheService } from "@spt/services/MatchBotDetailsCacheService";
|
import { MatchBotDetailsCacheService } from "@spt/services/MatchBotDetailsCacheService";
|
||||||
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
||||||
|
import { ProgressWriter } from "@spt/utils/ProgressWriter";
|
||||||
import { RandomUtil } from "@spt/utils/RandomUtil";
|
import { RandomUtil } from "@spt/utils/RandomUtil";
|
||||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
@ -306,15 +307,17 @@ export class BotController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We're below desired count, add bots to cache
|
// We're below desired count, add bots to cache
|
||||||
|
const progressWriter = new ProgressWriter(botGenerationDetails.botCountToGenerate);
|
||||||
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++) {
|
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++) {
|
||||||
const detailsClone = this.cloner.clone(botGenerationDetails);
|
const detailsClone = this.cloner.clone(botGenerationDetails);
|
||||||
botPromises.push(this.generateSingleBotAndStoreInCache(detailsClone, sessionId, cacheKey));
|
botPromises.push(this.generateSingleBotAndStoreInCache(detailsClone, sessionId, cacheKey));
|
||||||
|
progressWriter.increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(botPromises).then(() => {
|
return await Promise.all(botPromises).then(() => {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${
|
`Generated ${botGenerationDetails.botCountToGenerate} ${botGenerationDetails.role} (${
|
||||||
botGenerationDetails.eventRole ?? ""
|
botGenerationDetails.eventRole ?? botGenerationDetails.role ?? ""
|
||||||
}) ${botGenerationDetails.botDifficulty} bots`,
|
}) ${botGenerationDetails.botDifficulty} bots`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -48,5 +48,7 @@ export class ProgressWriter {
|
|||||||
readline.cursorTo(process.stdout, 0, null);
|
readline.cursorTo(process.stdout, 0, null);
|
||||||
this.done = true;
|
this.done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readline.cursorTo(process.stdout, 0, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user