Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 22x 22x 32x 32x 32x 32x 11x 7x 6x 4x 23x 23x 12x 7x 7x 5x 7x 6x 6x 1x 28x 28x | import { CommentSchema, CommentSupplier, CommentSupplierImpl } from '../model/commentSupplier' import { CommentSupplierConfig, CommentSupplierConfigSupplier } from '../value/commentSupplierConfig' import { CommentContext } from '../model/commentContext' /** * {@link CommentSupplier} を新規作成する際の各種設定を保持します. */ export interface CommentSupplierConfigure { /** * 作成する CommentSupplier に設定するコメント生成間隔(ミリ秒)を取得します. */ interval(): number /** * 作成する CommentSupplier に設定するコメント生成間隔(ミリ秒)を設定します. * * @param interval コメントの生成間隔(ミリ秒) */ interval(interval: number): CommentSupplierConfigure /** * 出力するコメントを追加します. * * @param comment コメント本文 * @param conditions コメントを出力する条件(複数指定可). 省略した場合、状況にかかわらず出力します. */ addComment(comment: string, ...conditions: ((ctx: CommentContext) => boolean)[]): CommentSupplierConfigure /** * 登録されたコメント設定を取得します */ comments(): CommentSchema[] /** * 出力するコメントを設定します. * * これまで設定した情報は削除されます. * * @param comments コメント情報 */ comments(comments: CommentSchema[]): CommentSupplierConfigure /** * 作成する CommentSupplier のライブラリ利用者が自由に使えるフィールドを取得します. */ vars (): unknown /** * 作成する CommentSupplier のライブラリ利用者が自由に使えるフィールドを設定します. * * @param vars ライブラリ利用者が自由に使えるフィールド */ vars (vars: unknown): CommentSupplierConfigure } export class CommentSupplierConfigureImpl implements CommentSupplierConfigure { private readonly getter: () => CommentSupplierConfig private readonly setter: (obj: Partial<CommentSupplierConfig>) => void private readonly commentAdder: (obj: CommentSchema) => void constructor (isDefault: boolean, private readonly scene: g.Scene, private readonly config: CommentSupplierConfigSupplier) { this.getter = () => isDefault ? config.default() : config.get() this.setter = obj => isDefault ? config.defaultIf(obj) : config.setIf(obj) this.commentAdder = obj => isDefault ? config.addDefaultComment(obj) : config.addComment(obj) } interval (): number interval (value: number): CommentSupplierConfigure interval (args?: number): number | CommentSupplierConfigure { if (typeof args === 'number') { this.setter({ interval: args }) return this } return this.getter().interval } addComment (comment: string, ...conditions: ((ctx: CommentContext) => boolean)[]): CommentSupplierConfigure { this.commentAdder({ comment, conditions }) return this } comments (): CommentSchema[] comments (value: CommentSchema[]): CommentSupplierConfigure comments (args?: CommentSchema[]): CommentSchema[] | CommentSupplierConfigure { if (args) { this.setter({ comments: args }) return this } return this.getter().comments } vars (): unknown vars (vars: unknown): CommentSupplierConfigure vars (args?: unknown): unknown | CommentSupplierConfigure { if (arguments.length > 0) { this.setter({ vars: args }) return this } return this.getter().vars } /** * CommentSupplier を作成します. */ build (): CommentSupplier { const config = this.config.get() return new CommentSupplierImpl({ scene: this.scene, interval: config.interval, fps: this.scene.game.fps, comments: config.comments, vars: config.vars }) } } |