2018-03-06 20:40:40 -06:00
|
|
|
<template>
|
2018-08-03 01:59:24 -05:00
|
|
|
<div class="xqnhankfuuilcwvhgsopeqncafzsquya">
|
2018-11-05 10:40:11 -06:00
|
|
|
<button class="go-index" v-if="selfNav" @click="goIndex"><fa icon="arrow-left"/></button>
|
2018-12-06 20:29:49 -06:00
|
|
|
<header><b><router-link :to="blackUser | userPage"><mk-user-name :user="blackUser"/></router-link></b>({{ $t('@.reversi.black') }}) vs <b><router-link :to="whiteUser | userPage"><mk-user-name :user="whiteUser"/></router-link></b>({{ $t('@.reversi.white') }})</header>
|
2018-03-08 02:57:57 -06:00
|
|
|
|
2018-08-05 06:57:24 -05:00
|
|
|
<div style="overflow: hidden; line-height: 28px;">
|
2019-01-18 17:28:46 -06:00
|
|
|
<p class="turn" v-if="!iAmPlayer && !game.isEnded">
|
2019-03-06 05:17:59 -06:00
|
|
|
<mfm :key="'turn:' + $options.filters.userName(turnUser)" :text="$t('@.reversi.turn-of', { name: $options.filters.userName(turnUser) })" :should-break="false" :plain-text="true" :custom-emojis="turnUser.emojis"/>
|
2019-01-18 17:28:46 -06:00
|
|
|
<mk-ellipsis/>
|
|
|
|
</p>
|
|
|
|
<p class="turn" v-if="logPos != logs.length">
|
2019-03-06 05:17:59 -06:00
|
|
|
<mfm :key="'past-turn-of:' + $options.filters.userName(turnUser)" :text="$t('@.reversi.past-turn-of', { name: $options.filters.userName(turnUser) })" :should-break="false" :plain-text="true" :custom-emojis="turnUser.emojis"/>
|
2019-01-18 17:28:46 -06:00
|
|
|
</p>
|
2018-11-08 12:44:35 -06:00
|
|
|
<p class="turn1" v-if="iAmPlayer && !game.isEnded && !isMyTurn">{{ $t('@.reversi.opponent-turn') }}<mk-ellipsis/></p>
|
|
|
|
<p class="turn2" v-if="iAmPlayer && !game.isEnded && isMyTurn" v-animate-css="{ classes: 'tada', iteration: 'infinite' }">{{ $t('@.reversi.my-turn') }}</p>
|
2018-03-29 00:48:47 -05:00
|
|
|
<p class="result" v-if="game.isEnded && logPos == logs.length">
|
2018-08-04 08:28:01 -05:00
|
|
|
<template v-if="game.winner">
|
2019-03-06 05:17:59 -06:00
|
|
|
<mfm :key="'won'" :text="$t('@.reversi.won', { name: $options.filters.userName(game.winner) })" :should-break="false" :plain-text="true" :custom-emojis="game.winner.emojis"/>
|
2018-11-08 12:44:35 -06:00
|
|
|
<span v-if="game.surrendered != null"> ({{ $t('surrendered') }})</span>
|
2018-08-04 08:28:01 -05:00
|
|
|
</template>
|
2018-11-08 12:44:35 -06:00
|
|
|
<template v-else>{{ $t('@.reversi.drawn') }}</template>
|
2018-03-09 22:22:20 -06:00
|
|
|
</p>
|
|
|
|
</div>
|
2018-03-08 02:57:57 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
<div class="board">
|
2018-08-21 19:10:39 -05:00
|
|
|
<div class="labels-x" v-if="this.$store.state.settings.games.reversi.showBoardLabels">
|
2019-04-07 07:50:36 -05:00
|
|
|
<span v-for="i in game.map[0].length">{{ String.fromCharCode(64 + i) }}</span>
|
2018-06-23 02:55:52 -05:00
|
|
|
</div>
|
|
|
|
<div class="flex">
|
2018-08-21 19:10:39 -05:00
|
|
|
<div class="labels-y" v-if="this.$store.state.settings.games.reversi.showBoardLabels">
|
2019-04-07 07:50:36 -05:00
|
|
|
<div v-for="i in game.map.length">{{ i }}</div>
|
2018-06-23 02:55:52 -05:00
|
|
|
</div>
|
|
|
|
<div class="cells" :style="cellsStyle">
|
|
|
|
<div v-for="(stone, i) in o.board"
|
|
|
|
:class="{ empty: stone == null, none: o.map[i] == 'null', isEnded: game.isEnded, myTurn: !game.isEnded && isMyTurn, can: turnUser ? o.canPut(turnUser.id == blackUser.id, i) : null, prev: o.prevPos == i }"
|
|
|
|
@click="set(i)"
|
2018-06-23 08:25:22 -05:00
|
|
|
:title="`${String.fromCharCode(65 + o.transformPosToXy(i)[0])}${o.transformPosToXy(i)[1] + 1}`">
|
2018-12-29 23:05:13 -06:00
|
|
|
<template v-if="$store.state.settings.games.reversi.useAvatarStones">
|
2018-12-16 01:12:41 -06:00
|
|
|
<img v-if="stone === true" :src="blackUser.avatarUrl" alt="black">
|
|
|
|
<img v-if="stone === false" :src="whiteUser.avatarUrl" alt="white">
|
2018-12-05 19:21:41 -06:00
|
|
|
</template>
|
2018-12-29 23:05:13 -06:00
|
|
|
<template v-else>
|
2018-12-05 19:21:41 -06:00
|
|
|
<fa v-if="stone === true" :icon="fasCircle"/>
|
|
|
|
<fa v-if="stone === false" :icon="farCircle"/>
|
|
|
|
</template>
|
2018-06-23 02:55:52 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-21 19:10:39 -05:00
|
|
|
<div class="labels-y" v-if="this.$store.state.settings.games.reversi.showBoardLabels">
|
2019-04-07 07:50:36 -05:00
|
|
|
<div v-for="i in game.map.length">{{ i }}</div>
|
2018-06-23 23:18:22 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-21 19:10:39 -05:00
|
|
|
<div class="labels-x" v-if="this.$store.state.settings.games.reversi.showBoardLabels">
|
2019-04-07 07:50:36 -05:00
|
|
|
<span v-for="i in game.map[0].length">{{ String.fromCharCode(64 + i) }}</span>
|
2018-03-07 02:48:32 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-08 02:57:57 -06:00
|
|
|
|
2018-11-08 12:44:35 -06:00
|
|
|
<p class="status"><b>{{ $t('@.reversi.this-turn', { count: logPos }) }}</b> {{ $t('@.reversi.black') }}:{{ o.blackCount }} {{ $t('@.reversi.white') }}:{{ o.whiteCount }} {{ $t('@.reversi.total') }}:{{ o.blackCount + o.whiteCount }}</p>
|
2018-03-08 02:57:57 -06:00
|
|
|
|
2018-08-04 08:28:01 -05:00
|
|
|
<div class="actions" v-if="!game.isEnded && iAmPlayer">
|
2018-11-08 12:44:35 -06:00
|
|
|
<form-button @click="surrender">{{ $t('surrender') }}</form-button>
|
2018-08-04 08:28:01 -05:00
|
|
|
</div>
|
|
|
|
|
2018-03-29 00:48:47 -05:00
|
|
|
<div class="player" v-if="game.isEnded">
|
2018-03-07 06:57:06 -06:00
|
|
|
<span>{{ logPos }} / {{ logs.length }}</span>
|
2018-11-24 14:10:48 -06:00
|
|
|
<ui-horizon-group>
|
|
|
|
<ui-button @click="logPos = 0" :disabled="logPos == 0"><fa :icon="faAngleDoubleLeft"/></ui-button>
|
|
|
|
<ui-button @click="logPos--" :disabled="logPos == 0"><fa :icon="faAngleLeft"/></ui-button>
|
|
|
|
<ui-button @click="logPos++" :disabled="logPos == logs.length"><fa :icon="faAngleRight"/></ui-button>
|
|
|
|
<ui-button @click="logPos = logs.length" :disabled="logPos == logs.length"><fa :icon="faAngleDoubleRight"/></ui-button>
|
|
|
|
</ui-horizon-group>
|
2018-03-07 06:57:06 -06:00
|
|
|
</div>
|
2018-08-12 11:25:50 -05:00
|
|
|
|
|
|
|
<div class="info">
|
2019-04-07 07:50:36 -05:00
|
|
|
<p v-if="game.isLlotheo">{{ $t('is-llotheo') }}</p>
|
|
|
|
<p v-if="game.loopedBoard">{{ $t('looped-map') }}</p>
|
|
|
|
<p v-if="game.canPutEverywhere">{{ $t('can-put-everywhere') }}</p>
|
2018-08-12 11:25:50 -05:00
|
|
|
</div>
|
2018-03-06 20:40:40 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 12:44:35 -06:00
|
|
|
import i18n from '../../../../../i18n';
|
2018-03-11 03:23:59 -05:00
|
|
|
import * as CRC32 from 'crc-32';
|
2018-07-10 23:47:01 -05:00
|
|
|
import Reversi, { Color } from '../../../../../../../games/reversi/core';
|
|
|
|
import { url } from '../../../../../config';
|
2018-11-24 14:10:48 -06:00
|
|
|
import { faAngleDoubleLeft, faAngleLeft, faAngleRight, faAngleDoubleRight } from '@fortawesome/free-solid-svg-icons';
|
2018-12-05 19:21:41 -06:00
|
|
|
import { faCircle as fasCircle } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faCircle as farCircle } from '@fortawesome/free-regular-svg-icons';
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-03-06 20:40:40 -06:00
|
|
|
export default Vue.extend({
|
2018-11-08 12:44:35 -06:00
|
|
|
i18n: i18n('common/views/components/games/reversi/reversi.game.vue'),
|
2018-08-04 23:40:26 -05:00
|
|
|
props: {
|
|
|
|
initGame: {
|
|
|
|
type: Object,
|
|
|
|
require: true
|
|
|
|
},
|
|
|
|
connection: {
|
|
|
|
type: Object,
|
|
|
|
require: true
|
|
|
|
},
|
|
|
|
selfNav: {
|
|
|
|
type: Boolean,
|
|
|
|
require: true
|
|
|
|
}
|
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
2018-03-06 20:40:40 -06:00
|
|
|
data() {
|
|
|
|
return {
|
2018-03-11 03:23:59 -05:00
|
|
|
game: null,
|
2018-06-16 18:10:54 -05:00
|
|
|
o: null as Reversi,
|
2018-03-07 06:57:06 -06:00
|
|
|
logs: [],
|
2018-03-11 03:23:59 -05:00
|
|
|
logPos: 0,
|
2018-11-24 14:10:48 -06:00
|
|
|
pollingClock: null,
|
2018-12-05 19:21:41 -06:00
|
|
|
faAngleDoubleLeft, faAngleLeft, faAngleRight, faAngleDoubleRight, fasCircle, farCircle
|
2018-03-06 20:40:40 -06:00
|
|
|
};
|
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
computed: {
|
2018-03-07 03:45:16 -06:00
|
|
|
iAmPlayer(): boolean {
|
2018-05-26 23:49:09 -05:00
|
|
|
if (!this.$store.getters.isSignedIn) return false;
|
|
|
|
return this.game.user1Id == this.$store.state.i.id || this.game.user2Id == this.$store.state.i.id;
|
2018-03-07 03:45:16 -06:00
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
myColor(): Color {
|
|
|
|
if (!this.iAmPlayer) return null;
|
2018-05-26 23:49:09 -05:00
|
|
|
if (this.game.user1Id == this.$store.state.i.id && this.game.black == 1) return true;
|
|
|
|
if (this.game.user2Id == this.$store.state.i.id && this.game.black == 2) return true;
|
2018-03-12 11:49:54 -05:00
|
|
|
return false;
|
2018-03-07 02:48:32 -06:00
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
opColor(): Color {
|
|
|
|
if (!this.iAmPlayer) return null;
|
2018-03-12 11:49:54 -05:00
|
|
|
return this.myColor === true ? false : true;
|
2018-03-08 02:57:57 -06:00
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
blackUser(): any {
|
|
|
|
return this.game.black == 1 ? this.game.user1 : this.game.user2;
|
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
whiteUser(): any {
|
|
|
|
return this.game.black == 1 ? this.game.user2 : this.game.user1;
|
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
turnUser(): any {
|
2018-03-12 11:49:54 -05:00
|
|
|
if (this.o.turn === true) {
|
2018-03-08 02:57:57 -06:00
|
|
|
return this.game.black == 1 ? this.game.user1 : this.game.user2;
|
2018-03-12 11:49:54 -05:00
|
|
|
} else if (this.o.turn === false) {
|
2018-03-08 02:57:57 -06:00
|
|
|
return this.game.black == 1 ? this.game.user2 : this.game.user1;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
isMyTurn(): boolean {
|
2018-07-26 14:01:12 -05:00
|
|
|
if (!this.iAmPlayer) return false;
|
|
|
|
if (this.turnUser == null) return false;
|
2018-05-26 23:49:09 -05:00
|
|
|
return this.turnUser.id == this.$store.state.i.id;
|
2018-06-23 02:55:52 -05:00
|
|
|
},
|
2018-08-04 08:28:01 -05:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
cellsStyle(): any {
|
|
|
|
return {
|
2019-04-07 07:50:36 -05:00
|
|
|
'grid-template-rows': `repeat(${this.game.map.length}, 1fr)`,
|
|
|
|
'grid-template-columns': `repeat(${this.game.map[0].length}, 1fr)`
|
2018-06-23 02:55:52 -05:00
|
|
|
};
|
2018-03-07 02:48:32 -06:00
|
|
|
}
|
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
|
|
|
watch: {
|
|
|
|
logPos(v) {
|
2018-03-29 00:48:47 -05:00
|
|
|
if (!this.game.isEnded) return;
|
2019-04-07 07:50:36 -05:00
|
|
|
this.o = new Reversi(this.game.map, {
|
|
|
|
isLlotheo: this.game.isLlotheo,
|
|
|
|
canPutEverywhere: this.game.canPutEverywhere,
|
|
|
|
loopedBoard: this.game.loopedBoard
|
2018-03-08 02:57:57 -06:00
|
|
|
});
|
2018-09-01 08:18:07 -05:00
|
|
|
for (const log of this.logs.slice(0, v)) {
|
|
|
|
this.o.put(log.color, log.pos);
|
|
|
|
}
|
2018-03-07 06:57:06 -06:00
|
|
|
this.$forceUpdate();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
created() {
|
2018-03-11 03:23:59 -05:00
|
|
|
this.game = this.initGame;
|
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
this.o = new Reversi(this.game.map, {
|
|
|
|
isLlotheo: this.game.isLlotheo,
|
|
|
|
canPutEverywhere: this.game.canPutEverywhere,
|
|
|
|
loopedBoard: this.game.loopedBoard
|
2018-03-08 02:57:57 -06:00
|
|
|
});
|
|
|
|
|
2018-12-11 05:36:55 -06:00
|
|
|
for (const log of this.game.logs) {
|
2018-03-15 01:02:15 -05:00
|
|
|
this.o.put(log.color, log.pos);
|
2018-12-11 05:36:55 -06:00
|
|
|
}
|
2018-03-06 20:40:40 -06:00
|
|
|
|
2018-03-07 06:57:06 -06:00
|
|
|
this.logs = this.game.logs;
|
|
|
|
this.logPos = this.logs.length;
|
2018-03-11 03:23:59 -05:00
|
|
|
|
|
|
|
// 通信を取りこぼしてもいいように定期的にポーリングさせる
|
2018-03-29 00:48:47 -05:00
|
|
|
if (this.game.isStarted && !this.game.isEnded) {
|
2018-03-11 03:23:59 -05:00
|
|
|
this.pollingClock = setInterval(() => {
|
2019-05-07 04:23:12 -05:00
|
|
|
if (this.game.isEnded) return;
|
2018-03-11 03:23:59 -05:00
|
|
|
const crc32 = CRC32.str(this.logs.map(x => x.pos.toString()).join(''));
|
2018-10-08 11:50:49 -05:00
|
|
|
this.connection.send('check', {
|
|
|
|
crc32: crc32
|
2018-03-11 03:23:59 -05:00
|
|
|
});
|
2018-03-11 17:53:58 -05:00
|
|
|
}, 3000);
|
2018-03-11 03:23:59 -05:00
|
|
|
}
|
2018-03-07 02:48:32 -06:00
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
mounted() {
|
2018-03-06 20:40:40 -06:00
|
|
|
this.connection.on('set', this.onSet);
|
2018-03-11 03:23:59 -05:00
|
|
|
this.connection.on('rescue', this.onRescue);
|
2018-08-04 08:28:01 -05:00
|
|
|
this.connection.on('ended', this.onEnded);
|
2018-03-06 20:40:40 -06:00
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
2018-03-06 20:40:40 -06:00
|
|
|
beforeDestroy() {
|
|
|
|
this.connection.off('set', this.onSet);
|
2018-03-11 03:23:59 -05:00
|
|
|
this.connection.off('rescue', this.onRescue);
|
2018-08-04 08:28:01 -05:00
|
|
|
this.connection.off('ended', this.onEnded);
|
2018-03-11 03:23:59 -05:00
|
|
|
|
|
|
|
clearInterval(this.pollingClock);
|
2018-03-06 20:40:40 -06:00
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
methods: {
|
|
|
|
set(pos) {
|
2018-03-29 00:48:47 -05:00
|
|
|
if (this.game.isEnded) return;
|
2018-03-08 03:30:28 -06:00
|
|
|
if (!this.iAmPlayer) return;
|
2018-03-07 03:45:16 -06:00
|
|
|
if (!this.isMyTurn) return;
|
2018-03-08 02:57:57 -06:00
|
|
|
if (!this.o.canPut(this.myColor, pos)) return;
|
|
|
|
|
|
|
|
this.o.put(this.myColor, pos);
|
|
|
|
|
2018-03-10 10:55:46 -06:00
|
|
|
// サウンドを再生する
|
2018-05-20 12:13:39 -05:00
|
|
|
if (this.$store.state.device.enableSounds) {
|
2018-06-16 18:10:54 -05:00
|
|
|
const sound = new Audio(`${url}/assets/reversi-put-me.mp3`);
|
2018-05-20 12:13:39 -05:00
|
|
|
sound.volume = this.$store.state.device.soundVolume;
|
2018-03-10 10:55:46 -06:00
|
|
|
sound.play();
|
|
|
|
}
|
|
|
|
|
2018-10-08 11:50:49 -05:00
|
|
|
this.connection.send('set', {
|
|
|
|
pos: pos
|
2018-03-07 02:48:32 -06:00
|
|
|
});
|
2018-03-08 02:57:57 -06:00
|
|
|
|
|
|
|
this.checkEnd();
|
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
2018-03-07 06:57:06 -06:00
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
onSet(x) {
|
2018-03-07 06:57:06 -06:00
|
|
|
this.logs.push(x);
|
|
|
|
this.logPos++;
|
2018-03-08 02:57:57 -06:00
|
|
|
this.o.put(x.color, x.pos);
|
|
|
|
this.checkEnd();
|
|
|
|
this.$forceUpdate();
|
2018-03-10 10:55:46 -06:00
|
|
|
|
|
|
|
// サウンドを再生する
|
2018-05-20 12:13:39 -05:00
|
|
|
if (this.$store.state.device.enableSounds && x.color != this.myColor) {
|
2018-06-16 18:10:54 -05:00
|
|
|
const sound = new Audio(`${url}/assets/reversi-put-you.mp3`);
|
2018-05-20 12:13:39 -05:00
|
|
|
sound.volume = this.$store.state.device.soundVolume;
|
2018-03-10 10:55:46 -06:00
|
|
|
sound.play();
|
|
|
|
}
|
2018-03-08 02:57:57 -06:00
|
|
|
},
|
2018-03-07 03:45:16 -06:00
|
|
|
|
2018-08-04 08:28:01 -05:00
|
|
|
onEnded(x) {
|
|
|
|
this.game = x.game;
|
|
|
|
},
|
|
|
|
|
2018-03-08 02:57:57 -06:00
|
|
|
checkEnd() {
|
2018-03-29 00:48:47 -05:00
|
|
|
this.game.isEnded = this.o.isEnded;
|
|
|
|
if (this.game.isEnded) {
|
2018-03-12 11:49:54 -05:00
|
|
|
if (this.o.winner === true) {
|
2018-03-29 00:48:47 -05:00
|
|
|
this.game.winnerId = this.game.black == 1 ? this.game.user1Id : this.game.user2Id;
|
2018-03-08 02:57:57 -06:00
|
|
|
this.game.winner = this.game.black == 1 ? this.game.user1 : this.game.user2;
|
2018-03-12 11:49:54 -05:00
|
|
|
} else if (this.o.winner === false) {
|
2018-03-29 00:48:47 -05:00
|
|
|
this.game.winnerId = this.game.black == 1 ? this.game.user2Id : this.game.user1Id;
|
2018-03-08 02:57:57 -06:00
|
|
|
this.game.winner = this.game.black == 1 ? this.game.user2 : this.game.user1;
|
|
|
|
} else {
|
2018-03-29 00:48:47 -05:00
|
|
|
this.game.winnerId = null;
|
2018-03-08 02:57:57 -06:00
|
|
|
this.game.winner = null;
|
2018-03-07 03:45:16 -06:00
|
|
|
}
|
2018-03-07 02:48:32 -06:00
|
|
|
}
|
2018-03-11 03:23:59 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
// 正しいゲーム情報が送られてきたとき
|
|
|
|
onRescue(game) {
|
|
|
|
this.game = game;
|
|
|
|
|
2019-04-07 07:50:36 -05:00
|
|
|
this.o = new Reversi(this.game.map, {
|
|
|
|
isLlotheo: this.game.isLlotheo,
|
|
|
|
canPutEverywhere: this.game.canPutEverywhere,
|
|
|
|
loopedBoard: this.game.loopedBoard
|
2018-03-11 03:23:59 -05:00
|
|
|
});
|
|
|
|
|
2018-12-11 05:36:55 -06:00
|
|
|
for (const log of this.game.logs) {
|
2018-03-12 11:49:54 -05:00
|
|
|
this.o.put(log.color, log.pos, true);
|
2018-12-11 05:36:55 -06:00
|
|
|
}
|
2018-03-11 03:23:59 -05:00
|
|
|
|
|
|
|
this.logs = this.game.logs;
|
|
|
|
this.logPos = this.logs.length;
|
|
|
|
|
|
|
|
this.checkEnd();
|
|
|
|
this.$forceUpdate();
|
2018-08-04 08:28:01 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
surrender() {
|
2018-11-08 17:13:34 -06:00
|
|
|
this.$root.api('games/reversi/games/surrender', {
|
2018-08-04 08:28:01 -05:00
|
|
|
gameId: this.game.id
|
|
|
|
});
|
2018-08-04 23:40:26 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
goIndex() {
|
|
|
|
this.$emit('go-index');
|
2018-03-07 02:48:32 -06:00
|
|
|
}
|
|
|
|
}
|
2018-03-06 20:40:40 -06:00
|
|
|
});
|
|
|
|
</script>
|
2018-03-07 02:48:32 -06:00
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 05:59:19 -05:00
|
|
|
.xqnhankfuuilcwvhgsopeqncafzsquya
|
2018-03-07 02:48:32 -06:00
|
|
|
text-align center
|
|
|
|
|
2018-08-04 23:40:26 -05:00
|
|
|
> .go-index
|
|
|
|
position absolute
|
|
|
|
top 0
|
|
|
|
left 0
|
|
|
|
z-index 1
|
|
|
|
width 42px
|
|
|
|
height 42px
|
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
> header
|
|
|
|
padding 8px
|
2018-09-28 05:59:19 -05:00
|
|
|
border-bottom dashed 1px var(--reversiGameHeaderLine)
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-08-04 08:28:01 -05:00
|
|
|
a
|
|
|
|
color inherit
|
|
|
|
|
2018-03-07 06:57:06 -06:00
|
|
|
> .board
|
2018-06-26 04:53:06 -05:00
|
|
|
width calc(100% - 16px)
|
|
|
|
max-width 500px
|
2018-03-07 02:48:32 -06:00
|
|
|
margin 0 auto
|
|
|
|
|
2018-06-23 23:18:22 -05:00
|
|
|
$label-size = 16px
|
2018-06-23 02:55:52 -05:00
|
|
|
$gap = 4px
|
|
|
|
|
|
|
|
> .labels-x
|
|
|
|
height $label-size
|
2018-06-23 23:18:22 -05:00
|
|
|
padding 0 $label-size
|
2018-06-23 02:55:52 -05:00
|
|
|
display flex
|
|
|
|
|
|
|
|
> *
|
|
|
|
flex 1
|
|
|
|
display flex
|
|
|
|
align-items center
|
|
|
|
justify-content center
|
2018-06-23 23:18:22 -05:00
|
|
|
font-size 12px
|
2018-06-23 02:55:52 -05:00
|
|
|
|
|
|
|
&:first-child
|
|
|
|
margin-left -($gap / 2)
|
|
|
|
|
|
|
|
&:last-child
|
|
|
|
margin-right -($gap / 2)
|
|
|
|
|
|
|
|
> .flex
|
|
|
|
display flex
|
|
|
|
|
|
|
|
> .labels-y
|
|
|
|
width $label-size
|
|
|
|
display flex
|
|
|
|
flex-direction column
|
|
|
|
|
|
|
|
> *
|
|
|
|
flex 1
|
|
|
|
display flex
|
|
|
|
align-items center
|
|
|
|
justify-content center
|
2018-06-23 23:18:22 -05:00
|
|
|
font-size 12px
|
2018-06-23 02:55:52 -05:00
|
|
|
|
|
|
|
&:first-child
|
|
|
|
margin-top -($gap / 2)
|
|
|
|
|
|
|
|
&:last-child
|
|
|
|
margin-bottom -($gap / 2)
|
|
|
|
|
|
|
|
> .cells
|
|
|
|
flex 1
|
|
|
|
display grid
|
|
|
|
grid-gap $gap
|
|
|
|
|
|
|
|
> div
|
|
|
|
background transparent
|
|
|
|
border-radius 6px
|
|
|
|
overflow hidden
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
user-select none
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.empty
|
2018-09-28 05:59:19 -05:00
|
|
|
border solid 2px var(--reversiGameEmptyCell)
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.empty.can
|
2018-09-28 05:59:19 -05:00
|
|
|
background var(--reversiGameEmptyCell)
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.empty.myTurn
|
2018-09-28 05:59:19 -05:00
|
|
|
border-color var(--reversiGameEmptyCellMyTurn)
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.can
|
2018-09-28 05:59:19 -05:00
|
|
|
background var(--reversiGameEmptyCellCanPut)
|
2018-06-23 02:55:52 -05:00
|
|
|
cursor pointer
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&:hover
|
2018-09-26 06:19:35 -05:00
|
|
|
border-color var(--primaryDarken10)
|
|
|
|
background var(--primary)
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&:active
|
2018-09-26 06:19:35 -05:00
|
|
|
background var(--primaryDarken10)
|
2018-03-07 02:48:32 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.prev
|
2018-09-26 06:19:35 -05:00
|
|
|
box-shadow 0 0 0 4px var(--primaryAlpha07)
|
2018-03-07 07:25:26 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.isEnded
|
2018-09-28 05:59:19 -05:00
|
|
|
border-color var(--reversiGameEmptyCellMyTurn)
|
2018-03-08 07:11:08 -06:00
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
&.none
|
|
|
|
border-color transparent !important
|
2018-03-08 02:57:57 -06:00
|
|
|
|
2018-12-05 19:21:41 -06:00
|
|
|
> svg
|
|
|
|
display block
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
|
2018-06-23 02:55:52 -05:00
|
|
|
> img
|
|
|
|
display block
|
|
|
|
width 100%
|
|
|
|
height 100%
|
2018-03-07 06:57:06 -06:00
|
|
|
|
|
|
|
> .graph
|
|
|
|
display grid
|
|
|
|
grid-template-columns repeat(61, 1fr)
|
|
|
|
width 300px
|
|
|
|
height 38px
|
|
|
|
margin 0 auto 16px auto
|
|
|
|
|
|
|
|
> div
|
|
|
|
&:not(:empty)
|
|
|
|
background #ccc
|
|
|
|
|
|
|
|
> div:first-child
|
|
|
|
background #333
|
|
|
|
|
|
|
|
> div:last-child
|
|
|
|
background #ccc
|
|
|
|
|
2018-03-16 09:38:25 -05:00
|
|
|
> .status
|
|
|
|
margin 0
|
|
|
|
padding 16px 0
|
|
|
|
|
2018-08-04 08:28:01 -05:00
|
|
|
> .actions
|
|
|
|
padding-bottom 16px
|
|
|
|
|
2018-03-07 06:57:06 -06:00
|
|
|
> .player
|
2018-11-24 14:10:48 -06:00
|
|
|
padding 0 16px 32px 16px
|
|
|
|
margin 0 auto
|
|
|
|
max-width 500px
|
2018-03-07 06:57:06 -06:00
|
|
|
|
|
|
|
> span
|
|
|
|
display inline-block
|
|
|
|
margin 0 8px
|
|
|
|
min-width 70px
|
2018-08-03 01:59:24 -05:00
|
|
|
|
2018-03-07 02:48:32 -06:00
|
|
|
</style>
|