diff --git a/client/README.md b/client/README.md deleted file mode 100644 index b58e0af8..00000000 --- a/client/README.md +++ /dev/null @@ -1,46 +0,0 @@ -# Getting Started with Create React App - -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `yarn start` - -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits.\ -You will also see any lint errors in the console. - -### `yarn test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `yarn build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/client/package.json b/client/package.json deleted file mode 100644 index 700d00fe..00000000 --- a/client/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@open-star-ter-village/webapp-client", - "version": "0.0.1", - "private": true, - "dependencies": { - "@chakra-ui/icons": "^1.1.7", - "@chakra-ui/react": "^1.8.8", - "@chakra-ui/theme": "^1.14.1", - "@chakra-ui/theme-tools": "^1.3.6", - "@emotion/react": "^11", - "@emotion/styled": "^11", - "@open-star-ter-village/webapp-game": "0.0.1", - "boardgame.io": "^0.49.11", - "framer-motion": "^6", - "react": "^17.0.2", - "react-dom": "^17.0.2", - "react-scripts": "^5.0.1", - "web-vitals": "^1.0.1" - }, - "devDependencies": { - "@testing-library/dom": "^8.5.0", - "@testing-library/jest-dom": "^5.11.4", - "@testing-library/react": "^11.1.0", - "@testing-library/user-event": "^12.1.10", - "@types/jest": "^26.0.24", - "@types/node": "^12.0.0", - "@types/react": "^17.0.0", - "@types/react-dom": "^17.0.0", - "typescript": "^4.1.2" - }, - "scripts": { - "dev": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } -} diff --git a/client/public/favicon.ico b/client/public/favicon.ico deleted file mode 100644 index a11777cc..00000000 Binary files a/client/public/favicon.ico and /dev/null differ diff --git a/client/public/index.html b/client/public/index.html deleted file mode 100644 index aa069f27..00000000 --- a/client/public/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - React App - - - -
- - - diff --git a/client/public/logo192.png b/client/public/logo192.png deleted file mode 100644 index fc44b0a3..00000000 Binary files a/client/public/logo192.png and /dev/null differ diff --git a/client/public/logo512.png b/client/public/logo512.png deleted file mode 100644 index a4e47a65..00000000 Binary files a/client/public/logo512.png and /dev/null differ diff --git a/client/public/manifest.json b/client/public/manifest.json deleted file mode 100644 index 080d6c77..00000000 --- a/client/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/client/public/robots.txt b/client/public/robots.txt deleted file mode 100644 index e9e57dc4..00000000 --- a/client/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/client/src/App.css b/client/src/App.css deleted file mode 100644 index 5d64fa63..00000000 --- a/client/src/App.css +++ /dev/null @@ -1,15 +0,0 @@ -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - - to { - transform: rotate(360deg); - } -} diff --git a/client/src/App.test.tsx b/client/src/App.test.tsx deleted file mode 100644 index 8b8eb69c..00000000 --- a/client/src/App.test.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - render(); - const linkElement = screen.getByText(/OpenStarTerVillage/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/client/src/App.tsx b/client/src/App.tsx deleted file mode 100644 index 7a07b724..00000000 --- a/client/src/App.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Heading, HStack, Box, Text, Link, Image } from '@chakra-ui/react'; -import Boardgame from './BoardGame'; -import logo from './logo.svg'; -import './App.css'; - -function App() { - return ( - <> - - logo - - OpenStarTerVillage - - - - Clone from github - - - - - Player 0 view - - - - Player 1 view - - - - Observer view - - - - ); -} - -export default App; diff --git a/client/src/DevActions/DevActions.tsx b/client/src/DevActions/DevActions.tsx deleted file mode 100644 index 16508eb3..00000000 --- a/client/src/DevActions/DevActions.tsx +++ /dev/null @@ -1,217 +0,0 @@ -import { useCallback, useState } from 'react'; -import { BoardProps } from 'boardgame.io/react'; -import { OpenStarTerVillageType as Type } from 'packages/game/src/types'; -import { - Stack, - HStack, - Button, - Box, - RadioGroup, - Radio, - NumberInput, - NumberInputField, - NumberInputStepper, - NumberIncrementStepper, - NumberDecrementStepper, - Tabs, - TabList, - Tab, - TabPanel, - TabPanels, -} from '@chakra-ui/react' - -const CurrentPlayer: React.FC> = (props) => { - const { G, playerID, moves: nonTypeMoves, events, ctx } = props; - const moves = nonTypeMoves as unknown as Type.Move.AllMoves; - - const [projectCardIndex, setProjectCardIndex] = useState(0); - const [activeJobCardIndex, setActiveJobCardIndex] = useState(0); - const [activeProjectIndex, setActiveProjectIndex] = useState(0); - const [jobName, setJobName] = useState(''); - const [value, setValue] = useState(0); - const [contributions, setContributions] = useState<{ activeProjectIndex: number; jobName: string; value: number }[]>([]); - const onAddContribution = useCallback(() => { - if (activeProjectIndex >= 0 && jobName !== '' && value > 0) { - setContributions(cons => { - return [...cons, { activeProjectIndex, jobName, value }]; - }); - } - }, [activeProjectIndex, jobName, value]); - - if (playerID === null) { - return null; - } - - const onCreateProject = () => moves.createProject(projectCardIndex, activeJobCardIndex); - const onRecruit = () => moves.recruit(activeJobCardIndex, activeProjectIndex); - const onContributeJoinedProjects = () => { - moves.contributeJoinedProjects(contributions); - setContributions([]); - }; - const onContributeOwnedProjects = () => { - moves.contributeOwnedProjects(contributions); - setContributions([]); - }; - const onEndAction = () => events.endStage!(); - const onEndSettle = () => events.endStage!(); - const onRefillAndEnd = () => moves.refillAndEnd(); - const myCurrentStage = ctx.activePlayers ? ctx.activePlayers[playerID] : '' - - const renderHandProjectCards = () => ( - - Hand project cards - setProjectCardIndex(parseInt(val))} value={projectCardIndex}> - { - G.players[playerID].hand.projects.map((project, index) => - {project.name}
{JSON.stringify(project.requirements)}
) - } -
-
- ); - - const renderActiveJobCards = () => ( - - Active job cards - setActiveJobCardIndex(parseInt(val))} value={activeJobCardIndex}> - { - G.table.activeJobs.map((job, index) => - {job.name}) - } - - - ); - - const renderActiveProjectCards = () => ( - - Active project cards - setActiveProjectIndex(parseInt(val))} value={activeProjectIndex}> - { - G.table.activeProjects.map(activeProject => activeProject.card).map((project, index) => - {project.name}
{JSON.stringify(project.requirements)}
) - } -
-
- ); - - const renderActiveProjectJobName = () => ( - - Job name - - { - Object.keys(G.table.activeProjects[activeProjectIndex]?.card.requirements ?? []).map((jobName) => - {jobName}) - } - - - ); - - const renderValueInputBox = () => ( - - Value - setValue(val)}> - - - - - - - - ); - - return ( -
- {myCurrentStage ?
my current stage: {myCurrentStage}
: null} - { - myCurrentStage === 'action' && - <> - - - Create Project - Recruit - Contribute Owned Projects - Contribute Joined Projects - Remove and Refill Jobs - Mirror - - - - - - {renderHandProjectCards()} - {renderActiveJobCards()} - - - - - - {renderActiveProjectCards()} - {renderActiveJobCards()} - - - - - - {renderActiveProjectCards()} - {renderActiveProjectJobName()} - {renderValueInputBox()} - - current contribution entities: {JSON.stringify(contributions)} - - - - - - {renderActiveProjectCards()} - {renderActiveProjectJobName()} - {renderValueInputBox()} - - current contribution entities: {JSON.stringify(contributions)} - - - - - - {renderActiveJobCards()} - - - - - - - - - - } - { - myCurrentStage === 'settle' && - <> - -
- -
-
- - } - { - myCurrentStage === 'discard' && - <> - -
- -
-
- - } - { - myCurrentStage === 'refill' && - <> - - - - - } -
- ); -} - -export default CurrentPlayer; diff --git a/client/src/features/Project/ActiveProject.tsx b/client/src/features/Project/ActiveProject.tsx deleted file mode 100644 index 96b5d58a..00000000 --- a/client/src/features/Project/ActiveProject.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { OpenStarTerVillageType as Type } from 'packages/game/src/types'; -import { - Box, - Table, - Thead, - Tbody, - Tr, - Th, - Td, - TableCaption, - TableContainer, - Tfoot, -} from '@chakra-ui/react'; - -type Props = { - project?: Type.State.Project; -}; - -const ActiveProject: React.FC = ({ project }) => { - const projectName = project?.card.name; - const headRow = ( - - 玩家 - 職業 - 貢獻 - 進度 - - ); - - const workerRows = project?.contributions.map(worker => - - {worker.worker} - {worker.jobName} - {worker.value} - {project.card.requirements[worker.jobName]} - - ) - - return ( - - - - {projectName} - - {headRow} - - - {workerRows} - - - {headRow} - -
-
-
- ) -} - -export default ActiveProject; diff --git a/client/src/features/Table/Table.tsx b/client/src/features/Table/Table.tsx deleted file mode 100644 index c7b64f33..00000000 --- a/client/src/features/Table/Table.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { BoardProps } from 'boardgame.io/react'; -import { OpenStarTerVillageType as Type } from 'packages/game/src/types'; -import { Box, Stack } from '@chakra-ui/react'; -import ActiveProject from '../Project/ActiveProject'; - -type Props = BoardProps; - -const Table: React.FC = (props) => { - const activeProjects = [...props.G.table.activeProjects, ...Array(6)].slice(0, 6); - - return ( - - - {activeProjects.map((p, pIndex) => ( - - - - ))} - - - ) -} - -export default Table; diff --git a/client/src/index.css b/client/src/index.css deleted file mode 100644 index ec2585e8..00000000 --- a/client/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/client/src/index.tsx b/client/src/index.tsx deleted file mode 100644 index 77cfed30..00000000 --- a/client/src/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { ChakraProvider } from '@chakra-ui/react' -import { StrictMode } from 'react'; -import ReactDOM from 'react-dom'; -import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; - -ReactDOM.render( - - - - - , - document.getElementById('root') -); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); diff --git a/client/src/logo.svg b/client/src/logo.svg deleted file mode 100644 index 9dfc1c05..00000000 --- a/client/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/client/src/react-app-env.d.ts b/client/src/react-app-env.d.ts deleted file mode 100644 index 6431bc5f..00000000 --- a/client/src/react-app-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/client/src/reportWebVitals.ts b/client/src/reportWebVitals.ts deleted file mode 100644 index 49a2a16e..00000000 --- a/client/src/reportWebVitals.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ReportHandler } from 'web-vitals'; - -const reportWebVitals = (onPerfEntry?: ReportHandler) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals; diff --git a/client/src/setupTests.ts b/client/src/setupTests.ts deleted file mode 100644 index 8f2609b7..00000000 --- a/client/src/setupTests.ts +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom'; diff --git a/client/tsconfig.json b/client/tsconfig.json deleted file mode 100644 index 6089e831..00000000 --- a/client/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "allowJs": true, - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx" - }, - "include": [ - "src" - ] -} diff --git a/packages/webapp/src/app/page.tsx b/packages/webapp/src/app/page.tsx index 078fd4c5..22328397 100644 --- a/packages/webapp/src/app/page.tsx +++ b/packages/webapp/src/app/page.tsx @@ -1,5 +1,6 @@ import Image from "next/image"; import styles from "./page.module.css"; +import DevView from "@/components/DevView"; export default function Home() { return ( @@ -38,6 +39,8 @@ export default function Home() { priority /> + + ); } diff --git a/client/src/BoardGame.tsx b/packages/webapp/src/components/BoardGame.tsx similarity index 62% rename from client/src/BoardGame.tsx rename to packages/webapp/src/components/BoardGame.tsx index e6ad585f..bc52724c 100644 --- a/client/src/BoardGame.tsx +++ b/packages/webapp/src/components/BoardGame.tsx @@ -1,10 +1,9 @@ -import { OpenStarTerVillage } from '@open-star-ter-village/webapp-game'; import { Client, BoardProps } from 'boardgame.io/react'; import { Local } from 'boardgame.io/multiplayer'; -import { OpenStarTerVillageType } from 'packages/game/src/types'; -import Table from './features/Table/Table'; -import Players from './Players/Players'; -import DevActions from './DevActions/DevActions'; +import { OpenStarTerVillage } from '@/game'; +import Table from '@/components/Table/Table'; +import Players from '@/components/Players/Players'; +import DevActions from '@/components/DevActions/DevActions'; const Board: React.FC> = (props) => { return ( diff --git a/packages/webapp/src/components/DevActions/DevActions.tsx b/packages/webapp/src/components/DevActions/DevActions.tsx new file mode 100644 index 00000000..6421acf0 --- /dev/null +++ b/packages/webapp/src/components/DevActions/DevActions.tsx @@ -0,0 +1,203 @@ +import { useCallback, useState } from 'react'; +import { BoardProps } from 'boardgame.io/react'; +import { + Stack, + Button, + Box, + RadioGroup, + Radio, + FormControlLabel, + TextField, + Tab, +} from '@mui/material'; +import { TabContext, TabList, TabPanel } from '@mui/lab'; + +const DevActions: React.FC> = (props) => { + const { G, playerID, moves: nonTypeMoves, events, ctx } = props; + const moves = nonTypeMoves as unknown as OpenStarTerVillageType.Move.AllMoves; + + const [tabValue, setTabValue] = useState('create-project'); + const onTabChange = (event: React.SyntheticEvent, newValue: string) => { + setTabValue(newValue); + }; + + const [projectCardIndex, setProjectCardIndex] = useState(0); + const [activeJobCardIndex, setActiveJobCardIndex] = useState(0); + const [activeProjectIndex, setActiveProjectIndex] = useState(0); + const [jobName, setJobName] = useState(''); + const [value, setValue] = useState(0); + const [contributions, setContributions] = useState<{ activeProjectIndex: number; jobName: string; value: number }[]>([]); + const onAddContribution = useCallback(() => { + if (activeProjectIndex >= 0 && jobName !== '' && value > 0) { + setContributions(cons => { + return [...cons, { activeProjectIndex, jobName, value }]; + }); + } + }, [activeProjectIndex, jobName, value]); + + if (playerID === null) { + return null; + } + + const onCreateProject = () => moves.createProject(projectCardIndex, activeJobCardIndex); + const onRecruit = () => moves.recruit(activeJobCardIndex, activeProjectIndex); + const onContributeJoinedProjects = () => { + moves.contributeJoinedProjects(contributions); + setContributions([]); + }; + const onContributeOwnedProjects = () => { + moves.contributeOwnedProjects(contributions); + setContributions([]); + }; + const onEndAction = () => events.endStage!(); + const onEndSettle = () => events.endStage!(); + const onRefillAndEnd = () => moves.refillAndEnd(); + const myCurrentStage = ctx.activePlayers ? ctx.activePlayers[playerID] : '' + + const renderHandProjectCards = () => ( + + Hand project cards + setProjectCardIndex(parseInt(event.target.value))} value={projectCardIndex}> + { + G.players[playerID].hand.projects.map((project, index) => + } label={`${project.name} ${JSON.stringify(project.requirements)}`} />) + } + + + ); + + const renderActiveJobCards = () => ( + + Active job cards + setActiveJobCardIndex(parseInt(event.target.value))} value={activeJobCardIndex}> + { + G.table.activeJobs.map((job, index) => + } label={job.name} />) + } + + + ); + + const renderActiveProjectCards = () => ( + + Active project cards + setActiveProjectIndex(parseInt(event.target.value))} value={activeProjectIndex}> + { + G.table.activeProjects.map(activeProject => activeProject.card).map((project, index) => + } label={`${project.name} ${JSON.stringify(project.requirements)}`} />) + } + + + ); + + const renderActiveProjectJobName = () => ( + + Job name + setJobName(event.target.value)} value={jobName}> + { + Object.keys(G.table.activeProjects[activeProjectIndex]?.card.requirements ?? []).map((jobName) => + } label={jobName} />) + } + + + ); + + const renderValueInputBox = () => ( + + Value + setValue(parseInt(event.target.value))} + /> + + ); + + return ( +
+ {myCurrentStage ?
my current stage: {myCurrentStage}
: null} + { + myCurrentStage === 'action' && + + + + + + + + + + + + + {renderHandProjectCards()} + {renderActiveJobCards()} + + + + + + {renderActiveProjectCards()} + {renderActiveJobCards()} + + + + + + {renderActiveProjectCards()} + {renderActiveProjectJobName()} + {renderValueInputBox()} + + current contribution entities: {JSON.stringify(contributions)} + + + + + + {renderActiveProjectCards()} + {renderActiveProjectJobName()} + {renderValueInputBox()} + + current contribution entities: {JSON.stringify(contributions)} + + + + + + {renderActiveJobCards()} + + + + + + + + } + { + myCurrentStage === 'settle' && + +
+ +
+
+ } + { + myCurrentStage === 'discard' && + +
+ +
+
+ } + { + myCurrentStage === 'refill' && + + + + } +
+ ); +} + +export default DevActions; diff --git a/packages/webapp/src/components/DevView.tsx b/packages/webapp/src/components/DevView.tsx new file mode 100644 index 00000000..f97ef2e1 --- /dev/null +++ b/packages/webapp/src/components/DevView.tsx @@ -0,0 +1,25 @@ +'use client'; + +import { Box, Typography } from '@mui/material'; +import Boardgame from '@/components/BoardGame'; + +function DevView() { + return ( + <> + + Player 0 view + + + + Player 1 view + + + + Observer view + + + + ); +} + +export default DevView; diff --git a/client/src/Players/Players.tsx b/packages/webapp/src/components/Players/Players.tsx similarity index 68% rename from client/src/Players/Players.tsx rename to packages/webapp/src/components/Players/Players.tsx index 83dbf980..b24107bc 100644 --- a/client/src/Players/Players.tsx +++ b/packages/webapp/src/components/Players/Players.tsx @@ -1,14 +1,13 @@ import { BoardProps } from 'boardgame.io/react'; -import { OpenStarTerVillageType } from 'packages/game/src/types'; -import { HStack, List, ListItem, Heading, Stack } from '@chakra-ui/react'; +import { List, ListItem, Typography, Stack } from '@mui/material'; const Players: React.FC> = (props) => { const { G } = props; const players = Object.keys(G.players).map(player => ( - - Player {player} - + + Player {player} + WorkerTokens: {G.players[player].token.workers} @@ -19,12 +18,12 @@ const Players: React.FC> = (props) CompletedProjects: {JSON.stringify(G.players[player].completed.projects)} - + )); return ( <> - Players + Players {players} diff --git a/packages/webapp/src/components/Project/ActiveProject.tsx b/packages/webapp/src/components/Project/ActiveProject.tsx new file mode 100644 index 00000000..e2f85adb --- /dev/null +++ b/packages/webapp/src/components/Project/ActiveProject.tsx @@ -0,0 +1,61 @@ +import { + Box, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Typography, + Paper, +} from '@mui/material'; + +type Props = { + project?: OpenStarTerVillageType.State.Project; +}; + +const ActiveProject: React.FC = ({ project }) => { + const projectName = project?.card.name; + const headRow = ( + + 玩家 + 職業 + 貢獻 + 進度 + + ); + + const workerRows = project?.contributions.map(worker => + + {worker.worker} + {worker.jobName} + {worker.value} + {project.card.requirements[worker.jobName]} + + ) + + return ( + + + + + + + {projectName} + + + {headRow} + + + {workerRows} + + + {headRow} + +
+
+
+ ) +} + +export default ActiveProject; diff --git a/packages/webapp/src/components/Table/Table.tsx b/packages/webapp/src/components/Table/Table.tsx new file mode 100644 index 00000000..29dc8a3a --- /dev/null +++ b/packages/webapp/src/components/Table/Table.tsx @@ -0,0 +1,23 @@ +import { BoardProps } from 'boardgame.io/react'; +import { Box, Grid } from '@mui/material'; +import ActiveProject from '../Project/ActiveProject'; + +type Props = BoardProps; + +const Table: React.FC = (props) => { + const activeProjects = [...props.G.table.activeProjects, ...Array(6)].slice(0, 6); + + return ( + + + {activeProjects.map((p, pIndex) => ( + + + + ))} + + + ) +} + +export default Table;