Color-coded BitNode selection screen and added SF information

This commit is contained in:
danielyxie 2019-07-08 18:34:31 -07:00 committed by danielyxie
parent 6ae7b0136c
commit fbf5545708
5 changed files with 83 additions and 73 deletions

@ -7,16 +7,28 @@
position: fixed; position: fixed;
} }
.bitnode { .bitnode {
color: #00f; &.level-0 {
color: red;
} }
.bitnode-destroyed { &.level-1 {
color: #f00; color: yellow;
} }
.bitnode:hover, &.level-2 {
.bitnode-destroyed:hover { color: #48D1CC;
}
&.level-3 {
color: blue;
}
&.unimplemented {
color: gray;
}
&:hover {
color: #fff; color: #fff;
} }
}

@ -204,8 +204,8 @@ The list contains the name of (i.e. the value returned by
| | | the string, the result should be an array with only an empty string. | | | | the string, the result should be an array with only an empty string. |
| | | | | | | |
| | | Examples: | | | | Examples: |
| | | ()())() -> ["()()()", "(())()"] | | | | ()())() -> [()()(), (())()] |
| | | (a)())() -> ["(a)()()", "(a())()"] | | | | (a)())() -> [(a)()(), (a())()] |
| | | )( -> [""] | | | | )( -> [""] |
+------------------------------------+------------------------------------------------------------------------------------------+ +------------------------------------+------------------------------------------------------------------------------------------+
| Find All Valid Math Expressions | | You are given a string which contains only digits between 0 and 9 as well as a target | | Find All Valid Math Expressions | | You are given a string which contains only digits between 0 and 9 as well as a target |
@ -218,8 +218,8 @@ The list contains the name of (i.e. the value returned by
| | | | | | | |
| | | Examples: | | | | Examples: |
| | | Input: digits = "123", target = 6 | | | | Input: digits = "123", target = 6 |
| | | Output: ["1+2+3", "1*2*3"] | | | | Output: [1+2+3, 1*2*3] |
| | | | | | | |
| | | Input: digits = "105", target = 5 | | | | Input: digits = "105", target = 5 |
| | | Output: ["1*0+5", "10-5"] | | | | Output: [1*0+5, 10-5] |
+------------------------------------+------------------------------------------------------------------------------------------+ +------------------------------------+------------------------------------------------------------------------------------------+

@ -229,6 +229,7 @@ export let CONSTANTS: IMap<any> = {
* hacknet.getNodeStats() function now returns an additional property for Hacknet Servers: hashCapacity * hacknet.getNodeStats() function now returns an additional property for Hacknet Servers: hashCapacity
* Bug fix: workForFaction() function now properly accounts for disabled logs * Bug fix: workForFaction() function now properly accounts for disabled logs
* When writing to a file, the write() function now casts the data being written to a string (using String()) * When writing to a file, the write() function now casts the data being written to a string (using String())
* BitNode-selection page now shows what Source-File level you have for each BitNode
Misc Changes Misc Changes
* Added 'Solarized Dark' theme to CodeMirror editor * Added 'Solarized Dark' theme to CodeMirror editor

@ -5,8 +5,9 @@ import { BitNodes } from "./BitNode/BitNode";
import { Engine } from "./engine"; import { Engine } from "./engine";
import { Player } from "./Player"; import { Player } from "./Player";
import { prestigeSourceFile } from "./Prestige"; import { prestigeSourceFile } from "./Prestige";
import { SourceFiles } from "./SourceFile/SourceFiles";
import { PlayerOwnedSourceFile } from "./SourceFile/PlayerOwnedSourceFile"; import { PlayerOwnedSourceFile } from "./SourceFile/PlayerOwnedSourceFile";
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
import { SourceFiles } from "./SourceFile/SourceFiles";
import { Terminal } from "./Terminal"; import { Terminal } from "./Terminal";
import { setTimeoutRef } from "./utils/SetTimeoutRef"; import { setTimeoutRef } from "./utils/SetTimeoutRef";
@ -138,15 +139,25 @@ function giveSourceFile(bitNodeNumber) {
} }
} }
// Keeps track of what Source-Files the player will have AFTER the current bitnode
// is destroyed. Updated every time loadBitVerse() is called
let nextSourceFileFlags = [];
function loadBitVerse(destroyedBitNodeNum, flume=false) { function loadBitVerse(destroyedBitNodeNum, flume=false) {
// Clear the screen // Clear the screen
var container = document.getElementById("red-pill-content"); const container = document.getElementById("red-pill-content");
removeChildrenFromElement(container); removeChildrenFromElement(container);
// Update NextSourceFileFlags
nextSourceFileFlags = SourceFileFlags.slice();
if (!flume) {
++nextSourceFileFlags[destroyedBitNodeNum];
}
// Create the Bit Verse // Create the Bit Verse
var bitVerseImage = document.createElement("pre"); const bitVerseImage = document.createElement("pre");
var bitNodes = []; const bitNodes = [];
for (var i = 1; i <= 12; ++i) { for (let i = 1; i <= 12; ++i) {
bitNodes.push(createBitNode(i)); bitNodes.push(createBitNode(i));
} }
@ -177,53 +188,29 @@ function loadBitVerse(destroyedBitNodeNum, flume=false) {
" | | | | | | | | <br>" + " | | | | | | | | <br>" +
" \\JUMP3R|JUMP|3R| |R3|PMUJ|R3PMUJ/ <br><br><br><br>"; " \\JUMP3R|JUMP|3R| |R3|PMUJ|R3PMUJ/ <br><br><br><br>";
/*
" O <br>" +
" | O O | O O | <br>" +
" O | | / __| \ | | O <br>" +
" O | O | | O / | O | | O | O <br>" +
" | | | | |_/ |/ | \_ \_| | | | | <br>" +
" O | | | O | | O__/ | / \__ | | O | | | O <br>" +
" | | | | | | | / /| O / \| | | | | | | <br>" +
"O | | | \| | O / _/ | / O | |/ | | | O<br>" +
"| | | |O / | | O / | O O | | \ O| | | |<br>" +
"| | |/ \/ / __| | |/ \ | \ | |__ \ \/ \| | |<br>" +
" \| O | |_/ |\| \ O \__| \_| | O |/ <br>" +
" | | |_/ | | \| / | \_| | | <br>" +
" \| / \| | / / \ |/ <br>" +
" | O | | / | O | <br>" +
" O | | | | | | | O <br>" +
" | | | / / \ \ | | | <br>" +
" \| | / O / \ O \ | |/ <br>" +
" \ | / / | | \ \ | / <br>" +
" \ \JUMP O3R | | | | | | R3O PMUJ/ / <br>" +
" \|| | | | | | | | | ||/ <br>" +
" \| \_ | | | | | | _/ |/ <br>" +
" \ \| / \ / \ |/ / <br>" +
" O |/ O | | O \| O <br>" +
" | | | | | | | | <br>" +
" \JUMP3R|JUMP|3R| |R3|PMUJ|R3PMUJ/ <br>";
*/
container.appendChild(bitVerseImage); container.appendChild(bitVerseImage);
// Bit node event listeners // BitNode event listeners
for (var i = 1; i <= 12; ++i) { for (let i = 1; i <= 12; ++i) {
(function(i) { (function(i) {
var elemId = "bitnode-" + i.toString(); const elemId = "bitnode-" + i.toString();
var elem = clearEventListeners(elemId); const elem = clearEventListeners(elemId);
if (elem == null) { return; } if (elem == null) { return; }
if (i >= 1 && i <= 12) { if (i >= 1 && i <= 12) {
elem.addEventListener("click", function() { elem.addEventListener("click", function() {
var bitNodeKey = "BitNode" + i; const bitNodeKey = "BitNode" + i;
var bitNode = BitNodes[bitNodeKey]; const bitNode = BitNodes[bitNodeKey];
if (bitNode == null) { if (bitNode == null) {
console.log("ERROR: Could not find BitNode object for number: " + i); console.error(`Could not find BitNode object for number: ${i}`);
return; return;
} }
yesNoBoxCreate("BitNode-" + i + ": " + bitNode.name + "<br><br>" + bitNode.info);
createBitNodeYesNoEventListeners(i, destroyedBitNodeNum, flume); const maxSourceFileLevel = i === 12 ? "∞" : "3";
const popupBoxText = `BitNode-${i}: ${bitNode.name}<br>` +
`Source-File Level: ${nextSourceFileFlags[i]} / ${maxSourceFileLevel}<br><br>` +
`${bitNode.info}`;
yesNoBoxCreate(popupBoxText);
createBitNodeYesNoEventListener(i, destroyedBitNodeNum, flume);
}); });
} else { } else {
elem.addEventListener("click", function() { elem.addEventListener("click", function() {
@ -284,18 +271,28 @@ function loadBitVerse(destroyedBitNodeNum, flume=false) {
// Returns string with DOM element for Bit Node // Returns string with DOM element for Bit Node
function createBitNode(n) { function createBitNode(n) {
var bitNodeStr = "BitNode" + n.toString(); const bitNodeStr = "BitNode" + n.toString();
var bitNode = BitNodes[bitNodeStr]; const bitNode = BitNodes[bitNodeStr];
if (bitNode == null) { return "O"; } if (bitNode == null) { return "O"; }
return "<a class='bitnode tooltip' id='bitnode-" + bitNode.number.toString() + "'><strong>O</strong>" +
const level = nextSourceFileFlags[n];
let cssClass;
if (n === 12 && level >= 2) {
// Repeating BitNode
cssClass = "level-2";
} else {
cssClass = `level-${level}`;
}
return `<a class='bitnode ${cssClass} tooltip' id='bitnode-${bitNode.number}'><strong>O</strong>` +
"<span class='tooltiptext'>" + "<span class='tooltiptext'>" +
"<strong>BitNode-" + bitNode.number.toString() + "<br>" + bitNode.name+ "</strong><br>" + `<strong>BitNode-${bitNode.number.toString()}<br>${bitNode.name}</strong><br>` +
bitNode.desc + "<br>" + `${bitNode.desc}<br>` +
"</span></a>"; "</span></a>";
} }
function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=false) { function createBitNodeYesNoEventListener(newBitNode, destroyedBitNode, flume=false) {
var yesBtn = yesNoBoxGetYesButton(); const yesBtn = yesNoBoxGetYesButton();
yesBtn.innerHTML = "Enter BitNode-" + newBitNode; yesBtn.innerHTML = "Enter BitNode-" + newBitNode;
yesBtn.addEventListener("click", function() { yesBtn.addEventListener("click", function() {
if (!flume) { if (!flume) {
@ -311,7 +308,7 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa
// Set new Bit Node // Set new Bit Node
Player.bitNodeN = newBitNode; Player.bitNodeN = newBitNode;
console.log("Entering Bit Node " + Player.bitNodeN); console.log(`Entering Bit Node ${Player.bitNodeN}`);
// Reenable terminal // Reenable terminal
$("#hack-progress-bar").attr('id', "old-hack-progress-bar"); $("#hack-progress-bar").attr('id', "old-hack-progress-bar");
@ -324,7 +321,7 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa
prestigeSourceFile(); prestigeSourceFile();
yesNoBoxClose(); yesNoBoxClose();
}); });
var noBtn = yesNoBoxGetNoButton(); const noBtn = yesNoBoxGetNoButton();
noBtn.innerHTML = "Back"; noBtn.innerHTML = "Back";
noBtn.addEventListener("click", function() { noBtn.addEventListener("click", function() {
yesNoBoxClose(); yesNoBoxClose();

@ -748,8 +748,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
"the result should be an array with only an empty string.\n\n", "the result should be an array with only an empty string.\n\n",
"IMPORTANT: The string may contain letters, not just parentheses.", "IMPORTANT: The string may contain letters, not just parentheses.",
`Examples:\n`, `Examples:\n`,
`"()())()" -> ["()()()", "(())()"]\n`, `"()())()" -> [()()(), (())()]\n`,
`"(a)())()" -> ["(a)()()", "(a())()"]\n`, `"(a)())()" -> [(a)()(), (a())()]\n`,
`")( -> [""]`].join(" "); `")( -> [""]`].join(" ");
}, },
difficulty: 10, difficulty: 10,
@ -845,9 +845,9 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
`"1+01" is not a valid expression`, `"1+01" is not a valid expression`,
"Examples:\n\n", "Examples:\n\n",
`Input: digits = "123", target = 6\n`, `Input: digits = "123", target = 6\n`,
`Output: ["1+2+3", "1*2*3"]\n\n`, `Output: [1+2+3, 1*2*3]\n\n`,
`Input: digits = "105", target = 5\n`, `Input: digits = "105", target = 5\n`,
`Output: ["1*0+5", "10-5"]`].join(" "); `Output: [1*0+5, 10-5]`].join(" ");
}, },
difficulty: 10, difficulty: 10,
gen: () => { gen: () => {