This commit is contained in:
syuilo 2018-08-15 03:43:44 +09:00
parent f587d4043c
commit f7f93651d9
2 changed files with 8 additions and 7 deletions

View file

@ -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 {

View file

@ -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 => {