From 6d5b486833f068a95dceaa25adf1b7a0bd3fb7bb Mon Sep 17 00:00:00 2001 From: syuilo <syuilotan@yahoo.co.jp> Date: Thu, 8 Mar 2018 18:30:28 +0900 Subject: [PATCH] Fix bug --- src/api/stream/othello-game.ts | 1 + src/web/app/common/views/components/othello.game.vue | 4 +++- src/web/app/common/views/components/othello.room.vue | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/api/stream/othello-game.ts b/src/api/stream/othello-game.ts index 1dcd37efa1..2af1bd97a0 100644 --- a/src/api/stream/othello-game.ts +++ b/src/api/stream/othello-game.ts @@ -96,6 +96,7 @@ export default function(request: websocket.request, connection: websocket.connec setTimeout(async () => { const freshGame = await Game.findOne({ _id: gameId }); if (freshGame == null || freshGame.is_started || freshGame.is_ended) return; + if (!freshGame.user1_accepted || !freshGame.user2_accepted) return; let bw: number; if (freshGame.settings.bw == 'random') { diff --git a/src/web/app/common/views/components/othello.game.vue b/src/web/app/common/views/components/othello.game.vue index 2ef6b645ce..f0254a0b71 100644 --- a/src/web/app/common/views/components/othello.game.vue +++ b/src/web/app/common/views/components/othello.game.vue @@ -12,7 +12,7 @@ <div class="board" :style="{ 'grid-template-rows': `repeat(${ game.settings.map.size }, 1fr)`, 'grid-template-columns': `repeat(${ game.settings.map.size }, 1fr)` }"> <div v-for="(stone, i) in o.board" - :class="{ empty: stone == null, none: o.map.data[i] == ' ', myTurn: isMyTurn, can: turnUser ? o.canPut(turnUser.id == blackUser.id ? 'black' : 'white', i) : null, prev: o.prevPos == i }" + :class="{ empty: stone == null, none: o.map.data[i] == ' ', myTurn: !game.is_ended && isMyTurn, can: turnUser ? o.canPut(turnUser.id == blackUser.id ? 'black' : 'white', i) : null, prev: o.prevPos == i }" @click="set(i)" > <img v-if="stone == 'black'" :src="`${blackUser.avatar_url}?thumbnail&size=128`" alt=""> @@ -129,6 +129,8 @@ export default Vue.extend({ methods: { set(pos) { + if (this.game.is_ended) return; + if (!this.iAmPlayer) return; if (!this.isMyTurn) return; if (!this.o.canPut(this.myColor, pos)) return; diff --git a/src/web/app/common/views/components/othello.room.vue b/src/web/app/common/views/components/othello.room.vue index b41d97ec61..445a0b45d6 100644 --- a/src/web/app/common/views/components/othello.room.vue +++ b/src/web/app/common/views/components/othello.room.vue @@ -21,6 +21,13 @@ <mk-switch v-model="game.settings.is_llotheo" @change="onIsLlotheoChange" text="石の少ない方が勝ち(ロセオ)"/> </div> + <p class="status"> + <template v-if="isAccepted && isOpAccepted">ゲームは数秒後に開始されます<mk-ellipsis/></template> + <template v-if="isAccepted && !isOpAccepted">相手の準備が完了するのを待っています<mk-ellipsis/></template> + <template v-if="!isAccepted && isOpAccepted">あなたの準備が完了するのを待っています</template> + <template v-if="!isAccepted && !isOpAccepted">準備中<mk-ellipsis/></template> + </p> + <div class="actions"> <el-button @click="exit">キャンセル</el-button> <el-button type="primary" @click="accept" v-if="!isAccepted">準備完了</el-button> @@ -50,6 +57,11 @@ export default Vue.extend({ if (this.game.user1_id == (this as any).os.i.id && this.game.user1_accepted) return true; if (this.game.user2_id == (this as any).os.i.id && this.game.user2_accepted) return true; return false; + }, + isOpAccepted(): boolean { + if (this.game.user1_id != (this as any).os.i.id && this.game.user1_accepted) return true; + if (this.game.user2_id != (this as any).os.i.id && this.game.user2_accepted) return true; + return false; } },