mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 06:32:26 +01:00
Convert WIP root to use switch statement
This commit is contained in:
parent
bcb6176952
commit
cc5e89208e
@ -138,7 +138,8 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
|
||||
let workInfo: IWorkInfo | null;
|
||||
|
||||
if (player.workType == CONSTANTS.WorkTypeFaction) {
|
||||
switch (player.workType) {
|
||||
case CONSTANTS.WorkTypeFaction: {
|
||||
const faction = Factions[player.currentWorkFactionName];
|
||||
if (!faction) {
|
||||
workInfo = {
|
||||
@ -182,7 +183,8 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
player.workMoneyGained > 0 ? (
|
||||
<StatsRow name="Money" color={Settings.theme.money}>
|
||||
<Typography>
|
||||
<Money money={player.workMoneyGained} /> (<MoneyRate money={player.workMoneyGainRate * CYCLES_PER_SEC} />)
|
||||
<Money money={player.workMoneyGained} /> (
|
||||
<MoneyRate money={player.workMoneyGainRate * CYCLES_PER_SEC} />)
|
||||
</Typography>
|
||||
</StatsRow>
|
||||
) : (
|
||||
@ -202,7 +204,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
|
||||
stopText: "Stop Faction work",
|
||||
};
|
||||
} else if (player.className !== "") {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTANTS.WorkTypeStudyClass: {
|
||||
const className = player.className;
|
||||
function cancel(): void {
|
||||
player.finishClass(true);
|
||||
@ -216,10 +222,10 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
|
||||
let stopText = "";
|
||||
if (
|
||||
className == CONSTANTS.ClassGymStrength ||
|
||||
className == CONSTANTS.ClassGymDefense ||
|
||||
className == CONSTANTS.ClassGymDexterity ||
|
||||
className == CONSTANTS.ClassGymAgility
|
||||
className === CONSTANTS.ClassGymStrength ||
|
||||
className === CONSTANTS.ClassGymDefense ||
|
||||
className === CONSTANTS.ClassGymDexterity ||
|
||||
className === CONSTANTS.ClassGymAgility
|
||||
) {
|
||||
stopText = "Stop training at gym";
|
||||
} else {
|
||||
@ -240,7 +246,8 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
gains: [
|
||||
<StatsRow name="Total Cost" color={Settings.theme.money}>
|
||||
<Typography>
|
||||
<Money money={-player.workMoneyGained} /> (<MoneyRate money={player.workMoneyLossRate * CYCLES_PER_SEC} />)
|
||||
<Money money={-player.workMoneyGained} /> (<MoneyRate money={player.workMoneyLossRate * CYCLES_PER_SEC} />
|
||||
)
|
||||
</Typography>
|
||||
</StatsRow>,
|
||||
...expGains,
|
||||
@ -251,7 +258,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
|
||||
stopText: stopText,
|
||||
};
|
||||
} else if (player.workType == CONSTANTS.WorkTypeCompany) {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTANTS.WorkTypeCompany: {
|
||||
const comp = Companies[player.companyName];
|
||||
if (comp == null || !(comp instanceof Company)) {
|
||||
workInfo = {
|
||||
@ -322,7 +333,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish" +
|
||||
` but you will only gain ${penaltyString} of the reputation you've earned so far.`,
|
||||
};
|
||||
} else if (player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTANTS.WorkTypeCompanyPartTime: {
|
||||
function cancel(): void {
|
||||
player.finishWorkPartTime(true);
|
||||
router.toJob();
|
||||
@ -379,7 +394,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish" +
|
||||
" and there will be no penalty because this is a part-time job.",
|
||||
};
|
||||
} else if (player.crimeType !== "") {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTANTS.WorkTypeCrime: {
|
||||
const completion = Math.round((player.timeWorked / player.timeNeededToCompleteWork) * 100);
|
||||
|
||||
workInfo = {
|
||||
@ -398,7 +417,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
|
||||
stopText: "Cancel crime",
|
||||
};
|
||||
} else if (player.createProgramName !== "") {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTANTS.WorkTypeCreateProgram: {
|
||||
function cancel(): void {
|
||||
player.finishCreateProgramWork(true);
|
||||
router.toTerminal();
|
||||
@ -429,7 +452,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
stopText: "Stop creating program",
|
||||
stopTooltip: "Your work will be saved and you can return to complete the program later.",
|
||||
};
|
||||
} else if (player.graftAugmentationName !== "") {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CONSTANTS.WorkTypeGraftAugmentation: {
|
||||
function cancel(): void {
|
||||
player.finishGraftAugmentationWork(true);
|
||||
router.toTerminal();
|
||||
@ -464,11 +491,13 @@ export function WorkInProgressRoot(): React.ReactElement {
|
||||
</>
|
||||
),
|
||||
};
|
||||
} else if (!player.workType) {
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
router.toTerminal();
|
||||
workInfo = null;
|
||||
} else {
|
||||
workInfo = null;
|
||||
}
|
||||
|
||||
if (workInfo === null) {
|
||||
|
Loading…
Reference in New Issue
Block a user