diff --git a/locales/index.d.ts b/locales/index.d.ts index beace85fbf..b844b26a34 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -10849,6 +10849,14 @@ export interface Locale extends ILocale { * 相手が設定を変更しました */ "opponentHasSettingsChanged": string; + /** + * 変則許可 (完全フリー) + */ + "allowIrregularRules": string; + /** + * 変則なし + */ + "disallowIrregularRules": string; }; "_offlineScreen": { /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 55e0fd944a..a0cef0b93b 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2886,6 +2886,8 @@ _reversi: shareToTlTheGameWhenStart: "開始時に対局をタイムラインに投稿" iStartedAGame: "対局を開始しました! #MisskeyReversi" opponentHasSettingsChanged: "相手が設定を変更しました" + allowIrregularRules: "変則許可 (完全フリー)" + disallowIrregularRules: "変則なし" _offlineScreen: title: "オフライン - サーバーに接続できません" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index aaccd6d6ec..e3b849fc68 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -2804,6 +2804,8 @@ _reversi: shareToTlTheGameWhenStart: "대국 시작 시 타임라인에 대국 게시" iStartedAGame: "대국이 시작되었어요! #MisskeyReversi" opponentHasSettingsChanged: "상대방이 게임 설정을 변경했어요" + allowIrregularRules: "변칙 허용(완전 자유)" + disallowIrregularRules: "변칙 없음" _offlineScreen: title: "오프라인 - 서버에 연결할 수 없음" header: "서버에 연결할 수 없어요" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index ad973adb39..29177641b2 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -2572,6 +2572,11 @@ _reversi: freeMatch: "自由對戰" lookingForPlayer: "正在搜尋對手" gameCanceled: "對弈已被取消" + shareToTlTheGameWhenStart: "在遊戲開始時將對弈資訊發布到時間軸" + iStartedAGame: "對弈開始了! #MisskeyReversi" + opponentHasSettingsChanged: "對手更改了設定" + allowIrregularRules: "允許異常規則(完全自由)" + disallowIrregularRules: "不允許異常規則" _offlineScreen: title: "離線-無法連接伺服器" header: "無法連接伺服器" diff --git a/package.json b/package.json index 8f1d0c6d22..0044a7463a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cherrypick", "version": "4.7.0-beta.1", - "basedMisskeyVersion": "2024.2.0-beta.6", + "basedMisskeyVersion": "2024.2.0-beta.7", "codename": "nasubi", "repository": { "type": "git", diff --git a/packages/backend/migration/1706081514499-reversi-6.js b/packages/backend/migration/1706081514499-reversi-6.js new file mode 100644 index 0000000000..0e2fc8d555 --- /dev/null +++ b/packages/backend/migration/1706081514499-reversi-6.js @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey, cherrypick contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class Reversi61706081514499 { + name = 'Reversi61706081514499' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "reversi_game" ADD "noIrregularRules" boolean NOT NULL DEFAULT false`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "reversi_game" DROP COLUMN "noIrregularRules"`); + } +} diff --git a/packages/backend/src/core/ReversiService.ts b/packages/backend/src/core/ReversiService.ts index cccf18aef5..3b6289dea4 100644 --- a/packages/backend/src/core/ReversiService.ts +++ b/packages/backend/src/core/ReversiService.ts @@ -85,6 +85,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { map: game.map, bw: game.bw, crc32: game.crc32, + noIrregularRules: game.noIrregularRules, } satisfies Partial; } @@ -119,7 +120,9 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { if (invitations.includes(targetUser.id)) { await this.redisClient.zrem(`reversi:matchSpecific:${me.id}`, targetUser.id); - const game = await this.matched(targetUser.id, me.id); + const game = await this.matched(targetUser.id, me.id, { + noIrregularRules: false, + }); return game; } @@ -138,7 +141,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { } @bindThis - public async matchAnyUser(me: MiUser, multiple = false): Promise { + public async matchAnyUser(me: MiUser, options: { noIrregularRules: boolean }, multiple = false): Promise { if (!multiple) { // 既にマッチしている対局が無いか探す(3分以内) const games = await this.reversiGamesRepository.find({ @@ -165,7 +168,9 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { const invitorId = invitations[Math.floor(Math.random() * invitations.length)]; await this.redisClient.zrem(`reversi:matchSpecific:${me.id}`, invitorId); - const game = await this.matched(invitorId, me.id); + const game = await this.matched(invitorId, me.id, { + noIrregularRules: false, + }); return game; } @@ -177,19 +182,29 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { 2, // 自分自身のIDが入っている場合もあるので2つ取得 'REV'); - const userIds = matchings.filter(id => id !== me.id); + const items = matchings.filter(id => !id.startsWith(me.id)); - if (userIds.length > 0) { - const matchedUserId = userIds[0]; + if (items.length > 0) { + const [matchedUserId, option] = items[0].split(':'); - await this.redisClient.zrem('reversi:matchAny', me.id, matchedUserId); + await this.redisClient.zrem('reversi:matchAny', + me.id, + matchedUserId, + me.id + ':noIrregularRules', + matchedUserId + ':noIrregularRules'); - const game = await this.matched(matchedUserId, me.id); + const game = await this.matched(matchedUserId, me.id, { + noIrregularRules: options.noIrregularRules || option === 'noIrregularRules', + }); return game; } else { const redisPipeline = this.redisClient.pipeline(); - redisPipeline.zadd('reversi:matchAny', Date.now(), me.id); + if (options.noIrregularRules) { + redisPipeline.zadd('reversi:matchAny', Date.now(), me.id + ':noIrregularRules'); + } else { + redisPipeline.zadd('reversi:matchAny', Date.now(), me.id); + } redisPipeline.expire('reversi:matchAny', 15, 'NX'); await redisPipeline.exec(); return null; @@ -203,7 +218,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { @bindThis public async matchAnyUserCancel(user: MiUser) { - await this.redisClient.zrem('reversi:matchAny', user.id); + await this.redisClient.zrem('reversi:matchAny', user.id, user.id + ':noIrregularRules'); } @bindThis @@ -265,7 +280,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { } @bindThis - private async matched(parentId: MiUser['id'], childId: MiUser['id']): Promise { + private async matched(parentId: MiUser['id'], childId: MiUser['id'], options: { noIrregularRules: boolean; }): Promise { const game = await this.reversiGamesRepository.insert({ id: this.idService.gen(), user1Id: parentId, @@ -278,6 +293,7 @@ export class ReversiService implements OnApplicationShutdown, OnModuleInit { map: Reversi.maps.eighteight.data, bw: 'random', isLlotheo: false, + noIrregularRules: options.noIrregularRules, }).then(x => this.reversiGamesRepository.findOneOrFail({ where: { id: x.identifiers[0].id }, relations: ['user1', 'user2'], diff --git a/packages/backend/src/core/entities/ReversiGameEntityService.ts b/packages/backend/src/core/entities/ReversiGameEntityService.ts index d7cda35242..baa9cbfce9 100644 --- a/packages/backend/src/core/entities/ReversiGameEntityService.ts +++ b/packages/backend/src/core/entities/ReversiGameEntityService.ts @@ -61,6 +61,7 @@ export class ReversiGameEntityService { canPutEverywhere: game.canPutEverywhere, loopedBoard: game.loopedBoard, timeLimitForEachTurn: game.timeLimitForEachTurn, + noIrregularRules: game.noIrregularRules, logs: game.logs, map: game.map, }); @@ -105,6 +106,7 @@ export class ReversiGameEntityService { canPutEverywhere: game.canPutEverywhere, loopedBoard: game.loopedBoard, timeLimitForEachTurn: game.timeLimitForEachTurn, + noIrregularRules: game.noIrregularRules, }); } diff --git a/packages/backend/src/models/ReversiGame.ts b/packages/backend/src/models/ReversiGame.ts index 11d236e458..c03335dd63 100644 --- a/packages/backend/src/models/ReversiGame.ts +++ b/packages/backend/src/models/ReversiGame.ts @@ -106,6 +106,11 @@ export class MiReversiGame { }) public bw: string; + @Column('boolean', { + default: false, + }) + public noIrregularRules: boolean; + @Column('boolean', { default: false, }) diff --git a/packages/backend/src/models/json-schema/reversi-game.ts b/packages/backend/src/models/json-schema/reversi-game.ts index 3b232a4ade..e153ee5724 100644 --- a/packages/backend/src/models/json-schema/reversi-game.ts +++ b/packages/backend/src/models/json-schema/reversi-game.ts @@ -82,6 +82,10 @@ export const packedReversiGameLiteSchema = { type: 'string', optional: false, nullable: false, }, + noIrregularRules: { + type: 'boolean', + optional: false, nullable: false, + }, isLlotheo: { type: 'boolean', optional: false, nullable: false, @@ -196,6 +200,10 @@ export const packedReversiGameDetailedSchema = { type: 'string', optional: false, nullable: false, }, + noIrregularRules: { + type: 'boolean', + optional: false, nullable: false, + }, isLlotheo: { type: 'boolean', optional: false, nullable: false, diff --git a/packages/backend/src/server/api/endpoints/reversi/match.ts b/packages/backend/src/server/api/endpoints/reversi/match.ts index 33925eb9d1..04543d6288 100644 --- a/packages/backend/src/server/api/endpoints/reversi/match.ts +++ b/packages/backend/src/server/api/endpoints/reversi/match.ts @@ -37,6 +37,7 @@ export const paramDef = { type: 'object', properties: { userId: { type: 'string', format: 'misskey:id', nullable: true }, + noIrregularRules: { type: 'boolean', default: false }, multiple: { type: 'boolean', default: false }, }, required: [], @@ -57,7 +58,9 @@ export default class extends Endpoint { // eslint- throw err; }) : null; - const game = target ? await this.reversiService.matchSpecificUser(me, target, ps.multiple) : await this.reversiService.matchAnyUser(me, ps.multiple); + const game = target + ? await this.reversiService.matchSpecificUser(me, target, ps.multiple) + : await this.reversiService.matchAnyUser(me, { noIrregularRules: ps.noIrregularRules }, ps.multiple); if (game == null) return; diff --git a/packages/cherrypick-js/src/autogen/apiClientJSDoc.ts b/packages/cherrypick-js/src/autogen/apiClientJSDoc.ts index 8306ef19f2..43fb850783 100644 --- a/packages/cherrypick-js/src/autogen/apiClientJSDoc.ts +++ b/packages/cherrypick-js/src/autogen/apiClientJSDoc.ts @@ -1,7 +1,7 @@ /* * version: 4.7.0-beta.1 - * basedMisskeyVersion: 2024.2.0-beta.6 - * generatedAt: 2024-01-24T08:25:14.507Z + * basedMisskeyVersion: 2024.2.0-beta.7 + * generatedAt: 2024-01-25T07:07:45.745Z */ import type { SwitchCaseResponseType } from '../api.js'; diff --git a/packages/cherrypick-js/src/autogen/endpoint.ts b/packages/cherrypick-js/src/autogen/endpoint.ts index bdebb7c324..5f1999ecd1 100644 --- a/packages/cherrypick-js/src/autogen/endpoint.ts +++ b/packages/cherrypick-js/src/autogen/endpoint.ts @@ -1,7 +1,7 @@ /* * version: 4.7.0-beta.1 - * basedMisskeyVersion: 2024.2.0-beta.6 - * generatedAt: 2024-01-24T08:25:14.505Z + * basedMisskeyVersion: 2024.2.0-beta.7 + * generatedAt: 2024-01-25T07:07:45.742Z */ import type { diff --git a/packages/cherrypick-js/src/autogen/entities.ts b/packages/cherrypick-js/src/autogen/entities.ts index 415fbf5c39..ce0c2c5ac4 100644 --- a/packages/cherrypick-js/src/autogen/entities.ts +++ b/packages/cherrypick-js/src/autogen/entities.ts @@ -1,7 +1,7 @@ /* * version: 4.7.0-beta.1 - * basedMisskeyVersion: 2024.2.0-beta.6 - * generatedAt: 2024-01-24T08:25:14.504Z + * basedMisskeyVersion: 2024.2.0-beta.7 + * generatedAt: 2024-01-25T07:07:45.740Z */ import { operations } from './types.js'; diff --git a/packages/cherrypick-js/src/autogen/models.ts b/packages/cherrypick-js/src/autogen/models.ts index 386abae149..f57d26e24d 100644 --- a/packages/cherrypick-js/src/autogen/models.ts +++ b/packages/cherrypick-js/src/autogen/models.ts @@ -1,7 +1,7 @@ /* * version: 4.7.0-beta.1 - * basedMisskeyVersion: 2024.2.0-beta.6 - * generatedAt: 2024-01-24T08:25:14.503Z + * basedMisskeyVersion: 2024.2.0-beta.7 + * generatedAt: 2024-01-25T07:07:45.738Z */ import { components } from './types.js'; diff --git a/packages/cherrypick-js/src/autogen/types.ts b/packages/cherrypick-js/src/autogen/types.ts index 48406274ac..ee39245881 100644 --- a/packages/cherrypick-js/src/autogen/types.ts +++ b/packages/cherrypick-js/src/autogen/types.ts @@ -3,8 +3,8 @@ /* * version: 4.7.0-beta.1 - * basedMisskeyVersion: 2024.2.0-beta.6 - * generatedAt: 2024-01-24T08:25:14.421Z + * basedMisskeyVersion: 2024.2.0-beta.7 + * generatedAt: 2024-01-25T07:07:45.651Z */ /** @@ -4826,6 +4826,7 @@ export type components = { timeoutUserId: string | null; black: number | null; bw: string; + noIrregularRules: boolean; isLlotheo: boolean; canPutEverywhere: boolean; loopedBoard: boolean; @@ -4861,6 +4862,7 @@ export type components = { timeoutUserId: string | null; black: number | null; bw: string; + noIrregularRules: boolean; isLlotheo: boolean; canPutEverywhere: boolean; loopedBoard: boolean; @@ -27992,6 +27994,8 @@ export type operations = { /** Format: misskey:id */ userId?: string | null; /** @default false */ + noIrregularRules?: boolean; + /** @default false */ multiple?: boolean; }; }; diff --git a/packages/frontend/src/pages/reversi/game.setting.vue b/packages/frontend/src/pages/reversi/game.setting.vue index a2f3e808fb..3859721782 100644 --- a/packages/frontend/src/pages/reversi/game.setting.vue +++ b/packages/frontend/src/pages/reversi/game.setting.vue @@ -12,69 +12,74 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts._reversi.gameSettings }}
-
-
-
{{ mapName }}
- {{ i18n.ts._reversi.chooseBoard }} -
+ +
diff --git a/packages/frontend/src/pages/reversi/index.vue b/packages/frontend/src/pages/reversi/index.vue index eba2f68cdc..041ef36e59 100644 --- a/packages/frontend/src/pages/reversi/index.vue +++ b/packages/frontend/src/pages/reversi/index.vue @@ -157,6 +157,7 @@ if ($i) { const invitations = ref([]); const matchingUser = ref(null); const matchingAny = ref(false); +const noIrregularRules = ref(false); function startGame(game: Misskey.entities.ReversiGameDetailed) { matchingUser.value = null; @@ -182,6 +183,7 @@ async function matchHeatbeat() { } else if (matchingAny.value) { const res = await misskeyApi('reversi/match', { userId: null, + noIrregularRules: noIrregularRules.value, }); if (res != null) { @@ -199,10 +201,22 @@ async function matchUser() { matchHeatbeat(); } -async function matchAny() { - matchingAny.value = true; - - matchHeatbeat(); +function matchAny(ev: MouseEvent) { + os.popupMenu([{ + text: i18n.ts._reversi.allowIrregularRules, + action: () => { + noIrregularRules.value = false; + matchingAny.value = true; + matchHeatbeat(); + }, + }, { + text: i18n.ts._reversi.disallowIrregularRules, + action: () => { + noIrregularRules.value = true; + matchingAny.value = true; + matchHeatbeat(); + }, + }], ev.currentTarget ?? ev.target); } function cancelMatching() {