Fix VP card to honor game rule
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
e9a542bc64
commit
0c19b38c4d
@ -13,8 +13,9 @@ const ViewCard = ({cardActive, setCardActive}) => {
|
|||||||
const { ws } = useContext(GlobalContext);
|
const { ws } = useContext(GlobalContext);
|
||||||
const [priv, setPriv] = useState(undefined);
|
const [priv, setPriv] = useState(undefined);
|
||||||
const [turns, setTurns] = useState(0);
|
const [turns, setTurns] = useState(0);
|
||||||
|
const [rules, setRules] = useState({});
|
||||||
const fields = useMemo(() => [
|
const fields = useMemo(() => [
|
||||||
'private', 'turns'
|
'private', 'turns', 'rules'
|
||||||
], []);
|
], []);
|
||||||
const onWsMessage = (event) => {
|
const onWsMessage = (event) => {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
@ -27,6 +28,10 @@ const ViewCard = ({cardActive, setCardActive}) => {
|
|||||||
if ('turns' in data.update && data.update.turns !== turns) {
|
if ('turns' in data.update && data.update.turns !== turns) {
|
||||||
setTurns(data.update.turns);
|
setTurns(data.update.turns);
|
||||||
}
|
}
|
||||||
|
if ('rules' in data.update
|
||||||
|
&& !equal(data.update.rules, rules)) {
|
||||||
|
setRules(rules);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -84,6 +89,11 @@ const ViewCard = ({cardActive, setCardActive}) => {
|
|||||||
lookup = cardActive.type;
|
lookup = cardActive.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const points = ('victory-points' in rules)
|
||||||
|
&& rules['victory-points'].enabled
|
||||||
|
? rules['victory-points'].points
|
||||||
|
: 0;
|
||||||
|
|
||||||
let cardName = '';
|
let cardName = '';
|
||||||
switch (lookup) {
|
switch (lookup) {
|
||||||
case 'army':
|
case 'army':
|
||||||
@ -99,7 +109,7 @@ const ViewCard = ({cardActive, setCardActive}) => {
|
|||||||
description = <><div><b>1</b> victory point.</div>
|
description = <><div><b>1</b> victory point.</div>
|
||||||
<div>You only reveal your victory point cards when the game is over, either
|
<div>You only reveal your victory point cards when the game is over, either
|
||||||
when you or an opponent
|
when you or an opponent
|
||||||
reaches <b>10+</b> victory points on their turn and declares
|
reaches <b>{points}+</b> victory points on their turn and declares
|
||||||
victory!</div></>;
|
victory!</div></>;
|
||||||
break;
|
break;
|
||||||
case 'progress-road-1':
|
case 'progress-road-1':
|
||||||
@ -140,7 +150,7 @@ const ViewCard = ({cardActive, setCardActive}) => {
|
|||||||
points++;
|
points++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
canPlay = points >= 10;
|
canPlay = points >= points;
|
||||||
if (!canPlay && !cardActive.played) {
|
if (!canPlay && !cardActive.played) {
|
||||||
description = <>{description}<div>You do not have enough victory points to play this card yet. You can currently reach <b>{points}</b> points.</div></>;
|
description = <>{description}<div>You do not have enough victory points to play this card yet. You can currently reach <b>{points}</b> points.</div></>;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user