From 4c0ab9925b1b737580463d3cbf22768db52ddbf2 Mon Sep 17 00:00:00 2001 From: Chris Vickery Date: Fri, 1 Mar 2024 12:01:10 -0800 Subject: [PATCH] fix up some types and also add more military UI --- src/admin/add-levels.tsx | 4 ++-- src/admin/ban-toggle.tsx | 4 ++-- src/admin/create-item.tsx | 3 ++- src/admin/delete-account.tsx | 7 +++++-- src/admin/give-gold.tsx | 4 ++-- src/game/locations/settlement-manager.graphql | 1 + .../locations/settlement/attack-location.graphql | 8 ++++++++ src/game/locations/settlement/index.tsx | 1 + src/game/locations/settlement/military.tsx | 16 +++++++++------- 9 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/admin/add-levels.tsx b/src/admin/add-levels.tsx index 88e70b8..1de713f 100644 --- a/src/admin/add-levels.tsx +++ b/src/admin/add-levels.tsx @@ -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; + account: AdminAccountQuery["account"]; }): JSX.Element { const [levels, setLevels] = useState(""); const [giveGoldMutation, { data }] = useAddLevelsMutation(); diff --git a/src/admin/ban-toggle.tsx b/src/admin/ban-toggle.tsx index 8bb80a4..0f65828 100644 --- a/src/admin/ban-toggle.tsx +++ b/src/admin/ban-toggle.tsx @@ -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; + account: AdminAccountQuery["account"]; }): JSX.Element { const [banAccount] = useBanAccountMutation(); const [unbanAccount] = useUnbanAccountMutation(); diff --git a/src/admin/create-item.tsx b/src/admin/create-item.tsx index d0667d9..091262a 100644 --- a/src/admin/create-item.tsx +++ b/src/admin/create-item.tsx @@ -8,12 +8,13 @@ import { useCreateItemMutation, BaseAccount, EnchantmentType, + AdminAccountQuery, } from "src/generated/graphql"; export function CreateItem({ account, }: { - account: Omit; + account: AdminAccountQuery["account"]; }): JSX.Element { const [baseItem, setBaseItem] = useState(""); const [enchantment, setEnchantment] = useState(""); diff --git a/src/admin/delete-account.tsx b/src/admin/delete-account.tsx index ef4cad9..1fd7c3a 100644 --- a/src/admin/delete-account.tsx +++ b/src/admin/delete-account.tsx @@ -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; + account: AdminAccountQuery["account"]; }): JSX.Element { const [deleteAccountMutation] = useDeleteAccountMutation(); const [isArmed, setIsArmed] = useState(false); diff --git a/src/admin/give-gold.tsx b/src/admin/give-gold.tsx index 3f9e8c5..3390e64 100644 --- a/src/admin/give-gold.tsx +++ b/src/admin/give-gold.tsx @@ -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; + account: AdminAccountQuery["account"]; }): JSX.Element { const [amount, setAmount] = useState(""); const [giveGoldMutation, { data }] = useGiveGoldMutation(); diff --git a/src/game/locations/settlement-manager.graphql b/src/game/locations/settlement-manager.graphql index 29c118f..f5a79f7 100644 --- a/src/game/locations/settlement-manager.graphql +++ b/src/game/locations/settlement-manager.graphql @@ -57,6 +57,7 @@ query SettlementManager { type health maxHealth + remainingAttacks availableUpgrades { cost { name diff --git a/src/game/locations/settlement/attack-location.graphql b/src/game/locations/settlement/attack-location.graphql index a0825cc..8d0a2dc 100644 --- a/src/game/locations/settlement/attack-location.graphql +++ b/src/game/locations/settlement/attack-location.graphql @@ -45,6 +45,14 @@ mutation AttackLocation($target: LocationInput!, $units: MilitaryUnitInput!) { account { id nextAllowedAction + + hero { + id + home { + id + remainingAttacks + } + } } } } diff --git a/src/game/locations/settlement/index.tsx b/src/game/locations/settlement/index.tsx index c223cd2..635e60a 100644 --- a/src/game/locations/settlement/index.tsx +++ b/src/game/locations/settlement/index.tsx @@ -506,6 +506,7 @@ export function SettlementManager({ void; @@ -133,7 +135,11 @@ export function Military({ your control.
- Current target: + + Remaining attacks: {capital.remainingAttacks} + +
+ Current target {!location && ( Select a target using the map. )} @@ -222,7 +228,7 @@ export function Military({ )} {location && ( <> - Troups in this location + Troups in this location
    {(enlistedResource?.value ?? 0) > 0 && (
  • @@ -277,11 +283,7 @@ export function Military({
  • )}
- - )} - {location && ( - <> - + Troops to send