Skip to content

Commit

Permalink
expose settlement razing better
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisinajar committed Mar 4, 2024
1 parent 21adbf0 commit 2b7e4ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
21 changes: 20 additions & 1 deletion src/game/locations/settlement/building-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FormControl from "@mui/material/FormControl";
import InputLabel from "@mui/material/InputLabel";
import TextField from "@mui/material/TextField";
import Tooltip from "@mui/material/Tooltip";
import Typography from "@mui/material/Typography";

import LoadingButton from "@mui/lab/LoadingButton";

Expand All @@ -24,9 +25,11 @@ import { CampUpgrades } from "../camp";
export function BuildingDetails({
location,
hero,
onDestroy,
}: {
location: PlayerLocation;
hero: Hero;
onDestroy: (location: PlayerLocation) => void;
}): JSX.Element | null {
const [recruitAction, { loading: recruitLoading }] = useRecruitMutation();
const [purchaseBondsAction, { loading: bondsLoading }] =
Expand Down Expand Up @@ -66,9 +69,25 @@ export function BuildingDetails({
)}
</ul>

{location.type === PlayerLocationType.Settlement && (
{location.id === hero.home?.id && (
<CampUpgrades camp={location} hero={hero} />
)}
{location.type === PlayerLocationType.Settlement &&
location.id !== hero.home?.id && (
<>
<Typography>
This settlement is a former capital that has fallen. You can
destroy this location and reclaim most of the resources.
</Typography>
<Button
onClick={() => onDestroy(location)}
variant="contained"
color="error"
>
Destroy former settlement
</Button>
</>
)}

{location.type === PlayerLocationType.Barracks && (
<ResourcePurchase
Expand Down
12 changes: 10 additions & 2 deletions src/game/locations/settlement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,18 @@ export function SettlementManager({
</Typography>
)}
{selectedBuilding && (
<BuildingDetails location={selectedBuilding} hero={hero} />
<BuildingDetails
location={selectedBuilding}
hero={hero}
onDestroy={setDestroyConfirmation}
/>
)}
{!selectedBuilding && (
<BuildingDetails location={capital} hero={hero} />
<BuildingDetails
location={capital}
hero={hero}
onDestroy={setDestroyConfirmation}
/>
)}
</TabPanel>
<TabPanel value="military">
Expand Down

0 comments on commit 2b7e4ab

Please sign in to comment.