From d576d5e063b2e340483bacd586249784d5bb53f5 Mon Sep 17 00:00:00 2001 From: nickofolas Date: Sun, 24 Apr 2022 20:25:09 -0500 Subject: [PATCH 1/5] Reset Sleeve task if faction becomes gang --- src/PersonObjects/Sleeve/Sleeve.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 74295b062..ffeb03dad 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -519,6 +519,14 @@ export class Sleeve extends Person { break; } + // If the player has a gang with the faction the sleeve is working + // for, we need to reset the sleeve's task + if (p.gang) { + if (fac.name === p.gang.facName) { + this.resetTaskStatus(); + } + } + fac.playerReputation += this.getRepGain(p) * cyclesUsed; break; } From 79d6d77f98a0014b3b074ef011462a71cd30c39e Mon Sep 17 00:00:00 2001 From: nickofolas Date: Sun, 24 Apr 2022 20:38:07 -0500 Subject: [PATCH 2/5] Add task UI guard --- src/PersonObjects/Sleeve/ui/TaskSelector.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx index 8d3295076..d7876c77b 100644 --- a/src/PersonObjects/Sleeve/ui/TaskSelector.tsx +++ b/src/PersonObjects/Sleeve/ui/TaskSelector.tsx @@ -110,6 +110,8 @@ const tasks: { first: factions, second: (s1: string) => { const faction = Factions[s1]; + if (!faction) return ["------"]; + const facInfo = faction.getInfo(); const options: string[] = []; if (facInfo.offerHackingWork) { @@ -260,7 +262,7 @@ export function TaskSelector(props: IProps): React.ReactElement { const detailsF = tasks[n]; if (detailsF === undefined) throw new Error(`No function for task '${s0}'`); const details = detailsF(props.player, props.sleeve); - const details2 = details.second(details.first[0]); + const details2 = details.second(details.first[0]) ?? ["------"]; setS2(details2[0]); setS1(details.first[0]); setS0(n); From eed95cfa10cf57e8c321699c80b17466a5b44965 Mon Sep 17 00:00:00 2001 From: Staszek Welsh Date: Mon, 25 Apr 2022 16:48:33 +0100 Subject: [PATCH 3/5] Added descriptions for the following contracts: * Compression I: RLE Compression * Compression II: LZ Decompression * Compression III: LZ Compression --- doc/source/basicgameplay/codingcontracts.rst | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/doc/source/basicgameplay/codingcontracts.rst b/doc/source/basicgameplay/codingcontracts.rst index 596f6033f..715b2fb31 100644 --- a/doc/source/basicgameplay/codingcontracts.rst +++ b/doc/source/basicgameplay/codingcontracts.rst @@ -306,3 +306,67 @@ The list contains the name of (i.e. the value returned by | | | Input: [3, [[0, 1], [0, 2], [1, 2]]] | | | | Output: [] | +-----------------------------------------+------------------------------------------------------------------------------------------+ +| Compression I: RLE Compression | | Run-length encoding (RLE) is a data compression technique which encodes data as a | +| | | series of runs of a repeated single character. Runs are encoded as a length, followed | +| | | by the character itself. Lengths are encoded as a single ASCII digit; runs of 10 | +| | | characters or more are encoded by splitting them into multiple runs. | +| | | | +| | | You are given a string as input. Encode it using run-length encoding with the minimum | +| | | possible output length. | +| | | | +| | | Examples: | +| | | aaaaabccc -> 5a1b3c | +| | | aAaAaA -> 1a1A1a1A1a1A | +| | | 111112333 -> 511233 | +| | | zzzzzzzzzzzzzzzzzzz -> 9z9z1z (or 9z8z2z, etc.) | ++-----------------------------------------+------------------------------------------------------------------------------------------+ +| Compression II: LZ Decompression | | Lempel-Ziv (LZ) compression is a data compression technique which encodes data using | +| | | references to earlier parts of the data. In this variant of LZ, data is encoded in two | +| | | types of chunk. Each chunk begins with a length L, encoded as a single ASCII digit | +| | | from 1 - 9, followed by the chunk data, which is either: | +| | | | +| | | 1. Exactly L characters, which are to be copied directly into the uncompressed data. | +| | | 2. A reference to an earlier part of the uncompressed data. To do this, the length | +| | | is followed by a second ASCII digit X: each of the L output characters is a copy | +| | | of the character X places before it in the uncompressed data. | +| | | | +| | | For both chunk types, a length of 0 instead means the chunk ends immediately, and the | +| | | next character is the start of a new chunk. The two chunk types alternate, starting | +| | | with type 1, and the final chunk may be of either type. | +| | | | +| | | You are given an LZ-encoded string. Decode it and output the original string. | +| | | | +| | | Example: decoding '5aaabc340533bca' chunk-by-chunk | +| | | 5aaabc -> aaabc | +| | | 5aaabc34 -> aaabcaab | +| | | 5aaabc340 -> aaabcaab | +| | | 5aaabc34053 -> aaabcaabaabaa | +| | | 5aaabc340533bca -> aaabcaabaabaabca | ++-----------------------------------------+------------------------------------------------------------------------------------------+ +| Compression III: LZ Compression | | Lempel-Ziv (LZ) compression is a data compression technique which encodes data using | +| | | references to earlier parts of the data. In this variant of LZ, data is encoded in two | +| | | types of chunk. Each chunk begins with a length L, encoded as a single ASCII digit | +| | | from 1 - 9, followed by the chunk data, which is either: | +| | | | +| | | 1. Exactly L characters, which are to be copied directly into the uncompressed data. | +| | | 2. A reference to an earlier part of the uncompressed data. To do this, the length | +| | | is followed by a second ASCII digit X: each of the L output characters is a copy | +| | | of the character X places before it in the uncompressed data. | +| | | | +| | | For both chunk types, a length of 0 instead means the chunk ends immediately, and the | +| | | next character is the start of a new chunk. The two chunk types alternate, starting | +| | | with type 1, and the final chunk may be of either type. | +| | | | +| | | You are given a string as input. Encode it using Lempel-Ziv encoding with the minimum | +| | | possible output length. | +| | | | +| | | Examples (some have other possible encodings of minimal length): | +| | | abracadabra -> 7abracad47 | +| | | mississippi -> 4miss433ppi | +| | | aAAaAAaAaAA -> 3aAA53035 | +| | | 2718281828 -> 627182844 | +| | | abcdefghijk -> 9abcdefghi02jk | +| | | aaaaaaaaaaa -> 1a911a | +| | | aaaaaaaaaaaa -> 1a912aa | +| | | aaaaaaaaaaaaa -> 1a91031 | ++-----------------------------------------+------------------------------------------------------------------------------------------+ From 26bcdde9cbc6a6fa984d61b2d727b96135b48860 Mon Sep 17 00:00:00 2001 From: Staszek Welsh Date: Mon, 25 Apr 2022 17:02:17 +0100 Subject: [PATCH 4/5] Fix typo in import --- src/data/codingcontracttypes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/codingcontracttypes.ts b/src/data/codingcontracttypes.ts index 9c28ba795..f9c11f4a2 100644 --- a/src/data/codingcontracttypes.ts +++ b/src/data/codingcontracttypes.ts @@ -1,7 +1,7 @@ import { getRandomInt } from "../utils/helpers/getRandomInt"; import { MinHeap } from "../utils/Heap"; -import { comprGenChar, comprLZGenerate, comprLZEncode, comprLZDecode } from "../utils/CompressionContract"; +import { comprGenChar, comprLZGenerate, comprLZEncode, comprLZDecode } from "../utils/CompressionContracts"; import { HammingEncode, HammingDecode } from "../utils/HammingCodeTools"; /* tslint:disable:completed-docs no-magic-numbers arrow-return-shorthand */ From ab388777b54d3ac5583c0521d1056bc77e095645 Mon Sep 17 00:00:00 2001 From: PSEUDOSTAGE <61438810+PSEUDOSTAGE@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:02:49 -0400 Subject: [PATCH 5/5] Clarify definition for installAugmentations() Adds the sentence, "If you do not own uninstalled Augmentations then the game will not reset." to the description for installAugmentations(). --- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 6801bea07..e98b03557 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -2198,7 +2198,7 @@ export interface Singularity { * RAM cost: 5 GB * 16/4/1 * * - * This function will automatically install your Augmentations, resetting the game as usual. + * This function will automatically install your Augmentations, resetting the game as usual. If you do not own uninstalled Augmentations then the game will not reset. * * @param cbScript - This is a script that will automatically be run after Augmentations are installed (after the reset). This script will be run with no arguments and 1 thread. It must be located on your home computer. */