bitburner-src/src/Locations/ui/SlumsLocation.tsx

215 lines
6.7 KiB
TypeScript
Raw Normal View History

/**
* React Subcomponent for displaying a location's UI, when that location is a slum
*
* This subcomponent renders all of the buttons for committing crimes
*/
import * as React from "react";
2021-09-05 01:09:30 +02:00
import { Crimes } from "../../Crime/Crimes";
2021-09-05 01:09:30 +02:00
import { numeralWrapper } from "../../ui/numeralFormat";
import { AutoupdatingStdButton } from "../../ui/React/AutoupdatingStdButton";
2021-09-18 01:43:08 +02:00
import { use } from "../../ui/Context";
2021-09-18 01:43:08 +02:00
export function SlumsLocation(): React.ReactElement {
const player = use.Player();
const router = use.Router();
function shoplift(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Shoplift.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function robStore(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.RobStore.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function mug(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Mug.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function larceny(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Larceny.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function dealDrugs(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.DealDrugs.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function bondForgery(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.BondForgery.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function traffickArms(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.TraffickArms.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function homicide(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Homicide.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function grandTheftAuto(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.GrandTheftAuto.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function kidnap(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Kidnap.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function assassinate(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Assassination.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
function heist(e: React.MouseEvent<HTMLElement>): void {
2021-09-05 01:09:30 +02:00
if (!e.isTrusted) {
return;
}
2021-09-18 01:43:08 +02:00
Crimes.Heist.commit(player);
router.toWork();
2021-09-05 01:09:30 +02:00
}
2021-09-18 01:43:08 +02:00
const shopliftChance = Crimes.Shoplift.successRate(player);
const robStoreChance = Crimes.RobStore.successRate(player);
const mugChance = Crimes.Mug.successRate(player);
const larcenyChance = Crimes.Larceny.successRate(player);
const drugsChance = Crimes.DealDrugs.successRate(player);
const bondChance = Crimes.BondForgery.successRate(player);
const armsChance = Crimes.TraffickArms.successRate(player);
const homicideChance = Crimes.Homicide.successRate(player);
const gtaChance = Crimes.GrandTheftAuto.successRate(player);
const kidnapChance = Crimes.Kidnap.successRate(player);
const assassinateChance = Crimes.Assassination.successRate(player);
const heistChance = Crimes.Heist.successRate(player);
return (
<div>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={shoplift}
style={{ display: "block" }}
text={`Shoplift (${numeralWrapper.formatPercentage(shopliftChance)} chance of success)`}
tooltip={"Attempt to shoplift from a low-end retailer"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={robStore}
style={{ display: "block" }}
text={`Rob store (${numeralWrapper.formatPercentage(robStoreChance)} chance of success)`}
tooltip={"Attempt to commit armed robbery on a high-end store"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={mug}
style={{ display: "block" }}
text={`Mug someone (${numeralWrapper.formatPercentage(mugChance)} chance of success)`}
tooltip={"Attempt to mug a random person on the street"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={larceny}
style={{ display: "block" }}
text={`Larceny (${numeralWrapper.formatPercentage(larcenyChance)} chance of success)`}
tooltip={"Attempt to rob property from someone's house"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={dealDrugs}
style={{ display: "block" }}
text={`Deal Drugs (${numeralWrapper.formatPercentage(drugsChance)} chance of success)`}
tooltip={"Attempt to deal drugs"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={bondForgery}
style={{ display: "block" }}
text={`Bond Forgery (${numeralWrapper.formatPercentage(bondChance)} chance of success)`}
tooltip={"Attempt to forge corporate bonds"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={traffickArms}
style={{ display: "block" }}
text={`Traffick illegal Arms (${numeralWrapper.formatPercentage(armsChance)} chance of success)`}
tooltip={"Attempt to smuggle illegal arms into the city"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={homicide}
style={{ display: "block" }}
text={`Homicide (${numeralWrapper.formatPercentage(homicideChance)} chance of success)`}
tooltip={"Attempt to murder a random person on the street"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={grandTheftAuto}
style={{ display: "block" }}
text={`Grand theft Auto (${numeralWrapper.formatPercentage(gtaChance)} chance of success)`}
tooltip={"Attempt to commit grand theft auto"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={kidnap}
style={{ display: "block" }}
text={`Kidnap and Ransom (${numeralWrapper.formatPercentage(kidnapChance)} chance of success)`}
tooltip={"Attempt to kidnap and ransom a high-profile-target"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={assassinate}
style={{ display: "block" }}
text={`Assassinate (${numeralWrapper.formatPercentage(assassinateChance)} chance of success)`}
tooltip={"Attempt to assassinate a high-profile target"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={heist}
style={{ display: "block" }}
text={`Heist (${numeralWrapper.formatPercentage(heistChance)} chance of success)`}
tooltip={"Attempt to pull off the ultimate heist"}
/>
</div>
);
}