diff --git a/package.json b/package.json index 5eece45..95e3a34 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,13 @@ "version": "0.1.0", "private": true, "dependencies": { - "@material-ui/icons": "^4.9.1", "@material-ui/core": "^4.9.0", + "@material-ui/icons": "^4.9.1", "element-react": "^1.4.34", "element-theme-default": "^1.4.13", "node-sass": "^4.13.0", "react": "^16.12.0", + "react-addons-css-transition-group": "^15.6.2", "react-dom": "^16.12.0", "react-hot-loader": "^4.12.19", "react-router-dom": "^5.1.2", diff --git a/server/sample_data/sample_doudizhu-test.json b/server/sample_data/sample_doudizhu-test.json index 48dbb9d..dc7de35 100644 --- a/server/sample_data/sample_doudizhu-test.json +++ b/server/sample_data/sample_doudizhu-test.json @@ -24,23 +24,49 @@ "moveHistory": [ { "playerIdx": 2, - "move": "H3 S3 D3 D5" + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probabilities": [ + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + } + ] }, { "playerIdx": 0, - "move": "S9 H9 D9 S3" + "move": "S2 H2 HK DK HQ CQ DQ CJ S9 H9 D9 C7 S6 H6 C4 D4", + "probabilities": [ + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + }, + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + }, + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + } + ] }, { "playerIdx": 1, - "move": "P" - }, - { - "playerIdx": 2, - "move": "SJ HJ DJ D7" - }, - { - "playerIdx": 0, - "move": "P" + "move": "C2 HA CA DA SQ ST HT D8 S7 H7 C6 D6 S5 H5 C5 S4", + "probabilities": [ + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + }, + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + }, + { + "move": "RJ BJ D2 SA SK CK SJ HJ DJ CT DT C9 S8 H8 C8 D7 D5 H3 S3", + "probability": 1 + } + ] } ] } \ No newline at end of file diff --git a/src/assets/doudizhu.scss b/src/assets/doudizhu.scss index 08a1aa2..c849213 100644 --- a/src/assets/doudizhu.scss +++ b/src/assets/doudizhu.scss @@ -87,7 +87,7 @@ .played-card-area { position: relative; - left: 100px; + left: 20px; top: 20px; } } @@ -131,7 +131,7 @@ .played-card-area { position: relative; - right: 100px; + right: 20px; top: 20px; } } diff --git a/src/assets/gameview.scss b/src/assets/gameview.scss index 2a63f4c..b0180d4 100644 --- a/src/assets/gameview.scss +++ b/src/assets/gameview.scss @@ -4,4 +4,100 @@ .el-row { margin-bottom: 10px; } +} + +.doudizhu-view-container { + width: 1000px; + margin-left: auto; + margin-right: auto; + + + + .doudizhu-gameboard-paper { + height: calc(100% - 7px*2); + margin: 5px; + padding: 2px; + } + + .doudizhu-probability-paper { + height: calc(100% - 5px*2); + margin: 5px; + + .probability-player { + height: calc(72px - 16px*2); + padding: 16px; + } + + .probability-table { + display: table; + border-collapse: collapse; + + width: 100%; + height: calc(100% - 72px); + + .probability-item { + display: table-row; + + &:not(:first-child) { + border-top: 1px solid rgba(0, 0, 0, 0.12); + } + .waiting { + display: table-cell; + vertical-align: middle; + text-align: center; + } + .playing { + -webkit-transition: background-color 250ms ease; + -ms-transition: background-color 250ms ease; + transition: background-color 250ms ease; + display: table-cell; + height: 152px; + vertical-align: middle; + .playingCards { + visibility: visible; + transition: visibility 0s, opacity 0.5s; + opacity: 1; + } + .playingCards.hide { + visibility: hidden; + transition: visibility 0.1s, opacity 0.05s; + opacity: 0; + pointer-events:none; + } + .playingCards > ul.hand { + margin-bottom: 0; + } + .probability-move { + font-size: 10px; + width: 100%; + display: flex; + justify-content: center; + } + .non-card { + visibility: visible; + transition: visibility 0s, opacity 0.5s; + opacity: 1; + display: table; + width: 100%; + margin-top: 5%; + height: 25px; + + span { + display: table-cell; + vertical-align: middle; + text-align: center; + font-size: 16px; + } + } + .non-card.hide { + visibility: hidden; + transition: visibility 0.1s, opacity 0.05s; + opacity: 0; + pointer-events:none; + } + } + + } + } + } } \ No newline at end of file diff --git a/src/components/GameBoard/DoudizhuGameBoard.js b/src/components/GameBoard/DoudizhuGameBoard.js index 1e23ce3..6d7664c 100644 --- a/src/components/GameBoard/DoudizhuGameBoard.js +++ b/src/components/GameBoard/DoudizhuGameBoard.js @@ -1,5 +1,5 @@ import React from 'react'; -import { translateCardData, millisecond2Second } from '../../utils' +import { translateCardData, millisecond2Second, computeHandCardsWidth } from '../../utils' import '../../assets/doudizhu.scss'; @@ -15,7 +15,7 @@ class DoudizhuGameBoard extends React.Component { }else{ return (
-