From 6e5ad6a2670728ac1e76a1aae2dc05a42218edf6 Mon Sep 17 00:00:00 2001 From: tangmingyou <234767776@qq.com> Date: Tue, 14 Feb 2023 18:00:56 +0800 Subject: [PATCH] betting logic --- src/components/card.jsx | 44 ++++++++++++++++++---------------- src/components/style/card.scss | 13 ++++++++++ src/pages/table/table.jsx | 41 ++++++++++++++++--------------- src/pages/table/table.scss | 35 +++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 42 deletions(-) diff --git a/src/components/card.jsx b/src/components/card.jsx index 9586933..e2f0df0 100644 --- a/src/components/card.jsx +++ b/src/components/card.jsx @@ -26,32 +26,34 @@ const suits = { const dots = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]; function Card(props) { - const {w, h, dot, suit} = props; + const {w, h, dot, suit, flipIn} = props; // dot == -1 牌背面 dot == -2 弃牌背面 const width = Taro.pxTransform(w || 42); const height = Taro.pxTransform(h || 58); return ( - = 0})} style={{width, height}}> - { - dot < 0 ? : ( - - - {dots[dot || 0]} - - - - + dot < 0 ? ( + = 0})} style={{width, height}}> + + + ) : ( + = 0, 'flip180': flipIn})} style={{width, height}}> + + + {dots[dot || 0]} - ) - } - + + + + + + ) ) } diff --git a/src/components/style/card.scss b/src/components/style/card.scss index eb23fa1..b88b668 100644 --- a/src/components/style/card.scss +++ b/src/components/style/card.scss @@ -1,3 +1,16 @@ +@keyframes flip180 { + from { + transform: rotateY(90deg); + } + to { + transform: rotate(0deg); + } +} + +.flip180 { + animation: flip180 1000ms; +} + .card { border-radius: 5px; position: relative; diff --git a/src/pages/table/table.jsx b/src/pages/table/table.jsx index 56b83cc..af51695 100644 --- a/src/pages/table/table.jsx +++ b/src/pages/table/table.jsx @@ -63,7 +63,6 @@ class Table extends Component { tableNo: 0, stage: 0, // 游戏阶段: 1等待玩家准备;2下大盲注;3下小盲注;4发公共牌;5发第四张公共牌,轮流下注;6发第五张公共牌,轮流下注,7比牌结算 chip: 0, - roundTimes: 0, playerId: 0, masterId: 0, bigBlindPos: -1, @@ -138,7 +137,6 @@ class Table extends Component { tableNo: res.tableNo, stage: res.gameStage, chip: res.chip || 0, - roundTimes: res.roundTimes || 0, masterId: res.masterId, bigBlindPos: res.bigBlindPos, smallBlindPos: res.smallBlindPos, @@ -287,7 +285,7 @@ class Table extends Component { const { inGame, playerId, tableNo, stage, bigBlindPos, smallBlindPos, - chip, roundTimes, otherPlayers, + chip, otherPlayers, selfIndex, selfPlayer, bettingChip, betConfirmText, betSubmitLoading } = this.state; @@ -332,17 +330,17 @@ class Table extends Component { } { // 等待读秒,下注金额 - !inGame ? null : !isIn(player.status,4,6) ? null : + !inGame || !isIn(player.status,4,6) ? null : - { - // TODO All In ... - j%2 === 0 - ? - - 29 - + + + 29 + + {/* { + isIn(player.status, 4, 6) + ? : 99})}>+{player.chip} - } + } */} } { @@ -352,8 +350,8 @@ class Table extends Component { : null } {/* 玩家手牌 */} - {existsCard(selfPlayer.handCard[0]) && } - {existsCard(selfPlayer.handCard[0]) && } + {player.id && existsCard(selfPlayer.handCard[0]) ? : null} + {player.id && existsCard(selfPlayer.handCard[0]) ? : null} {/* 头像名称 */} {!player.id ? null : } @@ -381,8 +379,8 @@ class Table extends Component { { - this.state.publicCard.map((card, i) => ( - + !inGame ? null : this.state.publicCard.map((card, i) => ( + )) } @@ -428,18 +426,19 @@ class Table extends Component { { // TODO All In ... - true - ? + !isIn(selfPlayer.status, 4, 6) + ? null + : 29 - : +{selfPlayer.chip} + // : +{selfPlayer.chip} // , {'filling-chip-l': selfPlayer.chip > 99} } } - {existsCard(selfPlayer.handCard[0]) && } - {existsCard(selfPlayer.handCard[1]) && } + {existsCard(selfPlayer.handCard[0]) && } + {existsCard(selfPlayer.handCard[1]) && } { existsCard(selfPlayer.handCard[0]) && [1, 2, 3, 4, 5].map((_, i) => ( diff --git a/src/pages/table/table.scss b/src/pages/table/table.scss index e0693ba..e84200c 100644 --- a/src/pages/table/table.scss +++ b/src/pages/table/table.scss @@ -1,3 +1,38 @@ +@keyframes translate2Left { + from { + transform: rotate(-20deg) translateX(50%) translateY(200%); + } + to { + transform: rotate(0deg) translateX(0%) translateY(0%); + } +} +@keyframes translate2Right { + from { + transform: rotate(20deg) translateX(-50%) translateY(200%); + } + to { + transform: rotate(0deg) translateX(0%) translateY(0%); + } +} +@keyframes translate2Bottom { + from { + transform: rotate(20deg) translateX(150%) translateY(-200%); + } + to { + transform: rotate(0deg) translateX(0%) translateY(0%); + } +} +.translate-2l { + animation: translate2Left 1000ms; +} +.translate-2r { + animation: translate2Right 1000ms; +} + +.translate-2b { + animation: translate2Bottom 1000ms; +} + .tab { .playerRow { display: flex;