From fbf5545708081db7c393c83a4c46e824c6f6a11a Mon Sep 17 00:00:00 2001 From: danielyxie Date: Mon, 8 Jul 2019 18:34:31 -0700 Subject: [PATCH] Color-coded BitNode selection screen and added SF information --- css/redpill.scss | 30 +++-- doc/source/basicgameplay/codingcontracts.rst | 8 +- src/Constants.ts | 1 + src/RedPill.js | 109 +++++++++---------- src/data/codingcontracttypes.ts | 8 +- 5 files changed, 83 insertions(+), 73 deletions(-) diff --git a/css/redpill.scss b/css/redpill.scss index 1c8669cfe..1811b8b91 100644 --- a/css/redpill.scss +++ b/css/redpill.scss @@ -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; + } } diff --git a/doc/source/basicgameplay/codingcontracts.rst b/doc/source/basicgameplay/codingcontracts.rst index 98f2feb72..42b948649 100644 --- a/doc/source/basicgameplay/codingcontracts.rst +++ b/doc/source/basicgameplay/codingcontracts.rst @@ -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] | +------------------------------------+------------------------------------------------------------------------------------------+ diff --git a/src/Constants.ts b/src/Constants.ts index 3b5fd21a4..1f9c95138 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -229,6 +229,7 @@ export let CONSTANTS: IMap = { * 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 diff --git a/src/RedPill.js b/src/RedPill.js index c4cebac46..2556e77ba 100644 --- a/src/RedPill.js +++ b/src/RedPill.js @@ -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) { " | | | | | | | |
" + " \\JUMP3R|JUMP|3R| |R3|PMUJ|R3PMUJ/



"; - - /* - " O
" + - " | O O | O O |
" + - " O | | / __| \ | | O
" + - " O | O | | O / | O | | O | O
" + - " | | | | |_/ |/ | \_ \_| | | | |
" + - " O | | | O | | O__/ | / \__ | | O | | | O
" + - " | | | | | | | / /| O / \| | | | | | |
" + - "O | | | \| | O / _/ | / O | |/ | | | O
" + - "| | | |O / | | O / | O O | | \ O| | | |
" + - "| | |/ \/ / __| | |/ \ | \ | |__ \ \/ \| | |
" + - " \| O | |_/ |\| \ O \__| \_| | O |/
" + - " | | |_/ | | \| / | \_| | |
" + - " \| / \| | / / \ |/
" + - " | O | | / | O |
" + - " O | | | | | | | O
" + - " | | | / / \ \ | | |
" + - " \| | / O / \ O \ | |/
" + - " \ | / / | | \ \ | /
" + - " \ \JUMP O3R | | | | | | R3O PMUJ/ /
" + - " \|| | | | | | | | | ||/
" + - " \| \_ | | | | | | _/ |/
" + - " \ \| / \ / \ |/ /
" + - " O |/ O | | O \| O
" + - " | | | | | | | |
" + - " \JUMP3R|JUMP|3R| |R3|PMUJ|R3PMUJ/
"; - */ - 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 + "

" + bitNode.info); - createBitNodeYesNoEventListeners(i, destroyedBitNodeNum, flume); + + const maxSourceFileLevel = i === 12 ? "∞" : "3"; + const popupBoxText = `BitNode-${i}: ${bitNode.name}
` + + `Source-File Level: ${nextSourceFileFlags[i]} / ${maxSourceFileLevel}

` + + `${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 "O" + - "" + - "BitNode-" + bitNode.number.toString() + "
" + bitNode.name+ "

" + - bitNode.desc + "
" + - "
"; + 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 `O` + + "" + + `BitNode-${bitNode.number.toString()}
${bitNode.name}

` + + `${bitNode.desc}
` + + "
"; } -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(); diff --git a/src/data/codingcontracttypes.ts b/src/data/codingcontracttypes.ts index 02074ca84..9b50a1354 100644 --- a/src/data/codingcontracttypes.ts +++ b/src/data/codingcontracttypes.ts @@ -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: () => {