reversi 💮 💯

This commit is contained in:
syuilo 2018-06-17 08:10:54 +09:00
parent 68d7c4de0d
commit 6b54f277c3
48 changed files with 197 additions and 197 deletions

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "Mehr" refresh: "Mehr"
close: "Schließen" close: "Schließen"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "Othello" game: "Reversi"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "Verbunden" done: "Verbunden"
add-widget: "Widget hinzufügen:" add-widget: "Widget hinzufügen:"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "More" refresh: "More"
close: "Close" close: "Close"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "Othello" game: "Reversi"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "Submit" done: "Submit"
add-widget: "Add widget:" add-widget: "Add widget:"
@ -549,7 +549,7 @@ desktop/views/components/ui.header.nav.vue:
home: "Home" home: "Home"
deck: "Deck" deck: "Deck"
messaging: "Messages" messaging: "Messages"
game: "Play Othello" game: "Play Reversi"
desktop/views/components/ui.header.notifications.vue: desktop/views/components/ui.header.notifications.vue:
title: "Notifications" title: "Notifications"
desktop/views/components/ui.header.post.vue: desktop/views/components/ui.header.post.vue:

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "もっと見る" refresh: "もっと見る"
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"
add-widget: "ウィジェットを追加:" add-widget: "ウィジェットを追加:"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "Plus" refresh: "Plus"
close: "Fermer" close: "Fermer"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "Othello" game: "Reversi"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "Envoyer" done: "Envoyer"
add-widget: "Ajouter un widget" add-widget: "Ajouter un widget"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "もっと見る" refresh: "もっと見る"
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"
add-widget: "ウィジェットを追加:" add-widget: "ウィジェットを追加:"

View File

@ -384,7 +384,7 @@ desktop/views/components/friends-maker.vue:
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "もっと見る" refresh: "もっと見る"
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"
add-widget: "ウィジェットを追加:" add-widget: "ウィジェットを追加:"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "Więcej" refresh: "Więcej"
close: "Zamknij" close: "Zamknij"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "Othello" game: "Reversi"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "Wyślij" done: "Wyślij"
add-widget: "Dodaj widżet:" add-widget: "Dodaj widżet:"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "もっと見る" refresh: "もっと見る"
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"
add-widget: "ウィジェットを追加:" add-widget: "ウィジェットを追加:"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "もっと見る" refresh: "もっと見る"
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"
add-widget: "ウィジェットを追加:" add-widget: "ウィジェットを追加:"

View File

@ -333,7 +333,7 @@ desktop/views/components/friends-maker.vue:
refresh: "もっと見る" refresh: "もっと見る"
close: "閉じる" close: "閉じる"
desktop/views/components/game-window.vue: desktop/views/components/game-window.vue:
game: "オセロ" game: "リバーシ"
desktop/views/components/home.vue: desktop/views/components/home.vue:
done: "完了" done: "完了"
add-widget: "ウィジェットを追加:" add-widget: "ウィジェットを追加:"

View File

