mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-23 10:42:29 +01:00
Convert WIP root to use switch statement
This commit is contained in:
@ -138,7 +138,8 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
let workInfo: IWorkInfo | null;
|
let workInfo: IWorkInfo | null;
|
||||||
|
|
||||||
if (player.workType == CONSTANTS.WorkTypeFaction) {
|
switch (player.workType) {
|
||||||
|
case CONSTANTS.WorkTypeFaction: {
|
||||||
const faction = Factions[player.currentWorkFactionName];
|
const faction = Factions[player.currentWorkFactionName];
|
||||||
if (!faction) {
|
if (!faction) {
|
||||||
workInfo = {
|
workInfo = {
|
||||||
@ -182,7 +183,8 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
player.workMoneyGained > 0 ? (
|
player.workMoneyGained > 0 ? (
|
||||||
<StatsRow name="Money" color={Settings.theme.money}>
|
<StatsRow name="Money" color={Settings.theme.money}>
|
||||||
<Typography>
|
<Typography>
|
||||||
<Money money={player.workMoneyGained} /> (<MoneyRate money={player.workMoneyGainRate * CYCLES_PER_SEC} />)
|
<Money money={player.workMoneyGained} /> (
|
||||||
|
<MoneyRate money={player.workMoneyGainRate * CYCLES_PER_SEC} />)
|
||||||
</Typography>
|
</Typography>
|
||||||
</StatsRow>
|
</StatsRow>
|
||||||
) : (
|
) : (
|
||||||
@ -202,7 +204,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
stopText: "Stop Faction work",
|
stopText: "Stop Faction work",
|
||||||
};
|
};
|
||||||
} else if (player.className !== "") {
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CONSTANTS.WorkTypeStudyClass: {
|
||||||
const className = player.className;
|
const className = player.className;
|
||||||
function cancel(): void {
|
function cancel(): void {
|
||||||
player.finishClass(true);
|
player.finishClass(true);
|
||||||
@ -216,10 +222,10 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
let stopText = "";
|
let stopText = "";
|
||||||
if (
|
if (
|
||||||
className == CONSTANTS.ClassGymStrength ||
|
className === CONSTANTS.ClassGymStrength ||
|
||||||
className == CONSTANTS.ClassGymDefense ||
|
className === CONSTANTS.ClassGymDefense ||
|
||||||
className == CONSTANTS.ClassGymDexterity ||
|
className === CONSTANTS.ClassGymDexterity ||
|
||||||
className == CONSTANTS.ClassGymAgility
|
className === CONSTANTS.ClassGymAgility
|
||||||
) {
|
) {
|
||||||
stopText = "Stop training at gym";
|
stopText = "Stop training at gym";
|
||||||
} else {
|
} else {
|
||||||
@ -240,7 +246,8 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
gains: [
|
gains: [
|
||||||
<StatsRow name="Total Cost" color={Settings.theme.money}>
|
<StatsRow name="Total Cost" color={Settings.theme.money}>
|
||||||
<Typography>
|
<Typography>
|
||||||
<Money money={-player.workMoneyGained} /> (<MoneyRate money={player.workMoneyLossRate * CYCLES_PER_SEC} />)
|
<Money money={-player.workMoneyGained} /> (<MoneyRate money={player.workMoneyLossRate * CYCLES_PER_SEC} />
|
||||||
|
)
|
||||||
</Typography>
|
</Typography>
|
||||||
</StatsRow>,
|
</StatsRow>,
|
||||||
...expGains,
|
...expGains,
|
||||||
@ -251,7 +258,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
stopText: stopText,
|
stopText: stopText,
|
||||||
};
|
};
|
||||||
} else if (player.workType == CONSTANTS.WorkTypeCompany) {
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CONSTANTS.WorkTypeCompany: {
|
||||||
const comp = Companies[player.companyName];
|
const comp = Companies[player.companyName];
|
||||||
if (comp == null || !(comp instanceof Company)) {
|
if (comp == null || !(comp instanceof Company)) {
|
||||||
workInfo = {
|
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" +
|
"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.`,
|
` 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 {
|
function cancel(): void {
|
||||||
player.finishWorkPartTime(true);
|
player.finishWorkPartTime(true);
|
||||||
router.toJob();
|
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" +
|
"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.",
|
" 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);
|
const completion = Math.round((player.timeWorked / player.timeNeededToCompleteWork) * 100);
|
||||||
|
|
||||||
workInfo = {
|
workInfo = {
|
||||||
@ -398,7 +417,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
stopText: "Cancel crime",
|
stopText: "Cancel crime",
|
||||||
};
|
};
|
||||||
} else if (player.createProgramName !== "") {
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CONSTANTS.WorkTypeCreateProgram: {
|
||||||
function cancel(): void {
|
function cancel(): void {
|
||||||
player.finishCreateProgramWork(true);
|
player.finishCreateProgramWork(true);
|
||||||
router.toTerminal();
|
router.toTerminal();
|
||||||
@ -429,7 +452,11 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
stopText: "Stop creating program",
|
stopText: "Stop creating program",
|
||||||
stopTooltip: "Your work will be saved and you can return to complete the program later.",
|
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 {
|
function cancel(): void {
|
||||||
player.finishGraftAugmentationWork(true);
|
player.finishGraftAugmentationWork(true);
|
||||||
router.toTerminal();
|
router.toTerminal();
|
||||||
@ -464,11 +491,13 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else if (!player.workType) {
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
router.toTerminal();
|
router.toTerminal();
|
||||||
workInfo = null;
|
workInfo = null;
|
||||||
} else {
|
|
||||||
workInfo = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (workInfo === null) {
|
if (workInfo === null) {
|
||||||
|
Reference in New Issue
Block a user