Skip to content

Commit

Permalink
fix up some types and also add more military UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisinajar committed Mar 1, 2024
1 parent c54ffb2 commit 4c0ab99
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/admin/add-levels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import TextField from "@mui/material/TextField";

import { useAddLevelsMutation, BaseAccount } from "src/generated/graphql";
import { useAddLevelsMutation, AdminAccountQuery } from "src/generated/graphql";

export function AddLevels({
account,
}: {
account: Omit<BaseAccount, "password">;
account: AdminAccountQuery["account"];
}): JSX.Element {
const [levels, setLevels] = useState<string>("");
const [giveGoldMutation, { data }] = useAddLevelsMutation();
Expand Down
4 changes: 2 additions & 2 deletions src/admin/ban-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import Switch from "@mui/material/Switch";
import {
useBanAccountMutation,
useUnbanAccountMutation,
BaseAccount,
AdminAccountQuery,
} from "src/generated/graphql";

export function BanToggle({
account,
}: {
account: Omit<BaseAccount, "password">;
account: AdminAccountQuery["account"];
}): JSX.Element {
const [banAccount] = useBanAccountMutation();
const [unbanAccount] = useUnbanAccountMutation();
Expand Down
3 changes: 2 additions & 1 deletion src/admin/create-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import {
useCreateItemMutation,
BaseAccount,
EnchantmentType,
AdminAccountQuery,
} from "src/generated/graphql";

export function CreateItem({
account,
}: {
account: Omit<BaseAccount, "password">;
account: AdminAccountQuery["account"];
}): JSX.Element {
const [baseItem, setBaseItem] = useState<string>("");
const [enchantment, setEnchantment] = useState<string>("");
Expand Down
7 changes: 5 additions & 2 deletions src/admin/delete-account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import FormGroup from "@mui/material/FormGroup";
import FormControlLabel from "@mui/material/FormControlLabel";
import Switch from "@mui/material/Switch";

import { useDeleteAccountMutation, BaseAccount } from "src/generated/graphql";
import {
useDeleteAccountMutation,
AdminAccountQuery,
} from "src/generated/graphql";

export function DeleteAccount({
account,
}: {
account: Omit<BaseAccount, "password">;
account: AdminAccountQuery["account"];
}): JSX.Element {
const [deleteAccountMutation] = useDeleteAccountMutation();
const [isArmed, setIsArmed] = useState<boolean>(false);
Expand Down
4 changes: 2 additions & 2 deletions src/admin/give-gold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import TextField from "@mui/material/TextField";

import { useGiveGoldMutation, BaseAccount } from "src/generated/graphql";
import { useGiveGoldMutation, AdminAccountQuery } from "src/generated/graphql";

export function GiveGold({
account,
}: {
account: Omit<BaseAccount, "password">;
account: AdminAccountQuery["account"];
}): JSX.Element {
const [amount, setAmount] = useState<string>("");
const [giveGoldMutation, { data }] = useGiveGoldMutation();
Expand Down
1 change: 1 addition & 0 deletions src/game/locations/settlement-manager.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ query SettlementManager {
type
health
maxHealth
remainingAttacks
availableUpgrades {
cost {
name
Expand Down
8 changes: 8 additions & 0 deletions src/game/locations/settlement/attack-location.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ mutation AttackLocation($target: LocationInput!, $units: MilitaryUnitInput!) {
account {
id
nextAllowedAction

hero {
id
home {
id
remainingAttacks
}
}
}
}
}
1 change: 1 addition & 0 deletions src/game/locations/settlement/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ export function SettlementManager({
<TabPanel value="military">
<Military
location={selectedBuilding}
capital={capital}
resources={resources}
hero={hero}
refetch={refetch}
Expand Down
16 changes: 9 additions & 7 deletions src/game/locations/settlement/military.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import { AttackResultsModal } from "./attack-results-modal";

export function Military({
location,
capital,
hero,
resources,
refetch,
}: {
location: PlayerLocation | null;
capital: PlayerLocation;
hero: Hero;
resources: CampResources[];
refetch: () => void;
Expand Down Expand Up @@ -133,7 +135,11 @@ export function Military({
your control.
</Typography>
<br />
<Typography variant="h5">Current target:</Typography>
<Typography variant="h6" component="h4">
Remaining attacks: {capital.remainingAttacks}
</Typography>
<br />
<Typography variant="h5">Current target</Typography>
{!location && (
<Typography variant="body1">Select a target using the map.</Typography>
)}
Expand Down Expand Up @@ -222,7 +228,7 @@ export function Military({
)}
{location && (
<>
<Typography variant="h6">Troups in this location</Typography>
<Typography variant="h5">Troups in this location</Typography>
<ul>
{(enlistedResource?.value ?? 0) > 0 && (
<li>
Expand Down Expand Up @@ -277,11 +283,7 @@ export function Military({
</li>
)}
</ul>
</>
)}
{location && (
<>
<Typography mb={2} variant="h5">
<Typography mb={2} component="h6" variant="h5">
Troops to send
</Typography>
<Grid container columns={6} spacing={2}>
Expand Down

0 comments on commit 4c0ab99

Please sign in to comment.