1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-18 01:25:47 +02:00
This commit is contained in:
syuilo
2024-01-18 16:10:28 +09:00
parent 36450d7fac
commit 768d0bdc00
3 changed files with 37 additions and 86 deletions

View File

@@ -137,7 +137,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
user1Accepted: isAccepted,
});
this.globalEventService.publishReversiGameStream(game.id, 'changeAccepts', {
this.globalEventService.publishReversiGameStream(game.id, 'changeAcceptingStates', {
user1: isAccepted,
user2: game.user2Accepted,
});
@@ -148,7 +148,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
user2Accepted: isAccepted,
});
this.globalEventService.publishReversiGameStream(game.id, 'changeAccepts', {
this.globalEventService.publishReversiGameStream(game.id, 'changeAcceptingStates', {
user1: game.user1Accepted,
user2: isAccepted,
});
@@ -216,12 +216,32 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit {
}
//#endregion
this.globalEventService.publishReversiGameStream(game.id, 'started',
await this.reversiGameEntityService.pack(game.id, user));
this.globalEventService.publishReversiGameStream(game.id, 'started', {
game: await this.reversiGameEntityService.pack(game.id, user),
});
}, 3000);
}
}
@bindThis
public async updateSettings(game: MiReversiGame, user: MiUser, key: string, value: any) {
if (game.isStarted) return;
if ((game.user1Id !== user.id) && (game.user2Id !== user.id)) return;
if ((game.user1Id === user.id) && game.user1Accepted) return;
if ((game.user2Id === user.id) && game.user2Accepted) return;
if (!['map', 'bw', 'isLlotheo', 'canPutEverywhere', 'loopedBoard'].includes(key)) return;
await this.reversiGamesRepository.update(game.id, {
[key]: value,
});
this.globalEventService.publishReversiGameStream(game.id, 'updateSettings', {
key: key,
value: value,
});
}
@bindThis
public async putStoneToGame(game: MiReversiGame, user: MiUser, pos: number) {
if (!game.isStarted) return;