implemented usePreviousPlayer, preparing to implement gold chip funcitonality

This commit is contained in:
2022-08-09 14:27:59 -05:00
parent fd6d96737a
commit 35931eb8e5
22 changed files with 78 additions and 51 deletions

View File

@@ -1,26 +1,24 @@
import { ResourceProps } from "../../util/propTypes";
import { ResourceCost } from "../../util/types";
import { useEffect } from "react";
import { v4 } from "uuid";
import "./AvailableChips.css"
export default function AvailableChips({ state, setState, liftSelection }: ResourceProps) {
useEffect(() => {
return;
}, [state])
export default function AvailableChips({ state, liftSelection }: ResourceProps) {
return (
<div className="available-chips">
{
Object.keys(state.gameboard.tradingResources).map((key: string | keyof ResourceCost) => {
Object.keys(state.gameboard.tradingResources).map((key: string) => {
const typedKey = key as keyof ResourceCost;
return (
<div key={v4()} className={`chips-${key}`}>
<button
key={v4()}
value={key}
onClick={() => liftSelection(key as keyof ResourceCost)}
// @ts-ignore
disabled={state.gameboard.tradingResources[typedKey] <= 0}
onClick={() => liftSelection(typedKey)}
>
{key}: {state.gameboard.tradingResources[key as keyof ResourceCost]}
{key}: {state.gameboard.tradingResources[typedKey]}
</button>
</div>
)