import { useEffect, useState } from "react"; import { v4 } from "uuid"; import { setStateGetChips, setStateReserveCard, setStateReservePlusGold } from "../../hooks/stateSetters"; import { useCurrentPlayer } from "../../hooks/useCurrentPlayer"; import { StateProps } from "../../util/propTypes"; import { ResourceCost } from "../../util/types"; import { getChipsActions } from "../Player/ActionMethods"; import { hasMaxChips } from "../Player/ActionMethods/getChipsActions"; const { getChips } = getChipsActions; export const GetChipsHTML = ({ state, setState }: StateProps) => { const [prompt, setPrompt] = useState(""); const currentPlayer = useCurrentPlayer(state); useEffect(() => { if (!state.actions.getChips.active) setPrompt(""); if (state.actions.getChips.selection?.length === 0) { setPrompt("Please make a selection."); } else { setPrompt(`Your selection is ${state.actions.getChips.valid ? '' : "not"} valid`); } }, [state]) return (

{currentPlayer?.name} has elected to collect resources!

{prompt}
{ state.actions.getChips.active && state.actions.getChips.selection?.map((each: keyof ResourceCost) =>

{each}

) }
{ state.actions.getChips.valid ? : }
) } export const ReserveCardHTML = ({ state, setState }: StateProps) => { const [takeGold, setTakeGold] = useState(false); const currentPlayer = useCurrentPlayer(state); useEffect(() => { switch (takeGold) { case true: setState((prev) => setStateReservePlusGold(prev)); break; case false: setState((prev) => setStateReserveCard(prev)); break; default: break; } }, [takeGold]); return (

{currentPlayer?.name} has elected to reserve a card!

Please make your selection above. { !hasMaxChips(currentPlayer) && (

Take a gold chip with your card? {takeGold}

setTakeGold(true)} type="radio" > setTakeGold(false)} type="radio">
)}
) }