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

231 lines
7.4 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";
import { IPlayer } from "../../PersonObjects/IPlayer";
2021-09-05 01:09:30 +02:00
import { numeralWrapper } from "../../ui/numeralFormat";
import { AutoupdatingStdButton } from "../../ui/React/AutoupdatingStdButton";
type IProps = {
2021-09-05 01:09:30 +02:00
p: IPlayer;
};
export class SlumsLocation extends React.Component<IProps, any> {
2021-09-05 01:09:30 +02:00
/**
* Stores button styling that sets them all to block display
*/
btnStyle: any;
constructor(props: IProps) {
super(props);
this.btnStyle = { display: "block" };
this.shoplift = this.shoplift.bind(this);
this.robStore = this.robStore.bind(this);
this.mug = this.mug.bind(this);
this.larceny = this.larceny.bind(this);
this.dealDrugs = this.dealDrugs.bind(this);
this.bondForgery = this.bondForgery.bind(this);
this.traffickArms = this.traffickArms.bind(this);
this.homicide = this.homicide.bind(this);
this.grandTheftAuto = this.grandTheftAuto.bind(this);
this.kidnap = this.kidnap.bind(this);
this.assassinate = this.assassinate.bind(this);
this.heist = this.heist.bind(this);
}
shoplift(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Shoplift.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
robStore(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.RobStore.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
mug(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Mug.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
larceny(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Larceny.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
dealDrugs(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.DealDrugs.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
bondForgery(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.BondForgery.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
traffickArms(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.TraffickArms.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
homicide(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Homicide.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
grandTheftAuto(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.GrandTheftAuto.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
kidnap(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Kidnap.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
assassinate(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Assassination.commit(this.props.p);
}
2021-09-05 01:09:30 +02:00
heist(e: React.MouseEvent<HTMLElement>): void {
if (!e.isTrusted) {
return;
}
2021-09-05 01:09:30 +02:00
Crimes.Heist.commit(this.props.p);
}
render(): React.ReactNode {
const shopliftChance = Crimes.Shoplift.successRate(this.props.p);
const robStoreChance = Crimes.RobStore.successRate(this.props.p);
const mugChance = Crimes.Mug.successRate(this.props.p);
const larcenyChance = Crimes.Larceny.successRate(this.props.p);
const drugsChance = Crimes.DealDrugs.successRate(this.props.p);
const bondChance = Crimes.BondForgery.successRate(this.props.p);
const armsChance = Crimes.TraffickArms.successRate(this.props.p);
const homicideChance = Crimes.Homicide.successRate(this.props.p);
const gtaChance = Crimes.GrandTheftAuto.successRate(this.props.p);
const kidnapChance = Crimes.Kidnap.successRate(this.props.p);
const assassinateChance = Crimes.Assassination.successRate(this.props.p);
const heistChance = Crimes.Heist.successRate(this.props.p);
return (
<div>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.shoplift}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Shoplift (${numeralWrapper.formatPercentage(shopliftChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to shoplift from a low-end retailer"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.robStore}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Rob store (${numeralWrapper.formatPercentage(robStoreChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to commit armed robbery on a high-end store"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.mug}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Mug someone (${numeralWrapper.formatPercentage(mugChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to mug a random person on the street"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.larceny}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Larceny (${numeralWrapper.formatPercentage(larcenyChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to rob property from someone's house"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.dealDrugs}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Deal Drugs (${numeralWrapper.formatPercentage(drugsChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to deal drugs"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.bondForgery}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Bond Forgery (${numeralWrapper.formatPercentage(bondChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to forge corporate bonds"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.traffickArms}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Traffick illegal Arms (${numeralWrapper.formatPercentage(armsChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to smuggle illegal arms into the city"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.homicide}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Homicide (${numeralWrapper.formatPercentage(homicideChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to murder a random person on the street"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.grandTheftAuto}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Grand theft Auto (${numeralWrapper.formatPercentage(gtaChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to commit grand theft auto"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.kidnap}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Kidnap and Ransom (${numeralWrapper.formatPercentage(kidnapChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to kidnap and ransom a high-profile-target"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.assassinate}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Assassinate (${numeralWrapper.formatPercentage(assassinateChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to assassinate a high-profile target"}
/>
<AutoupdatingStdButton
intervalTime={5e3}
onClick={this.heist}
style={this.btnStyle}
2021-09-09 05:47:34 +02:00
text={`Heist (${numeralWrapper.formatPercentage(heistChance)} chance of success)`}
2021-09-05 01:09:30 +02:00
tooltip={"Attempt to pull off the ultimate heist"}
/>
</div>
);
}
}