changed tokens style

This commit is contained in:
lpan 2020-02-24 16:24:49 -08:00
parent bf3546922d
commit 1bd9ce7eda
7 changed files with 67 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -11,7 +11,8 @@
.played-card-area { .played-card-area {
font-size: 12px; font-size: 12px;
width: 100%; width: 40%;
margin-left: 90%;
position: relative; position: relative;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -76,18 +77,42 @@
white-space: pre; white-space: pre;
text-align: center; 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 { .player-main-area {
background-color: initial; background-color: initial;
width: 380px; width: 300px;
height: 130px; height: 130px;
position: relative; position: relative;
.player-hand { .player-hand {
position: absolute; position: absolute;
top: 15px; top: 15px;
left: 56px; left: 65px;
padding-left: 20px; padding-left: 20px;
margin-left: 130px; margin-left: 130px;
width: 75px; width: 75px;
@ -107,14 +132,14 @@
#top-player { #top-player {
position: absolute; position: absolute;
top: 10px; top: 10px;
left: 50%; left: 40%;
margin-left: -190px; margin-left: -190px;
} }
#bottom-player { #bottom-player {
position: absolute; position: absolute;
bottom: 10px; bottom: 10px;
left: 50%; left: 40%;
margin-left: -190px; margin-left: -190px;
} }

View File

@ -49,13 +49,45 @@ class LeducHoldemGameBoard extends React.Component {
</div> </div>
) )
} }
computeActionImage(action) { computeActionImage(action) {
if (action.length > 0) { if (action.length > 0) {
return <img src={require('../../assets/images/Actions/' + action + '.png')} alt={action} height="80%" width="100%" /> return <img src={require('../../assets/images/Actions/' + action + '.png')} alt={action} height="80%" width="100%" />
} }
} }
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(<div key={key + '_' + j}><img src={require('../../assets/images/Tokens/Token_' + key + '.png')} height="100%" width="100%" /></div>);
}
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) { computeHand(card) {
const [rankClass, suitClass, rankText, suitText] = translateCardData(card); const [rankClass, suitClass, rankText, suitText] = translateCardData(card);
return ( return (
@ -125,7 +157,8 @@ class LeducHoldemGameBoard extends React.Component {
<div className="player-main-area"> <div className="player-main-area">
<div className="player-info"> <div className="player-info">
{this.computePlayerPortrait(bottomId, bottomIdx)} {this.computePlayerPortrait(bottomId, bottomIdx)}
<span>{`Bet: ${this.props.pot[bottomIdx]}`}</span> <span className="bet-value">{`Bet: ${this.props.pot[bottomIdx]}`}</span>
{this.computeTokenImage(this.props.pot[bottomIdx])}
</div> </div>
{bottomIdx >= 0 ? <div className="player-hand">{this.computeHand(this.props.hands[bottomIdx])}</div> : <div className="player-hand-placeholder"><span>Waiting...</span></div>} {bottomIdx >= 0 ? <div className="player-hand">{this.computeHand(this.props.hands[bottomIdx])}</div> : <div className="player-hand-placeholder"><span>Waiting...</span></div>}
</div> </div>
@ -134,7 +167,8 @@ class LeducHoldemGameBoard extends React.Component {
<div className="player-main-area"> <div className="player-main-area">
<div className="player-info"> <div className="player-info">
{this.computePlayerPortrait(topId, topIdx)} {this.computePlayerPortrait(topId, topIdx)}
<span>{`Bet: ${this.props.pot[topIdx]}`}</span> <span className="bet-value">{`Bet: ${this.props.pot[topIdx]}`}</span>
{this.computeTokenImage(this.props.pot[topIdx])}
</div> </div>
{topIdx >= 0 ? <div className="player-hand">{this.computeHand(this.props.hands[topIdx])}</div> : <div className="player-hand-placeholder"><span>Waiting...</span></div>} {topIdx >= 0 ? <div className="player-hand">{this.computeHand(this.props.hands[topIdx])}</div> : <div className="player-hand-placeholder"><span>Waiting...</span></div>}
</div> </div>