From 59fbf693ed05082e9dcb1cd3731116d83d9cfc10 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 10 Mar 2018 12:48:41 +0900 Subject: Implement othello map editing --- .../app/common/views/components/othello.room.vue | 50 ++++++++++++---------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'src/web') diff --git a/src/web/app/common/views/components/othello.room.vue b/src/web/app/common/views/components/othello.room.vue index 41226057b3..6c8ce16531 100644 --- a/src/web/app/common/views/components/othello.room.vue +++ b/src/web/app/common/views/components/othello.room.vue @@ -16,6 +16,7 @@
@@ -23,11 +24,11 @@
- +
- ランダム - {{ game.user1.name }}が黒 - {{ game.user2.name }}が黒 + ランダム + {{ game.user1.name }}が黒 + {{ game.user2.name }}が黒
@@ -114,34 +115,38 @@ export default Vue.extend({ this.$forceUpdate(); }, - onUpdateSettings(settings) { - this.game.settings = settings; - this.mapName = Object.entries(maps).find(x => x[1].data.join('') == this.game.settings.map.join(''))[1].name; - }, - - onMapChange(v) { - this.game.settings.map = Object.entries(maps).find(x => x[1].name == v)[1].data; + updateSettings() { this.connection.send({ type: 'update-settings', settings: this.game.settings }); - this.$forceUpdate(); }, - onIsLlotheoChange(v) { - this.connection.send({ - type: 'update-settings', - settings: this.game.settings - }); + onUpdateSettings(settings) { + this.game.settings = settings; + const foundMap = Object.entries(maps).find(x => x[1].data.join('') == this.game.settings.map.join('')); + this.mapName = foundMap ? foundMap[1].name : '-Custom-'; + }, + + onMapChange(v) { + this.game.settings.map = Object.entries(maps).find(x => x[1].name == v)[1].data; this.$forceUpdate(); + this.updateSettings(); }, - onBwChange(v) { - this.connection.send({ - type: 'update-settings', - settings: this.game.settings - }); + onPixelClick(pos, pixel) { + const x = pos % this.game.settings.map[0].length; + const y = Math.floor(pos / this.game.settings.map[0].length); + const newPixel = + pixel == ' ' ? '-' : + pixel == '-' ? 'b' : + pixel == 'b' ? 'w' : + ' '; + const line = this.game.settings.map[y].split(''); + line[x] = newPixel; + this.$set(this.game.settings.map, y, line.join('')); this.$forceUpdate(); + this.updateSettings(); } } }); @@ -172,6 +177,7 @@ export default Vue.extend({ border solid 2px #ddd border-radius 6px overflow hidden + cursor pointer * pointer-events none -- cgit v1.2.3-freya