mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-13 03:03:54 +01:00
SF -1 related fixes
This commit is contained in:
parent
a4bc793cf1
commit
b9cc6321fd
@ -14,11 +14,12 @@ interface SfMinus1 {
|
|||||||
info: React.ReactElement;
|
info: React.ReactElement;
|
||||||
n: number;
|
n: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
lvl: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const safeGetSf = (sfNum: number): SourceFile | SfMinus1 | null => {
|
const safeGetSf = (sfNum: number): SourceFile | SfMinus1 | null => {
|
||||||
if (sfNum === -1) {
|
if (sfNum === -1) {
|
||||||
return {
|
const sfMinus1: SfMinus1 = {
|
||||||
info: (
|
info: (
|
||||||
<>
|
<>
|
||||||
This Source-File can only be acquired with obscure knowledge of the game, javascript, and the web ecosystem.
|
This Source-File can only be acquired with obscure knowledge of the game, javascript, and the web ecosystem.
|
||||||
@ -42,6 +43,7 @@ const safeGetSf = (sfNum: number): SourceFile | SfMinus1 | null => {
|
|||||||
n: -1,
|
n: -1,
|
||||||
name: "Source-File -1: Exploits in the BitNodes",
|
name: "Source-File -1: Exploits in the BitNodes",
|
||||||
};
|
};
|
||||||
|
return sfMinus1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const srcFileKey = "SourceFile" + sfNum;
|
const srcFileKey = "SourceFile" + sfNum;
|
||||||
@ -53,9 +55,31 @@ const safeGetSf = (sfNum: number): SourceFile | SfMinus1 | null => {
|
|||||||
return sfObj;
|
return sfObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getMaxLevel = (sfObj: SourceFile | SfMinus1): string | number => {
|
||||||
|
let maxLevel;
|
||||||
|
switch (sfObj.n) {
|
||||||
|
case 12:
|
||||||
|
maxLevel = "∞";
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
maxLevel = Object.keys(Exploit).length;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
maxLevel = "3";
|
||||||
|
}
|
||||||
|
return maxLevel;
|
||||||
|
};
|
||||||
|
|
||||||
export function SourceFilesElement(): React.ReactElement {
|
export function SourceFilesElement(): React.ReactElement {
|
||||||
const sourceSfs = Player.sourceFiles.slice();
|
const sourceSfs = Player.sourceFiles.slice();
|
||||||
const exploits = Player.exploits;
|
const exploits = Player.exploits;
|
||||||
|
// Create a fake SF for -1, if "owned"
|
||||||
|
if (exploits.length > 0) {
|
||||||
|
sourceSfs.unshift({
|
||||||
|
n: -1,
|
||||||
|
lvl: exploits.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.OwnedAugmentationsOrder === OwnedAugmentationsOrderSetting.Alphabetically) {
|
if (Settings.OwnedAugmentationsOrder === OwnedAugmentationsOrderSetting.Alphabetically) {
|
||||||
sourceSfs.sort((sf1, sf2) => {
|
sourceSfs.sort((sf1, sf2) => {
|
||||||
@ -63,12 +87,12 @@ export function SourceFilesElement(): React.ReactElement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const [selectedSf, setSelectedSf] = useState<any>(sourceSfs[0]);
|
|
||||||
|
|
||||||
if (sourceSfs.length === 0) {
|
if (sourceSfs.length === 0) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [selectedSf, setSelectedSf] = useState(sourceSfs[0]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ width: "100%", mt: 1 }}>
|
<Box sx={{ width: "100%", mt: 1 }}>
|
||||||
<Paper sx={{ p: 1 }}>
|
<Paper sx={{ p: 1 }}>
|
||||||
@ -80,29 +104,11 @@ export function SourceFilesElement(): React.ReactElement {
|
|||||||
sx={{ height: 400, overflowY: "scroll", borderRight: `1px solid ${Settings.theme.welllight}` }}
|
sx={{ height: 400, overflowY: "scroll", borderRight: `1px solid ${Settings.theme.welllight}` }}
|
||||||
disablePadding
|
disablePadding
|
||||||
>
|
>
|
||||||
{exploits.length > 0 && (
|
|
||||||
<ListItemButton
|
|
||||||
key={-1}
|
|
||||||
onClick={() => setSelectedSf({ n: -1, lvl: exploits.length })}
|
|
||||||
selected={selectedSf.n === -1}
|
|
||||||
sx={{ py: 0 }}
|
|
||||||
>
|
|
||||||
<ListItemText
|
|
||||||
disableTypography
|
|
||||||
primary={<Typography>Source-File -1: Exploits in the BitNodes</Typography>}
|
|
||||||
secondary={
|
|
||||||
<Typography>
|
|
||||||
Level {exploits.length} / {Object.keys(Exploit).length}
|
|
||||||
</Typography>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</ListItemButton>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{sourceSfs.map((e, i) => {
|
{sourceSfs.map((e, i) => {
|
||||||
const sfObj = safeGetSf(e.n);
|
const sfObj = safeGetSf(e.n);
|
||||||
if (!sfObj) return;
|
if (!sfObj) return;
|
||||||
const maxLevel = sfObj?.n === 12 ? "∞" : "3";
|
|
||||||
|
const maxLevel = getMaxLevel(sfObj);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItemButton key={i + 1} onClick={() => setSelectedSf(e)} selected={selectedSf === e} sx={{ py: 0 }}>
|
<ListItemButton key={i + 1} onClick={() => setSelectedSf(e)} selected={selectedSf === e} sx={{ py: 0 }}>
|
||||||
@ -129,24 +135,14 @@ export function SourceFilesElement(): React.ReactElement {
|
|||||||
const sfObj = safeGetSf(selectedSf.n);
|
const sfObj = safeGetSf(selectedSf.n);
|
||||||
if (!sfObj) return;
|
if (!sfObj) return;
|
||||||
|
|
||||||
let maxLevel;
|
const maxLevel = getMaxLevel(sfObj);
|
||||||
switch (sfObj?.n) {
|
|
||||||
case 12:
|
|
||||||
maxLevel = "∞";
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
maxLevel = Object.keys(Exploit).length;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
maxLevel = "3";
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
Level {selectedSf.lvl} / {maxLevel}
|
Level {selectedSf.lvl} / {maxLevel}
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
{sfObj?.info}
|
{sfObj.info}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
|
Loading…
Reference in New Issue
Block a user