diff --git a/CHANGELOG.md b/CHANGELOG.md index 82b029438d..381d2accd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ - Enhance: ハッシュタグ入力時に、本文の末尾の行に何も書かれていない場合は新たにスペースを追加しないように - Enhance: チャンネルノートのピン留めをノートのメニューからできるように - Enhance: 管理者の場合はAPI tokenの発行画面で管理機能に関する権限を付与できるように +- Enhance: AiScriptを0.17.0に更新 [CHANGELOG](https://github.com/aiscript-dev/aiscript/blob/bb89d132b633a622d3cb0eff0d0cc7e476c0cfdd/CHANGELOG.md) + - 配列の範囲外・非整数のインデックスへの代入が完全禁止になるので注意 +- Enhance: 絵文字ピッカー・オートコンプリートで、完全一致した絵文字を優先的に表示するように - Fix: ネイティブモードの絵文字がモノクロにならないように - Fix: v2023.12.0で追加された「モデレーターがユーザーのアイコンもしくはバナー画像を未設定状態にできる機能」が管理画面上で正しく表示されていない問題を修正 - Fix: AiScriptの`readline`関数が不正な値を返すことがある問題のv2023.12.0時点での修正がPlay以外に適用されていないのを修正 diff --git a/locales/index.d.ts b/locales/index.d.ts index 449864cbfc..92df106ff1 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1206,11 +1206,20 @@ export interface Locale { "showReplay": string; "replay": string; "replaying": string; + "ranking": string; "abuseReportCategory": string; "selectCategory": string; "reportComplete": string; "blockThisUser": string; "muteThisUser": string; + "_bubbleGame": { + "howToPlay": string; + "_howToPlay": { + "section1": string; + "section2": string; + "section3": string; + }; + }; "_abuseReportMsgs": { "rightsAbuseCantAccept": string; }; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 666bf95891..d62d4a3fe2 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1203,12 +1203,20 @@ soundWillBePlayed: "サウンドが再生されます" showReplay: "リプレイを見る" replay: "リプレイ" replaying: "リプレイ中" +ranking: "ランキング" abuseReportCategory: "通報の種類" selectCategory: "カテゴリを選択" reportComplete: "通報完了" blockThisUser: "このユーザーをブロックする" muteThisUser: "このユーザーをミュートする" +_bubbleGame: + howToPlay: "遊び方" + _howToPlay: + section1: "位置を調整してハコにモノを落とします。" + section2: "同じ種類のモノがくっつくと別のモノに変化して、スコアが得られます。" + section3: "モノがハコからあふれるとゲームオーバーです。ハコからあふれないようにしつつモノを融合させてハイスコアを目指そう!" + _abuseReportMsgs: rightsAbuseCantAccept: "申し訳ございません。権利侵害の通報は権利者ご本人からのみ受け付けております。" diff --git a/packages/backend/migration/1704959805077-bubble-game-record.js b/packages/backend/migration/1704959805077-bubble-game-record.js new file mode 100644 index 0000000000..cc45b09c82 --- /dev/null +++ b/packages/backend/migration/1704959805077-bubble-game-record.js @@ -0,0 +1,24 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class BubbleGameRecord1704959805077 { + name = 'BubbleGameRecord1704959805077' + + async up(queryRunner) { + await queryRunner.query(`CREATE TABLE "bubble_game_record" ("id" character varying(32) NOT NULL, "userId" character varying(32) NOT NULL, "seededAt" TIMESTAMP WITH TIME ZONE NOT NULL, "seed" character varying(1024) NOT NULL, "gameVersion" integer NOT NULL, "gameMode" character varying(128) NOT NULL, "score" integer NOT NULL, "logs" jsonb NOT NULL DEFAULT '[]', "isVerified" boolean NOT NULL DEFAULT false, CONSTRAINT "PK_a75395fe404b392e2893b50d7ea" PRIMARY KEY ("id"))`); + await queryRunner.query(`CREATE INDEX "IDX_75276757070d21fdfaf4c05290" ON "bubble_game_record" ("userId") `); + await queryRunner.query(`CREATE INDEX "IDX_4ae7053179014915d1432d3f40" ON "bubble_game_record" ("seededAt") `); + await queryRunner.query(`CREATE INDEX "IDX_26d4ee490b5a487142d35466ee" ON "bubble_game_record" ("score") `); + await queryRunner.query(`ALTER TABLE "bubble_game_record" ADD CONSTRAINT "FK_75276757070d21fdfaf4c052909" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "bubble_game_record" DROP CONSTRAINT "FK_75276757070d21fdfaf4c052909"`); + await queryRunner.query(`DROP INDEX "public"."IDX_26d4ee490b5a487142d35466ee"`); + await queryRunner.query(`DROP INDEX "public"."IDX_4ae7053179014915d1432d3f40"`); + await queryRunner.query(`DROP INDEX "public"."IDX_75276757070d21fdfaf4c05290"`); + await queryRunner.query(`DROP TABLE "bubble_game_record"`); + } +} diff --git a/packages/backend/src/di-symbols.ts b/packages/backend/src/di-symbols.ts index 8403f80659..162084d395 100644 --- a/packages/backend/src/di-symbols.ts +++ b/packages/backend/src/di-symbols.ts @@ -79,5 +79,6 @@ export const DI = { flashsRepository: Symbol('flashsRepository'), flashLikesRepository: Symbol('flashLikesRepository'), userMemosRepository: Symbol('userMemosRepository'), + bubbleGameRecordsRepository: Symbol('bubbleGameRecordsRepository'), //#endregion }; diff --git a/packages/backend/src/models/BubbleGameRecord.ts b/packages/backend/src/models/BubbleGameRecord.ts new file mode 100644 index 0000000000..4b483ed4d3 --- /dev/null +++ b/packages/backend/src/models/BubbleGameRecord.ts @@ -0,0 +1,57 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm'; +import { id } from './util/id.js'; +import { MiUser } from './User.js'; + +@Entity('bubble_game_record') +export class MiBubbleGameRecord { + @PrimaryColumn(id()) + public id: string; + + @Index() + @Column({ + ...id(), + }) + public userId: MiUser['id']; + + @ManyToOne(type => MiUser, { + onDelete: 'CASCADE', + }) + @JoinColumn() + public user: MiUser | null; + + @Index() + @Column('timestamp with time zone') + public seededAt: Date; + + @Column('varchar', { + length: 1024, + }) + public seed: string; + + @Column('integer') + public gameVersion: number; + + @Column('varchar', { + length: 128, + }) + public gameMode: string; + + @Index() + @Column('integer') + public score: number; + + @Column('jsonb', { + default: [], + }) + public logs: any[]; + + @Column('boolean', { + default: false, + }) + public isVerified: boolean; +} diff --git a/packages/backend/src/models/RepositoryModule.ts b/packages/backend/src/models/RepositoryModule.ts index 3ee2f0e7a3..74dad69f6e 100644 --- a/packages/backend/src/models/RepositoryModule.ts +++ b/packages/backend/src/models/RepositoryModule.ts @@ -5,7 +5,7 @@ import { Module } from '@nestjs/common'; import { DI } from '@/di-symbols.js'; -import { MiAbuseReportResolver, MiAbuseUserReport, MiAccessToken, MiAd, MiAnnouncement, MiAnnouncementRead, MiAntenna, MiApp, MiAuthSession, MiAvatarDecoration, MiBlocking, MiChannel, MiChannelFavorite, MiChannelFollowing, MiClip, MiClipFavorite, MiClipNote, MiDriveFile, MiDriveFolder, MiEmoji, MiFlash, MiFlashLike, MiFollowRequest, MiFollowing, MiGalleryLike, MiGalleryPost, MiHashtag, MiInstance, MiMeta, MiModerationLog, MiMuting, MiNote, MiNoteFavorite, MiNoteReaction, MiNoteThreadMuting, MiNoteUnread, MiPage, MiPageLike, MiPasswordResetRequest, MiPoll, MiPollVote, MiPromoNote, MiPromoRead, MiRegistrationTicket, MiRegistryItem, MiRelay, MiRenoteMuting, MiRetentionAggregation, MiRole, MiRoleAssignment, MiSignin, MiSwSubscription, MiUsedUsername, MiUser, MiUserIp, MiUserKeypair, MiUserList, MiUserListFavorite, MiUserListMembership, MiUserMemo, MiUserNotePining, MiUserPending, MiUserProfile, MiUserPublickey, MiUserSecurityKey, MiWebhook } from './_.js'; +import { MiAbuseReportResolver, MiAbuseUserReport, MiAccessToken, MiAd, MiAnnouncement, MiAnnouncementRead, MiAntenna, MiApp, MiAuthSession, MiAvatarDecoration, MiBlocking, MiChannel, MiChannelFavorite, MiChannelFollowing, MiClip, MiClipFavorite, MiClipNote, MiDriveFile, MiDriveFolder, MiEmoji, MiFlash, MiFlashLike, MiFollowRequest, MiFollowing, MiGalleryLike, MiGalleryPost, MiHashtag, MiInstance, MiMeta, MiModerationLog, MiMuting, MiNote, MiNoteFavorite, MiNoteReaction, MiNoteThreadMuting, MiNoteUnread, MiPage, MiPageLike, MiPasswordResetRequest, MiPoll, MiPollVote, MiPromoNote, MiPromoRead, MiRegistrationTicket, MiRegistryItem, MiRelay, MiRenoteMuting, MiRetentionAggregation, MiRole, MiRoleAssignment, MiSignin, MiSwSubscription, MiUsedUsername, MiUser, MiUserIp, MiUserKeypair, MiUserList, MiUserListFavorite, MiUserListMembership, MiUserMemo, MiUserNotePining, MiUserPending, MiUserProfile, MiUserPublickey, MiUserSecurityKey, MiWebhook, MiBubbleGameRecord } from './_.js'; import type { DataSource } from 'typeorm'; import type { Provider } from '@nestjs/common'; @@ -399,6 +399,12 @@ const $userMemosRepository: Provider = { inject: [DI.db], }; +export const $bubbleGameRecordsRepository: Provider = { + provide: DI.bubbleGameRecordsRepository, + useFactory: (db: DataSource) => db.getRepository(MiBubbleGameRecord), + inject: [DI.db], +}; + const $abuseReportResolversRepository: Provider = { provide: DI.abuseReportResolversRepository, useFactory: (db: DataSource) => db.getRepository(MiAbuseReportResolver), @@ -474,6 +480,7 @@ const $abuseReportResolversRepository: Provider = { $flashsRepository, $flashLikesRepository, $userMemosRepository, + $bubbleGameRecordsRepository, $abuseReportResolversRepository, ], exports: [ @@ -542,6 +549,7 @@ const $abuseReportResolversRepository: Provider = { $flashsRepository, $flashLikesRepository, $userMemosRepository, + $bubbleGameRecordsRepository, $abuseReportResolversRepository, ], }) diff --git a/packages/backend/src/models/_.ts b/packages/backend/src/models/_.ts index 2a0ae382fe..900b393a41 100644 --- a/packages/backend/src/models/_.ts +++ b/packages/backend/src/models/_.ts @@ -69,6 +69,7 @@ import { MiRoleAssignment } from '@/models/RoleAssignment.js'; import { MiFlash } from '@/models/Flash.js'; import { MiFlashLike } from '@/models/FlashLike.js'; import { MiUserListFavorite } from '@/models/UserListFavorite.js'; +import { MiBubbleGameRecord } from '@/models/BubbleGameRecord.js'; import type { Repository } from 'typeorm'; export { @@ -138,6 +139,7 @@ export { MiFlash, MiFlashLike, MiUserMemo, + MiBubbleGameRecord, }; export type AbuseReportResolversRepository = Repository; @@ -206,3 +208,4 @@ export type RoleAssignmentsRepository = Repository; export type FlashsRepository = Repository; export type FlashLikesRepository = Repository; export type UserMemoRepository = Repository; +export type BubbleGameRecordsRepository = Repository; diff --git a/packages/backend/src/postgres.ts b/packages/backend/src/postgres.ts index fa5ce55da3..6499dc5f05 100644 --- a/packages/backend/src/postgres.ts +++ b/packages/backend/src/postgres.ts @@ -77,6 +77,7 @@ import { MiRoleAssignment } from '@/models/RoleAssignment.js'; import { MiFlash } from '@/models/Flash.js'; import { MiFlashLike } from '@/models/FlashLike.js'; import { MiUserMemo } from '@/models/UserMemo.js'; +import { MiBubbleGameRecord } from '@/models/BubbleGameRecord.js'; import { Config } from '@/config.js'; import MisskeyLogger from '@/logger.js'; @@ -192,6 +193,7 @@ export const entities = [ MiFlash, MiFlashLike, MiUserMemo, + MiBubbleGameRecord, ...charts, ]; diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index c74c6d9beb..a9ae05f2dd 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -369,6 +369,8 @@ import * as ep___users_updateMemo from './endpoints/users/update-memo.js'; import * as ep___fetchRss from './endpoints/fetch-rss.js'; import * as ep___fetchExternalResources from './endpoints/fetch-external-resources.js'; import * as ep___retention from './endpoints/retention.js'; +import * as ep___bubbleGame_register from './endpoints/bubble-game/register.js'; +import * as ep___bubbleGame_ranking from './endpoints/bubble-game/ranking.js'; import { GetterService } from './GetterService.js'; import { ApiLoggerService } from './ApiLoggerService.js'; import type { Provider } from '@nestjs/common'; @@ -736,6 +738,8 @@ const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass: const $fetchRss: Provider = { provide: 'ep:fetch-rss', useClass: ep___fetchRss.default }; const $fetchExternalResources: Provider = { provide: 'ep:fetch-external-resources', useClass: ep___fetchExternalResources.default }; const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention.default }; +const $bubbleGame_register: Provider = { provide: 'ep:bubble-game/register', useClass: ep___bubbleGame_register.default }; +const $bubbleGame_ranking: Provider = { provide: 'ep:bubble-game/ranking', useClass: ep___bubbleGame_ranking.default }; @Module({ imports: [ @@ -1107,6 +1111,8 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $fetchRss, $fetchExternalResources, $retention, + $bubbleGame_register, + $bubbleGame_ranking, ], exports: [ $admin_meta, @@ -1469,6 +1475,8 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $fetchRss, $fetchExternalResources, $retention, + $bubbleGame_register, + $bubbleGame_ranking, ], }) export class EndpointsModule {} diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 5c3533ab28..8111877bda 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -370,6 +370,8 @@ import * as ep___users_updateMemo from './endpoints/users/update-memo.js'; import * as ep___fetchRss from './endpoints/fetch-rss.js'; import * as ep___fetchExternalResources from './endpoints/fetch-external-resources.js'; import * as ep___retention from './endpoints/retention.js'; +import * as ep___bubbleGame_register from './endpoints/bubble-game/register.js'; +import * as ep___bubbleGame_ranking from './endpoints/bubble-game/ranking.js'; const eps = [ ['admin/meta', ep___admin_meta], @@ -735,6 +737,8 @@ const eps = [ ['fetch-rss', ep___fetchRss], ['fetch-external-resources', ep___fetchExternalResources], ['retention', ep___retention], + ['bubble-game/register', ep___bubbleGame_register], + ['bubble-game/ranking', ep___bubbleGame_ranking], ]; interface IEndpointMetaBase { diff --git a/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts b/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts new file mode 100644 index 0000000000..9c057760ca --- /dev/null +++ b/packages/backend/src/server/api/endpoints/bubble-game/ranking.ts @@ -0,0 +1,73 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { Inject, Injectable } from '@nestjs/common'; +import { MoreThan } from 'typeorm'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import type { BubbleGameRecordsRepository } from '@/models/_.js'; +import { DI } from '@/di-symbols.js'; +import { UserEntityService } from '@/core/entities/UserEntityService.js'; + +export const meta = { + allowGet: true, + cacheSec: 60, + + errors: { + }, + + res: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + properties: { + id: { type: 'string', format: 'misskey:id' }, + score: { type: 'integer' }, + user: { ref: 'UserLite' }, + }, + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + gameMode: { type: 'string' }, + }, + required: ['gameMode'], +} as const; + +@Injectable() +export default class extends Endpoint { // eslint-disable-line import/no-default-export + constructor( + @Inject(DI.bubbleGameRecordsRepository) + private bubbleGameRecordsRepository: BubbleGameRecordsRepository, + + private userEntityService: UserEntityService, + ) { + super(meta, paramDef, async (ps) => { + const records = await this.bubbleGameRecordsRepository.find({ + where: { + gameMode: ps.gameMode, + seededAt: MoreThan(new Date(Date.now() - 1000 * 60 * 60 * 24 * 7)), + }, + order: { + score: 'DESC', + }, + take: 10, + relations: ['user'], + }); + + const users = await this.userEntityService.packMany(records.map(r => r.user!), null, { detail: false }); + + return records.map(r => ({ + id: r.id, + score: r.score, + user: users.find(u => u.id === r.user!.id), + })); + }); + } +} diff --git a/packages/backend/src/server/api/endpoints/bubble-game/register.ts b/packages/backend/src/server/api/endpoints/bubble-game/register.ts new file mode 100644 index 0000000000..f092d16a70 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/bubble-game/register.ts @@ -0,0 +1,84 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { Inject, Injectable } from '@nestjs/common'; +import ms from 'ms'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { IdService } from '@/core/IdService.js'; +import type { BubbleGameRecordsRepository } from '@/models/_.js'; +import { DI } from '@/di-symbols.js'; +import { ApiError } from '../../error.js'; + +export const meta = { + requireCredential: true, + + kind: 'write:account', + + limit: { + duration: ms('1hour'), + max: 120, + minInterval: ms('30sec'), + }, + + errors: { + invalidSeed: { + message: 'Provided seed is invalid.', + code: 'INVALID_SEED', + id: 'eb627bc7-574b-4a52-a860-3c3eae772b88', + }, + }, + + res: { + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + score: { type: 'integer', minimum: 0 }, + seed: { type: 'string', minLength: 1, maxLength: 1024 }, + logs: { type: 'array' }, + gameMode: { type: 'string' }, + gameVersion: { type: 'integer' }, + }, + required: ['score', 'seed', 'logs', 'gameMode', 'gameVersion'], +} as const; + +@Injectable() +export default class extends Endpoint { // eslint-disable-line import/no-default-export + constructor( + @Inject(DI.bubbleGameRecordsRepository) + private bubbleGameRecordsRepository: BubbleGameRecordsRepository, + + private idService: IdService, + ) { + super(meta, paramDef, async (ps, me) => { + const seedDate = new Date(parseInt(ps.seed, 10)); + const now = new Date(); + + // シードが未来なのは通常のプレイではありえないので弾く + if (seedDate.getTime() > now.getTime()) { + throw new ApiError(meta.errors.invalidSeed); + } + + // シードが古すぎる(1時間以上前)のも弾く + if (seedDate.getTime() < now.getTime() - 1000 * 60 * 60) { + throw new ApiError(meta.errors.invalidSeed); + } + + await this.bubbleGameRecordsRepository.insert({ + id: this.idService.gen(now.getTime()), + seed: ps.seed, + seededAt: seedDate, + userId: me.id, + score: ps.score, + logs: ps.logs, + gameMode: ps.gameMode, + gameVersion: ps.gameVersion, + isVerified: false, + }); + }); + } +} diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 8598048f3a..40db4fbc25 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -25,7 +25,7 @@ "@rollup/plugin-replace": "5.0.5", "@rollup/plugin-typescript": "11.1.5", "@rollup/pluginutils": "5.1.0", - "@syuilo/aiscript": "0.16.0", + "@syuilo/aiscript": "0.17.0", "@tabler/icons-webfont": "2.44.0", "@twemoji/parser": "15.0.0", "@vitejs/plugin-vue": "5.0.2", diff --git a/packages/frontend/src/pages/drop-and-fusion.game.vue b/packages/frontend/src/pages/drop-and-fusion.game.vue new file mode 100644 index 0000000000..c222fdeb40 --- /dev/null +++ b/packages/frontend/src/pages/drop-and-fusion.game.vue @@ -0,0 +1,1221 @@ + + + + + + + diff --git a/packages/frontend/src/pages/drop-and-fusion.vue b/packages/frontend/src/pages/drop-and-fusion.vue index d041a675f8..0938ca6a87 100644 --- a/packages/frontend/src/pages/drop-and-fusion.vue +++ b/packages/frontend/src/pages/drop-and-fusion.vue @@ -4,17 +4,23 @@ SPDX-License-Identifier: AGPL-3.0-only --> diff --git a/packages/frontend/src/scripts/drop-and-fusion-engine.ts b/packages/frontend/src/scripts/drop-and-fusion-engine.ts index 16fe87d97a..41af9cb7a4 100644 --- a/packages/frontend/src/scripts/drop-and-fusion-engine.ts +++ b/packages/frontend/src/scripts/drop-and-fusion-engine.ts @@ -6,7 +6,6 @@ import { EventEmitter } from 'eventemitter3'; import * as Matter from 'matter-js'; import seedrandom from 'seedrandom'; -import * as sound from '@/scripts/sound.js'; export type Mono = { id: string; @@ -38,45 +37,47 @@ export class DropAndFusionGame extends EventEmitter<{ changeCombo: (newCombo: number) => void; changeStock: (newStock: { id: string; mono: Mono }[]) => void; changeHolding: (newHolding: { id: string; mono: Mono } | null) => void; - dropped: () => void; + dropped: (x: number) => void; fusioned: (x: number, y: number, scoreDelta: number) => void; monoAdded: (mono: Mono) => void; gameOver: () => void; + sfx(type: string, params: { volume: number; pan: number; pitch: number; }): void; }> { private PHYSICS_QUALITY_FACTOR = 16; // 低いほどパフォーマンスが高いがガタガタして安定しなくなる、逆に高すぎても何故か不安定になる - private COMBO_INTERVAL = 1000; + private COMBO_INTERVAL = 60; // frame + public readonly GAME_VERSION = 1; + public readonly GAME_WIDTH = 450; + public readonly GAME_HEIGHT = 600; public readonly DROP_INTERVAL = 500; public readonly PLAYAREA_MARGIN = 25; private STOCK_MAX = 4; private TICK_DELTA = 1000 / 60; // 60fps - private loaded = false; - private frame = 0; - private engine: Matter.Engine; - private render: Matter.Render; - private tickRaf: ReturnType | null = null; + + public frame = 0; + public engine: Matter.Engine; private tickCallbackQueue: { frame: number; callback: () => void; }[] = []; private overflowCollider: Matter.Body; private isGameOver = false; - private gameWidth: number; - private gameHeight: number; private monoDefinitions: Mono[] = []; - private monoTextures: Record = {}; - private monoTextureUrls: Record = {}; private rng: () => number; private logs: Log[] = []; private replaying = false; - private sfxVolume = 1; - /** * フィールドに出ていて、かつ合体の対象となるアイテム */ private activeBodyIds: Matter.Body['id'][] = []; + /** + * fusion予約アイテムのペア + * TODO: これらのモノは光らせるなどの演出をすると視覚的に楽しそう + */ + private fusionReservedPairs: { bodyA: Matter.Body; bodyB: Matter.Body }[] = []; + private latestDroppedBodyId: Matter.Body['id'] | null = null; private latestDroppedAt = 0; - private latestFusionedAt = 0; + private latestFusionedAt = 0; // frame private stock: { id: string; mono: Mono }[] = []; private holding: { id: string; mono: Mono } | null = null; @@ -98,29 +99,17 @@ export class DropAndFusionGame extends EventEmitter<{ this.emit('changeScore', value); } - private comboIntervalId: number | null = null; + public replayPlaybackRate = 1; - constructor(opts: { - canvas: HTMLCanvasElement; - width: number; - height: number; - monoDefinitions: Mono[]; - seed: string; - sfxVolume?: number; - }) { + constructor(env: { monoDefinitions: Mono[]; seed: string; replaying?: boolean }) { super(); + this.replaying = !!env.replaying; + this.monoDefinitions = env.monoDefinitions; + this.rng = seedrandom(env.seed); + this.tick = this.tick.bind(this); - this.gameWidth = opts.width; - this.gameHeight = opts.height; - this.monoDefinitions = opts.monoDefinitions; - this.rng = seedrandom(opts.seed); - - if (opts.sfxVolume) { - this.sfxVolume = opts.sfxVolume; - } - this.engine = Matter.Engine.create({ constraintIterations: 2 * this.PHYSICS_QUALITY_FACTOR, positionIterations: 6 * this.PHYSICS_QUALITY_FACTOR, @@ -135,26 +124,11 @@ export class DropAndFusionGame extends EventEmitter<{ enableSleeping: false, }); - this.render = Matter.Render.create({ - engine: this.engine, - canvas: opts.canvas, - options: { - width: this.gameWidth, - height: this.gameHeight, - background: 'transparent', // transparent to hide - wireframeBackground: 'transparent', // transparent to hide - wireframes: false, - showSleeping: false, - pixelRatio: Math.max(2, window.devicePixelRatio), - }, - }); - - Matter.Render.run(this.render); - this.engine.world.bodies = []; //#region walls const WALL_OPTIONS: Matter.IChamferableBodyDefinition = { + label: '_wall_', isStatic: true, friction: 0.7, slop: 1.0, @@ -166,13 +140,13 @@ export class DropAndFusionGame extends EventEmitter<{ const thickness = 100; Matter.Composite.add(this.engine.world, [ - Matter.Bodies.rectangle(this.gameWidth / 2, this.gameHeight + (thickness / 2) - this.PLAYAREA_MARGIN, this.gameWidth, thickness, WALL_OPTIONS), - Matter.Bodies.rectangle(this.gameWidth + (thickness / 2) - this.PLAYAREA_MARGIN, this.gameHeight / 2, thickness, this.gameHeight, WALL_OPTIONS), - Matter.Bodies.rectangle(-((thickness / 2) - this.PLAYAREA_MARGIN), this.gameHeight / 2, thickness, this.gameHeight, WALL_OPTIONS), + Matter.Bodies.rectangle(this.GAME_WIDTH / 2, this.GAME_HEIGHT + (thickness / 2) - this.PLAYAREA_MARGIN, this.GAME_WIDTH, thickness, WALL_OPTIONS), + Matter.Bodies.rectangle(this.GAME_WIDTH + (thickness / 2) - this.PLAYAREA_MARGIN, this.GAME_HEIGHT / 2, thickness, this.GAME_HEIGHT, WALL_OPTIONS), + Matter.Bodies.rectangle(-((thickness / 2) - this.PLAYAREA_MARGIN), this.GAME_HEIGHT / 2, thickness, this.GAME_HEIGHT, WALL_OPTIONS), ]); //#endregion - this.overflowCollider = Matter.Bodies.rectangle(this.gameWidth / 2, 0, this.gameWidth, 200, { + this.overflowCollider = Matter.Bodies.rectangle(this.GAME_WIDTH / 2, 0, this.GAME_WIDTH, 200, { isStatic: true, isSensor: true, render: { @@ -181,12 +155,10 @@ export class DropAndFusionGame extends EventEmitter<{ }, }); Matter.Composite.add(this.engine.world, this.overflowCollider); + } - // fit the render viewport to the scene - Matter.Render.lookAt(this.render, { - min: { x: 0, y: 0 }, - max: { x: this.gameWidth, y: this.gameHeight }, - }); + private msToFrame(ms: number) { + return Math.round(ms / this.TICK_DELTA); } private createBody(mono: Mono, x: number, y: number) { @@ -219,13 +191,12 @@ export class DropAndFusionGame extends EventEmitter<{ } private fusion(bodyA: Matter.Body, bodyB: Matter.Body) { - const now = Date.now(); - if (this.latestFusionedAt > now - this.COMBO_INTERVAL) { + if (this.latestFusionedAt > this.frame - this.COMBO_INTERVAL) { this.combo++; } else { this.combo = 1; } - this.latestFusionedAt = now; + this.latestFusionedAt = this.frame; // TODO: 単に位置だけでなくそれぞれの動きベクトルも融合する? const newX = (bodyA.position.x + bodyB.position.x) / 2; @@ -243,7 +214,7 @@ export class DropAndFusionGame extends EventEmitter<{ // 連鎖してfusionした場合の分かりやすさのため少し間を置いてからfusion対象になるようにする this.tickCallbackQueue.push({ - frame: this.frame + 6, + frame: this.frame + this.msToFrame(100), callback: () => { this.activeBodyIds.push(body.id); }, @@ -253,27 +224,69 @@ export class DropAndFusionGame extends EventEmitter<{ const additionalScore = Math.round(currentMono.score * comboBonus); this.score += additionalScore; - // TODO: 効果音再生はコンポーネント側の責務なので移動する - const pan = ((newX / this.gameWidth) - 0.5) * 2; - sound.playUrl('/client-assets/drop-and-fusion/bubble2.mp3', { - volume: this.sfxVolume, - pan, - playbackRate: nextMono.sfxPitch, - }); - this.emit('monoAdded', nextMono); this.emit('fusioned', newX, newY, additionalScore); + + const panV = newX - this.PLAYAREA_MARGIN; + const panW = this.GAME_WIDTH - this.PLAYAREA_MARGIN - this.PLAYAREA_MARGIN; + const pan = ((panV / panW) - 0.5) * 2; + this.emit('sfx', 'fusion', { volume: 1, pan, pitch: nextMono.sfxPitch }); } else { - //const VELOCITY = 30; - //for (let i = 0; i < 10; i++) { - // const body = createBody(FRUITS.find(x => x.level === (1 + Math.floor(this.rng() * 3)))!, x + ((this.rng() * VELOCITY) - (VELOCITY / 2)), y + ((this.rng() * VELOCITY) - (VELOCITY / 2))); - // Matter.Composite.add(world, body); - // bodies.push(body); - //} - //sound.playUrl({ - // type: 'syuilo/bubble2', - // volume: this.sfxVolume, - //}); + // nop + } + } + + private onCollision(event: Matter.IEventCollision) { + const minCollisionEnergyForSound = 2.5; + const maxCollisionEnergyForSound = 9; + const soundPitchMax = 4; + const soundPitchMin = 0.5; + + for (const pairs of event.pairs) { + const { bodyA, bodyB } = pairs; + + if (bodyA.id === this.overflowCollider.id || bodyB.id === this.overflowCollider.id) { + if (bodyA.id === this.latestDroppedBodyId || bodyB.id === this.latestDroppedBodyId) { + continue; + } + this.gameOver(); + break; + } + + const shouldFusion = (bodyA.label === bodyB.label) && + !this.fusionReservedPairs.some(x => + x.bodyA.id === bodyA.id || + x.bodyA.id === bodyB.id || + x.bodyB.id === bodyA.id || + x.bodyB.id === bodyB.id); + + if (shouldFusion) { + if (this.activeBodyIds.includes(bodyA.id) && this.activeBodyIds.includes(bodyB.id)) { + this.fusion(bodyA, bodyB); + } else { + this.fusionReservedPairs.push({ bodyA, bodyB }); + this.tickCallbackQueue.push({ + frame: this.frame + this.msToFrame(100), + callback: () => { + this.fusionReservedPairs = this.fusionReservedPairs.filter(x => x.bodyA.id !== bodyA.id && x.bodyB.id !== bodyB.id); + this.fusion(bodyA, bodyB); + }, + }); + } + } else { + const energy = pairs.collision.depth; + if (energy > minCollisionEnergyForSound) { + const volume = (Math.min(maxCollisionEnergyForSound, energy - minCollisionEnergyForSound) / maxCollisionEnergyForSound) / 4; + const panV = + pairs.bodyA.label === '_wall_' ? bodyB.position.x - this.PLAYAREA_MARGIN : + pairs.bodyB.label === '_wall_' ? bodyA.position.x - this.PLAYAREA_MARGIN : + ((bodyA.position.x + bodyB.position.x) / 2) - this.PLAYAREA_MARGIN; + const panW = this.GAME_WIDTH - this.PLAYAREA_MARGIN - this.PLAYAREA_MARGIN; + const pan = ((panV / panW) - 0.5) * 2; + const pitch = soundPitchMin + ((soundPitchMax - soundPitchMin) * (1 - (Math.min(10, energy) / 10))); + this.emit('sfx', 'collision', { volume, pan, pitch }); + } + } } } @@ -288,51 +301,10 @@ export class DropAndFusionGame extends EventEmitter<{ private gameOver() { this.isGameOver = true; - if (this.tickRaf) window.cancelAnimationFrame(this.tickRaf); - this.tickRaf = null; this.emit('gameOver'); - - // TODO: 効果音再生はコンポーネント側の責務なので移動する - sound.playUrl('/client-assets/drop-and-fusion/gameover.mp3', { - volume: this.sfxVolume, - }); } - /** テクスチャをすべてキャッシュする */ - private async loadMonoTextures() { - async function loadSingleMonoTexture(mono: Mono, game: DropAndFusionGame) { - // Matter-js内にキャッシュがある場合はスキップ - if (game.render.textures[mono.img]) return; - console.log('loading', mono.img); - - let src = mono.img; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (game.monoTextureUrls[mono.img]) { - src = game.monoTextureUrls[mono.img]; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - } else if (game.monoTextures[mono.img]) { - src = URL.createObjectURL(game.monoTextures[mono.img]); - game.monoTextureUrls[mono.img] = src; - } else { - const res = await fetch(mono.img); - const blob = await res.blob(); - game.monoTextures[mono.img] = blob; - src = URL.createObjectURL(blob); - game.monoTextureUrls[mono.img] = src; - } - - const image = new Image(); - image.src = src; - game.render.textures[mono.img] = image; - } - - return Promise.all(this.monoDefinitions.map(x => loadSingleMonoTexture(x, this))); - } - - public start(logs?: Log[]) { - if (!this.loaded) throw new Error('game is not loaded yet'); - if (logs) this.replaying = true; - + public start() { for (let i = 0; i < this.STOCK_MAX; i++) { this.stock.push({ id: this.rng().toString(), @@ -341,111 +313,20 @@ export class DropAndFusionGame extends EventEmitter<{ } this.emit('changeStock', this.stock); - // TODO: fusion予約状態のアイテムは光らせるなどの演出をすると楽しそう - let fusionReservedPairs: { bodyA: Matter.Body; bodyB: Matter.Body }[] = []; - - const minCollisionEnergyForSound = 2.5; - const maxCollisionEnergyForSound = 9; - const soundPitchMax = 4; - const soundPitchMin = 0.5; - - Matter.Events.on(this.engine, 'collisionStart', (event) => { - for (const pairs of event.pairs) { - const { bodyA, bodyB } = pairs; - if (bodyA.id === this.overflowCollider.id || bodyB.id === this.overflowCollider.id) { - if (bodyA.id === this.latestDroppedBodyId || bodyB.id === this.latestDroppedBodyId) { - continue; - } - this.gameOver(); - break; - } - const shouldFusion = (bodyA.label === bodyB.label) && !fusionReservedPairs.some(x => x.bodyA.id === bodyA.id || x.bodyA.id === bodyB.id || x.bodyB.id === bodyA.id || x.bodyB.id === bodyB.id); - if (shouldFusion) { - if (this.activeBodyIds.includes(bodyA.id) && this.activeBodyIds.includes(bodyB.id)) { - this.fusion(bodyA, bodyB); - } else { - fusionReservedPairs.push({ bodyA, bodyB }); - this.tickCallbackQueue.push({ - frame: this.frame + 6, - callback: () => { - fusionReservedPairs = fusionReservedPairs.filter(x => x.bodyA.id !== bodyA.id && x.bodyB.id !== bodyB.id); - this.fusion(bodyA, bodyB); - }, - }); - } - } else { - const energy = pairs.collision.depth; - if (energy > minCollisionEnergyForSound) { - // TODO: 効果音再生はコンポーネント側の責務なので移動する - const vol = ((Math.min(maxCollisionEnergyForSound, energy - minCollisionEnergyForSound) / maxCollisionEnergyForSound) / 4) * this.sfxVolume; - const pan = ((((bodyA.position.x + bodyB.position.x) / 2) / this.gameWidth) - 0.5) * 2; - const pitch = soundPitchMin + ((soundPitchMax - soundPitchMin) * (1 - (Math.min(10, energy) / 10))); - sound.playUrl('/client-assets/drop-and-fusion/poi1.mp3', { - volume: vol, - pan, - playbackRate: pitch, - }); - } - } - } - }); - - this.comboIntervalId = window.setInterval(() => { - if (this.latestFusionedAt < Date.now() - this.COMBO_INTERVAL) { - this.combo = 0; - } - }, 500); - - if (logs) { - const playTick = () => { - this.frame++; - const log = logs.find(x => x.frame === this.frame - 1); - if (log) { - switch (log.operation) { - case 'drop': { - this.drop(log.x); - break; - } - case 'hold': { - this.hold(); - break; - } - case 'surrender': { - this.surrender(); - break; - } - default: - break; - } - } - this.tickCallbackQueue = this.tickCallbackQueue.filter(x => { - if (x.frame === this.frame) { - x.callback(); - return false; - } else { - return true; - } - }); - - Matter.Engine.update(this.engine, this.TICK_DELTA); - - if (!this.isGameOver) { - this.tickRaf = window.requestAnimationFrame(playTick); - } - }; - - playTick(); - } else { - this.tick(); - } + Matter.Events.on(this.engine, 'collisionStart', this.onCollision.bind(this)); } public getLogs() { return this.logs; } - private tick() { + public tick() { this.frame++; + + if (this.latestFusionedAt < this.frame - this.COMBO_INTERVAL) { + this.combo = 0; + } + this.tickCallbackQueue = this.tickCallbackQueue.filter(x => { if (x.frame === this.frame) { x.callback(); @@ -454,35 +335,12 @@ export class DropAndFusionGame extends EventEmitter<{ return true; } }); + Matter.Engine.update(this.engine, this.TICK_DELTA); - if (!this.isGameOver) { - this.tickRaf = window.requestAnimationFrame(this.tick); - } - } - public async load() { - await this.loadMonoTextures(); - this.loaded = true; - } + const hasNextTick = !this.isGameOver; - public setSfxVolume(volume: number) { - this.sfxVolume = volume; - } - - public getTextureImageUrl(mono: Mono) { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (this.monoTextureUrls[mono.img]) { - return this.monoTextureUrls[mono.img]; - - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - } else if (this.monoTextures[mono.img]) { - // Gameクラス内にキャッシュがある場合はそれを使う - const out = URL.createObjectURL(this.monoTextures[mono.img]); - this.monoTextureUrls[mono.img] = out; - return out; - } else { - return mono.img; - } + return hasNextTick; } public getActiveMonos() { @@ -491,6 +349,7 @@ export class DropAndFusionGame extends EventEmitter<{ public drop(_x: number) { if (this.isGameOver) return; + // TODO: フレームで計算するようにすればリプレイかどうかのチェックは不要になる if (!this.replaying && (Date.now() - this.latestDroppedAt < this.DROP_INTERVAL)) return; const head = this.stock.shift()!; @@ -501,7 +360,7 @@ export class DropAndFusionGame extends EventEmitter<{ this.emit('changeStock', this.stock); const inputX = Math.round(_x); - const x = Math.min(this.gameWidth - this.PLAYAREA_MARGIN - (head.mono.size / 2), Math.max(this.PLAYAREA_MARGIN + (head.mono.size / 2), inputX)); + const x = Math.min(this.GAME_WIDTH - this.PLAYAREA_MARGIN - (head.mono.size / 2), Math.max(this.PLAYAREA_MARGIN + (head.mono.size / 2), inputX)); const body = this.createBody(head.mono, x, 50 + head.mono.size / 2); this.logs.push({ frame: this.frame, @@ -512,15 +371,8 @@ export class DropAndFusionGame extends EventEmitter<{ this.activeBodyIds.push(body.id); this.latestDroppedBodyId = body.id; this.latestDroppedAt = Date.now(); - this.emit('dropped'); + this.emit('dropped', x); this.emit('monoAdded', head.mono); - - // TODO: 効果音再生はコンポーネント側の責務なので移動する - const pan = ((x / this.gameWidth) - 0.5) * 2; - sound.playUrl('/client-assets/drop-and-fusion/poi2.mp3', { - volume: this.sfxVolume, - pan, - }); } public hold() { @@ -547,17 +399,69 @@ export class DropAndFusionGame extends EventEmitter<{ this.emit('changeHolding', this.holding); this.emit('changeStock', this.stock); } + } - sound.playUrl('/client-assets/drop-and-fusion/hold.mp3', { - volume: 0.5 * this.sfxVolume, - }); + public static serializeLogs(logs: Log[]) { + const _logs: number[][] = []; + + for (let i = 0; i < logs.length; i++) { + const log = logs[i]; + const frameDelta = i === 0 ? log.frame : log.frame - logs[i - 1].frame; + + switch (log.operation) { + case 'drop': + _logs.push([frameDelta, 0, log.x]); + break; + case 'hold': + _logs.push([frameDelta, 1]); + break; + case 'surrender': + _logs.push([frameDelta, 2]); + break; + } + } + + return _logs; + } + + public static deserializeLogs(logs: number[][]) { + const _logs: Log[] = []; + + let frame = 0; + + for (const log of logs) { + const frameDelta = log[0]; + frame += frameDelta; + + const operation = log[1]; + + switch (operation) { + case 0: + _logs.push({ + frame, + operation: 'drop', + x: log[2], + }); + break; + case 1: + _logs.push({ + frame, + operation: 'hold', + }); + break; + case 2: + _logs.push({ + frame, + operation: 'surrender', + }); + break; + } + } + + return _logs; } public dispose() { - if (this.comboIntervalId) window.clearInterval(this.comboIntervalId); - if (this.tickRaf) window.cancelAnimationFrame(this.tickRaf); - this.tickRaf = null; - Matter.Render.stop(this.render); Matter.World.clear(this.engine.world, false); Matter.Engine.clear(this.engine); } diff --git a/packages/frontend/src/scripts/sound.ts b/packages/frontend/src/scripts/sound.ts index 858b61b0f3..4386a18ab6 100644 --- a/packages/frontend/src/scripts/sound.ts +++ b/packages/frontend/src/scripts/sound.ts @@ -154,14 +154,12 @@ export type OperationType = typeof operationTypes[number]; * @param options `useCache`: デフォルトは`true` 一度再生した音声はキャッシュする */ export async function loadAudio(url: string, options?: { useCache?: boolean; }) { - if (_DEV_) console.log('loading audio. opts:', options); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (ctx == null) { ctx = new AudioContext(); } if (options?.useCache ?? true) { if (cache.has(url)) { - if (_DEV_) console.log('use cache'); return cache.get(url) as AudioBuffer; } } @@ -190,7 +188,6 @@ export async function loadAudio(url: string, options?: { useCache?: boolean; }) */ export function playMisskeySfx(operationType: OperationType) { const sound = defaultStore.state[`sound_${operationType}`]; - if (_DEV_) console.log('play', operationType, sound); if (sound.type == null || !canPlay) return; canPlay = false; diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index bfdb282ada..e6f9fee0af 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -494,6 +494,18 @@ type BlockingListRequest = operations['blocking/list']['requestBody']['content'] // @public (undocumented) type BlockingListResponse = operations['blocking/list']['responses']['200']['content']['application/json']; +// @public (undocumented) +type BubbleGameRankingRequest = operations['bubble-game/ranking']['requestBody']['content']['application/json']; + +// @public (undocumented) +type BubbleGameRankingResponse = operations['bubble-game/ranking']['responses']['200']['content']['application/json']; + +// @public (undocumented) +type BubbleGameRegisterRequest = operations['bubble-game/register']['requestBody']['content']['application/json']; + +// @public (undocumented) +type BubbleGameRegisterResponse = operations['bubble-game/register']['responses']['200']['content']['application/json']; + // @public (undocumented) type Channel = components['schemas']['Channel']; @@ -1636,6 +1648,10 @@ declare namespace entities { FetchExternalResourcesRequest, FetchExternalResourcesResponse, RetentionResponse, + BubbleGameRegisterRequest, + BubbleGameRegisterResponse, + BubbleGameRankingRequest, + BubbleGameRankingResponse, Error_2 as Error, UserLite, UserDetailedNotMeOnly, diff --git a/packages/misskey-js/src/autogen/apiClientJSDoc.ts b/packages/misskey-js/src/autogen/apiClientJSDoc.ts index 4b410cfb3f..60a58c7d27 100644 --- a/packages/misskey-js/src/autogen/apiClientJSDoc.ts +++ b/packages/misskey-js/src/autogen/apiClientJSDoc.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.2-io.2c - * generatedAt: 2024-01-09T17:42:52.871Z + * version: 2023.12.2 + * generatedAt: 2024-01-11T14:29:04.817Z */ import type { SwitchCaseResponseType } from '../api.js'; @@ -4040,5 +4040,27 @@ declare module '../api.js' { params: P, credential?: string | null, ): Promise>; + + /** + * No description provided. + * + * **Credential required**: *Yes* / **Permission**: *write:account* + */ + request( + endpoint: E, + params: P, + credential?: string | null, + ): Promise>; + + /** + * No description provided. + * + * **Credential required**: *No* + */ + request( + endpoint: E, + params: P, + credential?: string | null, + ): Promise>; } } diff --git a/packages/misskey-js/src/autogen/endpoint.ts b/packages/misskey-js/src/autogen/endpoint.ts index 437a950212..83e6b39430 100644 --- a/packages/misskey-js/src/autogen/endpoint.ts +++ b/packages/misskey-js/src/autogen/endpoint.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.2-io.2c - * generatedAt: 2024-01-09T17:42:52.867Z + * version: 2023.12.2 + * generatedAt: 2024-01-11T14:29:04.814Z */ import type { @@ -548,6 +548,10 @@ import type { FetchExternalResourcesRequest, FetchExternalResourcesResponse, RetentionResponse, + BubbleGameRegisterRequest, + BubbleGameRegisterResponse, + BubbleGameRankingRequest, + BubbleGameRankingResponse, } from './entities.js'; export type Endpoints = { @@ -914,4 +918,6 @@ export type Endpoints = { 'fetch-rss': { req: FetchRssRequest; res: FetchRssResponse }; 'fetch-external-resources': { req: FetchExternalResourcesRequest; res: FetchExternalResourcesResponse }; 'retention': { req: EmptyRequest; res: RetentionResponse }; + 'bubble-game/register': { req: BubbleGameRegisterRequest; res: BubbleGameRegisterResponse }; + 'bubble-game/ranking': { req: BubbleGameRankingRequest; res: BubbleGameRankingResponse }; } diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index fda990130a..f8890e811a 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.2-io.2c - * generatedAt: 2024-01-09T17:42:52.865Z + * version: 2023.12.2 + * generatedAt: 2024-01-11T14:29:04.811Z */ import { operations } from './types.js'; @@ -550,3 +550,7 @@ export type FetchRssResponse = operations['fetch-rss']['responses']['200']['cont export type FetchExternalResourcesRequest = operations['fetch-external-resources']['requestBody']['content']['application/json']; export type FetchExternalResourcesResponse = operations['fetch-external-resources']['responses']['200']['content']['application/json']; export type RetentionResponse = operations['retention']['responses']['200']['content']['application/json']; +export type BubbleGameRegisterRequest = operations['bubble-game/register']['requestBody']['content']['application/json']; +export type BubbleGameRegisterResponse = operations['bubble-game/register']['responses']['200']['content']['application/json']; +export type BubbleGameRankingRequest = operations['bubble-game/ranking']['requestBody']['content']['application/json']; +export type BubbleGameRankingResponse = operations['bubble-game/ranking']['responses']['200']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/models.ts b/packages/misskey-js/src/autogen/models.ts index 941f56af94..0aeb605081 100644 --- a/packages/misskey-js/src/autogen/models.ts +++ b/packages/misskey-js/src/autogen/models.ts @@ -1,6 +1,6 @@ /* - * version: 2023.12.2-io.2c - * generatedAt: 2024-01-09T17:42:52.864Z + * version: 2023.12.2 + * generatedAt: 2024-01-11T14:29:04.810Z */ import { components } from './types.js'; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 259ce93e63..97e81d2f81 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -2,8 +2,8 @@ /* eslint @typescript-eslint/no-explicit-any: 0 */ /* - * version: 2023.12.2-io.2c - * generatedAt: 2024-01-09T17:42:52.751Z + * version: 2023.12.2 + * generatedAt: 2024-01-11T14:29:04.681Z */ /** @@ -3492,6 +3492,31 @@ export type paths = { */ post: operations['retention']; }; + '/bubble-game/register': { + /** + * bubble-game/register + * @description No description provided. + * + * **Credential required**: *Yes* / **Permission**: *write:account* + */ + post: operations['bubble-game/register']; + }; + '/bubble-game/ranking': { + /** + * bubble-game/ranking + * @description No description provided. + * + * **Credential required**: *No* + */ + get: operations['bubble-game/ranking']; + /** + * bubble-game/ranking + * @description No description provided. + * + * **Credential required**: *No* + */ + post: operations['bubble-game/ranking']; + }; }; export type webhooks = Record; @@ -25896,5 +25921,126 @@ export type operations = { }; }; }; + /** + * bubble-game/register + * @description No description provided. + * + * **Credential required**: *Yes* / **Permission**: *write:account* + */ + 'bubble-game/register': { + requestBody: { + content: { + 'application/json': { + score: number; + seed: string; + logs: unknown[]; + gameMode: string; + gameVersion: number; + }; + }; + }; + responses: { + /** @description OK (with results) */ + 200: { + content: { + 'application/json': unknown; + }; + }; + /** @description Client error */ + 400: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Authentication error */ + 401: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Forbidden error */ + 403: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description I'm Ai */ + 418: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description To many requests */ + 429: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Internal server error */ + 500: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + }; + }; + /** + * bubble-game/ranking + * @description No description provided. + * + * **Credential required**: *No* + */ + 'bubble-game/ranking': { + requestBody: { + content: { + 'application/json': { + gameMode: string; + }; + }; + }; + responses: { + /** @description OK (with results) */ + 200: { + content: { + 'application/json': { + /** Format: misskey:id */ + id: string; + score: number; + user: components['schemas']['UserLite']; + }[]; + }; + }; + /** @description Client error */ + 400: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Authentication error */ + 401: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Forbidden error */ + 403: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description I'm Ai */ + 418: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + /** @description Internal server error */ + 500: { + content: { + 'application/json': components['schemas']['Error']; + }; + }; + }; + }; }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13f3ccb723..24e789f7b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -689,8 +689,8 @@ importers: specifier: 5.1.0 version: 5.1.0(rollup@4.9.1) '@syuilo/aiscript': - specifier: 0.16.0 - version: 0.16.0 + specifier: 0.17.0 + version: 0.17.0 '@tabler/icons-webfont': specifier: 2.44.0 version: 2.44.0 @@ -7671,8 +7671,8 @@ packages: dev: false optional: true - /@syuilo/aiscript@0.16.0: - resolution: {integrity: sha512-CXvoWOq6kmOSUQtKv0IEf7Ebfkk5PO1LxAgLqgRRPgssPvDvINCXu/gFNXKdapkFMkmX+Gj8qjemKR1vnUS4ZA==} + /@syuilo/aiscript@0.17.0: + resolution: {integrity: sha512-3JtQ1rWJHMxQ3153zLCXMUOwrOgjPPYGBl0dPHhR0ohm4tn7okMQRugxMCT0t3YxByemb9FfiM6TUjd0tEGxdA==} dependencies: seedrandom: 3.0.5 stringz: 2.1.0