@ -55,7 +55,7 @@ export default function(type, data): Notification {
icon: data.user.avatarUrl + '?thumbnail&size=64' icon: data.user.avatarUrl + '?thumbnail&size=64'
}; };
case 'othello_invited': case 'reversi_invited':
return { return {
title: '対局への招待があります', title: '対局への招待があります',
body: `${getUserName(data.parent)}さんから`, body: `${getUserName(data.parent)}さんから`,

View File

@ -1,9 +1,9 @@
import Stream from './stream'; import Stream from './stream';
import MiOS from '../../../mios'; import MiOS from '../../../mios';
export class OthelloGameStream extends Stream { export class ReversiGameStream extends Stream {
constructor(os: MiOS, me, game) { constructor(os: MiOS, me, game) {
super(os, 'othello-game', { super(os, 'reversi-game', {
i: me ? me.token : null, i: me ? me.token : null,
game: game.id game: game.id
}); });

View File

@ -2,15 +2,15 @@ import StreamManager from './stream-manager';
import Stream from './stream'; import Stream from './stream';
import MiOS from '../../../mios'; import MiOS from '../../../mios';
export class OthelloStream extends Stream { export class ReversiStream extends Stream {
constructor(os: MiOS, me) { constructor(os: MiOS, me) {
super(os, 'othello', { super(os, 'reversi', {
i: me.token i: me.token
}); });
} }
} }
export class OthelloStreamManager extends StreamManager<OthelloStream> { export class ReversiStreamManager extends StreamManager<ReversiStream> {
private me; private me;
private os: MiOS; private os: MiOS;
@ -23,7 +23,7 @@ export class OthelloStreamManager extends StreamManager<OthelloStream> {
public getConnection() { public getConnection() {
if (this.connection == null) { if (this.connection == null) {
this.connection = new OthelloStream(this.os, this.me); this.connection = new ReversiStream(this.os, this.me);
} }
return this.connection; return this.connection;

View File

@ -27,7 +27,7 @@ import urlPreview from './url-preview.vue';
import twitterSetting from './twitter-setting.vue'; import twitterSetting from './twitter-setting.vue';
import fileTypeIcon from './file-type-icon.vue'; import fileTypeIcon from './file-type-icon.vue';
import Switch from './switch.vue'; import Switch from './switch.vue';
import Othello from './othello.vue'; import Reversi from './reversi.vue';
import welcomeTimeline from './welcome-timeline.vue'; import welcomeTimeline from './welcome-timeline.vue';
import uiInput from './ui/input.vue'; import uiInput from './ui/input.vue';
import uiButton from './ui/button.vue'; import uiButton from './ui/button.vue';
@ -65,7 +65,7 @@ Vue.component('mk-url-preview', urlPreview);
Vue.component('mk-twitter-setting', twitterSetting); Vue.component('mk-twitter-setting', twitterSetting);
Vue.component('mk-file-type-icon', fileTypeIcon); Vue.component('mk-file-type-icon', fileTypeIcon);
Vue.component('mk-switch', Switch); Vue.component('mk-switch', Switch);
Vue.component('mk-othello', Othello); Vue.component('mk-reversi', Reversi);
Vue.component('mk-welcome-timeline', welcomeTimeline); Vue.component('mk-welcome-timeline', welcomeTimeline);
Vue.component('ui-input', uiInput); Vue.component('ui-input', uiInput);
Vue.component('ui-button', uiButton); Vue.component('ui-button', uiButton);

View File

@ -43,7 +43,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import * as CRC32 from 'crc-32'; import * as CRC32 from 'crc-32';
import Othello, { Color } from '../../../../../othello/core'; import Reversi, { Color } from '../../../../../reversi/core';
import { url } from '../../../config'; import { url } from '../../../config';
export default Vue.extend({ export default Vue.extend({
@ -52,7 +52,7 @@ export default Vue.extend({
data() { data() {
return { return {
game: null, game: null,
o: null as Othello, o: null as Reversi,
logs: [], logs: [],
logPos: 0, logPos: 0,
pollingClock: null pollingClock: null
@ -98,7 +98,7 @@ export default Vue.extend({
watch: { watch: {
logPos(v) { logPos(v) {
if (!this.game.isEnded) return; if (!this.game.isEnded) return;
this.o = new Othello(this.game.settings.map, { this.o = new Reversi(this.game.settings.map, {
isLlotheo: this.game.settings.isLlotheo, isLlotheo: this.game.settings.isLlotheo,
canPutEverywhere: this.game.settings.canPutEverywhere, canPutEverywhere: this.game.settings.canPutEverywhere,
loopedBoard: this.game.settings.loopedBoard loopedBoard: this.game.settings.loopedBoard
@ -115,7 +115,7 @@ export default Vue.extend({
created() { created() {
this.game = this.initGame; this.game = this.initGame;
this.o = new Othello(this.game.settings.map, { this.o = new Reversi(this.game.settings.map, {
isLlotheo: this.game.settings.isLlotheo, isLlotheo: this.game.settings.isLlotheo,
canPutEverywhere: this.game.settings.canPutEverywhere, canPutEverywhere: this.game.settings.canPutEverywhere,
loopedBoard: this.game.settings.loopedBoard loopedBoard: this.game.settings.loopedBoard
@ -163,7 +163,7 @@ export default Vue.extend({
// //
if (this.$store.state.device.enableSounds) { if (this.$store.state.device.enableSounds) {
const sound = new Audio(`${url}/assets/othello-put-me.mp3`); const sound = new Audio(`${url}/assets/reversi-put-me.mp3`);
sound.volume = this.$store.state.device.soundVolume; sound.volume = this.$store.state.device.soundVolume;
sound.play(); sound.play();
} }
@ -187,7 +187,7 @@ export default Vue.extend({
// //
if (this.$store.state.device.enableSounds && x.color != this.myColor) { if (this.$store.state.device.enableSounds && x.color != this.myColor) {
const sound = new Audio(`${url}/assets/othello-put-you.mp3`); const sound = new Audio(`${url}/assets/reversi-put-you.mp3`);
sound.volume = this.$store.state.device.soundVolume; sound.volume = this.$store.state.device.soundVolume;
sound.play(); sound.play();
} }
@ -213,7 +213,7 @@ export default Vue.extend({
onRescue(game) { onRescue(game) {
this.game = game; this.game = game;
this.o = new Othello(this.game.settings.map, { this.o = new Reversi(this.game.settings.map, {
isLlotheo: this.game.settings.isLlotheo, isLlotheo: this.game.settings.isLlotheo,
canPutEverywhere: this.game.settings.canPutEverywhere, canPutEverywhere: this.game.settings.canPutEverywhere,
loopedBoard: this.game.settings.loopedBoard loopedBoard: this.game.settings.loopedBoard

View File

@ -7,9 +7,9 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import XGame from './othello.game.vue'; import XGame from './reversi.game.vue';
import XRoom from './othello.room.vue'; import XRoom from './reversi.room.vue';
import { OthelloGameStream } from '../../scripts/streaming/othello-game'; import { ReversiGameStream } from '../../scripts/streaming/reversi-game';
export default Vue.extend({ export default Vue.extend({
components: { components: {
@ -25,7 +25,7 @@ export default Vue.extend({
}, },
created() { created() {
this.g = this.game; this.g = this.game;
this.connection = new OthelloGameStream((this as any).os, this.$store.state.i, this.game); this.connection = new ReversiGameStream((this as any).os, this.$store.state.i, this.game);
this.connection.on('started', this.onStarted); this.connection.on('started', this.onStarted);
}, },
beforeDestroy() { beforeDestroy() {

View File

@ -94,7 +94,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import * as maps from '../../../../../othello/maps'; import * as maps from '../../../../../reversi/maps';
export default Vue.extend({ export default Vue.extend({
props: ['game', 'connection'], props: ['game', 'connection'],

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="mk-othello"> <div class="mk-reversi">
<div v-if="game"> <div v-if="game">
<x-gameroom :game="game"/> <x-gameroom :game="game"/>
</div> </div>
@ -11,14 +11,14 @@
</div> </div>
<div class="index" v-else> <div class="index" v-else>
<h1>Misskey %fa:circle%thell%fa:circle R%</h1> <h1>Misskey %fa:circle%thell%fa:circle R%</h1>
<p>他のMisskeyユーザーとオセロで対戦しよう</p> <p>他のMisskeyユーザーとリバーシで対戦しよう</p>
<div class="play"> <div class="play">
<el-button round>フリーマッチ(準備中)</el-button> <el-button round>フリーマッチ(準備中)</el-button>
<el-button type="primary" round @click="match">指名</el-button> <el-button type="primary" round @click="match">指名</el-button>
<details> <details>
<summary>遊び方</summary> <summary>遊び方</summary>
<div> <div>
<p>オセロ相手と交互に石をボードに置いてゆき相手の石を挟んでひっくり返しながら最終的に残った石が多い方が勝ちというボードゲームです</p> <p>リバーシ相手と交互に石をボードに置いてゆき相手の石を挟んでひっくり返しながら最終的に残った石が多い方が勝ちというボードゲームです</p>
<dl> <dl>
<dt><b>フリーマッチ</b></dt> <dt><b>フリーマッチ</b></dt>
<dd>ランダムなユーザーと対戦するモードです</dd> <dd>ランダムなユーザーと対戦するモードです</dd>
@ -39,7 +39,7 @@
</section> </section>
<section v-if="myGames.length > 0"> <section v-if="myGames.length > 0">
<h2>自分の対局</h2> <h2>自分の対局</h2>
<a class="game" v-for="g in myGames" tabindex="-1" @click.prevent="go(g)" :href="`/othello/${g.id}`"> <a class="game" v-for="g in myGames" tabindex="-1" @click.prevent="go(g)" :href="`/reversi/${g.id}`">
<mk-avatar class="avatar" :user="g.user1"/> <mk-avatar class="avatar" :user="g.user1"/>
<mk-avatar class="avatar" :user="g.user2"/> <mk-avatar class="avatar" :user="g.user2"/>
<span><b>{{ g.user1.name }}</b> vs <b>{{ g.user2.name }}</b></span> <span><b>{{ g.user1.name }}</b> vs <b>{{ g.user2.name }}</b></span>
@ -48,7 +48,7 @@
</section> </section>
<section v-if="games.length > 0"> <section v-if="games.length > 0">
<h2>みんなの対局</h2> <h2>みんなの対局</h2>
<a class="game" v-for="g in games" tabindex="-1" @click.prevent="go(g)" :href="`/othello/${g.id}`"> <a class="game" v-for="g in games" tabindex="-1" @click.prevent="go(g)" :href="`/reversi/${g.id}`">
<mk-avatar class="avatar" :user="g.user1"/> <mk-avatar class="avatar" :user="g.user1"/>
<mk-avatar class="avatar" :user="g.user2"/> <mk-avatar class="avatar" :user="g.user2"/>
<span><b>{{ g.user1.name }}</b> vs <b>{{ g.user2.name }}</b></span> <span><b>{{ g.user1.name }}</b> vs <b>{{ g.user2.name }}</b></span>
@ -61,7 +61,7 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import XGameroom from './othello.gameroom.vue'; import XGameroom from './reversi.gameroom.vue';
export default Vue.extend({ export default Vue.extend({
components: { components: {
@ -93,24 +93,24 @@ export default Vue.extend({
} }
}, },
mounted() { mounted() {
this.connection = (this as any).os.streams.othelloStream.getConnection(); this.connection = (this as any).os.streams.reversiStream.getConnection();
this.connectionId = (this as any).os.streams.othelloStream.use(); this.connectionId = (this as any).os.streams.reversiStream.use();
this.connection.on('matched', this.onMatched); this.connection.on('matched', this.onMatched);
this.connection.on('invited', this.onInvited); this.connection.on('invited', this.onInvited);
(this as any).api('othello/games', { (this as any).api('reversi/games', {
my: true my: true
}).then(games => { }).then(games => {
this.myGames = games; this.myGames = games;
}); });
(this as any).api('othello/games').then(games => { (this as any).api('reversi/games').then(games => {
this.games = games; this.games = games;
this.gamesFetching = false; this.gamesFetching = false;
}); });
(this as any).api('othello/invitations').then(invitations => { (this as any).api('reversi/invitations').then(invitations => {
this.invitations = this.invitations.concat(invitations); this.invitations = this.invitations.concat(invitations);
}); });
@ -126,13 +126,13 @@ export default Vue.extend({
beforeDestroy() { beforeDestroy() {
this.connection.off('matched', this.onMatched); this.connection.off('matched', this.onMatched);
this.connection.off('invited', this.onInvited); this.connection.off('invited', this.onInvited);
(this as any).os.streams.othelloStream.dispose(this.connectionId); (this as any).os.streams.reversiStream.dispose(this.connectionId);
clearInterval(this.pingClock); clearInterval(this.pingClock);
}, },
methods: { methods: {
go(game) { go(game) {
(this as any).api('othello/games/show', { (this as any).api('reversi/games/show', {
gameId: game.id gameId: game.id
}).then(game => { }).then(game => {
this.matching = null; this.matching = null;
@ -146,7 +146,7 @@ export default Vue.extend({
(this as any).api('users/show', { (this as any).api('users/show', {
username username
}).then(user => { }).then(user => {
(this as any).api('othello/match', { (this as any).api('reversi/match', {
userId: user.id userId: user.id
}).then(res => { }).then(res => {
if (res == null) { if (res == null) {
@ -160,10 +160,10 @@ export default Vue.extend({
}, },
cancel() { cancel() {
this.matching = null; this.matching = null;
(this as any).api('othello/match/cancel'); (this as any).api('reversi/match/cancel');
}, },
accept(invitation) { accept(invitation) {
(this as any).api('othello/match', { (this as any).api('reversi/match', {
userId: invitation.parent.id userId: invitation.parent.id
}).then(game => { }).then(game => {
if (game) { if (game) {
@ -186,7 +186,7 @@ export default Vue.extend({
<style lang="stylus" scoped> <style lang="stylus" scoped>
@import '~const.styl' @import '~const.styl'
.mk-othello .mk-reversi
color #677f84 color #677f84
background #fff background #fff

View File

@ -34,7 +34,7 @@ import MkMessagingRoom from './views/pages/messaging-room.vue';
import MkNote from './views/pages/note.vue'; import MkNote from './views/pages/note.vue';
import MkSearch from './views/pages/search.vue'; import MkSearch from './views/pages/search.vue';
import MkTag from './views/pages/tag.vue'; import MkTag from './views/pages/tag.vue';
import MkOthello from './views/pages/othello.vue'; import MkReversi from './views/pages/reversi.vue';
import MkShare from './views/pages/share.vue'; import MkShare from './views/pages/share.vue';
/** /**
@ -64,8 +64,8 @@ init(async (launch) => {
{ path: '/search', component: MkSearch }, { path: '/search', component: MkSearch },
{ path: '/tags/:tag', component: MkTag }, { path: '/tags/:tag', component: MkTag },
{ path: '/share', component: MkShare }, { path: '/share', component: MkShare },
{ path: '/othello', component: MkOthello }, { path: '/reversi', component: MkReversi },
{ path: '/othello/:game', component: MkOthello }, { path: '/reversi/:game', component: MkReversi },
{ path: '/@:user', component: MkUser }, { path: '/@:user', component: MkUser },
{ path: '/notes/:note', component: MkNote } { path: '/notes/:note', component: MkNote }
] ]
@ -166,8 +166,8 @@ function registerNotifications(stream: HomeStreamManager) {
setTimeout(n.close.bind(n), 7000); setTimeout(n.close.bind(n), 7000);
}); });
connection.on('othello_invited', matching => { connection.on('reversi_invited', matching => {
const _n = composeNotification('othello_invited', matching); const _n = composeNotification('reversi_invited', matching);
const n = new Notification(_n.title, { const n = new Notification(_n.title, {
body: _n.body, body: _n.body,
icon: _n.icon icon: _n.icon

View File

@ -1,7 +1,7 @@
<template> <template>
<mk-window ref="window" width="500px" height="560px" :popout-url="popout" @closed="$destroy"> <mk-window ref="window" width="500px" height="560px" :popout-url="popout" @closed="$destroy">
<span slot="header" :class="$style.header">%fa:gamepad%%i18n:@game%</span> <span slot="header" :class="$style.header">%fa:gamepad%%i18n:@game%</span>
<mk-othello :class="$style.content" @gamed="g => game = g"/> <mk-reversi :class="$style.content" @gamed="g => game = g"/>
</mk-window> </mk-window>
</template> </template>
@ -18,8 +18,8 @@ export default Vue.extend({
computed: { computed: {
popout(): string { popout(): string {
return this.game return this.game
? `${url}/othello/${this.game.id}` ? `${url}/reversi/${this.game.id}`
: `${url}/othello`; : `${url}/reversi`;
} }
} }
}); });

View File

@ -56,23 +56,23 @@ export default Vue.extend({
this.connection = (this as any).os.stream.getConnection(); this.connection = (this as any).os.stream.getConnection();
this.connectionId = (this as any).os.stream.use(); this.connectionId = (this as any).os.stream.use();
this.connection.on('othello_invited', this.onOthelloInvited); this.connection.on('reversi_invited', this.onReversiInvited);
this.connection.on('othello_no_invites', this.onOthelloNoInvites); this.connection.on('reversi_no_invites', this.onReversiNoInvites);
} }
}, },
beforeDestroy() { beforeDestroy() {
if (this.$store.getters.isSignedIn) { if (this.$store.getters.isSignedIn) {
this.connection.off('othello_invited', this.onOthelloInvited); this.connection.off('reversi_invited', this.onReversiInvited);
this.connection.off('othello_no_invites', this.onOthelloNoInvites); this.connection.off('reversi_no_invites', this.onReversiNoInvites);
(this as any).os.stream.dispose(this.connectionId); (this as any).os.stream.dispose(this.connectionId);
} }
}, },
methods: { methods: {
onOthelloInvited() { onReversiInvited() {
this.hasGameInvitations = true; this.hasGameInvitations = true;
}, },
onOthelloNoInvites() { onReversiNoInvites() {
this.hasGameInvitations = false; this.hasGameInvitations = false;
}, },

View File

@ -1,6 +1,6 @@
<template> <template>
<component :is="ui ? 'mk-ui' : 'div'"> <component :is="ui ? 'mk-ui' : 'div'">
<mk-othello v-if="!fetching" :init-game="game" @gamed="onGamed"/> <mk-reversi v-if="!fetching" :init-game="game" @gamed="onGamed"/>
</component> </component>
</template> </template>
@ -33,7 +33,7 @@ export default Vue.extend({
Progress.start(); Progress.start();
this.fetching = true; this.fetching = true;
(this as any).api('othello/games/show', { (this as any).api('reversi/games/show', {
gameId: this.$route.params.game gameId: this.$route.params.game
}).then(game => { }).then(game => {
this.game = game; this.game = game;
@ -43,7 +43,7 @@ export default Vue.extend({
}); });
}, },
onGamed(game) { onGamed(game) {
history.pushState(null, null, '/othello/' + game.id); history.pushState(null, null, '/reversi/' + game.id);
} }
} }
}); });

View File

@ -11,7 +11,7 @@ import { DriveStreamManager } from './common/scripts/streaming/drive';
import { ServerStatsStreamManager } from './common/scripts/streaming/server-stats'; import { ServerStatsStreamManager } from './common/scripts/streaming/server-stats';
import { NotesStatsStreamManager } from './common/scripts/streaming/notes-stats'; import { NotesStatsStreamManager } from './common/scripts/streaming/notes-stats';
import { MessagingIndexStreamManager } from './common/scripts/streaming/messaging-index'; import { MessagingIndexStreamManager } from './common/scripts/streaming/messaging-index';
import { OthelloStreamManager } from './common/scripts/streaming/othello'; import { ReversiStreamManager } from './common/scripts/streaming/reversi';
import Err from './common/views/components/connect-failed.vue'; import Err from './common/views/components/connect-failed.vue';
import { LocalTimelineStreamManager } from './common/scripts/streaming/local-timeline'; import { LocalTimelineStreamManager } from './common/scripts/streaming/local-timeline';
@ -108,7 +108,7 @@ export default class MiOS extends EventEmitter {
serverStatsStream: ServerStatsStreamManager; serverStatsStream: ServerStatsStreamManager;
notesStatsStream: NotesStatsStreamManager; notesStatsStream: NotesStatsStreamManager;
messagingIndexStream: MessagingIndexStreamManager; messagingIndexStream: MessagingIndexStreamManager;
othelloStream: OthelloStreamManager; reversiStream: ReversiStreamManager;
} = { } = {
localTimelineStream: null, localTimelineStream: null,
globalTimelineStream: null, globalTimelineStream: null,
@ -116,7 +116,7 @@ export default class MiOS extends EventEmitter {
serverStatsStream: null, serverStatsStream: null,
notesStatsStream: null, notesStatsStream: null,
messagingIndexStream: null, messagingIndexStream: null,
othelloStream: null reversiStream: null
}; };
/** /**
@ -233,7 +233,7 @@ export default class MiOS extends EventEmitter {
this.streams.globalTimelineStream = new GlobalTimelineStreamManager(this, this.store.state.i); this.streams.globalTimelineStream = new GlobalTimelineStreamManager(this, this.store.state.i);
this.streams.driveStream = new DriveStreamManager(this, this.store.state.i); this.streams.driveStream = new DriveStreamManager(this, this.store.state.i);
this.streams.messagingIndexStream = new MessagingIndexStreamManager(this, this.store.state.i); this.streams.messagingIndexStream = new MessagingIndexStreamManager(this, this.store.state.i);
this.streams.othelloStream = new OthelloStreamManager(this, this.store.state.i); this.streams.reversiStream = new ReversiStreamManager(this, this.store.state.i);
}); });
//#endregion //#endregion

View File

@ -35,7 +35,7 @@ import MkFavorites from './views/pages/favorites.vue';
import MkUserLists from './views/pages/user-lists.vue'; import MkUserLists from './views/pages/user-lists.vue';
import MkUserList from './views/pages/user-list.vue'; import MkUserList from './views/pages/user-list.vue';
import MkSettings from './views/pages/settings.vue'; import MkSettings from './views/pages/settings.vue';
import MkOthello from './views/pages/othello.vue'; import MkReversi from './views/pages/reversi.vue';
import MkTag from './views/pages/tag.vue'; import MkTag from './views/pages/tag.vue';
import MkShare from './views/pages/share.vue'; import MkShare from './views/pages/share.vue';
@ -75,8 +75,8 @@ init((launch) => {
{ path: '/search', component: MkSearch }, { path: '/search', component: MkSearch },
{ path: '/tags/:tag', component: MkTag }, { path: '/tags/:tag', component: MkTag },
{ path: '/share', component: MkShare }, { path: '/share', component: MkShare },
{ path: '/othello', name: 'othello', component: MkOthello }, { path: '/reversi', name: 'reversi', component: MkReversi },
{ path: '/othello/:game', component: MkOthello }, { path: '/reversi/:game', component: MkReversi },
{ path: '/@:user', component: MkUser }, { path: '/@:user', component: MkUser },
{ path: '/@:user/followers', component: MkFollowers }, { path: '/@:user/followers', component: MkFollowers },
{ path: '/@:user/following', component: MkFollowing }, { path: '/@:user/following', component: MkFollowing },

View File

@ -45,8 +45,8 @@ export default Vue.extend({
this.connection = (this as any).os.stream.getConnection(); this.connection = (this as any).os.stream.getConnection();
this.connectionId = (this as any).os.stream.use(); this.connectionId = (this as any).os.stream.use();
this.connection.on('othello_invited', this.onOthelloInvited); this.connection.on('reversi_invited', this.onReversiInvited);
this.connection.on('othello_no_invites', this.onOthelloNoInvites); this.connection.on('reversi_no_invites', this.onReversiNoInvites);
const ago = (new Date().getTime() - new Date(this.$store.state.i.lastUsedAt).getTime()) / 1000; const ago = (new Date().getTime() - new Date(this.$store.state.i.lastUsedAt).getTime()) / 1000;
const isHisasiburi = ago >= 3600; const isHisasiburi = ago >= 3600;
@ -98,16 +98,16 @@ export default Vue.extend({
}, },
beforeDestroy() { beforeDestroy() {
if (this.$store.getters.isSignedIn) { if (this.$store.getters.isSignedIn) {
this.connection.off('othello_invited', this.onOthelloInvited); this.connection.off('reversi_invited', this.onReversiInvited);
this.connection.off('othello_no_invites', this.onOthelloNoInvites); this.connection.off('reversi_no_invites', this.onReversiNoInvites);
(this as any).os.stream.dispose(this.connectionId); (this as any).os.stream.dispose(this.connectionId);
} }
}, },
methods: { methods: {
onOthelloInvited() { onReversiInvited() {
this.hasGameInvitation = true; this.hasGameInvitation = true;
}, },
onOthelloNoInvites() { onReversiNoInvites() {
this.hasGameInvitation = false; this.hasGameInvitation = false;
} }
} }

View File

@ -19,7 +19,7 @@
<li><router-link to="/i/notifications" :data-active="$route.name == 'notifications'">%fa:R bell%%i18n:@notifications%<template v-if="hasUnreadNotification">%fa:circle%</template>%fa:angle-right%</router-link></li> <li><router-link to="/i/notifications" :data-active="$route.name == 'notifications'">%fa:R bell%%i18n:@notifications%<template v-if="hasUnreadNotification">%fa:circle%</template>%fa:angle-right%</router-link></li>
<li><router-link to="/i/messaging" :data-active="$route.name == 'messaging'">%fa:R comments%%i18n:@messaging%<template v-if="hasUnreadMessagingMessage">%fa:circle%</template>%fa:angle-right%</router-link></li> <li><router-link to="/i/messaging" :data-active="$route.name == 'messaging'">%fa:R comments%%i18n:@messaging%<template v-if="hasUnreadMessagingMessage">%fa:circle%</template>%fa:angle-right%</router-link></li>
<li v-if="$store.getters.isSignedIn && $store.state.i.isLocked"><router-link to="/i/received-follow-requests" :data-active="$route.name == 'received-follow-requests'">%fa:R envelope%%i18n:@follow-requests%<template v-if="$store.getters.isSignedIn && $store.state.i.pendingReceivedFollowRequestsCount">%fa:circle%</template>%fa:angle-right%</router-link></li> <li v-if="$store.getters.isSignedIn && $store.state.i.isLocked"><router-link to="/i/received-follow-requests" :data-active="$route.name == 'received-follow-requests'">%fa:R envelope%%i18n:@follow-requests%<template v-if="$store.getters.isSignedIn && $store.state.i.pendingReceivedFollowRequestsCount">%fa:circle%</template>%fa:angle-right%</router-link></li>
<li><router-link to="/othello" :data-active="$route.name == 'othello'">%fa:gamepad%%i18n:@game%<template v-if="hasGameInvitation">%fa:circle%</template>%fa:angle-right%</router-link></li> <li><router-link to="/reversi" :data-active="$route.name == 'reversi'">%fa:gamepad%%i18n:@game%<template v-if="hasGameInvitation">%fa:circle%</template>%fa:angle-right%</router-link></li>
</ul> </ul>
<ul> <ul>
<li><router-link to="/i/widgets" :data-active="$route.name == 'widgets'">%fa:R calendar-alt%%i18n:@widgets%%fa:angle-right%</router-link></li> <li><router-link to="/i/widgets" :data-active="$route.name == 'widgets'">%fa:R calendar-alt%%i18n:@widgets%%fa:angle-right%</router-link></li>
@ -66,14 +66,14 @@ export default Vue.extend({
this.connection = (this as any).os.stream.getConnection(); this.connection = (this as any).os.stream.getConnection();
this.connectionId = (this as any).os.stream.use(); this.connectionId = (this as any).os.stream.use();
this.connection.on('othello_invited', this.onOthelloInvited); this.connection.on('reversi_invited', this.onReversiInvited);
this.connection.on('othello_no_invites', this.onOthelloNoInvites); this.connection.on('reversi_no_invites', this.onReversiNoInvites);
} }
}, },
beforeDestroy() { beforeDestroy() {
if (this.$store.getters.isSignedIn) { if (this.$store.getters.isSignedIn) {
this.connection.off('othello_invited', this.onOthelloInvited); this.connection.off('reversi_invited', this.onReversiInvited);
this.connection.off('othello_no_invites', this.onOthelloNoInvites); this.connection.off('reversi_no_invites', this.onReversiNoInvites);
(this as any).os.stream.dispose(this.connectionId); (this as any).os.stream.dispose(this.connectionId);
} }
}, },
@ -83,10 +83,10 @@ export default Vue.extend({
if (query == null || query == '') return; if (query == null || query == '') return;
this.$router.push('/search?q=' + encodeURIComponent(query)); this.$router.push('/search?q=' + encodeURIComponent(query));
}, },
onOthelloInvited() { onReversiInvited() {
this.hasGameInvitation = true; this.hasGameInvitation = true;
}, },
onOthelloNoInvites() { onReversiNoInvites() {
this.hasGameInvitation = false; this.hasGameInvitation = false;
}, },
dark() { dark() {

View File

@ -1,7 +1,7 @@
<template> <template>
<mk-ui> <mk-ui>
<span slot="header">%fa:gamepad%オセロ</span> <span slot="header">%fa:gamepad%リバーシ</span>
<mk-othello v-if="!fetching" :init-game="game" @gamed="onGamed"/> <mk-reversi v-if="!fetching" :init-game="game" @gamed="onGamed"/>
</mk-ui> </mk-ui>
</template> </template>
@ -23,7 +23,7 @@ export default Vue.extend({
this.fetch(); this.fetch();
}, },
mounted() { mounted() {
document.title = 'Misskey オセロ'; document.title = 'Misskey リバーシ';
document.documentElement.style.background = '#fff'; document.documentElement.style.background = '#fff';
}, },
methods: { methods: {
@ -33,7 +33,7 @@ export default Vue.extend({
Progress.start(); Progress.start();
this.fetching = true; this.fetching = true;
(this as any).api('othello/games/show', { (this as any).api('reversi/games/show', {
gameId: this.$route.params.game gameId: this.$route.params.game
}).then(game => { }).then(game => {
this.game = game; this.game = game;
@ -43,7 +43,7 @@ export default Vue.extend({
}); });
}, },
onGamed(game) { onGamed(game) {
history.pushState(null, null, '/othello/' + game.id); history.pushState(null, null, '/reversi/' + game.id);
} }
} }
}); });

View File

@ -60,7 +60,7 @@ export type Source = {
hook_secret: string; hook_secret: string;
username: string; username: string;
}; };
othello_ai?: { reversi_ai?: {
id: string; id: string;
i: string; i: string;
}; };

View File

@ -3,10 +3,10 @@ import * as deepcopy from 'deepcopy';
import db from '../db/mongodb'; import db from '../db/mongodb';
import { IUser, pack as packUser } from './user'; import { IUser, pack as packUser } from './user';
const OthelloGame = db.get<IOthelloGame>('othelloGames'); const ReversiGame = db.get<IReversiGame>('reversiGames');
export default OthelloGame; export default ReversiGame;
export interface IOthelloGame { export interface IReversiGame {
_id: mongo.ObjectID; _id: mongo.ObjectID;
createdAt: Date; createdAt: Date;
startedAt: Date; startedAt: Date;
@ -45,7 +45,7 @@ export interface IOthelloGame {
} }
/** /**
* Pack an othello game for API response * Pack an reversi game for API response
*/ */
export const pack = ( export const pack = (
game: any, game: any,
@ -62,11 +62,11 @@ export const pack = (
// Populate the game if 'game' is ID // Populate the game if 'game' is ID
if (mongo.ObjectID.prototype.isPrototypeOf(game)) { if (mongo.ObjectID.prototype.isPrototypeOf(game)) {
_game = await OthelloGame.findOne({ _game = await ReversiGame.findOne({
_id: game _id: game
}); });
} else if (typeof game === 'string') { } else if (typeof game === 'string') {
_game = await OthelloGame.findOne({ _game = await ReversiGame.findOne({
_id: new mongo.ObjectID(game) _id: new mongo.ObjectID(game)
}); });
} else { } else {

View File

@ -3,7 +3,7 @@ import * as deepcopy from 'deepcopy';
import db from '../db/mongodb'; import db from '../db/mongodb';
import { IUser, pack as packUser } from './user'; import { IUser, pack as packUser } from './user';
const Matching = db.get<IMatching>('othelloMatchings'); const Matching = db.get<IMatching>('reversiMatchings');
export default Matching; export default Matching;
export interface IMatching { export interface IMatching {
@ -14,7 +14,7 @@ export interface IMatching {
} }
/** /**
* Pack an othello matching for API response * Pack an reversi matching for API response
*/ */
export const pack = ( export const pack = (
matching: any, matching: any,

View File

@ -37,12 +37,12 @@ class MisskeyEvent {
this.publish(`messaging-index-stream:${userId}`, type, typeof value === 'undefined' ? null : value); this.publish(`messaging-index-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
} }
public publishOthelloStream(userId: ID, type: string, value?: any): void { public publishReversiStream(userId: ID, type: string, value?: any): void {
this.publish(`othello-stream:${userId}`, type, typeof value === 'undefined' ? null : value); this.publish(`reversi-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
} }
public publishOthelloGameStream(gameId: ID, type: string, value?: any): void { public publishReversiGameStream(gameId: ID, type: string, value?: any): void {
this.publish(`othello-game-stream:${gameId}`, type, typeof value === 'undefined' ? null : value); this.publish(`reversi-game-stream:${gameId}`, type, typeof value === 'undefined' ? null : value);
} }
public publishLocalTimelineStream(note: any): void { public publishLocalTimelineStream(note: any): void {
@ -73,5 +73,5 @@ export const publishUserListStream = ev.publishUserListStream.bind(ev);
export const publishNoteStream = ev.publishNoteStream.bind(ev); export const publishNoteStream = ev.publishNoteStream.bind(ev);
export const publishMessagingStream = ev.publishMessagingStream.bind(ev); export const publishMessagingStream = ev.publishMessagingStream.bind(ev);
export const publishMessagingIndexStream = ev.publishMessagingIndexStream.bind(ev); export const publishMessagingIndexStream = ev.publishMessagingIndexStream.bind(ev);
export const publishOthelloStream = ev.publishOthelloStream.bind(ev); export const publishReversiStream = ev.publishReversiStream.bind(ev);
export const publishOthelloGameStream = ev.publishOthelloGameStream.bind(ev); export const publishReversiGameStream = ev.publishReversiGameStream.bind(ev);

View File

@ -7,7 +7,7 @@
*/ */
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import Othello, { Color } from '../core'; import Reversi, { Color } from '../core';
import conf from '../../config'; import conf from '../../config';
import getUserName from '../../renderers/get-user-name'; import getUserName from '../../renderers/get-user-name';
@ -17,12 +17,12 @@ let form;
/** /**
* BotアカウントのユーザーID * BotアカウントのユーザーID
*/ */
const id = conf.othello_ai.id; const id = conf.reversi_ai.id;
/** /**
* BotアカウントのAPIキー * BotアカウントのAPIキー
*/ */
const i = conf.othello_ai.i; const i = conf.reversi_ai.i;
let note; let note;
@ -44,7 +44,7 @@ process.on('message', async msg => {
//#region TLに投稿する //#region TLに投稿する
const game = msg.body; const game = msg.body;
const url = `${conf.url}/othello/${game.id}`; const url = `${conf.url}/reversi/${game.id}`;
const user = game.user1Id == id ? game.user2 : game.user1; const user = game.user1Id == id ? game.user2 : game.user1;
const isSettai = form[0].value === 0; const isSettai = form[0].value === 0;
const text = isSettai const text = isSettai
@ -100,7 +100,7 @@ process.on('message', async msg => {
} }
}); });
let o: Othello; let o: Reversi;
let botColor: Color; let botColor: Color;
// 各マスの強さ // 各マスの強さ
@ -113,8 +113,8 @@ let cellWeights;
function onGameStarted(g) { function onGameStarted(g) {
game = g; game = g;
// オセロエンジン初期化 // リバーシエンジン初期化
o = new Othello(game.settings.map, { o = new Reversi(game.settings.map, {
isLlotheo: game.settings.isLlotheo, isLlotheo: game.settings.isLlotheo,
canPutEverywhere: game.settings.canPutEverywhere, canPutEverywhere: game.settings.canPutEverywhere,
loopedBoard: game.settings.loopedBoard loopedBoard: game.settings.loopedBoard

View File

@ -17,12 +17,12 @@ import conf from '../../config';
/** /**
* BotアカウントのAPIキー * BotアカウントのAPIキー
*/ */
const i = conf.othello_ai.i; const i = conf.reversi_ai.i;
/** /**
* BotアカウントのユーザーID * BotアカウントのユーザーID
*/ */
const id = conf.othello_ai.id; const id = conf.reversi_ai.id;
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -59,7 +59,7 @@ homeStream.on('message', message => {
}); });
if (note.text) { if (note.text) {
if (note.text.indexOf('オセロ') > -1) { if (note.text.indexOf('リバーシ') > -1) {
request.post(`${conf.api_url}/notes/create`, { request.post(`${conf.api_url}/notes/create`, {
json: { i, json: { i,
replyId: note.id, replyId: note.id,
@ -76,7 +76,7 @@ homeStream.on('message', message => {
if (msg.type == 'messaging_message') { if (msg.type == 'messaging_message') {
const message = msg.body; const message = msg.body;
if (message.text) { if (message.text) {
if (message.text.indexOf('オセロ') > -1) { if (message.text.indexOf('リバーシ') > -1) {
request.post(`${conf.api_url}/messaging/messages/create`, { request.post(`${conf.api_url}/messaging/messages/create`, {
json: { i, json: { i,
userId: message.userId, userId: message.userId,
@ -92,7 +92,7 @@ homeStream.on('message', message => {
// ユーザーを対局に誘う // ユーザーを対局に誘う
function invite(userId) { function invite(userId) {
request.post(`${conf.api_url}/othello/match`, { request.post(`${conf.api_url}/reversi/match`, {
json: { i, json: { i,
userId: userId userId: userId
} }
@ -100,21 +100,21 @@ function invite(userId) {
} }
/** /**
* *
*/ */
const othelloStream = new ReconnectingWebSocket(`${conf.ws_url}/othello?i=${i}`, undefined, { const reversiStream = new ReconnectingWebSocket(`${conf.ws_url}/reversi?i=${i}`, undefined, {
constructor: WebSocket constructor: WebSocket
}); });
othelloStream.on('open', () => { reversiStream.on('open', () => {
console.log('othello stream opened'); console.log('reversi stream opened');
}); });
othelloStream.on('close', () => { reversiStream.on('close', () => {
console.log('othello stream closed'); console.log('reversi stream closed');
}); });
othelloStream.on('message', message => { reversiStream.on('message', message => {
const msg = JSON.parse(message.toString()); const msg = JSON.parse(message.toString());
// 招待されたとき // 招待されたとき
@ -134,12 +134,12 @@ othelloStream.on('message', message => {
*/ */
function gameStart(game) { function gameStart(game) {
// ゲームストリームに接続 // ゲームストリームに接続
const gw = new ReconnectingWebSocket(`${conf.ws_url}/othello-game?i=${i}&game=${game.id}`, undefined, { const gw = new ReconnectingWebSocket(`${conf.ws_url}/reversi-game?i=${i}&game=${game.id}`, undefined, {
constructor: WebSocket constructor: WebSocket
}); });
gw.on('open', () => { gw.on('open', () => {
console.log('othello game stream opened'); console.log('reversi game stream opened');
// フォーム // フォーム
const form = [{ const form = [{
@ -210,19 +210,19 @@ function gameStart(game) {
}); });
gw.on('close', () => { gw.on('close', () => {
console.log('othello game stream closed'); console.log('reversi game stream closed');
}); });
} }
/** /**
* *
* @param inviter * @param inviter
*/ */
async function onInviteMe(inviter) { async function onInviteMe(inviter) {
console.log(`Someone invited me: @${inviter.username}`); console.log(`Someone invited me: @${inviter.username}`);
// 承認 // 承認
const game = await request.post(`${conf.api_url}/othello/match`, { const game = await request.post(`${conf.api_url}/reversi/match`, {
json: { json: {
i, i,
userId: inviter.id userId: inviter.id

View File

@ -37,9 +37,9 @@ export type Undo = {
}; };
/** /**
* *
*/ */
export default class Othello { export default class Reversi {
public map: MapPixel[]; public map: MapPixel[];
public mapWidth: number; public mapWidth: number;
public mapHeight: number; public mapHeight: number;

View File

@ -892,7 +892,7 @@ export const test4: Map = {
] ]
}; };
// https://misskey.xyz/othello/5aaabf7fe126e10b5216ea09 64 // https://misskey.xyz/reversi/5aaabf7fe126e10b5216ea09 64
export const test5: Map = { export const test5: Map = {
name: 'Test5', name: 'Test5',
category: 'Test', category: 'Test',

View File

@ -245,27 +245,27 @@ const endpoints: Endpoint[] = [
}, },
{ {
name: 'othello/match', name: 'reversi/match',
withCredential: true withCredential: true
}, },
{ {
name: 'othello/match/cancel', name: 'reversi/match/cancel',
withCredential: true withCredential: true
}, },
{ {
name: 'othello/invitations', name: 'reversi/invitations',
withCredential: true withCredential: true
}, },
{ {
name: 'othello/games', name: 'reversi/games',
withCredential: true withCredential: true
}, },
{ {
name: 'othello/games/show' name: 'reversi/games/show'
}, },
{ {

View File

@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../cafy-id'; import $ from 'cafy'; import ID from '../../../../cafy-id';
import OthelloGame, { pack } from '../../../../models/othello-game'; import ReversiGame, { pack } from '../../../../models/reversi-game';
module.exports = (params, user) => new Promise(async (res, rej) => { module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'my' parameter // Get 'my' parameter
@ -50,7 +50,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
} }
// Fetch games // Fetch games
const games = await OthelloGame.find(q, { const games = await ReversiGame.find(q, {
sort, sort,
limit limit
}); });

View File

@ -1,19 +1,19 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id'; import $ from 'cafy'; import ID from '../../../../../cafy-id';
import OthelloGame, { pack } from '../../../../../models/othello-game'; import ReversiGame, { pack } from '../../../../../models/reversi-game';
import Othello from '../../../../../othello/core'; import Reversi from '../../../../../reversi/core';
module.exports = (params, user) => new Promise(async (res, rej) => { module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'gameId' parameter // Get 'gameId' parameter
const [gameId, gameIdErr] = $.type(ID).get(params.gameId); const [gameId, gameIdErr] = $.type(ID).get(params.gameId);
if (gameIdErr) return rej('invalid gameId param'); if (gameIdErr) return rej('invalid gameId param');
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (game == null) { if (game == null) {
return rej('game not found'); return rej('game not found');
} }
const o = new Othello(game.settings.map, { const o = new Reversi(game.settings.map, {
isLlotheo: game.settings.isLlotheo, isLlotheo: game.settings.isLlotheo,
canPutEverywhere: game.settings.canPutEverywhere, canPutEverywhere: game.settings.canPutEverywhere,
loopedBoard: game.settings.loopedBoard loopedBoard: game.settings.loopedBoard

View File

@ -1,4 +1,4 @@
import Matching, { pack as packMatching } from '../../../../models/othello-matching'; import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
module.exports = (params, user) => new Promise(async (res, rej) => { module.exports = (params, user) => new Promise(async (res, rej) => {
// Find session // Find session

View File

@ -1,9 +1,9 @@
import $ from 'cafy'; import ID from '../../../../cafy-id'; import $ from 'cafy'; import ID from '../../../../cafy-id';
import Matching, { pack as packMatching } from '../../../../models/othello-matching'; import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
import OthelloGame, { pack as packGame } from '../../../../models/othello-game'; import ReversiGame, { pack as packGame } from '../../../../models/reversi-game';
import User from '../../../../models/user'; import User from '../../../../models/user';
import publishUserStream, { publishOthelloStream } from '../../../../publishers/stream'; import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
import { eighteight } from '../../../../othello/maps'; import { eighteight } from '../../../../reversi/maps';
module.exports = (params, user) => new Promise(async (res, rej) => { module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'userId' parameter // Get 'userId' parameter
@ -28,7 +28,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}); });
// Create game // Create game
const game = await OthelloGame.insert({ const game = await ReversiGame.insert({
createdAt: new Date(), createdAt: new Date(),
user1Id: exist.parentId, user1Id: exist.parentId,
user2Id: user._id, user2Id: user._id,
@ -47,14 +47,14 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Reponse // Reponse
res(await packGame(game, user)); res(await packGame(game, user));
publishOthelloStream(exist.parentId, 'matched', await packGame(game, exist.parentId)); publishReversiStream(exist.parentId, 'matched', await packGame(game, exist.parentId));
const other = await Matching.count({ const other = await Matching.count({
childId: user._id childId: user._id
}); });
if (other == 0) { if (other == 0) {
publishUserStream(user._id, 'othello_no_invites'); publishUserStream(user._id, 'reversi_no_invites');
} }
} else { } else {
// Fetch child // Fetch child
@ -88,8 +88,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const packed = await packMatching(matching, child); const packed = await packMatching(matching, child);
// 招待 // 招待
publishOthelloStream(child._id, 'invited', packed); publishReversiStream(child._id, 'invited', packed);
publishUserStream(child._id, 'othello_invited', packed); publishUserStream(child._id, 'reversi_invited', packed);
} }
}); });

View File

@ -1,4 +1,4 @@
import Matching from '../../../../../models/othello-matching'; import Matching from '../../../../../models/reversi-matching';
module.exports = (params, user) => new Promise(async (res, rej) => { module.exports = (params, user) => new Promise(async (res, rej) => {
await Matching.remove({ await Matching.remove({

View File

@ -1,10 +1,10 @@
import * as websocket from 'websocket'; import * as websocket from 'websocket';
import * as redis from 'redis'; import * as redis from 'redis';
import * as CRC32 from 'crc-32'; import * as CRC32 from 'crc-32';
import OthelloGame, { pack } from '../../../models/othello-game'; import ReversiGame, { pack } from '../../../models/reversi-game';
import { publishOthelloGameStream } from '../../../publishers/stream'; import { publishReversiGameStream } from '../../../publishers/stream';
import Othello from '../../../othello/core'; import Reversi from '../../../reversi/core';
import * as maps from '../../../othello/maps'; import * as maps from '../../../reversi/maps';
import { ParsedUrlQuery } from 'querystring'; import { ParsedUrlQuery } from 'querystring';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void { export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void {
@ -12,7 +12,7 @@ export default function(request: websocket.request, connection: websocket.connec
const gameId = q.game; const gameId = q.game;
// Subscribe game stream // Subscribe game stream
subscriber.subscribe(`misskey:othello-game-stream:${gameId}`); subscriber.subscribe(`misskey:reversi-game-stream:${gameId}`);
subscriber.on('message', (_, data) => { subscriber.on('message', (_, data) => {
connection.send(data); connection.send(data);
}); });
@ -62,24 +62,24 @@ export default function(request: websocket.request, connection: websocket.connec
}); });
async function updateSettings(settings) { async function updateSettings(settings) {
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (game.isStarted) return; if (game.isStarted) return;
if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return; if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return;
if (game.user1Id.equals(user._id) && game.user1Accepted) return; if (game.user1Id.equals(user._id) && game.user1Accepted) return;
if (game.user2Id.equals(user._id) && game.user2Accepted) return; if (game.user2Id.equals(user._id) && game.user2Accepted) return;
await OthelloGame.update({ _id: gameId }, { await ReversiGame.update({ _id: gameId }, {
$set: { $set: {
settings settings
} }
}); });
publishOthelloGameStream(gameId, 'update-settings', settings); publishReversiGameStream(gameId, 'update-settings', settings);
} }
async function initForm(form) { async function initForm(form) {
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (game.isStarted) return; if (game.isStarted) return;
if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return; if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return;
@ -90,18 +90,18 @@ export default function(request: websocket.request, connection: websocket.connec
form2: form form2: form
}; };
await OthelloGame.update({ _id: gameId }, { await ReversiGame.update({ _id: gameId }, {
$set: set $set: set
}); });
publishOthelloGameStream(gameId, 'init-form', { publishReversiGameStream(gameId, 'init-form', {
userId: user._id, userId: user._id,
form form
}); });
} }
async function updateForm(id, value) { async function updateForm(id, value) {
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (game.isStarted) return; if (game.isStarted) return;
if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return; if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return;
@ -120,11 +120,11 @@ export default function(request: websocket.request, connection: websocket.connec
form1: form form1: form
}; };
await OthelloGame.update({ _id: gameId }, { await ReversiGame.update({ _id: gameId }, {
$set: set $set: set
}); });
publishOthelloGameStream(gameId, 'update-form', { publishReversiGameStream(gameId, 'update-form', {
userId: user._id, userId: user._id,
id, id,
value value
@ -133,40 +133,40 @@ export default function(request: websocket.request, connection: websocket.connec
async function message(message) { async function message(message) {
message.id = Math.random(); message.id = Math.random();
publishOthelloGameStream(gameId, 'message', { publishReversiGameStream(gameId, 'message', {
userId: user._id, userId: user._id,
message message
}); });
} }
async function accept(accept: boolean) { async function accept(accept: boolean) {
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (game.isStarted) return; if (game.isStarted) return;
let bothAccepted = false; let bothAccepted = false;
if (game.user1Id.equals(user._id)) { if (game.user1Id.equals(user._id)) {
await OthelloGame.update({ _id: gameId }, { await ReversiGame.update({ _id: gameId }, {
$set: { $set: {
user1Accepted: accept user1Accepted: accept
} }
}); });
publishOthelloGameStream(gameId, 'change-accepts', { publishReversiGameStream(gameId, 'change-accepts', {
user1: accept, user1: accept,
user2: game.user2Accepted user2: game.user2Accepted
}); });
if (accept && game.user2Accepted) bothAccepted = true; if (accept && game.user2Accepted) bothAccepted = true;
} else if (game.user2Id.equals(user._id)) { } else if (game.user2Id.equals(user._id)) {
await OthelloGame.update({ _id: gameId }, { await ReversiGame.update({ _id: gameId }, {
$set: { $set: {
user2Accepted: accept user2Accepted: accept
} }
}); });
publishOthelloGameStream(gameId, 'change-accepts', { publishReversiGameStream(gameId, 'change-accepts', {
user1: game.user1Accepted, user1: game.user1Accepted,
user2: accept user2: accept
}); });
@ -179,7 +179,7 @@ export default function(request: websocket.request, connection: websocket.connec
if (bothAccepted) { if (bothAccepted) {
// 3秒後、まだacceptされていたらゲーム開始 // 3秒後、まだacceptされていたらゲーム開始
setTimeout(async () => { setTimeout(async () => {
const freshGame = await OthelloGame.findOne({ _id: gameId }); const freshGame = await ReversiGame.findOne({ _id: gameId });
if (freshGame == null || freshGame.isStarted || freshGame.isEnded) return; if (freshGame == null || freshGame.isStarted || freshGame.isEnded) return;
if (!freshGame.user1Accepted || !freshGame.user2Accepted) return; if (!freshGame.user1Accepted || !freshGame.user2Accepted) return;
@ -198,7 +198,7 @@ export default function(request: websocket.request, connection: websocket.connec
const map = freshGame.settings.map != null ? freshGame.settings.map : getRandomMap(); const map = freshGame.settings.map != null ? freshGame.settings.map : getRandomMap();
await OthelloGame.update({ _id: gameId }, { await ReversiGame.update({ _id: gameId }, {
$set: { $set: {
startedAt: new Date(), startedAt: new Date(),
isStarted: true, isStarted: true,
@ -208,7 +208,7 @@ export default function(request: websocket.request, connection: websocket.connec
}); });
//#region 盤面に最初から石がないなどして始まった瞬間に勝敗が決定する場合があるのでその処理 //#region 盤面に最初から石がないなどして始まった瞬間に勝敗が決定する場合があるのでその処理
const o = new Othello(map, { const o = new Reversi(map, {
isLlotheo: freshGame.settings.isLlotheo, isLlotheo: freshGame.settings.isLlotheo,
canPutEverywhere: freshGame.settings.canPutEverywhere, canPutEverywhere: freshGame.settings.canPutEverywhere,
loopedBoard: freshGame.settings.loopedBoard loopedBoard: freshGame.settings.loopedBoard
@ -224,7 +224,7 @@ export default function(request: websocket.request, connection: websocket.connec
winner = null; winner = null;
} }
await OthelloGame.update({ await ReversiGame.update({
_id: gameId _id: gameId
}, { }, {
$set: { $set: {
@ -233,27 +233,27 @@ export default function(request: websocket.request, connection: websocket.connec
} }
}); });
publishOthelloGameStream(gameId, 'ended', { publishReversiGameStream(gameId, 'ended', {
winnerId: winner, winnerId: winner,
game: await pack(gameId, user) game: await pack(gameId, user)
}); });
} }
//#endregion //#endregion
publishOthelloGameStream(gameId, 'started', await pack(gameId, user)); publishReversiGameStream(gameId, 'started', await pack(gameId, user));
}, 3000); }, 3000);
} }
} }
// 石を打つ // 石を打つ
async function set(pos) { async function set(pos) {
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (!game.isStarted) return; if (!game.isStarted) return;
if (game.isEnded) return; if (game.isEnded) return;
if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return; if (!game.user1Id.equals(user._id) && !game.user2Id.equals(user._id)) return;
const o = new Othello(game.settings.map, { const o = new Reversi(game.settings.map, {
isLlotheo: game.settings.isLlotheo, isLlotheo: game.settings.isLlotheo,
canPutEverywhere: game.settings.canPutEverywhere, canPutEverywhere: game.settings.canPutEverywhere,
loopedBoard: game.settings.loopedBoard loopedBoard: game.settings.loopedBoard
@ -290,7 +290,7 @@ export default function(request: websocket.request, connection: websocket.connec
const crc32 = CRC32.str(game.logs.map(x => x.pos.toString()).join('') + pos.toString()); const crc32 = CRC32.str(game.logs.map(x => x.pos.toString()).join('') + pos.toString());
await OthelloGame.update({ await ReversiGame.update({
_id: gameId _id: gameId
}, { }, {
$set: { $set: {
@ -303,12 +303,12 @@ export default function(request: websocket.request, connection: websocket.connec
} }
}); });
publishOthelloGameStream(gameId, 'set', Object.assign(log, { publishReversiGameStream(gameId, 'set', Object.assign(log, {
next: o.turn next: o.turn
})); }));
if (o.isEnded) { if (o.isEnded) {
publishOthelloGameStream(gameId, 'ended', { publishReversiGameStream(gameId, 'ended', {
winnerId: winner, winnerId: winner,
game: await pack(gameId, user) game: await pack(gameId, user)
}); });
@ -316,7 +316,7 @@ export default function(request: websocket.request, connection: websocket.connec
} }
async function check(crc32) { async function check(crc32) {
const game = await OthelloGame.findOne({ _id: gameId }); const game = await ReversiGame.findOne({ _id: gameId });
if (!game.isStarted) return; if (!game.isStarted) return;

View File

@ -1,12 +1,12 @@
import * as mongo from 'mongodb'; import * as mongo from 'mongodb';
import * as websocket from 'websocket'; import * as websocket from 'websocket';
import * as redis from 'redis'; import * as redis from 'redis';
import Matching, { pack } from '../../../models/othello-matching'; import Matching, { pack } from '../../../models/reversi-matching';
import publishUserStream from '../../../publishers/stream'; import publishUserStream from '../../../publishers/stream';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
// Subscribe othello stream // Subscribe reversi stream
subscriber.subscribe(`misskey:othello-stream:${user._id}`); subscriber.subscribe(`misskey:reversi-stream:${user._id}`);
subscriber.on('message', (_, data) => { subscriber.on('message', (_, data) => {
connection.send(data); connection.send(data);
}); });
@ -22,7 +22,7 @@ export default function(request: websocket.request, connection: websocket.connec
childId: new mongo.ObjectID(msg.id) childId: new mongo.ObjectID(msg.id)
}); });
if (matching == null) return; if (matching == null) return;
publishUserStream(matching.childId, 'othello_invited', await pack(matching, matching.childId)); publishUserStream(matching.childId, 'reversi_invited', await pack(matching, matching.childId));
break; break;
} }
}); });

View File

@ -10,8 +10,8 @@ import userListStream from './stream/user-list';
import driveStream from './stream/drive'; import driveStream from './stream/drive';
import messagingStream from './stream/messaging'; import messagingStream from './stream/messaging';
import messagingIndexStream from './stream/messaging-index'; import messagingIndexStream from './stream/messaging-index';
import othelloGameStream from './stream/othello-game'; import reversiGameStream from './stream/reversi-game';
import othelloStream from './stream/othello'; import reversiStream from './stream/reversi';
import serverStatsStream from './stream/server-stats'; import serverStatsStream from './stream/server-stats';
import notesStatsStream from './stream/notes-stats'; import notesStatsStream from './stream/notes-stats';
import requestsStream from './stream/requests'; import requestsStream from './stream/requests';
@ -56,8 +56,8 @@ module.exports = (server: http.Server) => {
const q = request.resourceURL.query as ParsedUrlQuery; const q = request.resourceURL.query as ParsedUrlQuery;
const [user, app] = await authenticate(q.i as string); const [user, app] = await authenticate(q.i as string);
if (request.resourceURL.pathname === '/othello-game') { if (request.resourceURL.pathname === '/reversi-game') {
othelloGameStream(request, connection, subscriber, user); reversiGameStream(request, connection, subscriber, user);
return; return;
} }
@ -75,7 +75,7 @@ module.exports = (server: http.Server) => {
request.resourceURL.pathname === '/drive' ? driveStream : request.resourceURL.pathname === '/drive' ? driveStream :
request.resourceURL.pathname === '/messaging' ? messagingStream : request.resourceURL.pathname === '/messaging' ? messagingStream :
request.resourceURL.pathname === '/messaging-index' ? messagingIndexStream : request.resourceURL.pathname === '/messaging-index' ? messagingIndexStream :
request.resourceURL.pathname === '/othello' ? othelloStream : request.resourceURL.pathname === '/reversi' ? reversiStream :
null; null;
if (channel !== null) { if (channel !== null) {