mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-20 06:33:49 +01:00
Merge pull request #3528 from borisflagell/FIX-#3415-Manage-Gang-button-improvements.-
UI: FIX #3415 Tweak Manage Gang button visibility
This commit is contained in:
commit
6e9f33470b
@ -18,8 +18,7 @@ import { Faction } from "../Faction";
|
|||||||
import { use } from "../../ui/Context";
|
import { use } from "../../ui/Context";
|
||||||
import { CreateGangModal } from "./CreateGangModal";
|
import { CreateGangModal } from "./CreateGangModal";
|
||||||
|
|
||||||
import Typography from "@mui/material/Typography";
|
import { Box, Paper, Typography, Button, Tooltip } from "@mui/material";
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import { CovenantPurchasesRoot } from "../../PersonObjects/Sleeve/ui/CovenantPurchasesRoot";
|
import { CovenantPurchasesRoot } from "../../PersonObjects/Sleeve/ui/CovenantPurchasesRoot";
|
||||||
import { FactionNames } from "../data/FactionNames";
|
import { FactionNames } from "../data/FactionNames";
|
||||||
import { GangConstants } from "../../Gang/data/Constants";
|
import { GangConstants } from "../../Gang/data/Constants";
|
||||||
@ -105,12 +104,17 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
|||||||
|
|
||||||
const canPurchaseSleeves = faction.name === FactionNames.TheCovenant && player.bitNodeN === 10;
|
const canPurchaseSleeves = faction.name === FactionNames.TheCovenant && player.bitNodeN === 10;
|
||||||
|
|
||||||
let canAccessGang = player.canAccessGang() && GangConstants.Names.includes(faction.name);
|
// Note : For future-proofing sake, an assumption is made that player is intended to retain access to his gang if his karma were to somehow increases.
|
||||||
|
let isManageGangVisible = GangConstants.Names.includes(faction.name) && player.isAwareOfGang();
|
||||||
|
// karma threshold is only checked at that point, via canAccessGang(). No further check is made.
|
||||||
|
let isManageGangClickable = player.canAccessGang();
|
||||||
if (player.inGang()) {
|
if (player.inGang()) {
|
||||||
if (player.getGangName() !== faction.name) {
|
if (player.getGangName() !== faction.name) {
|
||||||
canAccessGang = false;
|
isManageGangVisible = false;
|
||||||
} else if (player.getGangName() === faction.name) {
|
} else if (player.getGangName() === faction.name) {
|
||||||
canAccessGang = true;
|
isManageGangVisible = true;
|
||||||
|
// The following line will enable the button, without checking for karma threshold.
|
||||||
|
isManageGangClickable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +125,23 @@ function MainPage({ faction, rerender, onAugmentations }: IMainProps): React.Rea
|
|||||||
{faction.name}
|
{faction.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Info faction={faction} factionInfo={factionInfo} />
|
<Info faction={faction} factionInfo={factionInfo} />
|
||||||
{canAccessGang && (
|
{isManageGangVisible && (
|
||||||
<>
|
<>
|
||||||
<Option buttonText={"Manage Gang"} infoText={gangInfo} onClick={manageGang} />
|
<Box>
|
||||||
|
<Paper sx={{ my: 1, p: 1 }}>
|
||||||
|
<Tooltip
|
||||||
|
title={!isManageGangClickable ? <Typography>Unlocked when reaching {GangConstants.GangKarmaRequirement} karma</Typography> : ""}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<Button onClick={manageGang} disabled={!isManageGangClickable}>
|
||||||
|
{"Manage Gang"}
|
||||||
|
</Button>
|
||||||
|
<Typography>{gangInfo}</Typography>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
|
||||||
<CreateGangModal facName={faction.name} open={gangOpen} onClose={() => setGangOpen(false)} />
|
<CreateGangModal facName={faction.name} open={gangOpen} onClose={() => setGangOpen(false)} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -6,6 +6,7 @@ export const GangConstants: {
|
|||||||
CyclesPerTerritoryAndPowerUpdate: number;
|
CyclesPerTerritoryAndPowerUpdate: number;
|
||||||
AscensionMultiplierRatio: number;
|
AscensionMultiplierRatio: number;
|
||||||
Names: string[];
|
Names: string[];
|
||||||
|
GangKarmaRequirement: number;
|
||||||
} = {
|
} = {
|
||||||
// Respect is divided by this to get rep gain
|
// Respect is divided by this to get rep gain
|
||||||
GangRespectToReputationRatio: 75,
|
GangRespectToReputationRatio: 75,
|
||||||
@ -23,4 +24,5 @@ export const GangConstants: {
|
|||||||
FactionNames.NiteSec,
|
FactionNames.NiteSec,
|
||||||
FactionNames.TheBlackHand,
|
FactionNames.TheBlackHand,
|
||||||
],
|
],
|
||||||
|
GangKarmaRequirement: -54000,
|
||||||
};
|
};
|
||||||
|
@ -208,6 +208,7 @@ export interface IPlayer {
|
|||||||
hasProgram(program: string): boolean;
|
hasProgram(program: string): boolean;
|
||||||
inBladeburner(): boolean;
|
inBladeburner(): boolean;
|
||||||
inGang(): boolean;
|
inGang(): boolean;
|
||||||
|
isAwareOfGang(): boolean;
|
||||||
isQualified(company: Company, position: CompanyPosition): boolean;
|
isQualified(company: Company, position: CompanyPosition): boolean;
|
||||||
loseMoney(money: number, source: string): void;
|
loseMoney(money: number, source: string): void;
|
||||||
process(router: IRouter, numCycles?: number): void;
|
process(router: IRouter, numCycles?: number): void;
|
||||||
|
@ -218,6 +218,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
hasProgram: (program: string) => boolean;
|
hasProgram: (program: string) => boolean;
|
||||||
inBladeburner: () => boolean;
|
inBladeburner: () => boolean;
|
||||||
inGang: () => boolean;
|
inGang: () => boolean;
|
||||||
|
isAwareOfGang: () => boolean;
|
||||||
isQualified: (company: Company, position: CompanyPosition) => boolean;
|
isQualified: (company: Company, position: CompanyPosition) => boolean;
|
||||||
loseMoney: (money: number, source: string) => void;
|
loseMoney: (money: number, source: string) => void;
|
||||||
reapplyAllAugmentations: (resetMultipliers?: boolean) => void;
|
reapplyAllAugmentations: (resetMultipliers?: boolean) => void;
|
||||||
@ -604,6 +605,7 @@ export class PlayerObject implements IPlayer {
|
|||||||
this.hasCorporation = corporationMethods.hasCorporation;
|
this.hasCorporation = corporationMethods.hasCorporation;
|
||||||
this.startCorporation = corporationMethods.startCorporation;
|
this.startCorporation = corporationMethods.startCorporation;
|
||||||
this.canAccessGang = gangMethods.canAccessGang;
|
this.canAccessGang = gangMethods.canAccessGang;
|
||||||
|
this.isAwareOfGang = gangMethods.isAwareOfGang;
|
||||||
this.getGangFaction = gangMethods.getGangFaction;
|
this.getGangFaction = gangMethods.getGangFaction;
|
||||||
this.getGangName = gangMethods.getGangName;
|
this.getGangName = gangMethods.getGangName;
|
||||||
this.hasGangWith = gangMethods.hasGangWith;
|
this.hasGangWith = gangMethods.hasGangWith;
|
||||||
|
@ -2,9 +2,9 @@ import { Factions } from "../../Faction/Factions";
|
|||||||
import { Faction } from "../../Faction/Faction";
|
import { Faction } from "../../Faction/Faction";
|
||||||
import { Gang } from "../../Gang/Gang";
|
import { Gang } from "../../Gang/Gang";
|
||||||
import { IPlayer } from "../IPlayer";
|
import { IPlayer } from "../IPlayer";
|
||||||
|
import { GangConstants } from "../../Gang/data/Constants"
|
||||||
|
|
||||||
|
|
||||||
// Amount of negative karma needed to manage a gang in BitNodes other than 2
|
|
||||||
const GangKarmaRequirement = -54000;
|
|
||||||
|
|
||||||
export function canAccessGang(this: IPlayer): boolean {
|
export function canAccessGang(this: IPlayer): boolean {
|
||||||
if (this.bitNodeN === 2) {
|
if (this.bitNodeN === 2) {
|
||||||
@ -14,7 +14,11 @@ export function canAccessGang(this: IPlayer): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.karma <= GangKarmaRequirement;
|
return this.karma <= GangConstants.GangKarmaRequirement;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isAwareOfGang(this: IPlayer): boolean {
|
||||||
|
return this.bitNodeN === 2 || this.sourceFileLvl(2) >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGangFaction(this: IPlayer): Faction {
|
export function getGangFaction(this: IPlayer): Faction {
|
||||||
|
Loading…
Reference in New Issue
Block a user