This commit is contained in:
Snarling
2022-09-06 09:07:12 -04:00
parent cc2246213f
commit 83d357e758
203 changed files with 2263 additions and 3018 deletions
+50 -51
View File
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { Sleeve } from "../Sleeve";
import { IPlayer } from "../../IPlayer";
import { Player } from "../../../Player";
import { Crimes } from "../../../Crime/Crimes";
import { LocationName } from "../../../Locations/data/LocationNames";
import { CityName } from "../../../Locations/data/CityNames";
@@ -43,7 +43,6 @@ const bladeburnerSelectorOptions: string[] = [
interface IProps {
sleeve: Sleeve;
player: IPlayer;
setABC: (abc: string[]) => void;
}
@@ -52,10 +51,10 @@ interface ITaskDetails {
second: (s1: string) => string[];
}
function possibleJobs(player: IPlayer, sleeve: Sleeve): string[] {
function possibleJobs(sleeve: Sleeve): string[] {
// Array of all companies that other sleeves are working at
const forbiddenCompanies: string[] = [];
for (const otherSleeve of player.sleeves) {
for (const otherSleeve of Player.sleeves) {
if (sleeve === otherSleeve) {
continue;
}
@@ -63,18 +62,18 @@ function possibleJobs(player: IPlayer, sleeve: Sleeve): string[] {
forbiddenCompanies.push(otherSleeve.currentWork.companyName);
}
}
const allJobs: string[] = Object.keys(player.jobs);
const allJobs: string[] = Object.keys(Player.jobs);
return allJobs.filter((company) => !forbiddenCompanies.includes(company));
}
function possibleFactions(player: IPlayer, sleeve: Sleeve): string[] {
function possibleFactions(sleeve: Sleeve): string[] {
// Array of all factions that other sleeves are working for
const forbiddenFactions = [FactionNames.Bladeburners as string, FactionNames.ShadowsOfAnarchy as string];
if (player.gang) {
forbiddenFactions.push(player.gang.facName);
if (Player.gang) {
forbiddenFactions.push(Player.gang.facName);
}
for (const otherSleeve of player.sleeves) {
for (const otherSleeve of Player.sleeves) {
if (sleeve === otherSleeve) {
continue;
}
@@ -84,7 +83,7 @@ function possibleFactions(player: IPlayer, sleeve: Sleeve): string[] {
}
const factions = [];
for (const fac of player.factions) {
for (const fac of Player.factions) {
if (!forbiddenFactions.includes(fac)) {
factions.push(fac);
}
@@ -98,13 +97,13 @@ function possibleFactions(player: IPlayer, sleeve: Sleeve): string[] {
});
}
function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] {
const bb = player.bladeburner;
function possibleContracts(sleeve: Sleeve): string[] {
const bb = Player.bladeburner;
if (bb === null) {
return ["------"];
}
let contracts = bb.getContractNamesNetscriptFn();
for (const otherSleeve of player.sleeves) {
for (const otherSleeve of Player.sleeves) {
if (sleeve === otherSleeve) {
continue;
}
@@ -120,28 +119,28 @@ function possibleContracts(player: IPlayer, sleeve: Sleeve): string[] {
}
const tasks: {
[key: string]: undefined | ((player: IPlayer, sleeve: Sleeve) => ITaskDetails);
["------"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Work for Company"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Work for Faction"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Commit Crime"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Take University Course"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Workout at Gym"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Perform Bladeburner Actions"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Shock Recovery"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
["Synchronize"]: (player: IPlayer, sleeve: Sleeve) => ITaskDetails;
[key: string]: undefined | ((sleeve: Sleeve) => ITaskDetails);
["------"]: (sleeve: Sleeve) => ITaskDetails;
["Work for Company"]: (sleeve: Sleeve) => ITaskDetails;
["Work for Faction"]: (sleeve: Sleeve) => ITaskDetails;
["Commit Crime"]: (sleeve: Sleeve) => ITaskDetails;
["Take University Course"]: (sleeve: Sleeve) => ITaskDetails;
["Workout at Gym"]: (sleeve: Sleeve) => ITaskDetails;
["Perform Bladeburner Actions"]: (sleeve: Sleeve) => ITaskDetails;
["Shock Recovery"]: (sleeve: Sleeve) => ITaskDetails;
["Synchronize"]: (sleeve: Sleeve) => ITaskDetails;
} = {
"------": (): ITaskDetails => {
return { first: ["------"], second: () => ["------"] };
},
"Work for Company": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
let jobs = possibleJobs(player, sleeve);
"Work for Company": (sleeve: Sleeve): ITaskDetails => {
let jobs = possibleJobs(sleeve);
if (jobs.length === 0) jobs = ["------"];
return { first: jobs, second: () => ["------"] };
},
"Work for Faction": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
let factions = possibleFactions(player, sleeve);
"Work for Faction": (sleeve: Sleeve): ITaskDetails => {
let factions = possibleFactions(sleeve);
if (factions.length === 0) factions = ["------"];
return {
@@ -168,7 +167,7 @@ const tasks: {
"Commit Crime": (): ITaskDetails => {
return { first: Object.values(Crimes).map((crime) => crime.name), second: () => ["------"] };
},
"Take University Course": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
"Take University Course": (sleeve: Sleeve): ITaskDetails => {
let universities: string[] = [];
switch (sleeve.city) {
case CityName.Aevum:
@@ -187,7 +186,7 @@ const tasks: {
return { first: universitySelectorOptions, second: () => universities };
},
"Workout at Gym": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
"Workout at Gym": (sleeve: Sleeve): ITaskDetails => {
let gyms: string[] = [];
switch (sleeve.city) {
case CityName.Aevum:
@@ -206,12 +205,12 @@ const tasks: {
return { first: gymSelectorOptions, second: () => gyms };
},
"Perform Bladeburner Actions": (player: IPlayer, sleeve: Sleeve): ITaskDetails => {
"Perform Bladeburner Actions": (sleeve: Sleeve): ITaskDetails => {
return {
first: bladeburnerSelectorOptions,
second: (s1: string) => {
if (s1 === "Take on contracts") {
return possibleContracts(player, sleeve);
return possibleContracts(sleeve);
} else {
return ["------"];
}
@@ -227,28 +226,28 @@ const tasks: {
};
const canDo: {
[key: string]: undefined | ((player: IPlayer, sleeve: Sleeve) => boolean);
["------"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Work for Company"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Work for Faction"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Commit Crime"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Take University Course"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Workout at Gym"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Perform Bladeburner Actions"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Shock Recovery"]: (player: IPlayer, sleeve: Sleeve) => boolean;
["Synchronize"]: (player: IPlayer, sleeve: Sleeve) => boolean;
[key: string]: undefined | ((sleeve: Sleeve) => boolean);
["------"]: (sleeve: Sleeve) => boolean;
["Work for Company"]: (sleeve: Sleeve) => boolean;
["Work for Faction"]: (sleeve: Sleeve) => boolean;
["Commit Crime"]: (sleeve: Sleeve) => boolean;
["Take University Course"]: (sleeve: Sleeve) => boolean;
["Workout at Gym"]: (sleeve: Sleeve) => boolean;
["Perform Bladeburner Actions"]: (sleeve: Sleeve) => boolean;
["Shock Recovery"]: (sleeve: Sleeve) => boolean;
["Synchronize"]: (sleeve: Sleeve) => boolean;
} = {
"------": () => true,
"Work for Company": (player: IPlayer, sleeve: Sleeve) => possibleJobs(player, sleeve).length > 0,
"Work for Faction": (player: IPlayer, sleeve: Sleeve) => possibleFactions(player, sleeve).length > 0,
"Work for Company": (sleeve: Sleeve) => possibleJobs(sleeve).length > 0,
"Work for Faction": (sleeve: Sleeve) => possibleFactions(sleeve).length > 0,
"Commit Crime": () => true,
"Take University Course": (player: IPlayer, sleeve: Sleeve) =>
"Take University Course": (sleeve: Sleeve) =>
[CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
"Workout at Gym": (player: IPlayer, sleeve: Sleeve) =>
"Workout at Gym": (sleeve: Sleeve) =>
[CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
"Perform Bladeburner Actions": (player: IPlayer) => player.inBladeburner(),
"Shock Recovery": (player: IPlayer, sleeve: Sleeve) => sleeve.shock < 100,
Synchronize: (player: IPlayer, sleeve: Sleeve) => sleeve.sync < 100,
"Perform Bladeburner Actions": () => Player.inBladeburner(),
"Shock Recovery": (sleeve: Sleeve) => sleeve.shock < 100,
Synchronize: (sleeve: Sleeve) => sleeve.sync < 100,
};
function getABC(sleeve: Sleeve): [string, string, string] {
@@ -345,12 +344,12 @@ export function TaskSelector(props: IProps): React.ReactElement {
const [s2, setS2] = useState(abc[2]);
const validActions = Object.keys(canDo).filter((k) =>
(canDo[k] as (player: IPlayer, sleeve: Sleeve) => boolean)(props.player, props.sleeve),
(canDo[k] as (sleeve: Sleeve) => boolean)(props.sleeve),
);
const detailsF = tasks[s0];
if (detailsF === undefined) throw new Error(`No function for task '${s0}'`);
const details = detailsF(props.player, props.sleeve);
const details = detailsF(props.sleeve);
const details2 = details.second(s1);
if (details.first.length > 0 && !details.first.includes(s1)) {
@@ -366,7 +365,7 @@ export function TaskSelector(props: IProps): React.ReactElement {
const n = event.target.value;
const detailsF = tasks[n];
if (detailsF === undefined) throw new Error(`No function for task '${s0}'`);
const details = detailsF(props.player, props.sleeve);
const details = detailsF(props.sleeve);
const details2 = details.second(details.first[0]) ?? ["------"];
setS2(details2[0]);
setS1(details.first[0]);