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); setProgram(event.target.value as CompletedProgramName);
} }
function addProgram(): void { function addProgram(): void {
if (!Player.hasProgram(program)) Player.getHomeComputer().programs.push(program); Player.getHomeComputer().pushProgram(program);
} }
function addAllPrograms(): void { function addAllPrograms(): void {
const home = Player.getHomeComputer();
for (const name of Object.values(CompletedProgramName)) { 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) { } else if (!recvd(MessageFilename.Jumper0) && Player.skills.hacking >= 25) {
sendMessage(MessageFilename.Jumper0); sendMessage(MessageFilename.Jumper0);
const homeComp = Player.getHomeComputer(); Player.getHomeComputer().pushProgram(CompletedProgramName.flight);
if (!homeComp.programs.includes(CompletedProgramName.flight)) {
homeComp.programs.push(CompletedProgramName.flight);
}
} else if (!recvd(MessageFilename.Jumper1) && Player.skills.hacking >= 40) { } else if (!recvd(MessageFilename.Jumper1) && Player.skills.hacking >= 40) {
sendMessage(MessageFilename.Jumper1); sendMessage(MessageFilename.Jumper1);
} else if (!recvd(MessageFilename.CyberSecTest) && Player.skills.hacking >= 50) { } else if (!recvd(MessageFilename.CyberSecTest) && Player.skills.hacking >= 50) {

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

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

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

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