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

186 lines
5.9 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-25 21:34:12 +02:00
import Button from "@mui/material/Button";
import Tooltip from "@mui/material/Tooltip";
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";
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-20 07:45:32 +02:00
Crimes.Shoplift.commit(router, player);
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-20 07:45:32 +02:00
Crimes.RobStore.commit(router, player);
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-20 07:45:32 +02:00
Crimes.Mug.commit(router, player);
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-20 07:45:32 +02:00
Crimes.Larceny.commit(router, player);
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-20 07:45:32 +02:00
Crimes.DealDrugs.commit(router, player);
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-20 07:45:32 +02:00
Crimes.BondForgery.commit(router, player);
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-20 07:45:32 +02:00
Crimes.TraffickArms.commit(router, player);
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-20 07:45:32 +02:00
Crimes.Homicide.commit(router, player);
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-20 07:45:32 +02:00
Crimes.GrandTheftAuto.commit(router, player);
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-20 07:45:32 +02:00
Crimes.Kidnap.commit(router, player);
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-20 07:45:32 +02:00
Crimes.Assassination.commit(router, player);
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-20 07:45:32 +02:00
Crimes.Heist.commit(router, player);
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 (
2021-10-01 19:08:37 +02:00
<>
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to shoplift from a low-end retailer</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={shoplift}>
Shoplift ({numeralWrapper.formatPercentage(shopliftChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to commit armed robbery on a high-end store</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={robStore}>
Rob store ({numeralWrapper.formatPercentage(robStoreChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to mug a random person on the street</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={mug}>Mug someone ({numeralWrapper.formatPercentage(mugChance)} chance of success)</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to rob property from someone's house</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={larceny}>Larceny ({numeralWrapper.formatPercentage(larcenyChance)} chance of success)</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to deal drugs</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={dealDrugs}>
Deal Drugs ({numeralWrapper.formatPercentage(drugsChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to forge corporate bonds</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={bondForgery}>
Bond Forgery ({numeralWrapper.formatPercentage(bondChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to smuggle illegal arms into the city</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={traffickArms}>
Traffick illegal Arms ({numeralWrapper.formatPercentage(armsChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to murder a random person on the street</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={homicide}>
Homicide ({numeralWrapper.formatPercentage(homicideChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to commit grand theft auto</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={grandTheftAuto}>
Grand theft Auto ({numeralWrapper.formatPercentage(gtaChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to kidnap and ransom a high-profile-target</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={kidnap}>
Kidnap and Ransom ({numeralWrapper.formatPercentage(kidnapChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to assassinate a high-profile target</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={assassinate}>
Assassinate ({numeralWrapper.formatPercentage(assassinateChance)} chance of success)
</Button>
</Tooltip>
<br />
2021-09-29 07:49:22 +02:00
<Tooltip title={<>Attempt to pull off the ultimate heist</>}>
2021-09-25 21:34:12 +02:00
<Button onClick={heist}>Heist ({numeralWrapper.formatPercentage(heistChance)} chance of success)</Button>
</Tooltip>
<br />
2021-10-01 19:08:37 +02:00
</>
2021-09-18 01:43:08 +02:00
);
}