From 109c6dc25f778fa911eedbae9d40b3cbad96e160 Mon Sep 17 00:00:00 2001 From: Oliveriver Date: Wed, 7 Aug 2024 17:42:43 +0100 Subject: [PATCH] Fix a lot of issues around order entry and coasts --- .../user-interface/common/Checkbox.tsx | 22 +++ client/src/components/world/boards/Board.tsx | 10 +- .../components/world/boards/BoardGhost.tsx | 13 +- .../components/world/boards/BoardLayer.tsx | 19 +-- client/src/components/world/boards/Map.tsx | 34 +++-- client/src/components/world/boards/Region.tsx | 53 +++---- .../src/components/world/orders/Disband.tsx | 2 +- client/src/hooks/useOrderEntryReducer.tsx | 35 ++++- client/src/hooks/useSelectLocation.tsx | 129 ++++++++++++++++++ .../src/hooks/useSetAvailableInputModes.tsx | 12 +- client/src/types/location.ts | 10 +- server/Adjudication/Adjudicator.cs | 11 +- server/Adjudication/Validation/Validator.cs | 10 +- server/Mappers/ModelMapper.cs | 2 +- 14 files changed, 270 insertions(+), 92 deletions(-) create mode 100644 client/src/components/user-interface/common/Checkbox.tsx create mode 100644 client/src/hooks/useSelectLocation.tsx diff --git a/client/src/components/user-interface/common/Checkbox.tsx b/client/src/components/user-interface/common/Checkbox.tsx new file mode 100644 index 0000000..318cc68 --- /dev/null +++ b/client/src/components/user-interface/common/Checkbox.tsx @@ -0,0 +1,22 @@ +import colours from '../../../utils/colours'; + +type CheckboxProps = { + title: string; + value: boolean; + onChange: (value: boolean) => void; +}; + +const Checkbox = ({ title, value, onChange }: CheckboxProps) => ( +
+

{title}

+
+); + +export default Checkbox; diff --git a/client/src/components/world/boards/Board.tsx b/client/src/components/world/boards/Board.tsx index c4f377d..ef6700d 100644 --- a/client/src/components/world/boards/Board.tsx +++ b/client/src/components/world/boards/Board.tsx @@ -13,13 +13,11 @@ import colours from '../../../utils/colours'; type BoardProps = { board: BoardData; - isActive: boolean; winner: Nation | null; }; -const Board = ({ board, isActive, winner }: BoardProps) => { +const Board = ({ board, winner }: BoardProps) => { const { phase } = board; - const showWinner = isActive && winner; const width = phase === Phase.Winter ? minorBoardWidth : majorBoardWidth; @@ -41,12 +39,12 @@ const Board = ({ board, isActive, winner }: BoardProps) => { minHeight: width, height: width, borderWidth: boardBorderWidth, - borderColor: showWinner ? getNationColour(winner) : colours.boardBorder, - boxShadow: showWinner ? `0px 0px 100px 50px ${getNationColour(winner)}` : '', + borderColor: winner ? getNationColour(winner) : colours.boardBorder, + boxShadow: winner ? `0px 0px 100px 50px ${getNationColour(winner)}` : '', }} >

{getBoardName(board)}

- + {phase === Phase.Winter && } diff --git a/client/src/components/world/boards/BoardGhost.tsx b/client/src/components/world/boards/BoardGhost.tsx index 00aa18c..669ae21 100644 --- a/client/src/components/world/boards/BoardGhost.tsx +++ b/client/src/components/world/boards/BoardGhost.tsx @@ -7,12 +7,15 @@ import Map from './Map'; import TextInput from '../../user-interface/common/TextInput'; import Select from '../../user-interface/common/Select'; import { isInteger } from '../../../utils/numberUtils'; +import Checkbox from '../../user-interface/common/Checkbox'; type LocationInputProps = { board: Board; onTimelineEntered: (value: string) => void; onYearEntered: (value: string) => void; onPhaseEntered: (value: Phase) => void; + isShowingCoasts: boolean; + onCoastsToggled: (value: boolean) => void; }; const LocationInput = ({ @@ -20,8 +23,10 @@ const LocationInput = ({ onTimelineEntered, onYearEntered, onPhaseEntered, + isShowingCoasts, + onCoastsToggled, }: LocationInputProps) => ( -
+