BUGFIX: Duplicated program in edge case (#1549)

This commit is contained in:
catloversg 2024-08-06 03:43:56 +07:00 committed by GitHub
parent 180dae1d2c
commit 1a8dcad02b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 16 deletions

@ -18,12 +18,13 @@ export function ProgramsDev(): React.ReactElement {
setProgram(event.target.value as CompletedProgramName);
}
function addProgram(): void {
if (!Player.hasProgram(program)) Player.getHomeComputer().programs.push(program);
Player.getHomeComputer().pushProgram(program);
}
function addAllPrograms(): void {
const home = Player.getHomeComputer();
for (const name of Object.values(CompletedProgramName)) {
if (!Player.hasProgram(name)) Player.getHomeComputer().programs.push(name);
home.pushProgram(name);
}
}

@ -74,10 +74,7 @@ function checkForMessagesToSend(): void {
}
} else if (!recvd(MessageFilename.Jumper0) && Player.skills.hacking >= 25) {
sendMessage(MessageFilename.Jumper0);
const homeComp = Player.getHomeComputer();
if (!homeComp.programs.includes(CompletedProgramName.flight)) {
homeComp.programs.push(CompletedProgramName.flight);
}
Player.getHomeComputer().pushProgram(CompletedProgramName.flight);
} else if (!recvd(MessageFilename.Jumper1) && Player.skills.hacking >= 40) {
sendMessage(MessageFilename.Jumper1);
} else if (!recvd(MessageFilename.CyberSecTest) && Player.skills.hacking >= 50) {

@ -67,7 +67,7 @@ export function init(this: PlayerObject): void {
this.currentServer = SpecialServers.Home;
AddToAllServers(t_homeComp);
this.getHomeComputer().programs.push(CompletedProgramName.nuke);
this.getHomeComputer().pushProgram(CompletedProgramName.nuke);
}
export function prestigeAugmentation(this: PlayerObject): void {

@ -80,11 +80,11 @@ export function prestigeAugmentation(): void {
const aug = Augmentations[ownedAug.name];
Player.gainMoney(aug.startingMoney, "other");
for (const program of aug.programs) {
homeComp.programs.push(program);
homeComp.pushProgram(program);
}
}
if (canAccessBitNodeFeature(5)) {
homeComp.programs.push(CompletedProgramName.formulas);
homeComp.pushProgram(CompletedProgramName.formulas);
}
// Re-create foreign servers
@ -248,7 +248,7 @@ export function prestigeSourceFile(isFlume: boolean): void {
Player.reapplyAllSourceFiles();
if (canAccessBitNodeFeature(5)) {
homeComp.programs.push(CompletedProgramName.formulas);
homeComp.pushProgram(CompletedProgramName.formulas);
}
// BitNode 3: Corporatocracy

@ -197,9 +197,9 @@ export function prestigeHomeComputer(homeComp: Server): void {
homeComp.serversOnNetwork = [];
homeComp.isConnectedTo = true;
homeComp.ramUsed = 0;
homeComp.programs.push(CompletedProgramName.nuke);
homeComp.pushProgram(CompletedProgramName.nuke);
if (hasBitflume) {
homeComp.programs.push(CompletedProgramName.bitFlume);
homeComp.pushProgram(CompletedProgramName.bitFlume);
}
homeComp.messages.length = 0; //Remove .lit and .msg files

@ -87,14 +87,12 @@ export class CreateProgramWork extends Work {
dialogBoxCreate(lines.join("\n"));
}
if (!Player.getHomeComputer().programs.includes(programName)) {
Player.getHomeComputer().programs.push(programName);
}
Player.getHomeComputer().pushProgram(programName);
} else if (!Player.getHomeComputer().programs.includes(programName)) {
//Incomplete case
const perc = ((100 * this.unitCompleted) / this.unitNeeded()).toFixed(2);
const incompleteName = asProgramFilePath(programName + "-" + perc + "%-INC");
Player.getHomeComputer().programs.push(incompleteName);
Player.getHomeComputer().pushProgram(incompleteName);
}
}