import React, { useState, useCallback } from "react"; import "./ViewCard.css"; import Paper from '@material-ui/core/Paper'; import Button from '@material-ui/core/Button'; import Resource from './Resource.js'; const ViewCard = ({table, card}) => { if (!table.game.player) { return <>>; } const playCard = (event) => { table.playCard(card); } const close = (event) => { table.closeCard(); }; const capitalize = (string) => { if (string === 'vp') { return 'Victory Point'; } if (string === 'army') { return 'Knight'; } return string.charAt(0).toUpperCase() + string.slice(1); }; const descriptions = { army: <>When played, you must move the robber.
Steal 1 resource card from the owner of an adjacent settlement or city.
You may only play one development card during your turn -- either one knight or one progress card.
>, vp: <>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 victory!
>, 'progress-road-1': <>Play 2 new roads as if you had just built them.
This is still limited by the number of roads you have (a maximum of 15.)
NOTE: This card is not yet implemented. The server will give you 2 wood and 2 brick and we trust you will use them to build 2 roads.
If you do not have enough roads remaining, you may end up with extra resources... but the game is in beta, so... be happy :)
As an FYI, you currently have {15 - table.game.player.roads} roads remaining.
>, 'progress-road-2': <>Play 2 new roads as if you had just built them.
This is still limited by the number of roads you have (a maximum of 15.)
NOTE: This card is not yet implemented. The server will give you 2 wood and 2 brick and we trust you will use them to build 2 roads.
If you do not have enough roads remaining, you may end up with extra resources... but the game is in beta, so... be happy :)
As an FYI, you currently have {15 - table.game.player.roads} roads remaining.
>, 'progress-monopoly': <> When you play this card, you will select 1 type of resource. All other players must give you all their resource cards of that type. >, 'progress-year-of-plenty': <> Take any 2 resources from the bank. Add them to your hand. They can be 2 of the same resource or 2 different resources.Unfortunately the current implementation only lets you pick a single resource and you will then get 2 of those.
> }; let description; if (card.type == 'progress') { description = descriptions[`${card.type}-${card.card}`]; } else { description = descriptions[card.type]; } if (description === undefined) { console.log(`No description for ${card.type}-${card.card}`); } let canPlay = false; if (card.type === 'vp') { let points = table.game.player.points; table.game.player.development.forEach(item => { if (item.type === 'vp') { points++; } }); canPlay = points >= 10; if (!canPlay && !card.played) { description = <>{description}You do not have enough victory points to play this card yet.
>; } } else { canPlay = card.turn < table.game.turns; if (!canPlay) { description = <>{description}You can not play this card until your next turn.
>; } if (canPlay) { canPlay = table.game.player.playedCard !== table.game.turns; if (!canPlay) { description = <>{description}You have already played a development card this turn.
>; } } } if (card.played) { description = <>{description}You have already played this card.
>; canPlay = false; } return (