From ceb4a05289e11b79e8db8ba733d9d13b43f409e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zo=C3=AB=20Hoekstra?= Date: Thu, 25 Aug 2022 23:34:29 +0200 Subject: [PATCH 1/3] Fix type of RFAMessages with non-String results --- src/RemoteFileAPI/MessageDefinitions.ts | 4 ++-- src/RemoteFileAPI/MessageHandlers.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/RemoteFileAPI/MessageDefinitions.ts b/src/RemoteFileAPI/MessageDefinitions.ts index 05b21ad02..75386f72a 100644 --- a/src/RemoteFileAPI/MessageDefinitions.ts +++ b/src/RemoteFileAPI/MessageDefinitions.ts @@ -1,13 +1,13 @@ export class RFAMessage { jsonrpc = "2.0"; // Transmits version of JSON-RPC. Compliance maybe allows some funky interaction with external tools? public method?: string; // Is defined when it's a request/notification, otherwise undefined - public result?: string | number; // Is defined when it's a response, otherwise undefined + public result?: string | Array | number; // Is defined when it's a response, otherwise undefined public params?: FileMetadata; // Optional parameters to method public error?: string; // Only defined on error public id?: number; // ID to keep track of request -> response interaction, undefined with notifications, defined with request/response constructor( - obj: { method?: string; result?: string | number; params?: FileMetadata; error?: string; id?: number } = {}, + obj: { method?: string; result?: string | Array | number; params?: FileMetadata; error?: string; id?: number } = {}, ) { this.method = obj.method; this.result = obj.result; diff --git a/src/RemoteFileAPI/MessageHandlers.ts b/src/RemoteFileAPI/MessageHandlers.ts index 068f7b1cb..0c9326ed2 100644 --- a/src/RemoteFileAPI/MessageHandlers.ts +++ b/src/RemoteFileAPI/MessageHandlers.ts @@ -93,7 +93,7 @@ export const RFARequestHandler: Record void | R ...server.scripts.map((scr): string => scr.filename), ]; - return new RFAMessage({ result: JSON.stringify(fileNameList), id: msg.id }); + return new RFAMessage({ result: fileNameList, id: msg.id }); }, getAllFiles: function (msg: RFAMessage): RFAMessage { @@ -111,7 +111,7 @@ export const RFARequestHandler: Record void | R }), ]; - return new RFAMessage({ result: JSON.stringify(fileList), id: msg.id }); + return new RFAMessage({ result: fileList, id: msg.id }); }, calculateRam: function (msg: RFAMessage): RFAMessage { From 45c15c9953a46a3f4c99e009f7368c8303d95c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zo=C3=AB=20Hoekstra?= Date: Fri, 26 Aug 2022 11:31:37 +0200 Subject: [PATCH 2/3] Extract result type and correct it for getAllFiles --- src/RemoteFileAPI/MessageDefinitions.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/RemoteFileAPI/MessageDefinitions.ts b/src/RemoteFileAPI/MessageDefinitions.ts index 75386f72a..6ca272749 100644 --- a/src/RemoteFileAPI/MessageDefinitions.ts +++ b/src/RemoteFileAPI/MessageDefinitions.ts @@ -1,14 +1,12 @@ export class RFAMessage { jsonrpc = "2.0"; // Transmits version of JSON-RPC. Compliance maybe allows some funky interaction with external tools? public method?: string; // Is defined when it's a request/notification, otherwise undefined - public result?: string | Array | number; // Is defined when it's a response, otherwise undefined + public result?: ResultType; // Is defined when it's a response, otherwise undefined public params?: FileMetadata; // Optional parameters to method public error?: string; // Only defined on error public id?: number; // ID to keep track of request -> response interaction, undefined with notifications, defined with request/response - constructor( - obj: { method?: string; result?: string | Array | number; params?: FileMetadata; error?: string; id?: number } = {}, - ) { + constructor(obj: { method?: string; result?: ResultType; params?: FileMetadata; error?: string; id?: number } = {}) { this.method = obj.method; this.result = obj.result; this.params = obj.params; @@ -17,6 +15,7 @@ export class RFAMessage { } } +type ResultType = string | number | Array | Array; type FileMetadata = FileData | FileContent | FileLocation | FileServer; export interface FileData { From e16140fe9c9029c4bbe70c4208e392bbfea8079c Mon Sep 17 00:00:00 2001 From: Kelenius Date: Fri, 26 Aug 2022 21:03:30 +0300 Subject: [PATCH 3/3] Improvements to crime work UI --- src/Crime/Crime.ts | 5 +++++ src/Crime/Crimes.ts | 24 ++++++++++++------------ src/ui/WorkInProgressRoot.tsx | 4 +++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Crime/Crime.ts b/src/Crime/Crime.ts index e68096504..8100d9c0e 100644 --- a/src/Crime/Crime.ts +++ b/src/Crime/Crime.ts @@ -39,6 +39,9 @@ export class Crime { // Name of crime name = ""; + // Name of crime as it appears on work screen: "You are attempting..." + workName = ""; + // Milliseconds it takes to attempt the crime time = 0; @@ -64,6 +67,7 @@ export class Crime { constructor( name = "", + workName = "", type: CrimeType, time = 0, money = 0, @@ -72,6 +76,7 @@ export class Crime { params: IConstructorParams = {}, ) { this.name = name; + this.workName = workName; this.type = type; this.time = time; this.money = money; diff --git a/src/Crime/Crimes.ts b/src/Crime/Crimes.ts index 407eb85ad..d1f24b646 100644 --- a/src/Crime/Crimes.ts +++ b/src/Crime/Crimes.ts @@ -6,7 +6,7 @@ import { IMap } from "../types"; import { CrimeType } from "../utils/WorkType"; export const Crimes: IMap = { - Shoplift: new Crime("Shoplift", CrimeType.SHOPLIFT, 2e3, 15e3, 1 / 20, 0.1, { + Shoplift: new Crime("Shoplift", "to shoplift", CrimeType.SHOPLIFT, 2e3, 15e3, 1 / 20, 0.1, { dexterity_success_weight: 1, agility_success_weight: 1, @@ -14,7 +14,7 @@ export const Crimes: IMap = { agility_exp: 2, }), - RobStore: new Crime("Rob Store", CrimeType.ROB_STORE, 60e3, 400e3, 1 / 5, 0.5, { + RobStore: new Crime("Rob Store", "to rob a store", CrimeType.ROB_STORE, 60e3, 400e3, 1 / 5, 0.5, { hacking_exp: 30, dexterity_exp: 45, agility_exp: 45, @@ -26,7 +26,7 @@ export const Crimes: IMap = { intelligence_exp: 7.5 * CONSTANTS.IntelligenceCrimeBaseExpGain, }), - Mug: new Crime("Mug", CrimeType.MUG, 4e3, 36e3, 1 / 5, 0.25, { + Mug: new Crime("Mug", "to mug", CrimeType.MUG, 4e3, 36e3, 1 / 5, 0.25, { strength_exp: 3, defense_exp: 3, dexterity_exp: 3, @@ -38,7 +38,7 @@ export const Crimes: IMap = { agility_success_weight: 0.5, }), - Larceny: new Crime("Larceny", CrimeType.LARCENY, 90e3, 800e3, 1 / 3, 1.5, { + Larceny: new Crime("Larceny", "larceny", CrimeType.LARCENY, 90e3, 800e3, 1 / 3, 1.5, { hacking_exp: 45, dexterity_exp: 60, agility_exp: 60, @@ -50,7 +50,7 @@ export const Crimes: IMap = { intelligence_exp: 15 * CONSTANTS.IntelligenceCrimeBaseExpGain, }), - DealDrugs: new Crime("Deal Drugs", CrimeType.DRUGS, 10e3, 120e3, 1, 0.5, { + DealDrugs: new Crime("Deal Drugs", "to deal drugs", CrimeType.DRUGS, 10e3, 120e3, 1, 0.5, { dexterity_exp: 5, agility_exp: 5, charisma_exp: 10, @@ -60,7 +60,7 @@ export const Crimes: IMap = { agility_success_weight: 1, }), - BondForgery: new Crime("Bond Forgery", CrimeType.BOND_FORGERY, 300e3, 4.5e6, 1 / 2, 0.1, { + BondForgery: new Crime("Bond Forgery", "to forge bonds", CrimeType.BOND_FORGERY, 300e3, 4.5e6, 1 / 2, 0.1, { hacking_exp: 100, dexterity_exp: 150, charisma_exp: 15, @@ -71,7 +71,7 @@ export const Crimes: IMap = { intelligence_exp: 60 * CONSTANTS.IntelligenceCrimeBaseExpGain, }), - TraffickArms: new Crime("Traffick Arms", CrimeType.TRAFFIC_ARMS, 40e3, 600e3, 2, 1, { + TraffickArms: new Crime("Traffick Arms", "to traffic arms", CrimeType.TRAFFIC_ARMS, 40e3, 600e3, 2, 1, { strength_exp: 20, defense_exp: 20, dexterity_exp: 20, @@ -85,7 +85,7 @@ export const Crimes: IMap = { agility_success_weight: 1, }), - Homicide: new Crime("Homicide", CrimeType.HOMICIDE, 3e3, 45e3, 1, 3, { + Homicide: new Crime("Homicide", "homicide", CrimeType.HOMICIDE, 3e3, 45e3, 1, 3, { strength_exp: 2, defense_exp: 2, dexterity_exp: 2, @@ -99,7 +99,7 @@ export const Crimes: IMap = { kills: 1, }), - GrandTheftAuto: new Crime("Grand Theft Auto", CrimeType.GRAND_THEFT_AUTO, 80e3, 1.6e6, 8, 5, { + GrandTheftAuto: new Crime("Grand Theft Auto", "grand theft auto", CrimeType.GRAND_THEFT_AUTO, 80e3, 1.6e6, 8, 5, { strength_exp: 20, defense_exp: 20, dexterity_exp: 20, @@ -115,7 +115,7 @@ export const Crimes: IMap = { intelligence_exp: 16 * CONSTANTS.IntelligenceCrimeBaseExpGain, }), - Kidnap: new Crime("Kidnap", CrimeType.KIDNAP, 120e3, 3.6e6, 5, 6, { + Kidnap: new Crime("Kidnap", "to kidnap", CrimeType.KIDNAP, 120e3, 3.6e6, 5, 6, { strength_exp: 80, defense_exp: 80, dexterity_exp: 80, @@ -130,7 +130,7 @@ export const Crimes: IMap = { intelligence_exp: 26 * CONSTANTS.IntelligenceCrimeBaseExpGain, }), - Assassination: new Crime("Assassination", CrimeType.ASSASSINATION, 300e3, 12e6, 8, 10, { + Assassination: new Crime("Assassination", "to assassinate", CrimeType.ASSASSINATION, 300e3, 12e6, 8, 10, { strength_exp: 300, defense_exp: 300, dexterity_exp: 300, @@ -145,7 +145,7 @@ export const Crimes: IMap = { kills: 1, }), - Heist: new Crime("Heist", CrimeType.HEIST, 600e3, 120e6, 18, 15, { + Heist: new Crime("Heist", "a heist", CrimeType.HEIST, 600e3, 120e6, 18, 15, { hacking_exp: 450, strength_exp: 450, defense_exp: 450, diff --git a/src/ui/WorkInProgressRoot.tsx b/src/ui/WorkInProgressRoot.tsx index 70e847cc6..8f5ba77ce 100644 --- a/src/ui/WorkInProgressRoot.tsx +++ b/src/ui/WorkInProgressRoot.tsx @@ -221,6 +221,7 @@ export function WorkInProgressRoot(): React.ReactElement { const crime = player.currentWork.getCrime(); const completion = (player.currentWork.unitCompleted / crime.time) * 100; const gains = player.currentWork.earnings(); + const successChance = crime.successRate(player); workInfo = { buttons: { cancel: () => { @@ -232,9 +233,10 @@ export function WorkInProgressRoot(): React.ReactElement { player.stopFocusing(); }, }, - title: `You are attempting to ${crime.type}`, + title: `You are attempting ${crime.workName}`, gains: [ + Success chance: {numeralWrapper.formatPercentage(successChance)}, Gains (on success),