mirror of
https://github.com/syuilo/ai.git
synced 2024-11-14 01:37:59 +00:00
Fix bug
This commit is contained in:
parent
f587d4043c
commit
f7f93651d9
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
import * as request from 'request-promise-native';
|
import * as request from 'request-promise-native';
|
||||||
import Reversi, { Color } from 'misskey-reversi';
|
import Reversi, { Color } from 'misskey-reversi';
|
||||||
|
import config from '../../config';
|
||||||
const config = require('../config.json');
|
|
||||||
|
|
||||||
const db = {};
|
const db = {};
|
||||||
|
|
||||||
|
@ -25,6 +24,7 @@ const titles = [
|
||||||
];
|
];
|
||||||
|
|
||||||
class Session {
|
class Session {
|
||||||
|
private account: any;
|
||||||
private game: any;
|
private game: any;
|
||||||
private form: any;
|
private form: any;
|
||||||
private o: Reversi;
|
private o: Reversi;
|
||||||
|
@ -35,14 +35,13 @@ class Session {
|
||||||
*/
|
*/
|
||||||
private cellWeights: number[];
|
private cellWeights: number[];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 対局が開始したことを知らせた投稿
|
* 対局が開始したことを知らせた投稿
|
||||||
*/
|
*/
|
||||||
private startedNote: any = null;
|
private startedNote: any = null;
|
||||||
|
|
||||||
private get user(): any {
|
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 {
|
private get userName(): string {
|
||||||
|
@ -84,6 +83,7 @@ class Session {
|
||||||
private onInit = (msg: any) => {
|
private onInit = (msg: any) => {
|
||||||
this.game = msg.game;
|
this.game = msg.game;
|
||||||
this.form = msg.form;
|
this.form = msg.form;
|
||||||
|
this.account = msg.account;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,7 +195,7 @@ class Session {
|
||||||
|
|
||||||
//#endregion
|
//#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) {
|
if (this.botColor) {
|
||||||
this.think();
|
this.think();
|
||||||
|
@ -220,7 +220,7 @@ class Session {
|
||||||
text = `${this.userName}が投了しちゃいました`;
|
text = `${this.userName}が投了しちゃいました`;
|
||||||
}
|
}
|
||||||
} else if (msg.body.winnerId) {
|
} else if (msg.body.winnerId) {
|
||||||
if (msg.body.winnerId == config.id) {
|
if (msg.body.winnerId == this.account.id) {
|
||||||
if (this.isSettai) {
|
if (this.isSettai) {
|
||||||
text = `${this.userName}に接待で勝ってしまいました...`;
|
text = `${this.userName}に接待で勝ってしまいました...`;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -145,7 +145,8 @@ export default class ReversiModule implements IModule {
|
||||||
ai.send({
|
ai.send({
|
||||||
type: '_init_',
|
type: '_init_',
|
||||||
game,
|
game,
|
||||||
form
|
form,
|
||||||
|
account: this.ai.account
|
||||||
});
|
});
|
||||||
|
|
||||||
ai.on('message', msg => {
|
ai.on('message', msg => {
|
||||||
|
|
Loading…
Reference in a new issue