fix: refresh auto time error

This commit is contained in:
wzdwc
2021-03-28 14:20:14 +08:00
parent 3c07b45b29
commit 10bc48eee2
10 changed files with 88 additions and 80 deletions
+2 -1
View File
@@ -7,4 +7,5 @@ test/unit/coverage
run/
logs/
npm-debug.*
/server/src/config/
/server/src/config/config.local.ts
/server/src/config/config.prod.ts
+18 -49
View File
@@ -28,22 +28,14 @@
<list default="true" id="f9039135-aa11-4abd-ad74-f40c84e4fdb2" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/assets/less/base.less" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/assets/less/base.less" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/components/SitList.vue" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/components/SitList.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/interface/IPlayer.ts" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/interface/IPlayer.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/utils/request.ts" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/utils/request.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/views/game.vue" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/views/game.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/views/home.vue" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/views/home.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client/src/views/login.vue" beforeDir="false" afterPath="$PROJECT_DIR$/client/src/views/login.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src.zip" beforeDir="false" afterPath="$PROJECT_DIR$/server/src.zip" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/app/core/Player.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/app/core/Player.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/app/core/PokerGame.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/app/core/PokerGame.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/app/io/controller/game.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/app/io/controller/game.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/app/io/middleware/join.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/app/io/middleware/join.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/app/router.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/app/router.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/config/config.prod.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/config/config.prod.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/lib/baseSocketController.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/lib/baseSocketController.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server/src/service/account.ts" beforeDir="false" afterPath="$PROJECT_DIR$/server/src/service/account.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -85,7 +77,7 @@
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="js.linters.configure.manually.selectedtslint" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/client/src/interface" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/server/src/config" />
<property name="list.type.of.created.stylesheet" value="Less" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.standard" value="true" />
@@ -101,15 +93,15 @@
<property name="ts.external.directory.path" value="$PROJECT_DIR$/server/node_modules/typescript/lib" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/server/src/config" />
<recent name="$PROJECT_DIR$/client/src/interface" />
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/server" />
<recent name="$PROJECT_DIR$/database" />
<recent name="$PROJECT_DIR$/server/src/service" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
</key>
</component>
<component name="SvnConfiguration">
@@ -143,7 +135,9 @@
<workItem from="1599739988741" duration="1817000" />
<workItem from="1599904748126" duration="799000" />
<workItem from="1599912369521" duration="681000" />
<workItem from="1616871635424" duration="298000" />
<workItem from="1616871635424" duration="5010000" />
<workItem from="1616902156349" duration="4139000" />
<workItem from="1616907672434" duration="3493000" />
</task>
<servers />
</component>
@@ -171,7 +165,7 @@
<entry key="branch">
<value>
<list>
<option value="bk" />
<option value="master" />
</list>
</value>
</entry>
@@ -185,44 +179,19 @@
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state x="184" y="98" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1600508433832">
<screen x="0" y="23" width="1440" height="827" />
<state x="100" y="123" width="1240" height="622" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1616905008870">
<screen x="0" y="23" width="1440" height="822" />
</state>
<state x="184" y="98" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.23.1440.827@0.23.1440.827" timestamp="1600508433832" />
<state x="100" y="100" width="1240" height="696" key="DiffContextDialog" timestamp="1607254387585">
<screen x="0" y="23" width="1440" height="823" />
<state x="100" y="123" width="1240" height="622" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1440.822@0.23.1440.822" timestamp="1616905008870" />
<state x="385" y="173" width="670" height="672" key="search.everywhere.popup" timestamp="1616902799000">
<screen x="0" y="23" width="1440" height="822" />
</state>
<state x="100" y="100" width="1240" height="700" key="DiffContextDialog/0.0.1440.900@0.0.1440.900" timestamp="1593070402308" />
<state x="100" y="100" width="1240" height="696" key="DiffContextDialog/0.23.1440.823@0.23.1440.823" timestamp="1607254387585" />
<state x="100" y="100" width="1240" height="700" key="DiffContextDialog/0.23.1440.828@0.23.1440.828" timestamp="1593348545499" />
<state x="100" y="99" width="1240" height="695" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1607254387585">
<screen x="0" y="23" width="1440" height="823" />
</state>
<state x="100" y="100" width="1240" height="700" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.0.1440.900@0.0.1440.900" timestamp="1593351376798" />
<state x="100" y="99" width="1240" height="695" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1440.823@0.23.1440.823" timestamp="1607254387585" />
<state x="100" y="100" width="1240" height="700" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1440.827@0.23.1440.827" timestamp="1593358666478" />
<state x="100" y="100" width="1240" height="700" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1440.828@0.23.1440.828" timestamp="1599741084335" />
<state x="100" y="100" width="1240" height="702" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1440.832@0.23.1440.832" timestamp="1599912309818" />
<state x="378" y="207" width="683" height="490" key="find.popup" timestamp="1593070201850">
<screen x="0" y="0" width="1440" height="900" />
</state>
<state x="378" y="207" width="683" height="490" key="find.popup/0.0.1440.900@0.0.1440.900" timestamp="1593070201850" />
<state x="385" y="197" key="run.anything.popup" timestamp="1605708588099">
<screen x="0" y="23" width="1440" height="823" />
</state>
<state x="385" y="197" key="run.anything.popup/0.23.1440.823@0.23.1440.823" timestamp="1605708588099" />
<state x="385" y="173" width="670" height="673" key="search.everywhere.popup" timestamp="1616837414379">
<screen x="0" y="23" width="1440" height="823" />
</state>
<state x="385" y="173" width="670" height="672" key="search.everywhere.popup/0.23.1440.822@0.23.1440.822" timestamp="1615119618414" />
<state x="385" y="173" width="670" height="672" key="search.everywhere.popup/0.23.1440.822@0.23.1440.822" timestamp="1616902799000" />
<state x="385" y="173" width="670" height="673" key="search.everywhere.popup/0.23.1440.823@0.23.1440.823" timestamp="1616837414379" />
<state x="385" y="174" width="670" height="676" key="search.everywhere.popup/0.23.1440.827@0.23.1440.827" timestamp="1600510032147" />
<state x="450" y="360" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1616839505918">
<screen x="0" y="23" width="1440" height="825" />
<state x="450" y="359" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1616873123947">
<screen x="0" y="23" width="1440" height="822" />
</state>
<state x="450" y="369" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.0.1440.900@0.0.1440.900" timestamp="1591504016729" />
<state x="450" y="359" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.23.1440.822@0.23.1440.822" timestamp="1616873123947" />
<state x="450" y="360" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.23.1440.825@0.23.1440.825" timestamp="1616839505918" />
<state x="450" y="362" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.23.1440.828@0.23.1440.828" timestamp="1599740214397" />
<state x="450" y="362" key="vcs.readOnlyHandler.ReadOnlyStatusDialog/0.23.1440.829@0.23.1440.829" timestamp="1600495902702" />
</component>
</project>
+3 -4
View File
@@ -165,10 +165,9 @@
}
private delayTime() {
if(this.currPlayer.delayCount > 0) {
console.log('delay')
this.$emit('update:time', this.time + 60);
this.$emit('delay')
if (this.currPlayer.delayCount > 0) {
// this.$emit('update:time', this.time + 60);
this.$emit('delay');
}
}
+35 -17
View File
@@ -30,14 +30,14 @@
</div>
<div class="game-record iconfont icon-record" @click="getRecord(0)"></div>
<actionDialog :base-size="baseSize"
:curr-player="currPlayer"
:is-action="isAction"
:is-pre-flop="commonCard.length === 0"
:min-action-size="minActionSize"
:is-two-player="gamePlayers.length === 2"
:pot="pot"
:prev-size="prevSize"
@action = 'action'
:curr-player="currPlayer"
:is-action="isAction"
:is-pre-flop="commonCard.length === 0"
:min-action-size="minActionSize"
:is-two-player="gamePlayers.length === 2"
:pot="pot"
:prev-size="prevSize"
@action = 'action'
></actionDialog>
<div class="setting">
<div class="iconfont icon-setting setting-btn"
@@ -150,6 +150,7 @@
private time = ACTION_TIME;
private timeSt = 0;
private commandRecordList = [];
private actionEndTime = 0;
private showCommandRecord = false;
private gameList: IGameRecord [] = [];
private currGameIndex = 0;
@@ -181,9 +182,13 @@
@Watch('actionUserId')
private actionUserIdChange() {
this.time = ACTION_TIME;
clearTimeout(this.timeSt);
this.doCountDown();
if (this.isPlay && this.actionEndTime) {
console.log('action player change-------', this.actionEndTime);
const now = Date.now();
this.time = Math.floor((this.actionEndTime - now) / 1000);
clearTimeout(this.timeSt);
this.doCountDown();
}
}
get msgListReverse() {
@@ -272,7 +277,9 @@
return;
}
this.timeSt = setTimeout(() => {
this.time--;
console.log('this.actionEndTime', this.actionEndTime)
const now = Date.now();
this.time = Math.floor((this.actionEndTime - now) / 1000);
this.doCountDown();
}, 1000);
}
@@ -344,7 +351,6 @@
});
this.socket.on('connect', () => {
const id: string = this.socket.id;
log('#connect,', id, this.socket);
// 监听自身 id 以实现 p2p 通讯
@@ -369,6 +375,7 @@
this.pot = payload.data.pot || 0;
this.prevSize = payload.data.prevSize;
this.commonCard = payload.data.commonCard;
this.actionEndTime = payload.data.actionEndTime;
console.log('msg.data.currPlayer.userId', msg.data);
this.actionUserId = payload.data.currPlayer.userId;
// this.isAction = !!(this.userInfo
@@ -402,6 +409,7 @@
if (msg.action === 'actionComplete') {
this.commonCard = msg.data.commonCard;
this.slidePots = msg.data.slidePots;
this.actionEndTime = msg.data.actionEndTime || Date.now() + 30 * 1000;
console.log('players', msg.data);
}
if (msg.action === 'gameInfo') {
@@ -410,6 +418,7 @@
this.roomConfig.smallBlind = msg.data.smallBlind;
this.prevSize = msg.data.prevSize;
this.actionUserId = msg.data.currPlayer.userId;
this.actionEndTime = msg.data.actionEndTime;
// this.isAction = !!(this.userInfo && this.userInfo.userId === msg.data.currPlayer.userId);
this.sitList = msg.data.sitList;
console.log('gameInfo', msg.data);
@@ -452,9 +461,13 @@
}
if (msg.action === 'delayTime') {
if (this.currPlayer?.userId !== this.actionUserId) {
this.time += 60;
}
console.log('delay======', msg)
this.actionEndTime = msg.data.actionEndTime;
const now = Date.now();
this.time = Math.floor((this.actionEndTime - now) / 1000);
// if (this.currPlayer?.userId !== this.actionUserId) {
// this.time += 60;
// }
}
if (msg.action === 'broadcast') {
@@ -468,7 +481,7 @@
// 系统事件
this.socket.on('disconnect', (msg: IMsg) => {
this.$plugin.toast('room is disconnect');
this.socketInit()
this.socketInit();
log('#disconnect', msg);
});
@@ -586,6 +599,11 @@
} catch (e) {
console.log(e);
}
document.addEventListener('visibilitychange', () => {
if (!document.hidden) {
this.socketInit();
}
});
}
}
</script>
+1 -1
View File
@@ -93,7 +93,7 @@
isShort: this.isShort,
smallBlind: this.smallBlind,
};
localStorage.setItem('roomConfig', JSON.stringify(roomConfig))
localStorage.setItem('roomConfig', JSON.stringify(roomConfig));
cookie.set('roomConfig', roomConfig, {expires: 1});
this.$router.push({ name: 'game', params: { roomNumber, isOwner: '1' } });
} catch (e) {
+1 -1
View File
@@ -44,7 +44,7 @@
const result = await service.login(this.userAccount, this.password);
const { token } = result.data;
cookie.set('token', token, {expires: 1});
localStorage.setItem('token', token)
localStorage.setItem('token', token);
await this.$router.push({name: 'home'});
} catch (e) {
this.$plugin.toast('Wrong password or account.');
+19 -3
View File
@@ -47,6 +47,12 @@ export enum EGameStatus {
*/
const ACTION_TIME = 30 * 1000;
/**
* Delay add time
* @type {number}
*/
const DELAY_ADD_TIME = 60 * 1000;
/**
* Class representing a poker game
*/
@@ -63,6 +69,7 @@ export class PokerGame {
private readonly actionRoundComplete: () => void;
private readonly gameOverCallBack: () => void;
private readonly autoActionCallBack: (actionType: string, userId: string) => void;
public actionEndTime: number = 0;
// hasStraddle = false;
public slidePots: number [] = [];
public prevSize: number;
@@ -101,6 +108,9 @@ export class PokerGame {
this.setBlind();
// UTG
this.currPlayer = this.playerLink.getNode(3);
// first round
this.startActionRound();
this.actionEndTime = Date.now() + ACTION_TIME;
}
/**
@@ -331,7 +341,7 @@ export class PokerGame {
console.log('come in delay round --------2', this.actionTimeDelayCount);
this.actionTimeDelayCount --;
clearTimeout(this.actionTimeOut);
this.startActionRound(60 * 1000);
this.startActionRound(DELAY_ADD_TIME);
return ;
}
const userId = this.currPlayer.node.userId || '';
@@ -410,6 +420,7 @@ export class PokerGame {
console.log('preSize', this.prevSize);
this.currPlayer = this.currPlayer.next;
// action time out, auto action fold
this.actionEndTime = Date.now() + ACTION_TIME;
this.startActionRound();
// this.actionTimeOut = setTimeout(() => {
// const actionType = 'fold';
@@ -501,6 +512,12 @@ export class PokerGame {
this.gameOver();
}, 300);
}
// action round complete, start auto action interval
if (this.status < EGameStatus.GAME_SHOWDOWN && this.playerSize > 1) {
this.actionEndTime = Date.now() + ACTION_TIME;
this.sendCard();
this.startActionRound();
}
this.actionRoundComplete();
}
@@ -640,8 +657,7 @@ export class PokerGame {
if (this.currPlayer.node.delayCount > 0) {
this.currPlayer.node.delayCount --;
this.actionTimeDelayCount ++;
console.log('come in delay round --------', this.actionTimeDelayCount);
this.actionEndTime += DELAY_ADD_TIME;
}
console.log('come in delay round --------', this.actionTimeDelayCount);
}
}
+7 -4
View File
@@ -82,14 +82,15 @@ class GameController extends BaseSocketController {
if (roomInfo.game) {
console.log('come in', roomInfo.game.status);
if (roomInfo.game.status < 6 && roomInfo.game.playerSize > 1) {
roomInfo.game.sendCard();
roomInfo.game.startActionRound();
// roomInfo.game.sendCard();
// roomInfo.game.startActionRound();
// has allindeal slide pot
if (roomInfo.game.allInPlayers.length > 0) {
slidePots = roomInfo.game.slidePots;
}
await this.adapter('online', 'actionComplete', {
slidePots,
actionEndTime: roomInfo.game.actionEndTime,
commonCard: roomInfo.game.commonCard,
});
}
@@ -171,7 +172,7 @@ class GameController extends BaseSocketController {
},
});
roomInfo.game.play();
roomInfo.game.startActionRound();
// roomInfo.game.startActionRound();
console.log('hand card', roomInfo.game.allPlayer);
// update counter, pot, status
await this.updateGameInfo();
@@ -418,7 +419,9 @@ class GameController extends BaseSocketController {
roomInfo.game.delayActionTime();
console.log('delayTime', roomInfo.game && roomInfo.game.currPlayer.node,
userInfo);
await this.adapter('online', 'delayTime', {});
await this.adapter('online', 'delayTime', {
actionEndTime: roomInfo.game.actionEndTime,
});
}
} catch (e) {
console.log(e);
+1
View File
@@ -113,6 +113,7 @@ export default function join(): any {
userId: roomInfo.game?.currPlayer.node.userId,
},
smallBlind: roomInfo.config.smallBlind,
actionEndTime: roomInfo.game?.actionEndTime || 0,
};
const game = ctx.helper.parseMsg('gameInfo', {
data: gameInfo,
+1
View File
@@ -74,6 +74,7 @@ export default class BaseSocketController extends Controller {
pot: roomInfo.game.pot,
prevSize: roomInfo.game.prevSize,
sitList: roomInfo.sit,
actionEndTime: roomInfo.game.actionEndTime,
currPlayer: {
userId: roomInfo.game.currPlayer.node.userId,
},