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;
}
.bitnode {
color: #00f;
}
&.level-0 {
color: red;
}
.bitnode-destroyed {
color: #f00;
}
&.level-1 {
color: yellow;
}
.bitnode:hover,
.bitnode-destroyed:hover {
color: #fff;
&.level-2 {
color: #48D1CC;
}
&.level-3 {
color: blue;
}
&.unimplemented {
color: gray;
}
&:hover {
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. |
| | | |
| | | 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 |
@ -218,8 +218,8 @@ The list contains the name of (i.e. the value returned by
| | | |
| | | Examples: |
| | | Input: digits = "123", target = 6 |
| | | Output: ["1+2+3", "1*2*3"] |
| | | Output: [1+2+3, 1*2*3] |
| | | |
| | | 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
* 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())
* BitNode-selection page now shows what Source-File level you have for each BitNode
Misc Changes
* Added 'Solarized Dark' theme to CodeMirror editor

@ -5,8 +5,9 @@ import { BitNodes } from "./BitNode/BitNode";
import { Engine } from "./engine";
import { Player } from "./Player";
import { prestigeSourceFile } from "./Prestige";
import { SourceFiles } from "./SourceFile/SourceFiles";
import { PlayerOwnedSourceFile } from "./SourceFile/PlayerOwnedSourceFile";
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
import { SourceFiles } from "./SourceFile/SourceFiles";
import { Terminal } from "./Terminal";
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) {
// Clear the screen
var container = document.getElementById("red-pill-content");
const container = document.getElementById("red-pill-content");
removeChildrenFromElement(container);
// Update NextSourceFileFlags
nextSourceFileFlags = SourceFileFlags.slice();
if (!flume) {
++nextSourceFileFlags[destroyedBitNodeNum];
}
// Create the Bit Verse
var bitVerseImage = document.createElement("pre");
var bitNodes = [];
for (var i = 1; i <= 12; ++i) {
const bitVerseImage = document.createElement("pre");
const bitNodes = [];
for (let i = 1; i <= 12; ++i) {
bitNodes.push(createBitNode(i));
}
@ -177,53 +188,29 @@ function loadBitVerse(destroyedBitNodeNum, flume=false) {
" | | | | | | | | <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);
// Bit node event listeners
for (var i = 1; i <= 12; ++i) {
// BitNode event listeners
for (let i = 1; i <= 12; ++i) {
(function(i) {
var elemId = "bitnode-" + i.toString();
var elem = clearEventListeners(elemId);
if (elem == null) {return;}
const elemId = "bitnode-" + i.toString();
const elem = clearEventListeners(elemId);
if (elem == null) { return; }
if (i >= 1 && i <= 12) {
elem.addEventListener("click", function() {
var bitNodeKey = "BitNode" + i;
var bitNode = BitNodes[bitNodeKey];
const bitNodeKey = "BitNode" + i;
const bitNode = BitNodes[bitNodeKey];
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;
}
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 {
elem.addEventListener("click", function() {
@ -284,18 +271,28 @@ function loadBitVerse(destroyedBitNodeNum, flume=false) {
// Returns string with DOM element for Bit Node
function createBitNode(n) {
var bitNodeStr = "BitNode" + n.toString();
var bitNode = BitNodes[bitNodeStr];
if (bitNode == null) {return "O";}
return "<a class='bitnode tooltip' id='bitnode-" + bitNode.number.toString() + "'><strong>O</strong>" +
"<span class='tooltiptext'>" +
"<strong>BitNode-" + bitNode.number.toString() + "<br>" + bitNode.name+ "</strong><br>" +
bitNode.desc + "<br>" +
"</span></a>";
const bitNodeStr = "BitNode" + n.toString();
const bitNode = BitNodes[bitNodeStr];
if (bitNode == null) { return "O"; }
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'>" +
`<strong>BitNode-${bitNode.number.toString()}<br>${bitNode.name}</strong><br>` +
`${bitNode.desc}<br>` +
"</span></a>";
}
function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=false) {
var yesBtn = yesNoBoxGetYesButton();
function createBitNodeYesNoEventListener(newBitNode, destroyedBitNode, flume=false) {
const yesBtn = yesNoBoxGetYesButton();
yesBtn.innerHTML = "Enter BitNode-" + newBitNode;
yesBtn.addEventListener("click", function() {
if (!flume) {
@ -311,7 +308,7 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa
// Set new Bit Node
Player.bitNodeN = newBitNode;
console.log("Entering Bit Node " + Player.bitNodeN);
console.log(`Entering Bit Node ${Player.bitNodeN}`);
// Reenable terminal
$("#hack-progress-bar").attr('id', "old-hack-progress-bar");
@ -324,7 +321,7 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa
prestigeSourceFile();
yesNoBoxClose();
});
var noBtn = yesNoBoxGetNoButton();
const noBtn = yesNoBoxGetNoButton();
noBtn.innerHTML = "Back";
noBtn.addEventListener("click", function() {
yesNoBoxClose();

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