Merge pull request #3873 from ilkecan/createProgram-cancel-message

createProgram: FIX #3846 Return correct message
This commit is contained in:
hydroflame 2022-07-06 14:38:38 -04:00 committed by GitHub
commit fb31903966
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1326,10 +1326,16 @@ export function createProgramWork(this: IPlayer, numCycles: number): boolean {
export function finishCreateProgramWork(this: IPlayer, cancelled: boolean): string { export function finishCreateProgramWork(this: IPlayer, cancelled: boolean): string {
const programName = this.createProgramName; const programName = this.createProgramName;
let message = "";
if (!cancelled) { if (!cancelled) {
//Complete case //Complete case
this.gainIntelligenceExp((CONSTANTS.IntelligenceProgramBaseExpGain * this.timeWorked) / 1000); this.gainIntelligenceExp((CONSTANTS.IntelligenceProgramBaseExpGain * this.timeWorked) / 1000);
dialogBoxCreate(`You've finished creating ${programName}!<br>The new program can be found on your home computer.`); const lines = [
`You've finished creating ${programName}!`,
"The new program can be found on your home computer.",
];
dialogBoxCreate(lines.join("<br>"));
message = lines.join(" ");
if (!this.getHomeComputer().programs.includes(programName)) { if (!this.getHomeComputer().programs.includes(programName)) {
this.getHomeComputer().programs.push(programName); this.getHomeComputer().programs.push(programName);
@ -1339,12 +1345,12 @@ export function finishCreateProgramWork(this: IPlayer, cancelled: boolean): stri
const perc = (Math.floor((this.timeWorkedCreateProgram / this.timeNeededToCompleteWork) * 10000) / 100).toString(); const perc = (Math.floor((this.timeWorkedCreateProgram / this.timeNeededToCompleteWork) * 10000) / 100).toString();
const incompleteName = programName + "-" + perc + "%-INC"; const incompleteName = programName + "-" + perc + "%-INC";
this.getHomeComputer().programs.push(incompleteName); this.getHomeComputer().programs.push(incompleteName);
message = `Cancelled creating program: ${programName} (${perc}% complete)`;
} }
this.isWorking = false; this.isWorking = false;
this.resetWorkStatus(); this.resetWorkStatus();
return "You've finished creating " + programName + "! The new program can be found on your home computer."; return message;
} }
export function startGraftAugmentationWork(this: IPlayer, augmentationName: string, time: number): void { export function startGraftAugmentationWork(this: IPlayer, augmentationName: string, time: number): void {