diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..e6014d8 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "prettier", + "prettier/react" + ], + "rules": { + "no-redeclare": "off", + "react/display-name": "off", + "react/prop-types": "off", + "react/react-in-jsx-scope": "off" + } +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..4a28355 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Folders +dist/ +node_modules/ +src/public/lib/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ade7841 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 120, + "tabWidth": 4 +} diff --git a/src/App.js b/src/App.js index 9d0520e..ca79191 100644 --- a/src/App.js +++ b/src/App.js @@ -1,28 +1,33 @@ import React from 'react'; import { BrowserRouter as Router, Route, Redirect } from "react-router-dom"; import LeaderBoard from './view/LeaderBoard'; -import { DoudizhuGameView, LeducHoldemGameView } from './view/GameView'; +import { DoudizhuReplayView, LeducHoldemReplayView } from './view/ReplayView'; +import { PvEDoudizhuDemoView } from './view/PvEView'; import Navbar from "./components/Navbar"; -import {makeStyles} from "@material-ui/core/styles"; -const useStyles = makeStyles(() => ({ - navBar: { - zIndex: 1002 - } -})); +const navbarSubtitleMap = { + "/leaderboard": "", + "/replay/doudizhu": "Doudizhu", + "/replay/leduc-holdem": "Leduc Hold'em", + "/pve/doudizhu-demo": "Doudizhu PvE Demo" +}; function App() { - const classes = useStyles(); + // todo: add 404 page + return ( - +
- + {/* for test use */} + {/* */} + - - + + +
); diff --git a/src/assets/cards.css b/src/assets/cards.css index a6f4b75..339cb64 100644 --- a/src/assets/cards.css +++ b/src/assets/cards.css @@ -37,8 +37,8 @@ .playingCards .card { display: inline-block; - width: 3.3em; - height: 4.6em; + width: 2.5em; + height: 3.5em; border: 1px solid #666; border-radius: .3em; -moz-border-radius: .3em; @@ -47,7 +47,7 @@ padding: .25em; margin: 0 .5em .5em 0; text-align: center; - font-size: 1.2em; /* @change: adjust this value to make bigger or smaller cards */ + font-size: 1.5em; /* @change: adjust this value to make bigger or smaller cards */ font-weight: normal; font-family: Arial, sans-serif; position: relative; @@ -60,8 +60,28 @@ .playingCards a.card { text-decoration: none; } + +.playingCards.selectable label.card { + cursor: pointer; +} + +/* override orignal hover style */ +.playingCards.selectable label.card:hover { + bottom: 0; +} + +.playingCards.selectable label.card:active::after { + background-color: rgba(23, 146, 210, 0.5); + content: ''; + position: absolute; + left: 0; + top: 0; + width: 3em; + height: 4em; +} + /* selected and hover state */ -.playingCards a.card:hover, .playingCards a.card:active, +.playingCards a.card:hover, .playingCards a.card:active, .playingCards.selectable label.card.selected, .playingCards label.card:hover, .playingCards strong .card { bottom: 1em; diff --git a/src/assets/doudizhu.scss b/src/assets/doudizhu.scss index f20b1e2..4adb9c4 100644 --- a/src/assets/doudizhu.scss +++ b/src/assets/doudizhu.scss @@ -26,6 +26,16 @@ transition: visibility 0.1s, opacity 0.05s; opacity: 0; } + + .main-player-action-wrapper { + display: flex; + align-items: center; + + button { + font-weight: bolder; + border-radius: 40px; + } + } .timer { visibility: visible; @@ -35,7 +45,7 @@ height: 60px; .timer-text { color: #303133; - margin-top: 5px; + transform: translateY(5px); font-size: 23px; font-weight: bold; text-shadow: 0 2px 2px #909399; diff --git a/src/components/GameBoard/DoudizhuGameBoard.js b/src/components/GameBoard/DoudizhuGameBoard.js index 2cf7dcc..09742e2 100644 --- a/src/components/GameBoard/DoudizhuGameBoard.js +++ b/src/components/GameBoard/DoudizhuGameBoard.js @@ -1,82 +1,84 @@ +import Avatar from '@material-ui/core/Avatar'; +import Button from '@material-ui/core/Button'; +import Chip from '@material-ui/core/Chip'; import React from 'react'; -import { translateCardData, millisecond2Second, computeHandCardsWidth } from '../../utils' - import '../../assets/doudizhu.scss'; import Landlord_wName from '../../assets/images/Portrait/Landlord_wName.png'; import Peasant_wName from '../../assets/images/Portrait/Peasant_wName.png'; import PlaceHolderPlayer from '../../assets/images/Portrait/Player.png'; - -import Chip from '@material-ui/core/Chip'; -import Avatar from '@material-ui/core/Avatar'; +import { computeHandCardsWidth, millisecond2Second, translateCardData } from '../../utils'; class DoudizhuGameBoard extends React.Component { - computePlayerPortrait(playerId, playerIdx){ - if(this.props.playerInfo.length > 0){ - return this.props.playerInfo[playerIdx].role === "landlord" ? + computePlayerPortrait(playerId, playerIdx) { + if (this.props.playerInfo.length > 0) { + return this.props.playerInfo[playerIdx].role === 'landlord' ? (
- {"Landlord"} - ID} - label={playerId} - clickable - color="primary" - /> + {'Landlord'} + ID} label={playerId} clickable color="primary" />
- : + ) : (
- {"Peasant"} - ID} - label={playerId} - clickable - color="primary" - /> + {'Peasant'} + ID} label={playerId} clickable color="primary" />
- }else + ); + } else return (
- {"Player"} - ID} - label={playerId} - clickable - color="primary" - /> + {'Player'} + ID} label={playerId} clickable color="primary" />
- ) + ); } - computeSingleLineHand(cards, fadeClassName="") { - if(cards === "pass"){ - return
PASS
- }else{ + computeSingleLineHand(cards, fadeClassName = '', cardSelectable = false) { + if (cards === 'pass') { return ( -
-