diff --git a/client/src/ViewCard.js b/client/src/ViewCard.js index a867ef0..1d201a9 100644 --- a/client/src/ViewCard.js +++ b/client/src/ViewCard.js @@ -13,8 +13,9 @@ const ViewCard = ({cardActive, setCardActive}) => { const { ws } = useContext(GlobalContext); const [priv, setPriv] = useState(undefined); const [turns, setTurns] = useState(0); + const [rules, setRules] = useState({}); const fields = useMemo(() => [ - 'private', 'turns' + 'private', 'turns', 'rules' ], []); const onWsMessage = (event) => { const data = JSON.parse(event.data); @@ -27,6 +28,10 @@ const ViewCard = ({cardActive, setCardActive}) => { if ('turns' in data.update && data.update.turns !== turns) { setTurns(data.update.turns); } + if ('rules' in data.update + && !equal(data.update.rules, rules)) { + setRules(rules); + } break; default: break; @@ -84,6 +89,11 @@ const ViewCard = ({cardActive, setCardActive}) => { lookup = cardActive.type; } + const points = ('victory-points' in rules) + && rules['victory-points'].enabled + ? rules['victory-points'].points + : 0; + let cardName = ''; switch (lookup) { case 'army': @@ -99,7 +109,7 @@ const ViewCard = ({cardActive, setCardActive}) => { description = <>
1 victory point.
You only reveal your victory point cards when the game is over, either when you or an opponent - reaches 10+ victory points on their turn and declares + reaches {points}+ victory points on their turn and declares victory!
; break; case 'progress-road-1': @@ -140,7 +150,7 @@ const ViewCard = ({cardActive, setCardActive}) => { points++; } }); - canPlay = points >= 10; + canPlay = points >= points; if (!canPlay && !cardActive.played) { description = <>{description}
You do not have enough victory points to play this card yet. You can currently reach {points} points.
; }