From 1bd9ce7edaed4af4089bd8541f2f7b4cf5fc3f7c Mon Sep 17 00:00:00 2001 From: lpan Date: Mon, 24 Feb 2020 16:24:49 -0800 Subject: [PATCH] changed tokens style --- .../Tokens/{Token_White_1.png => Token_1.png} | Bin .../{Token_Blue_10.png => Token_10.png} | Bin .../{Token_Black_100.png => Token_100.png} | Bin .../{Token_Green_25.png => Token_25.png} | Bin .../Tokens/{Token_Red_5.png => Token_5.png} | Bin src/assets/leducholdem.scss | 35 ++++++++++++--- .../GameBoard/LeducHoldemGameBoard.js | 40 ++++++++++++++++-- 7 files changed, 67 insertions(+), 8 deletions(-) rename src/assets/images/Tokens/{Token_White_1.png => Token_1.png} (100%) rename src/assets/images/Tokens/{Token_Blue_10.png => Token_10.png} (100%) rename src/assets/images/Tokens/{Token_Black_100.png => Token_100.png} (100%) rename src/assets/images/Tokens/{Token_Green_25.png => Token_25.png} (100%) rename src/assets/images/Tokens/{Token_Red_5.png => Token_5.png} (100%) diff --git a/src/assets/images/Tokens/Token_White_1.png b/src/assets/images/Tokens/Token_1.png similarity index 100% rename from src/assets/images/Tokens/Token_White_1.png rename to src/assets/images/Tokens/Token_1.png diff --git a/src/assets/images/Tokens/Token_Blue_10.png b/src/assets/images/Tokens/Token_10.png similarity index 100% rename from src/assets/images/Tokens/Token_Blue_10.png rename to src/assets/images/Tokens/Token_10.png diff --git a/src/assets/images/Tokens/Token_Black_100.png b/src/assets/images/Tokens/Token_100.png similarity index 100% rename from src/assets/images/Tokens/Token_Black_100.png rename to src/assets/images/Tokens/Token_100.png diff --git a/src/assets/images/Tokens/Token_Green_25.png b/src/assets/images/Tokens/Token_25.png similarity index 100% rename from src/assets/images/Tokens/Token_Green_25.png rename to src/assets/images/Tokens/Token_25.png diff --git a/src/assets/images/Tokens/Token_Red_5.png b/src/assets/images/Tokens/Token_5.png similarity index 100% rename from src/assets/images/Tokens/Token_Red_5.png rename to src/assets/images/Tokens/Token_5.png diff --git a/src/assets/leducholdem.scss b/src/assets/leducholdem.scss index 767ff96..5115b0a 100644 --- a/src/assets/leducholdem.scss +++ b/src/assets/leducholdem.scss @@ -11,7 +11,8 @@ .played-card-area { font-size: 12px; - width: 100%; + width: 40%; + margin-left: 90%; position: relative; display: flex; justify-content: center; @@ -76,18 +77,42 @@ white-space: pre; text-align: center; } + .bet-value { + position: relative; + top: -120px; + left: 120px; + font-weight: bold; + } + .token-container{ + position: relative; + top: -115px; + left: 120px; + width: 120px; + height: 80px; + display: flex; + flex-direction: row; + .pile-placeholder{ + width: 24px; + margin-top: 0; + } + div { + position: relative; + margin-top: -15px; + } + .pile-placeholder > :first-child { margin-top: 0 !important;} + } } .player-main-area { background-color: initial; - width: 380px; + width: 300px; height: 130px; position: relative; .player-hand { position: absolute; top: 15px; - left: 56px; + left: 65px; padding-left: 20px; margin-left: 130px; width: 75px; @@ -107,14 +132,14 @@ #top-player { position: absolute; top: 10px; - left: 50%; + left: 40%; margin-left: -190px; } #bottom-player { position: absolute; bottom: 10px; - left: 50%; + left: 40%; margin-left: -190px; } diff --git a/src/components/GameBoard/LeducHoldemGameBoard.js b/src/components/GameBoard/LeducHoldemGameBoard.js index 262b8c5..078ac8c 100644 --- a/src/components/GameBoard/LeducHoldemGameBoard.js +++ b/src/components/GameBoard/LeducHoldemGameBoard.js @@ -49,13 +49,45 @@ class LeducHoldemGameBoard extends React.Component { ) } - + computeActionImage(action) { if (action.length > 0) { return {action} } } + computeTokenImage(bet) { + const values = [100, 25, 10, 5, 1]; + let tokens = { + 100: 0, + 25: 0, + 10: 0, + 5: 0, + 1: 0, + } + let i = 0; + while (bet !== 0 && i < values.length) { + if (bet >= values[i]) { + bet -= values[i]; + tokens[values[i]]++; + } else { + i++; + } + } + let child = []; + for (let [key, value] of Object.entries(tokens)) { + if (value !== 0) { + let grandChild = []; + for (let j = 0; j < value; j++) { + grandChild.push(
); + } + let subElement = React.createElement("div", { className: "pile-placeholder", key: key+'_'+value}, grandChild); + child.push(subElement); + } + } + return React.createElement("div", { className: "token-container" }, child); + } + computeHand(card) { const [rankClass, suitClass, rankText, suitText] = translateCardData(card); return ( @@ -125,7 +157,8 @@ class LeducHoldemGameBoard extends React.Component {
{this.computePlayerPortrait(bottomId, bottomIdx)} - {`Bet: ${this.props.pot[bottomIdx]}`} + {`Bet: ${this.props.pot[bottomIdx]}`} + {this.computeTokenImage(this.props.pot[bottomIdx])}
{bottomIdx >= 0 ?
{this.computeHand(this.props.hands[bottomIdx])}
:
Waiting...
}
@@ -134,7 +167,8 @@ class LeducHoldemGameBoard extends React.Component {
{this.computePlayerPortrait(topId, topIdx)} - {`Bet: ${this.props.pot[topIdx]}`} + {`Bet: ${this.props.pot[topIdx]}`} + {this.computeTokenImage(this.props.pot[topIdx])}
{topIdx >= 0 ?
{this.computeHand(this.props.hands[topIdx])}
:
Waiting...
}