Merge branch 'dev' of github.com:danielyxie/bitburner into dev

This commit is contained in:
Olivier Gagnon 2021-12-18 14:36:30 -05:00
commit 47f20c666e
2 changed files with 100 additions and 63 deletions

@ -196,59 +196,63 @@ Here's what mine showed at the time I made this::
[home ~]> scan-analyze 2
~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~
>n00dles
--Root Access: NO, Required hacking skill: 1
n00dles
--Root Access: YES, Required hacking skill: 1
--Number of open ports required to NUKE: 0
--RAM: 16
--RAM: 4.00GB
>sigma-cosmetics
--Root Access: NO, Required hacking skill: 5
--Number of open ports required to NUKE: 0
--RAM: 16
>joesguns
--Root Access: NO, Required hacking skill: 10
--Number of open ports required to NUKE: 0
--RAM: 16
---->max-hardware
------Root Access: NO, Required hacking skill: 80
------Number of open ports required to NUKE: 1
------RAM: 32
>hong-fang-tea
--Root Access: NO, Required hacking skill: 30
--Number of open ports required to NUKE: 0
--RAM: 16
---->nectar-net
------Root Access: NO, Required hacking skill: 20
------Number of open ports required to NUKE: 0
------RAM: 16
>harakiri-sushi
--Root Access: NO, Required hacking skill: 40
--Number of open ports required to NUKE: 0
--RAM: 16
>iron-gym
--Root Access: NO, Required hacking skill: 100
--Number of open ports required to NUKE: 1
--RAM: 32
---->zer0
----zer0
------Root Access: NO, Required hacking skill: 75
------Number of open ports required to NUKE: 1
------RAM: 32
------RAM: 32.00GB
---->CSEC
foodnstuff
--Root Access: NO, Required hacking skill: 1
--Number of open ports required to NUKE: 0
--RAM: 16.00GB
sigma-cosmetics
--Root Access: NO, Required hacking skill: 5
--Number of open ports required to NUKE: 0
--RAM: 16.00GB
joesguns
--Root Access: NO, Required hacking skill: 10
--Number of open ports required to NUKE: 0
--RAM: 16.00GB
----max-hardware
------Root Access: NO, Required hacking skill: 80
------Number of open ports required to NUKE: 1
------RAM: 32.00GB
----CSEC
------Root Access: NO, Required hacking skill: 54
------Number of open ports required to NUKE: 1
------RAM: 8
------RAM: 8.00GB
hong-fang-tea
--Root Access: NO, Required hacking skill: 30
--Number of open ports required to NUKE: 0
--RAM: 16.00GB
----nectar-net
------Root Access: NO, Required hacking skill: 20
------Number of open ports required to NUKE: 0
------RAM: 16.00GB
harakiri-sushi
--Root Access: NO, Required hacking skill: 40
--Number of open ports required to NUKE: 0
--RAM: 16.00GB
iron-gym
--Root Access: NO, Required hacking skill: 100
--Number of open ports required to NUKE: 1
--RAM: 32.00GB
Take note of the following servers:
* |n00dles|
* |sigma-cosmetics|
* |joesguns|
* |nectar-net|
@ -279,16 +283,11 @@ servers, we have to do the following:
Here's the sequence of |Terminal| commands I used in order to achieve this::
$ home
$ scp early-hack-template.script n00dles
$ scp early-hack-template.script sigma-cosmetics
$ scp early-hack-template.script joesguns
$ scp early-hack-template.script nectar-net
$ scp early-hack-template.script hong-fang-tea
$ scp early-hack-template.script harakiri-sushi
$ connect n00dles
$ run NUKE.exe
$ run early-hack-template.script -t 6
$ home
$ connect sigma-cosmetics
$ run NUKE.exe
$ run early-hack-template.script -t 6

@ -48,12 +48,26 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
const terminalInput = useRef<HTMLInputElement>(null);
const [value, setValue] = useState(command);
const [postUpdateValue, setPostUpdateValue] = useState<{postUpdate: () => void} | null>()
const [possibilities, setPossibilities] = useState<string[]>([]);
const classes = useStyles();
function saveValue(value: string): void {
command = value;
setValue(value);
// Need to run after state updates, for example if we need to move cursor
// *after* we modify input
useEffect(() => {
if (postUpdateValue?.postUpdate) {
postUpdateValue.postUpdate();
setPostUpdateValue(null);
}
}, [postUpdateValue])
function saveValue(newValue: string, postUpdate?: () => void): void {
command = newValue;
setValue(newValue);
if (postUpdate) {
setPostUpdateValue({postUpdate});
}
}
function handleValueChange(event: React.ChangeEvent<HTMLInputElement>): void {
@ -76,24 +90,36 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
}
break;
case "deletewordbefore": // Delete rest of word before the cursor
for (let delStart = start - 1; delStart > 0; --delStart) {
if (inputText.charAt(delStart) === " ") {
saveValue(inputText.substr(0, delStart) + inputText.substr(start));
for (let delStart = start - 1; delStart > -2; --delStart) {
if ((inputText.charAt(delStart) === " " || delStart === -1) && delStart !== start - 1) {
saveValue(inputText.substr(0, delStart + 1) + inputText.substr(start), () => {
// Move cursor to correct location
// foo bar |baz bum --> foo |baz bum
const ref = terminalInput.current;
ref?.setSelectionRange(delStart+1, delStart+1);
});
return;
}
}
break;
case "deletewordafter": // Delete rest of word after the cursor
case "deletewordafter": // Delete rest of word after the cursor, including trailing space
for (let delStart = start + 1; delStart <= value.length + 1; ++delStart) {
if (inputText.charAt(delStart) === " ") {
saveValue(inputText.substr(0, start) + inputText.substr(delStart));
if (inputText.charAt(delStart) === " " || delStart === value.length + 1) {
saveValue(inputText.substr(0, start) + inputText.substr(delStart + 1), () => {
// Move cursor to correct location
// foo bar |baz bum --> foo bar |bum
const ref = terminalInput.current;
ref?.setSelectionRange(start, start)
});
return;
}
}
break;
case "clearafter": // Deletes everything after cursor
saveValue(inputText.substr(0, start));
break;
case "clearbefore:": // Deleetes everything before cursor
case "clearbefore": // Deletes everything before cursor
saveValue(inputText.substr(start), () => moveTextCursor("home"));
break;
}
}
@ -320,11 +346,23 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
event.preventDefault();
}
if (event.keyCode === KEY.W && event.ctrlKey) {
event.preventDefault();
modifyInput("deletewordbefore");
}
if (event.keyCode === KEY.U && event.ctrlKey) {
event.preventDefault();
modifyInput("clearbefore");
}
if (event.keyCode === KEY.K && event.ctrlKey) {
event.preventDefault();
modifyInput("clearafter");
}
// TODO AFTER THIS:
// alt + d deletes word after cursor
// ^w deletes word before cursor
// ^k clears line after cursor
// ^u clears line before cursor
}
}