diff --git a/src/common/othello/core.ts b/src/common/othello/core.ts index 8a0af4d50..62ec34f41 100644 --- a/src/common/othello/core.ts +++ b/src/common/othello/core.ts @@ -69,6 +69,7 @@ export default class Othello { * 黒石の比率 */ public get blackP() { + if (this.blackCount == 0 && this.whiteCount == 0) return 0; return this.blackCount / (this.blackCount + this.whiteCount); } @@ -76,6 +77,7 @@ export default class Othello { * 白石の比率 */ public get whiteP() { + if (this.blackCount == 0 && this.whiteCount == 0) return 0; return this.whiteCount / (this.blackCount + this.whiteCount); } diff --git a/src/web/app/common/views/components/othello.room.vue b/src/web/app/common/views/components/othello.room.vue index 41226057b..6c8ce1653 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(); }, + updateSettings() { + this.connection.send({ + type: 'update-settings', + settings: this.game.settings + }); + }, + onUpdateSettings(settings) { this.game.settings = settings; - this.mapName = Object.entries(maps).find(x => x[1].data.join('') == this.game.settings.map.join(''))[1].name; + 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.connection.send({ - type: 'update-settings', - settings: this.game.settings - }); this.$forceUpdate(); + this.updateSettings(); }, - onIsLlotheoChange(v) { - this.connection.send({ - type: 'update-settings', - settings: this.game.settings - }); - this.$forceUpdate(); - }, - - 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