diff --git a/src/modules/reversi/back.ts b/src/modules/reversi/back.ts index 7259e9e..94c135e 100644 --- a/src/modules/reversi/back.ts +++ b/src/modules/reversi/back.ts @@ -8,8 +8,7 @@ import * as request from 'request-promise-native'; import Reversi, { Color } from 'misskey-reversi'; - -const config = require('../config.json'); +import config from '../../config'; const db = {}; @@ -25,6 +24,7 @@ const titles = [ ]; class Session { + private account: any; private game: any; private form: any; private o: Reversi; @@ -35,14 +35,13 @@ class Session { */ private cellWeights: number[]; - /** * 対局が開始したことを知らせた投稿 */ private startedNote: any = null; private get user(): any { - return this.game.user1Id == config.id ? this.game.user2 : this.game.user1; + return this.game.user1Id == this.account.id ? this.game.user2 : this.game.user1; } private get userName(): string { @@ -84,6 +83,7 @@ class Session { private onInit = (msg: any) => { this.game = msg.game; this.form = msg.form; + this.account = msg.account; } /** @@ -195,7 +195,7 @@ class Session { //#endregion - this.botColor = this.game.user1Id == config.id && this.game.black == 1 || this.game.user2Id == config.id && this.game.black == 2; + this.botColor = this.game.user1Id == this.account.id && this.game.black == 1 || this.game.user2Id == this.account.id && this.game.black == 2; if (this.botColor) { this.think(); @@ -220,7 +220,7 @@ class Session { text = `${this.userName}が投了しちゃいました`; } } else if (msg.body.winnerId) { - if (msg.body.winnerId == config.id) { + if (msg.body.winnerId == this.account.id) { if (this.isSettai) { text = `${this.userName}に接待で勝ってしまいました...`; } else { diff --git a/src/modules/reversi/index.ts b/src/modules/reversi/index.ts index a41a8ee..b3e7ef2 100644 --- a/src/modules/reversi/index.ts +++ b/src/modules/reversi/index.ts @@ -145,7 +145,8 @@ export default class ReversiModule implements IModule { ai.send({ type: '_init_', game, - form + form, + account: this.ai.account }); ai.on('message', msg => {