mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-27 09:13:02 +00:00
Fix bug
This commit is contained in:
parent
b6e2213e7d
commit
6d5b486833
3 changed files with 16 additions and 1 deletions
|
@ -96,6 +96,7 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
const freshGame = await Game.findOne({ _id: gameId });
|
const freshGame = await Game.findOne({ _id: gameId });
|
||||||
if (freshGame == null || freshGame.is_started || freshGame.is_ended) return;
|
if (freshGame == null || freshGame.is_started || freshGame.is_ended) return;
|
||||||
|
if (!freshGame.user1_accepted || !freshGame.user2_accepted) return;
|
||||||
|
|
||||||
let bw: number;
|
let bw: number;
|
||||||
if (freshGame.settings.bw == 'random') {
|
if (freshGame.settings.bw == 'random') {
|
||||||
|
|
|
@ -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 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"
|
<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)"
|
@click="set(i)"
|
||||||
>
|
>
|
||||||
<img v-if="stone == 'black'" :src="`${blackUser.avatar_url}?thumbnail&size=128`" alt="">
|
<img v-if="stone == 'black'" :src="`${blackUser.avatar_url}?thumbnail&size=128`" alt="">
|
||||||
|
@ -129,6 +129,8 @@ export default Vue.extend({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
set(pos) {
|
set(pos) {
|
||||||
|
if (this.game.is_ended) return;
|
||||||
|
if (!this.iAmPlayer) return;
|
||||||
if (!this.isMyTurn) return;
|
if (!this.isMyTurn) return;
|
||||||
if (!this.o.canPut(this.myColor, pos)) return;
|
if (!this.o.canPut(this.myColor, pos)) return;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,13 @@
|
||||||
<mk-switch v-model="game.settings.is_llotheo" @change="onIsLlotheoChange" text="石の少ない方が勝ち(ロセオ)"/>
|
<mk-switch v-model="game.settings.is_llotheo" @change="onIsLlotheoChange" text="石の少ない方が勝ち(ロセオ)"/>
|
||||||
</div>
|
</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">
|
<div class="actions">
|
||||||
<el-button @click="exit">キャンセル</el-button>
|
<el-button @click="exit">キャンセル</el-button>
|
||||||
<el-button type="primary" @click="accept" v-if="!isAccepted">準備完了</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.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;
|
if (this.game.user2_id == (this as any).os.i.id && this.game.user2_accepted) return true;
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue