fixed bug

This commit is contained in:
wzdwc
2021-01-21 00:04:57 +08:00
parent 70ecee7d87
commit f8d86528a7
24 changed files with 304 additions and 190 deletions
+9 -7
View File
@@ -40,7 +40,7 @@
v-show="currPlayer && raiseSize === currPlayer.counter">Allin
</div>
<range :max="currPlayer && currPlayer.counter"
:min="minActionSize"
:min="0"
:is-horizontal="true"
v-model="raiseSize"
@change="getActionSize"></range>
@@ -108,9 +108,7 @@ import { IPlayer } from '@/interface/IPlayer';
@Watch('raiseSize')
private wRaiseSize(val: number) {
this.raiseSize = val > this.currPlayer.counter ? this.currPlayer.counter : val < this.minActionSize
? this.minActionSize
: val;
this.raiseSize = val > this.currPlayer.counter ? this.currPlayer.counter : val;
}
get canActionSize() {
@@ -152,7 +150,11 @@ import { IPlayer } from '@/interface/IPlayer';
}
private getActionSize(size: number) {
this.raiseSize = size;
if (size > this.minActionSize) {
this.raiseSize = size;
} else {
this.$plugin.toast('raise size too small');
}
}
private addSize() {
@@ -170,8 +172,8 @@ import { IPlayer } from '@/interface/IPlayer';
|| (this.isPreFlop
&& this.isTwoPlayer
&& this.currPlayer?.type === 'd'
&& this.prevSize === 2)
|| (this.currPlayer?.type === 'bb' && this.prevSize === 2 &&
&& this.prevSize === this.baseSize * 2)
|| (this.currPlayer?.type === 'bb' && this.prevSize === this.baseSize * 2 &&
this.isPreFlop);
}
// raise
+1 -1
View File
@@ -94,7 +94,7 @@
font-size: 20px;
text-align: center;
input{
width: 50px;
width: 70px;
font-size: 20px;
}
}
@@ -11,8 +11,12 @@
<div class="shadow"
v-show="shadow(card)"></div>
<b class="number">{{ map(card)[0] }}</b>
<b class="color">{{ map(card)[1] }}</b>
<b class="color big">{{ map(card)[1] }}</b>
<b class="color">
<cardStyle size="small" :type="map(card)[1]"></cardStyle>
</b>
<b class="color big">
<cardStyle size="big" :type="map(card)[1]"></cardStyle>
</b>
</span>
</div>
</div>
@@ -21,8 +25,13 @@
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import { mapCard } from '@/utils/map';
import cardStyle from '@/components/CardStyle.vue';
@Component
@Component({
components: {
cardStyle,
},
})
export default class Card extends Vue {
@Prop() private cardList: any;
@Prop({ default: () => [], type: Array }) private valueCards!: string[];
@@ -32,7 +41,7 @@
}
private isBlack(type: string) {
return type === '' || type === '';
return type === 's' || type === 'c';
}
private map(card: string) {
+49
View File
@@ -0,0 +1,49 @@
<template>
<div class="card-style-container">
<div class="svg">
<svg viewBox="0 0 100 100" :width="`${sizeValue}px`" :height="`${sizeValue}px`" xmlns="http://www.w3.org/2000/svg">
<path :d="path" :fill="color"/>
</svg>
</div>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component
export default class CardStyle extends Vue {
@Prop() private type: any;
@Prop() private size!: string;
private pathObj: any = {
h: 'M 0,25 A 25,25 0,0,1 50,25 A 25,25 0,0,1 100,25 C 100,60 70,60 50,100 C 30,60 0,60 0,25',
c: 'M25,25 A25,25 0,0,1 75,25 A25,25 0,1,1 52,65 A35,35 0,0,0 75,100 L25,100 A35,35 0,0,0 48,65 A25,25 0,1,1 25,25',
s: 'M 4,65 A 22,22 0,0,0 48,65 Q 50,90 30,100 L 70,100 Q 50,90 52,65 A 22,22 0,0,0 96,65 C 96,40 70,40 50,0 C 30,40 4,40 4,65',
d: 'M 50,0 Q50,15 15,50 Q50,85 50,100 Q50,85 85,50 Q50,15 50,0',
};
private sizeObj: any = {
big: 22,
small: 12,
default: 20,
};
get sizeValue() {
return this.sizeObj[this.size];
}
get path() {
return this.pathObj[this.type];
}
get color() {
return this.type === 'h' || this.type === 'd' ? 'red' : 'black';
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped
lang="less">
.card-style-container {
.svg {
position: relative;
}
}
</style>
@@ -1,59 +1,59 @@
<template>
<div class="notice-container">
<div class="notice-body">
<i v-for="message in messageList"
v-if="message !== ''"
:style="{top: `${message.top}vh`}"
>{{message.message}}</i>
</div>
</div>
</template>
<script lang="ts">
import {Component, Prop, Watch, Vue} from 'vue-property-decorator';
@Component
export default class Notice extends Vue {
@Prop() private messageList!: any[];
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped
lang="less">
.notice-container {
.notice-body{
position: fixed;
top: 0;
left: 0;
width: 100vw;
i{
position: absolute;
top: 20px;
left: 0;
transform: translate3d(100vw,0,0);
z-index: 10;
animation: 4s move linear forwards;
color: #fff;
padding: 4px;
font-size: 12px;
font-style: normal;
border-radius: 2px;
background-color: rgba(0,0,0,0.4);
}
}
@-webkit-keyframes move /* Safari 与 Chrome */ {
0% {
transform: translate3d(100vw,0,0);
}
99%{
transform: translate3d(-198px, 0px, 0px);
opacity: 1;
}
100% {
transform: translate3d(-200px, 0px, 0px);
opacity: 0;
}
}
}
</style>
<template>
<div class="notice-container">
<div class="notice-body">
<i v-for="message in messageList"
v-if="message !== ''"
:style="{top: `${message.top}vh`}"
>{{message.message}}</i>
</div>
</div>
</template>
<script lang="ts">
import {Component, Prop, Watch, Vue} from 'vue-property-decorator';
@Component
export default class Notice extends Vue {
@Prop() private messageList!: any[];
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped
lang="less">
.notice-container {
.notice-body{
position: fixed;
top: 0;
left: 0;
width: 100vw;
i{
position: absolute;
top: 20px;
left: 0;
transform: translate3d(100vw,0,0);
z-index: 10;
animation: 8s move linear forwards;
color: #fff;
padding: 4px;
font-size: 12px;
font-style: normal;
border-radius: 2px;
background-color: rgba(0,0,0,0.4);
}
}
@-webkit-keyframes move /* Safari 与 Chrome */ {
0% {
transform: translate3d(100vw,0,0);
}
99%{
transform: translate3d(-198px, 0px, 0px);
opacity: 1;
}
100% {
transform: translate3d(-200px, 0px, 0px);
opacity: 0;
}
}
}
</style>
@@ -4,7 +4,6 @@
<div class="range-body">
<input type="range"
v-model="rangeSize"
:class="{horizontal: !!isHorizontal}">
</div>
</div>
+2 -3
View File
@@ -78,7 +78,7 @@
</div>
<BuyIn :showBuyIn.sync="showBuyIn"
:min="0"
:max="1000"
:max="roomConfig.smallBlind * 1000"
@buyIn='buyIn'></BuyIn>
</div>
</template>
@@ -123,9 +123,8 @@
}
private buyIn(size: number) {
console.log('ccc');
this.showBuyIn = false;
this.currPlayer.counter += size;
this.currPlayer.counter += Number(size);
this.$emit('buyIn', Number(size));
this.sitDown(this.currSit);
}
+13 -29
View File
@@ -40,8 +40,8 @@ enum ShortPokerStyleEnum {
'FOUR_KIND',
'FLUSH',
'FULL_HOUSE',
'THREE_KIND',
'STRAIGHT',
'THREE_KIND',
'TWO_PAIR',
'PAIR',
'HIGH_CARD',
@@ -93,8 +93,8 @@ export class PokerStyle implements IPokerStyle {
'FOUR_KIND',
'FLUSH',
'FULL_HOUSE',
'THREE_KIND',
'STRAIGHT',
'THREE_KIND',
'TWO_PAIR',
'PAIR',
'HIGH_CARD',
@@ -250,35 +250,19 @@ export class PokerStyle implements IPokerStyle {
}
return;
}
if (this.isShort) {
// three of kind
if (isThree.length > 0) {
isThreeKind = isThree.join('');
isThreeKind += highCard[0] + highCard[1];
this.pokerStyle[5] = isThreeKind;
return;
}
// straight
if (this.isStraight() !== '0') {
this.pokerStyle[6] = `${this.isStraight()}`;
return;
}
// straight
if (this.isStraight() !== '0') {
this.pokerStyle[5] = `${this.isStraight()}`;
return;
}
} else {
// straight
if (this.isStraight() !== '0') {
this.pokerStyle[5] = `${this.isStraight()}`;
return;
}
// three of kind
if (isThree.length > 0) {
isThreeKind = isThree.join('');
isThreeKind += highCard[0] + highCard[1];
this.pokerStyle[6] = isThreeKind;
return;
}
// three of kind
if (isThree.length > 0) {
isThreeKind = isThree.join('');
isThreeKind += highCard[0] + highCard[1];
this.pokerStyle[6] = isThreeKind;
return;
}
// tow pair
+18 -18
View File
@@ -1,18 +1,18 @@
export default (cards: string []) => {
const cardNumber = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
const color = ['♦', '♣', '♥', '♠'];
return cards?.map((c: string) => {
const cNumber = c.charCodeAt(0) - 97;
const cColor = Number(c[1]) - 1;
return [`${cardNumber[cNumber]}`, `${color[cColor]}`];
});
};
const mapCard = (card: string) => {
const cardNumber = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
const color = ['', '', '', ''];
const cNumber = card.charCodeAt(0) - 97;
const cColor = Number(card[1]) - 1;
return [`${cardNumber[cNumber]}`, `${color[cColor]}`];
};
export { mapCard };
export default (cards: string []) => {
const cardNumber = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
const color = ['♦', '♣', '♥', '♠'];
return cards?.map((c: string) => {
const cNumber = c.charCodeAt(0) - 97;
const cColor = Number(c[1]) - 1;
return [`${cardNumber[cNumber]}`, `${color[cColor]}`];
});
};
const mapCard = (card: string) => {
const cardNumber = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
const color = ['d', 'c', 'h', 's'];
const cNumber = card.charCodeAt(0) - 97;
const cColor = Number(card[1]) - 1;
return [`${cardNumber[cNumber]}`, `${color[cColor]}`];
};
export { mapCard };
+16 -6
View File
@@ -44,12 +44,13 @@
<div class="setting-body"
:class="{show: showSetting}">
<i @click="showBuyInDialog()">buy in</i>
<i @click="standUp()">stand Up</i>
<i @click="showCounterRecord">counter record</i>
</div>
</div>
<BuyIn :showBuyIn.sync='showBuyIn'
:min='0'
:max='1000'
:max='baseSize * 1000'
@buyIn='buyIn'></BuyIn>
<toast :show.sync="showMsg"
:text="msg"></toast>
@@ -106,6 +107,7 @@
}
const GAME_BASE_SIZE = 1;
const ACTION_TIME = 60;
@Component({
components: {
@@ -142,10 +144,9 @@
private actionUserId = '';
private showAllin = false;
private showMsg = false;
private baseSize = GAME_BASE_SIZE;
private playIncome = false;
private msg = '';
private time = 30;
private time = ACTION_TIME;
private timeSt = 0;
private commandRecordList = [];
private showCommandRecord = false;
@@ -179,7 +180,7 @@
@Watch('actionUserId')
private actionUserIdChange() {
this.time = 30;
this.time = ACTION_TIME;
clearTimeout(this.timeSt);
this.doCountDown();
}
@@ -230,7 +231,11 @@
}
get minActionSize() {
return this.prevSize <= 0 ? GAME_BASE_SIZE * 2 : this.prevSize * 2;
return this.prevSize <= 0 ? this.baseSize * 2 : this.prevSize * 2;
}
get baseSize() {
return this.roomConfig.smallBlind || GAME_BASE_SIZE;
}
private init() {
@@ -239,7 +244,7 @@
this.commonCard = [];
this.pot = 0;
this.prevSize = 0;
this.time = 30;
this.time = ACTION_TIME;
this.winner = [];
this.showBuyIn = false;
this.initSitLink();
@@ -391,6 +396,7 @@
if (msg.action === 'gameInfo') {
this.players = msg.data.players;
this.pot = msg.data.pot || 0;
this.roomConfig.smallBlind = msg.data.smallBlind;
this.prevSize = msg.data.prevSize;
this.actionUserId = msg.data.currPlayer.userId;
// this.isAction = !!(this.userInfo && this.userInfo.userId === msg.data.currPlayer.userId);
@@ -474,6 +480,10 @@
console.log(e);
}
}
private standUp() {
this.emit('standUp');
this.showSetting = false;
}
private play() {
if (this.players.length >= 2) {