2019-03-29 08:12:41 +01:00
|
|
|
/**
|
2019-04-01 11:23:25 +02:00
|
|
|
* React Subcomponent for displaying a location's UI, when that location is a company
|
|
|
|
*
|
|
|
|
* This subcomponent renders all of the buttons for applying to jobs at a company
|
2019-03-29 08:12:41 +01:00
|
|
|
*/
|
|
|
|
import * as React from "react";
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
import { ApplyToJobButton } from "./ApplyToJobButton";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
import { Location } from "../Location";
|
|
|
|
import { Locations } from "../Locations";
|
|
|
|
import { LocationName } from "../data/LocationNames";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
import { IEngine } from "../../IEngine";
|
|
|
|
import { beginInfiltration } from "../../Infiltration";
|
|
|
|
|
|
|
|
import { Companies } from "../../Company/Companies";
|
|
|
|
import { Company } from "../../Company/Company";
|
2019-04-04 02:08:11 +02:00
|
|
|
import { CompanyPosition } from "../../Company/CompanyPosition";
|
2019-04-01 11:23:25 +02:00
|
|
|
import { CompanyPositions } from "../../Company/CompanyPositions";
|
|
|
|
import * as posNames from "../../Company/data/companypositionnames";
|
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
2019-04-01 11:23:25 +02:00
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
2019-03-29 08:12:41 +01:00
|
|
|
|
|
|
|
type IProps = {
|
2019-04-01 11:23:25 +02:00
|
|
|
engine: IEngine;
|
2019-03-29 08:12:41 +01:00
|
|
|
locName: LocationName;
|
|
|
|
p: IPlayer;
|
|
|
|
}
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
type IState = {
|
|
|
|
employedHere: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class CompanyLocation extends React.Component<IProps, IState> {
|
2019-03-29 08:12:41 +01:00
|
|
|
/**
|
|
|
|
* We'll keep a reference to the Company that this component is being rendered for,
|
|
|
|
* so we don't have to look it up every time
|
|
|
|
*/
|
|
|
|
company: Company;
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
/**
|
|
|
|
* CompanyPosition object for the job that the player holds at this company
|
|
|
|
* (if he has one)
|
|
|
|
*/
|
|
|
|
companyPosition: CompanyPosition | null = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores button styling that sets them all to block display
|
|
|
|
*/
|
|
|
|
btnStyle: object;
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* Reference to the Location that this component is being rendered for
|
|
|
|
*/
|
|
|
|
location: Location;
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
/**
|
|
|
|
* Name of company position that player holds, if applicable
|
|
|
|
*/
|
|
|
|
jobTitle: string | null = null;
|
|
|
|
|
2019-03-29 08:12:41 +01:00
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
this.btnStyle = { display: "block" };
|
|
|
|
|
2019-03-29 08:12:41 +01:00
|
|
|
this.applyForAgentJob = this.applyForAgentJob.bind(this);
|
|
|
|
this.applyForBusinessConsultantJob = this.applyForBusinessConsultantJob.bind(this);
|
|
|
|
this.applyForBusinessJob = this.applyForBusinessJob.bind(this);
|
|
|
|
this.applyForEmployeeJob = this.applyForEmployeeJob.bind(this);
|
|
|
|
this.applyForItJob = this.applyForItJob.bind(this);
|
|
|
|
this.applyForPartTimeEmployeeJob = this.applyForPartTimeEmployeeJob.bind(this);
|
|
|
|
this.applyForPartTimeWaiterJob = this.applyForPartTimeWaiterJob.bind(this);
|
|
|
|
this.applyForSecurityJob = this.applyForSecurityJob.bind(this);
|
|
|
|
this.applyForSoftwareConsultantJob = this.applyForSoftwareConsultantJob.bind(this);
|
|
|
|
this.applyForSoftwareJob = this.applyForSoftwareJob.bind(this);
|
|
|
|
this.applyForWaiterJob = this.applyForWaiterJob.bind(this);
|
2019-04-01 11:23:25 +02:00
|
|
|
this.startInfiltration = this.startInfiltration.bind(this);
|
2019-04-04 02:08:11 +02:00
|
|
|
this.work = this.work.bind(this);
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
this.location = Locations[props.locName];
|
|
|
|
if (this.location == null) {
|
|
|
|
throw new Error(`CompanyLocation component constructed with invalid location: ${props.locName}`);
|
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
|
|
|
|
this.company = Companies[props.locName];
|
|
|
|
if (this.company == null) {
|
|
|
|
throw new Error(`CompanyLocation component constructed with invalid company: ${props.locName}`);
|
|
|
|
}
|
2019-04-04 02:08:11 +02:00
|
|
|
|
|
|
|
this.state = {
|
|
|
|
employedHere: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
this.checkIfEmployedHere(false);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForAgentJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForAgentJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForBusinessConsultantJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForBusinessConsultantJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForBusinessJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForBusinessJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForEmployeeJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForEmployeeJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForItJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForItJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForPartTimeEmployeeJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForPartTimeEmployeeJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForPartTimeWaiterJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForPartTimeWaiterJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForSecurityJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForSecurityJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForSoftwareConsultantJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForSoftwareConsultantJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForSoftwareJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForSoftwareJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applyForWaiterJob(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
this.props.p.applyForWaiterJob();
|
2019-04-05 11:08:41 +02:00
|
|
|
this.checkIfEmployedHere(true);
|
2019-04-04 02:08:11 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 11:08:41 +02:00
|
|
|
checkIfEmployedHere(updateState=false) {
|
2019-04-04 02:08:11 +02:00
|
|
|
this.jobTitle = this.props.p.jobs[this.props.locName];
|
|
|
|
if (this.jobTitle != null) {
|
|
|
|
this.companyPosition = CompanyPositions[this.jobTitle];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updateState) {
|
|
|
|
this.setState({
|
|
|
|
employedHere: this.jobTitle != null
|
|
|
|
});
|
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
startInfiltration(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
const loc = this.location;
|
2019-03-30 00:13:58 +01:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
this.props.engine.loadInfiltrationContent();
|
2019-03-30 00:13:58 +01:00
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
const data = loc.infiltrationData;
|
|
|
|
if (data == null) { return false; }
|
|
|
|
beginInfiltration(this.props.locName, data.startingSecurityLevel, data.baseRewardValue, data.maxClearanceLevel, data.difficulty);
|
2019-03-30 00:13:58 +01:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
work(e: React.MouseEvent<HTMLElement>) {
|
|
|
|
if (!e.isTrusted) { return false; }
|
|
|
|
|
|
|
|
const pos = this.companyPosition;
|
|
|
|
if (pos instanceof CompanyPosition) {
|
|
|
|
if (pos.isPartTimeJob() || pos.isSoftwareConsultantJob() || pos.isBusinessConsultantJob()) {
|
|
|
|
this.props.p.startWorkPartTime(this.props.locName);
|
|
|
|
} else {
|
|
|
|
this.props.p.startWork(this.props.locName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 08:12:41 +01:00
|
|
|
render() {
|
2019-04-04 02:08:11 +02:00
|
|
|
const isEmployedHere = this.jobTitle != null;
|
|
|
|
const favorGain = this.company.getFavorGain();
|
|
|
|
|
2019-03-29 08:12:41 +01:00
|
|
|
return (
|
|
|
|
<div>
|
2019-04-04 02:08:11 +02:00
|
|
|
{
|
|
|
|
isEmployedHere &&
|
|
|
|
<div>
|
|
|
|
<p>Job Title: {this.jobTitle}</p>
|
|
|
|
<p>--------------------</p>
|
|
|
|
<p className={"tooltip"}>
|
|
|
|
Company reputation: {numeralWrapper.format(this.company.playerReputation, "0,0.000")}
|
|
|
|
<span className={"tooltiptext"}>
|
|
|
|
You will earn ${numeralWrapper.format(favorGain[0], "0,0")} company
|
|
|
|
favor upon resetting after installing Augmentations
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<p>--------------------</p>
|
|
|
|
<p className={"tooltip"}>
|
|
|
|
Company Favor: {numeralWrapper.format(this.company.favor, "0,0")}
|
|
|
|
<span className={"tooltiptext"}>
|
|
|
|
Company favor increases the rate at which you earn reputation for this company by
|
|
|
|
1% per favor. Company favor is gained whenever you reset after installing Augmentations. The amount
|
|
|
|
of favor you gain depends on how much reputation you have with the comapny.
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<StdButton
|
|
|
|
id={"foo-work-button-id"}
|
|
|
|
onClick={this.work}
|
|
|
|
style={this.btnStyle}
|
|
|
|
text={"Work"}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
2019-03-29 08:12:41 +01:00
|
|
|
{
|
|
|
|
this.company.hasAgentPositions() &&
|
2019-04-01 11:23:25 +02:00
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.AgentCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForAgentJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for Agent Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasBusinessConsultantPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.BusinessConsultantCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForBusinessConsultantJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for Business Consultant Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasBusinessPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.BusinessCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForBusinessJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for Business Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasEmployeePositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.MiscCompanyPositions[1]]}
|
|
|
|
onClick={this.applyForEmployeeJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply to be an Employee"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasEmployeePositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.PartTimeCompanyPositions[1]]}
|
|
|
|
onClick={this.applyForPartTimeEmployeeJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply to be a part-time Employee"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasITPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.ITCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForItJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for IT Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasSecurityPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.SecurityCompanyPositions[2]]}
|
|
|
|
onClick={this.applyForSecurityJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for Security Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasSoftwareConsultantPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.SoftwareConsultantCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForSoftwareConsultantJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for Software Consultant Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasSoftwarePositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.SoftwareCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForSoftwareJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply for Software Job"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasWaiterPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.MiscCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForWaiterJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply to be a Waiter"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.company.hasWaiterPositions() &&
|
|
|
|
<ApplyToJobButton
|
|
|
|
company={this.company}
|
|
|
|
entryPosType={CompanyPositions[posNames.PartTimeCompanyPositions[0]]}
|
|
|
|
onClick={this.applyForPartTimeWaiterJob}
|
|
|
|
p={this.props.p}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Apply to be a part-time Waiter"}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
(this.location.infiltrationData != null) &&
|
|
|
|
<StdButton
|
|
|
|
onClick={this.startInfiltration}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={"Infiltration Company"}
|
|
|
|
/>
|
2019-03-29 08:12:41 +01:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|