mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
added logic to show a sorry page when augmenting with faction screen open
This commit is contained in:
parent
3917ef2663
commit
de0b0f9fa9
@ -70,7 +70,6 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
|||||||
const router = use.Router();
|
const router = use.Router();
|
||||||
const [sleevesOpen, setSleevesOpen] = useState(false);
|
const [sleevesOpen, setSleevesOpen] = useState(false);
|
||||||
const [gangOpen, setGangOpen] = useState(false);
|
const [gangOpen, setGangOpen] = useState(false);
|
||||||
const p = player;
|
|
||||||
const factionInfo = faction.getInfo();
|
const factionInfo = faction.getInfo();
|
||||||
|
|
||||||
function manageGang(): void {
|
function manageGang(): void {
|
||||||
@ -104,20 +103,20 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
|||||||
|
|
||||||
// We have a special flag for whether the player this faction is the player's
|
// We have a special flag for whether the player this faction is the player's
|
||||||
// gang faction because if the player has a gang, they cannot do any other action
|
// gang faction because if the player has a gang, they cannot do any other action
|
||||||
const isPlayersGang = p.inGang() && p.getGangName() === faction.name;
|
const isPlayersGang = player.inGang() && player.getGangName() === faction.name;
|
||||||
|
|
||||||
// Flags for whether special options (gang, sleeve purchases, donate, etc.)
|
// Flags for whether special options (gang, sleeve purchases, donate, etc.)
|
||||||
// should be shown
|
// should be shown
|
||||||
const favorToDonate = Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
const favorToDonate = Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
||||||
const canDonate = faction.favor >= favorToDonate;
|
const canDonate = faction.favor >= favorToDonate;
|
||||||
|
|
||||||
const canPurchaseSleeves = faction.name === "The Covenant" && p.bitNodeN === 10;
|
const canPurchaseSleeves = faction.name === "The Covenant" && player.bitNodeN === 10;
|
||||||
|
|
||||||
let canAccessGang = p.canAccessGang() && GangNames.includes(faction.name);
|
let canAccessGang = player.canAccessGang() && GangNames.includes(faction.name);
|
||||||
if (p.inGang()) {
|
if (player.inGang()) {
|
||||||
if (p.getGangName() !== faction.name) {
|
if (player.getGangName() !== faction.name) {
|
||||||
canAccessGang = false;
|
canAccessGang = false;
|
||||||
} else if (p.getGangName() === faction.name) {
|
} else if (player.getGangName() === faction.name) {
|
||||||
canAccessGang = true;
|
canAccessGang = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,6 +173,10 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
|||||||
|
|
||||||
export function FactionRoot(props: IProps): React.ReactElement {
|
export function FactionRoot(props: IProps): React.ReactElement {
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
|
const player = use.Player();
|
||||||
|
const router = use.Router();
|
||||||
|
const [purchasingAugs, setPurchasingAugs] = useState(false);
|
||||||
|
|
||||||
function rerender(): void {
|
function rerender(): void {
|
||||||
setRerender((old) => !old);
|
setRerender((old) => !old);
|
||||||
}
|
}
|
||||||
@ -185,7 +188,14 @@ export function FactionRoot(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
const faction = props.faction;
|
const faction = props.faction;
|
||||||
|
|
||||||
const [purchasingAugs, setPurchasingAugs] = useState(false);
|
if (player && !player.factions.includes(faction.name)) {
|
||||||
|
return <>
|
||||||
|
<Typography variant="h4" color="primary">
|
||||||
|
Sorry, You have not joined the faction {faction.name} yet!
|
||||||
|
</Typography>
|
||||||
|
<Button onClick={() => router.toFactions()}>Back to Factions</Button>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
return purchasingAugs ? (
|
return purchasingAugs ? (
|
||||||
<AugmentationsPage faction={faction} routeToMainPage={() => setPurchasingAugs(false)} />
|
<AugmentationsPage faction={faction} routeToMainPage={() => setPurchasingAugs(false)} />
|
||||||
|
Loading…
Reference in New Issue
Block a user