fix a few bugs

This commit is contained in:
Olivier Gagnon 2021-10-23 15:22:58 -04:00
parent 0afb2e5f5d
commit 6d39fda3fa
8 changed files with 67 additions and 39 deletions

64
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -13,6 +13,8 @@ import TableBody from "@mui/material/TableBody";
import { Table, TableCell } from "../../ui/React/Table";
import TableRow from "@mui/material/TableRow";
export const InvitationsSeen: string[] = [];
interface IProps {
player: IPlayer;
router: IRouter;
@ -27,6 +29,14 @@ export function FactionsRoot(props: IProps): React.ReactElement {
const id = setInterval(rerender, 200);
return () => clearInterval(id);
}, []);
useEffect(() => {
props.player.factionInvitations.forEach((faction) => {
if (InvitationsSeen.includes(faction)) return;
InvitationsSeen.push(faction);
});
}, []);
function openFaction(faction: Faction): void {
props.router.toFaction(faction);
}

@ -1882,10 +1882,11 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
updateDynamicRam("scriptKill", getRamCost("scriptKill"));
const server = safeGetServer(hostname, "scriptKill");
let suc = false;
for (let i = 0; i < server.runningScripts.length; ++i) {
for (let i = 0; i < server.runningScripts.length; i++) {
if (server.runningScripts[i].filename == scriptname) {
killWorkerScript(server.runningScripts[i], server.hostname);
suc = true;
i--;
}
}
return suc;

@ -27,6 +27,8 @@ import { Terminal } from "./Terminal";
import { dialogBoxCreate } from "./ui/React/DialogBox";
import Decimal from "decimal.js";
import { ProgramsSeen } from "./Programs/ui/ProgramsRoot";
import { InvitationsSeen } from "./Faction/ui/FactionsRoot";
const BitNode8StartingMoney = 250e6;
@ -138,6 +140,8 @@ export function prestigeAugmentation(): void {
}
resetPidCounter();
ProgramsSeen.splice(0, ProgramsSeen.length);
InvitationsSeen.splice(0, InvitationsSeen.length);
}
// Prestige by destroying Bit Node and gaining a Source File

@ -5,6 +5,8 @@ import { getAvailableCreatePrograms } from "../ProgramHelpers";
import { Tooltip, Typography } from "@mui/material";
import Button from "@mui/material/Button";
export const ProgramsSeen: string[] = [];
export function ProgramsRoot(): React.ReactElement {
const player = use.Player();
const router = use.Router();
@ -13,6 +15,15 @@ export function ProgramsRoot(): React.ReactElement {
setRerender((old) => !old);
}
const programs = getAvailableCreatePrograms(player);
useEffect(() => {
programs.forEach((p) => {
if (ProgramsSeen.includes(p.name)) return;
ProgramsSeen.push(p.name);
});
}, []);
useEffect(() => {
const id = setInterval(rerender, 200);
return () => clearInterval(id);
@ -27,7 +38,7 @@ export function ProgramsRoot(): React.ReactElement {
time. Your progress will be saved and you can continue later.
</Typography>
{getAvailableCreatePrograms(player).map((program) => {
{programs.map((program) => {
const create = program.create;
if (create === null) return <></>;

@ -51,6 +51,8 @@ import { Settings } from "../../Settings/Settings";
import { redPillFlag } from "../../RedPill";
import { KEY } from "../../utils/helpers/keyCodes";
import { ProgramsSeen } from "../../Programs/ui/ProgramsRoot";
import { InvitationsSeen } from "../../Faction/ui/FactionsRoot";
const openedMixin = (theme: Theme): CSSObject => ({
width: theme.spacing(31),
@ -133,8 +135,8 @@ export function SidebarRoot(props: IProps): React.ReactElement {
const flashTutorial = ITutorial.currStep === iTutorialSteps.WorldDescription;
const augmentationCount = props.player.queuedAugmentations.length;
const invitationsCount = props.player.factionInvitations.length;
const programCount = getAvailableCreatePrograms(props.player).length;
const invitationsCount = props.player.factionInvitations.length - InvitationsSeen.length;
const programCount = getAvailableCreatePrograms(props.player).length - ProgramsSeen.length;
const canCreateProgram =
programCount > 0 ||
props.player.augmentations.length > 0 ||