2019-04-01 11:23:25 +02:00
|
|
|
/**
|
|
|
|
* React Subcomponent for displaying a location's UI, when that location is a university
|
|
|
|
*
|
|
|
|
* This subcomponent renders all of the buttons for studying/taking courses
|
|
|
|
*/
|
|
|
|
import * as React from "react";
|
|
|
|
|
|
|
|
import { Location } from "../Location";
|
|
|
|
|
|
|
|
import { CONSTANTS } from "../../Constants";
|
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
2021-04-20 03:26:51 +02:00
|
|
|
import { getServer } from "../../Server/ServerHelpers";
|
|
|
|
import { Server } from "../../Server/Server";
|
|
|
|
import { SpecialServerIps } from "../../Server/SpecialServerIps";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
|
|
|
import { StdButton } from "../../ui/React/StdButton";
|
2021-03-31 06:45:21 +02:00
|
|
|
import { Money } from "../../ui/React/Money";
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
type IProps = {
|
|
|
|
loc: Location;
|
|
|
|
p: IPlayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class UniversityLocation extends React.Component<IProps, any> {
|
2019-04-04 02:08:11 +02:00
|
|
|
/**
|
|
|
|
* Stores button styling that sets them all to block display
|
|
|
|
*/
|
|
|
|
btnStyle: object;
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
2019-04-04 02:08:11 +02:00
|
|
|
this.btnStyle = { display: "block" };
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
this.take = this.take.bind(this);
|
2019-04-04 02:08:11 +02:00
|
|
|
this.study = this.study.bind(this);
|
2019-04-01 11:23:25 +02:00
|
|
|
this.dataStructures = this.dataStructures.bind(this);
|
|
|
|
this.networks = this.networks.bind(this);
|
|
|
|
this.algorithms = this.algorithms.bind(this);
|
|
|
|
this.management = this.management.bind(this);
|
|
|
|
this.leadership = this.leadership.bind(this);
|
2021-04-20 03:26:51 +02:00
|
|
|
|
|
|
|
this.calculateCost = this.calculateCost.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
calculateCost(): number {
|
|
|
|
const ip = SpecialServerIps.getIp(this.props.loc.name);
|
|
|
|
console.log(`ip: ${ip}`);
|
|
|
|
const server = getServer(ip);
|
|
|
|
if(server == null || !server.hasOwnProperty('manuallyHacked')) return this.props.loc.costMult;
|
|
|
|
const discount = (server as Server).manuallyHacked? 0.9 : 1;
|
|
|
|
return this.props.loc.costMult * discount;
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
take(stat: string) {
|
|
|
|
const loc = this.props.loc;
|
2021-04-20 03:26:51 +02:00
|
|
|
this.props.p.startClass(this.calculateCost(), loc.expMult, stat);
|
2019-04-01 11:23:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
study() {
|
|
|
|
return this.take(CONSTANTS.ClassStudyComputerScience);
|
|
|
|
}
|
|
|
|
|
|
|
|
dataStructures() {
|
|
|
|
return this.take(CONSTANTS.ClassDataStructures);
|
|
|
|
}
|
|
|
|
|
|
|
|
networks() {
|
|
|
|
return this.take(CONSTANTS.ClassNetworks);
|
|
|
|
}
|
|
|
|
|
|
|
|
algorithms() {
|
|
|
|
return this.take(CONSTANTS.ClassAlgorithms);
|
|
|
|
}
|
|
|
|
|
|
|
|
management() {
|
|
|
|
return this.take(CONSTANTS.ClassManagement);
|
|
|
|
}
|
|
|
|
|
|
|
|
leadership() {
|
|
|
|
return this.take(CONSTANTS.ClassLeadership);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2021-04-20 03:26:51 +02:00
|
|
|
const costMult: number = this.calculateCost();
|
2019-04-01 11:23:25 +02:00
|
|
|
|
|
|
|
const dataStructuresCost = CONSTANTS.ClassDataStructuresBaseCost * costMult;
|
|
|
|
const networksCost = CONSTANTS.ClassNetworksBaseCost * costMult;
|
|
|
|
const algorithmsCost = CONSTANTS.ClassAlgorithmsBaseCost * costMult;
|
|
|
|
const managementCost = CONSTANTS.ClassManagementBaseCost * costMult;
|
|
|
|
const leadershipCost = CONSTANTS.ClassLeadershipBaseCost * costMult;
|
|
|
|
|
2019-07-05 09:26:22 +02:00
|
|
|
const earnHackingExpTooltip = `Gain hacking experience!`
|
|
|
|
const earnCharismaExpTooltip = `Gain charisma experience!`;
|
|
|
|
|
2019-04-01 11:23:25 +02:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<StdButton
|
|
|
|
onClick={this.study}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2019-04-01 11:23:25 +02:00
|
|
|
text={`Study Computer Science (free)`}
|
2019-07-05 09:26:22 +02:00
|
|
|
tooltip={earnHackingExpTooltip}
|
2019-04-01 11:23:25 +02:00
|
|
|
/>
|
|
|
|
<StdButton
|
|
|
|
onClick={this.dataStructures}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2021-03-31 06:45:21 +02:00
|
|
|
text={<>Take Data Structures course ({Money(dataStructuresCost)} / sec)</>}
|
2019-07-05 09:26:22 +02:00
|
|
|
tooltip={earnHackingExpTooltip}
|
2019-04-01 11:23:25 +02:00
|
|
|
/>
|
|
|
|
<StdButton
|
|
|
|
onClick={this.networks}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2021-03-31 06:45:21 +02:00
|
|
|
text={<>Take Networks course ({Money(networksCost)} / sec)</>}
|
2019-07-05 09:26:22 +02:00
|
|
|
tooltip={earnHackingExpTooltip}
|
2019-04-01 11:23:25 +02:00
|
|
|
/>
|
|
|
|
<StdButton
|
|
|
|
onClick={this.algorithms}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2021-03-31 06:45:21 +02:00
|
|
|
text={<>Take Algorithms course ({Money(algorithmsCost)} / sec)</>}
|
2019-07-05 09:26:22 +02:00
|
|
|
tooltip={earnHackingExpTooltip}
|
2019-04-01 11:23:25 +02:00
|
|
|
/>
|
|
|
|
<StdButton
|
|
|
|
onClick={this.management}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2021-03-31 06:45:21 +02:00
|
|
|
text={<>Take Management course ({Money(managementCost)} / sec)</>}
|
2019-07-05 09:26:22 +02:00
|
|
|
tooltip={earnCharismaExpTooltip}
|
2019-04-01 11:23:25 +02:00
|
|
|
/>
|
|
|
|
<StdButton
|
|
|
|
onClick={this.leadership}
|
2019-04-04 02:08:11 +02:00
|
|
|
style={this.btnStyle}
|
2021-03-31 06:45:21 +02:00
|
|
|
text={<>Take Leadership course ({Money(leadershipCost)} / sec)</>}
|
2019-07-05 09:26:22 +02:00
|
|
|
tooltip={earnCharismaExpTooltip}
|
2019-04-01 11:23:25 +02:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|