2018-03-08 09:57:57 +01:00
|
|
|
<template>
|
2018-08-02 17:36:29 +02:00
|
|
|
<div class="urbixznjwwuukfsckrwzwsqzsxornqij">
|
2018-12-07 03:29:49 +01:00
|
|
|
<header><b><mk-user-name :user="game.user1"/></b> vs <b><mk-user-name :user="game.user2"/></b></header>
|
2018-03-08 09:57:57 +01:00
|
|
|
|
2018-03-10 23:07:17 +01:00
|
|
|
<div>
|
2018-11-08 19:44:35 +01:00
|
|
|
<p>{{ $t('settings-of-the-game') }}</p>
|
2018-03-10 23:07:17 +01:00
|
|
|
|
2018-08-02 17:36:29 +02:00
|
|
|
<div class="card map">
|
2018-08-02 15:54:52 +02:00
|
|
|
<header>
|
2018-11-09 05:47:22 +01:00
|
|
|
<select v-model="mapName" :placeholder="$t('choose-map')" @change="onMapChange">
|
2018-08-02 17:36:29 +02:00
|
|
|
<option label="-Custom-" :value="mapName" v-if="mapName == '-Custom-'"/>
|
2018-11-09 05:47:22 +01:00
|
|
|
<option :label="$t('random')" :value="null"/>
|
2018-08-02 17:36:29 +02:00
|
|
|
<optgroup v-for="c in mapCategories" :key="c" :label="c">
|
|
|
|
<option v-for="m in maps" v-if="m.category == c" :key="m.name" :label="m.name" :value="m.name">{{ m.name }}</option>
|
|
|
|
</optgroup>
|
|
|
|
</select>
|
2018-08-02 15:54:52 +02:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
2019-04-07 14:50:36 +02:00
|
|
|
<div class="random" v-if="game.map == null"><fa icon="dice"/></div>
|
|
|
|
<div class="board" v-else :style="{ 'grid-template-rows': `repeat(${ game.map.length }, 1fr)`, 'grid-template-columns': `repeat(${ game.map[0].length }, 1fr)` }">
|
|
|
|
<div v-for="(x, i) in game.map.join('')"
|
2018-08-02 15:54:52 +02:00
|
|
|
:data-none="x == ' '"
|
|
|
|
@click="onPixelClick(i, x)">
|
2018-11-23 23:01:12 +01:00
|
|
|
<fa v-if="x == 'b'" :icon="fasCircle"/>
|
|
|
|
<fa v-if="x == 'w'" :icon="farCircle"/>
|
2018-08-02 15:54:52 +02:00
|
|
|
</div>
|
2018-03-10 23:07:17 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-02 15:54:52 +02:00
|
|
|
</div>
|
2018-03-10 23:07:17 +01:00
|
|
|
|
2018-08-02 15:54:52 +02:00
|
|
|
<div class="card">
|
|
|
|
<header>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('black-or-white') }}</span>
|
2018-08-02 15:54:52 +02:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
2019-04-07 14:50:36 +02:00
|
|
|
<form-radio v-model="game.bw" value="random" @change="updateSettings('bw')">{{ $t('random') }}</form-radio>
|
|
|
|
<form-radio v-model="game.bw" :value="1" @change="updateSettings('bw')">{{ this.$t('black-is').split('{}')[0] }}<b><mk-user-name :user="game.user1"/></b>{{ this.$t('black-is').split('{}')[1] }}</form-radio>
|
|
|
|
<form-radio v-model="game.bw" :value="2" @change="updateSettings('bw')">{{ this.$t('black-is').split('{}')[0] }}<b><mk-user-name :user="game.user2"/></b>{{ this.$t('black-is').split('{}')[1] }}</form-radio>
|
2018-03-10 23:07:17 +01:00
|
|
|
</div>
|
2018-08-02 15:54:52 +02:00
|
|
|
</div>
|
2018-03-10 23:07:17 +01:00
|
|
|
|
2018-08-02 15:54:52 +02:00
|
|
|
<div class="card">
|
|
|
|
<header>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('rules') }}</span>
|
2018-08-02 15:54:52 +02:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
2019-04-07 14:50:36 +02:00
|
|
|
<ui-switch v-model="game.isLlotheo" @change="updateSettings('isLlotheo')">{{ $t('is-llotheo') }}</ui-switch>
|
|
|
|
<ui-switch v-model="game.loopedBoard" @change="updateSettings('loopedBoard')">{{ $t('looped-map') }}</ui-switch>
|
|
|
|
<ui-switch v-model="game.canPutEverywhere" @change="updateSettings('canPutEverywhere')">{{ $t('can-put-everywhere') }}</ui-switch>
|
2018-03-10 23:07:17 +01:00
|
|
|
</div>
|
2018-08-02 15:54:52 +02:00
|
|
|
</div>
|
2018-03-10 23:07:17 +01:00
|
|
|
|
2018-08-04 04:24:15 +02:00
|
|
|
<div class="card form" v-if="form">
|
2018-08-02 15:54:52 +02:00
|
|
|
<header>
|
2018-11-08 19:44:35 +01:00
|
|
|
<span>{{ $t('settings-of-the-bot') }}</span>
|
2018-08-02 15:54:52 +02:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<template v-for="item in form">
|
2018-12-13 05:40:10 +01:00
|
|
|
<ui-switch v-if="item.type == 'switch'" v-model="item.value" :key="item.id" @change="onChangeForm(item)">{{ item.label || item.desc || '' }}</ui-switch>
|
2018-08-02 15:54:52 +02:00
|
|
|
|
|
|
|
<div class="card" v-if="item.type == 'radio'" :key="item.id">
|
|
|
|
<header>
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
2018-08-04 04:25:39 +02:00
|
|
|
<form-radio v-for="(r, i) in item.items" :key="item.id + ':' + i" v-model="item.value" :value="r.value" @change="onChangeForm(item)">{{ r.label }}</form-radio>
|
2018-08-02 15:54:52 +02:00
|
|
|
</div>
|
2018-03-10 23:07:17 +01:00
|
|
|
</div>
|
|
|
|
|
2018-08-04 04:24:15 +02:00
|
|
|
<div class="card" v-if="item.type == 'slider'" :key="item.id">
|
|
|
|
<header>
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
2018-08-04 04:25:39 +02:00
|
|
|
<input type="range" :min="item.min" :max="item.max" :step="item.step || 1" v-model="item.value" @change="onChangeForm(item)"/>
|
2018-08-04 04:24:15 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2018-08-02 15:54:52 +02:00
|
|
|
<div class="card" v-if="item.type == 'textbox'" :key="item.id">
|
|
|
|
<header>
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div>
|
2018-09-15 14:48:10 +02:00
|
|
|
<input v-model="item.value" @change="onChangeForm(item)"/>
|
2018-08-02 15:54:52 +02:00
|
|
|
</div>
|
2018-03-10 23:07:17 +01:00
|
|
|
</div>
|
2018-08-02 15:54:52 +02:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-03-08 09:57:57 +01:00
|
|
|
</div>
|
|
|
|
|
2018-03-08 14:11:08 +01:00
|
|
|
<footer>
|
|
|
|
<p class="status">
|
2018-11-08 19:44:35 +01:00
|
|
|
<template v-if="isAccepted && isOpAccepted">{{ $t('this-game-is-started-soon') }}<mk-ellipsis/></template>
|
|
|
|
<template v-if="isAccepted && !isOpAccepted">{{ $t('waiting-for-other') }}<mk-ellipsis/></template>
|
|
|
|
<template v-if="!isAccepted && isOpAccepted">{{ $t('waiting-for-me') }}</template>
|
|
|
|
<template v-if="!isAccepted && !isOpAccepted">{{ $t('waiting-for-both') }}<mk-ellipsis/></template>
|
2018-03-08 14:11:08 +01:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<div class="actions">
|
2018-11-08 19:44:35 +01:00
|
|
|
<form-button @click="exit">{{ $t('cancel') }}</form-button>
|
|
|
|
<form-button primary @click="accept" v-if="!isAccepted">{{ $t('ready') }}</form-button>
|
|
|
|
<form-button primary @click="cancel" v-if="isAccepted">{{ $t('cancel-ready') }}</form-button>
|
2018-03-08 14:11:08 +01:00
|
|
|
</div>
|
|
|
|
</footer>
|
2018-03-08 09:57:57 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../../../i18n';
|
2018-07-11 06:47:01 +02:00
|
|
|
import * as maps from '../../../../../../../games/reversi/maps';
|
2018-11-23 23:01:12 +01:00
|
|
|
import { faCircle as fasCircle } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faCircle as farCircle } from '@fortawesome/free-regular-svg-icons';
|
2018-03-08 09:57:57 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('common/views/components/games/reversi/reversi.room.vue'),
|
2018-03-08 09:57:57 +01:00
|
|
|
props: ['game', 'connection'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
o: null,
|
|
|
|
isLlotheo: false,
|
|
|
|
mapName: maps.eighteight.name,
|
2018-03-10 23:07:17 +01:00
|
|
|
maps: maps,
|
|
|
|
form: null,
|
2018-11-23 23:01:12 +01:00
|
|
|
messages: [],
|
|
|
|
fasCircle, farCircle
|
2018-03-08 09:57:57 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2018-03-08 14:11:08 +01:00
|
|
|
mapCategories(): string[] {
|
2018-07-23 07:04:53 +02:00
|
|
|
const categories = Object.values(maps).map(x => x.category);
|
2018-03-08 14:11:08 +01:00
|
|
|
return categories.filter((item, pos) => categories.indexOf(item) == pos);
|
|
|
|
},
|
2018-03-08 09:57:57 +01:00
|
|
|
isAccepted(): boolean {
|
2018-05-27 06:49:09 +02:00
|
|
|
if (this.game.user1Id == this.$store.state.i.id && this.game.user1Accepted) return true;
|
|
|
|
if (this.game.user2Id == this.$store.state.i.id && this.game.user2Accepted) return true;
|
2018-03-08 09:57:57 +01:00
|
|
|
return false;
|
2018-03-08 10:30:28 +01:00
|
|
|
},
|
|
|
|
isOpAccepted(): boolean {
|
2018-05-27 06:49:09 +02:00
|
|
|
if (this.game.user1Id != this.$store.state.i.id && this.game.user1Accepted) return true;
|
|
|
|
if (this.game.user2Id != this.$store.state.i.id && this.game.user2Accepted) return true;
|
2018-03-08 10:30:28 +01:00
|
|
|
return false;
|
2018-03-08 09:57:57 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2018-10-08 18:50:49 +02:00
|
|
|
this.connection.on('changeAccepts', this.onChangeAccepts);
|
|
|
|
this.connection.on('updateSettings', this.onUpdateSettings);
|
|
|
|
this.connection.on('initForm', this.onInitForm);
|
2018-03-10 23:07:17 +01:00
|
|
|
this.connection.on('message', this.onMessage);
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
if (this.game.user1Id != this.$store.state.i.id && this.game.form1) this.form = this.game.form1;
|
|
|
|
if (this.game.user2Id != this.$store.state.i.id && this.game.form2) this.form = this.game.form2;
|
2018-03-08 09:57:57 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
2018-10-08 18:50:49 +02:00
|
|
|
this.connection.off('changeAccepts', this.onChangeAccepts);
|
|
|
|
this.connection.off('updateSettings', this.onUpdateSettings);
|
|
|
|
this.connection.off('initForm', this.onInitForm);
|
2018-03-10 23:07:17 +01:00
|
|
|
this.connection.off('message', this.onMessage);
|
2018-03-08 09:57:57 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
exit() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
accept() {
|
2018-10-08 18:50:49 +02:00
|
|
|
this.connection.send('accept', {});
|
2018-03-08 09:57:57 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
cancel() {
|
2018-10-08 18:50:49 +02:00
|
|
|
this.connection.send('cancelAccept', {});
|
2018-03-08 09:57:57 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
onChangeAccepts(accepts) {
|
2018-03-29 07:48:47 +02:00
|
|
|
this.game.user1Accepted = accepts.user1;
|
|
|
|
this.game.user2Accepted = accepts.user2;
|
2018-03-08 09:57:57 +01:00
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
updateSettings(key: string) {
|
2018-10-08 18:50:49 +02:00
|
|
|
this.connection.send('updateSettings', {
|
2019-04-07 14:50:36 +02:00
|
|
|
key: key,
|
|
|
|
value: this.game[key]
|
2018-03-08 09:57:57 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
onUpdateSettings({ key, value }) {
|
|
|
|
this.game[key] = value;
|
|
|
|
if (this.game.map == null) {
|
2018-03-10 05:42:26 +01:00
|
|
|
this.mapName = null;
|
|
|
|
} else {
|
2019-04-07 14:50:36 +02:00
|
|
|
const found = Object.values(maps).find(x => x.data.join('') == this.game.map.join(''));
|
2018-07-23 07:04:53 +02:00
|
|
|
this.mapName = found ? found.name : '-Custom-';
|
2018-03-10 05:42:26 +01:00
|
|
|
}
|
2018-03-10 04:48:41 +01:00
|
|
|
},
|
|
|
|
|
2018-03-10 23:07:17 +01:00
|
|
|
onInitForm(x) {
|
2018-05-27 06:49:09 +02:00
|
|
|
if (x.userId == this.$store.state.i.id) return;
|
2018-03-10 23:07:17 +01:00
|
|
|
this.form = x.form;
|
|
|
|
},
|
|
|
|
|
|
|
|
onMessage(x) {
|
2018-05-27 06:49:09 +02:00
|
|
|
if (x.userId == this.$store.state.i.id) return;
|
2018-03-10 23:07:17 +01:00
|
|
|
this.messages.unshift(x.message);
|
|
|
|
},
|
|
|
|
|
2018-08-04 04:25:39 +02:00
|
|
|
onChangeForm(item) {
|
2018-10-08 18:50:49 +02:00
|
|
|
this.connection.send('updateForm', {
|
2018-03-10 23:07:17 +01:00
|
|
|
id: item.id,
|
2018-08-04 04:24:15 +02:00
|
|
|
value: item.value
|
2018-03-10 23:07:17 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-08-02 17:36:29 +02:00
|
|
|
onMapChange() {
|
|
|
|
if (this.mapName == null) {
|
2019-04-07 14:50:36 +02:00
|
|
|
this.game.map = null;
|
2018-03-10 05:42:26 +01:00
|
|
|
} else {
|
2019-04-07 14:50:36 +02:00
|
|
|
this.game.map = Object.values(maps).find(x => x.name == this.mapName).data;
|
2018-03-10 05:42:26 +01:00
|
|
|
}
|
2018-03-08 09:57:57 +01:00
|
|
|
this.$forceUpdate();
|
2019-05-07 11:14:37 +02:00
|
|
|
this.updateSettings('map');
|
2018-03-09 19:24:01 +01:00
|
|
|
},
|
|
|
|
|
2018-03-10 04:48:41 +01:00
|
|
|
onPixelClick(pos, pixel) {
|
2019-04-07 14:50:36 +02:00
|
|
|
const x = pos % this.game.map[0].length;
|
|
|
|
const y = Math.floor(pos / this.game.map[0].length);
|
2018-03-10 04:48:41 +01:00
|
|
|
const newPixel =
|
|
|
|
pixel == ' ' ? '-' :
|
2018-10-08 18:50:49 +02:00
|
|
|
pixel == '-' ? 'b' :
|
|
|
|
pixel == 'b' ? 'w' :
|
|
|
|
' ';
|
2019-04-07 14:50:36 +02:00
|
|
|
const line = this.game.map[y].split('');
|
2018-03-10 04:48:41 +01:00
|
|
|
line[x] = newPixel;
|
2019-04-07 14:50:36 +02:00
|
|
|
this.$set(this.game.map, y, line.join(''));
|
2018-03-09 19:24:01 +01:00
|
|
|
this.$forceUpdate();
|
2019-04-07 14:50:36 +02:00
|
|
|
this.updateSettings('map');
|
2018-03-08 09:57:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 12:59:19 +02:00
|
|
|
.urbixznjwwuukfsckrwzwsqzsxornqij
|
2018-03-08 09:57:57 +01:00
|
|
|
text-align center
|
2018-09-28 12:59:19 +02:00
|
|
|
background var(--bg)
|
2018-03-08 09:57:57 +01:00
|
|
|
|
|
|
|
> header
|
|
|
|
padding 8px
|
|
|
|
border-bottom dashed 1px #c4cdd4
|
|
|
|
|
2018-03-10 23:07:17 +01:00
|
|
|
> div
|
|
|
|
padding 0 16px
|
2018-03-08 09:57:57 +01:00
|
|
|
|
2018-08-02 15:54:52 +02:00
|
|
|
> .card
|
2018-03-10 23:07:17 +01:00
|
|
|
margin 0 auto 16px auto
|
2018-03-08 14:11:08 +01:00
|
|
|
|
2018-08-02 17:36:29 +02:00
|
|
|
&.map
|
|
|
|
> header
|
|
|
|
> select
|
|
|
|
width 100%
|
2018-08-03 08:59:24 +02:00
|
|
|
padding 12px 14px
|
2018-09-26 13:28:13 +02:00
|
|
|
background var(--face)
|
2018-09-28 12:59:19 +02:00
|
|
|
border 1px solid var(--reversiMapSelectBorder)
|
2018-08-02 17:36:29 +02:00
|
|
|
border-radius 4px
|
2018-09-28 12:59:19 +02:00
|
|
|
color var(--text)
|
2018-08-03 08:59:24 +02:00
|
|
|
cursor pointer
|
2018-08-02 17:36:29 +02:00
|
|
|
transition border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)
|
2018-08-04 04:32:53 +02:00
|
|
|
-webkit-appearance none
|
|
|
|
-moz-appearance none
|
|
|
|
appearance none
|
2018-08-02 17:36:29 +02:00
|
|
|
|
|
|
|
&:hover
|
2018-09-28 12:59:19 +02:00
|
|
|
border-color var(--reversiMapSelectHoverBorder)
|
2018-08-02 17:36:29 +02:00
|
|
|
|
|
|
|
&:focus
|
|
|
|
&:active
|
2018-09-26 13:19:35 +02:00
|
|
|
border-color var(--primary)
|
2018-08-02 17:36:29 +02:00
|
|
|
|
2018-08-03 08:59:24 +02:00
|
|
|
> div
|
|
|
|
> .random
|
|
|
|
padding 32px 0
|
|
|
|
font-size 64px
|
2018-09-28 12:59:19 +02:00
|
|
|
color var(--text)
|
|
|
|
opacity 0.7
|
2018-08-03 08:59:24 +02:00
|
|
|
|
|
|
|
> .board
|
|
|
|
display grid
|
|
|
|
grid-gap 4px
|
|
|
|
width 300px
|
|
|
|
height 300px
|
|
|
|
margin 0 auto
|
2018-09-28 12:59:19 +02:00
|
|
|
color var(--text)
|
2018-08-03 08:59:24 +02:00
|
|
|
|
|
|
|
> div
|
|
|
|
background transparent
|
2018-09-28 12:59:19 +02:00
|
|
|
border solid 2px var(--faceDivider)
|
2018-08-03 08:59:24 +02:00
|
|
|
border-radius 6px
|
|
|
|
overflow hidden
|
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
user-select none
|
|
|
|
width 100%
|
|
|
|
height 100%
|
|
|
|
|
|
|
|
&[data-none]
|
|
|
|
border-color transparent
|
|
|
|
|
2018-08-04 04:24:15 +02:00
|
|
|
&.form
|
|
|
|
> div
|
|
|
|
> .card + .card
|
|
|
|
margin-top 16px
|
|
|
|
|
|
|
|
input[type='range']
|
|
|
|
width 100%
|
|
|
|
|
2018-08-02 15:54:52 +02:00
|
|
|
.card
|
|
|
|
max-width 400px
|
|
|
|
border-radius 4px
|
2018-09-26 13:28:13 +02:00
|
|
|
background var(--face)
|
2018-09-28 12:59:19 +02:00
|
|
|
color var(--text)
|
|
|
|
box-shadow 0 2px 12px 0 var(--reversiRoomFormShadow)
|
2018-08-02 15:54:52 +02:00
|
|
|
|
|
|
|
> header
|
|
|
|
padding 18px 20px
|
2018-09-28 12:59:19 +02:00
|
|
|
border-bottom 1px solid var(--faceDivider)
|
2018-08-02 15:54:52 +02:00
|
|
|
|
|
|
|
> div
|
|
|
|
padding 20px
|
2018-09-28 12:59:19 +02:00
|
|
|
color var(--text)
|
2018-08-02 15:54:52 +02:00
|
|
|
|
2018-03-08 14:11:08 +01:00
|
|
|
> footer
|
|
|
|
position sticky
|
|
|
|
bottom 0
|
|
|
|
padding 16px
|
2018-09-28 12:59:19 +02:00
|
|
|
background var(--reversiRoomFooterBg)
|
|
|
|
border-top solid 1px var(--faceDivider)
|
2018-03-08 09:57:57 +01:00
|
|
|
|
2018-03-08 14:11:08 +01:00
|
|
|
> .status
|
|
|
|
margin 0 0 16px 0
|
2018-08-03 02:39:03 +02:00
|
|
|
|
2018-03-08 09:57:57 +01:00
|
|
|
</style>
|