From fb5db57b424b334d981d64b21b77e6bd76a5ced1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 11 May 2019 12:37:53 +0900 Subject: [PATCH] complexity --- src/modules/maze/gen-maze.ts | 12 ++++++++++-- src/modules/maze/index.ts | 10 +++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/modules/maze/gen-maze.ts b/src/modules/maze/gen-maze.ts index 6c291b9..a4d220f 100644 --- a/src/modules/maze/gen-maze.ts +++ b/src/modules/maze/gen-maze.ts @@ -77,10 +77,18 @@ const cellVariants = { type Dir = 'left' | 'right' | 'top' | 'bottom'; -export function genMaze(seed) { +export function genMaze(seed, complexity?) { const rand = gen.create(seed); - const mazeSize = 11 + rand(21); + let mazeSize; + if (complexity) { + if (complexity === 'easy') mazeSize = 10 + rand(12); + if (complexity === 'hard') mazeSize = 20 + rand(15); + if (complexity === 'veryHard') mazeSize = 35 + rand(15); + } else { + mazeSize = 11 + rand(21); + } + const donut = rand(3) === 0; const donutWidth = mazeSize / 3; diff --git a/src/modules/maze/index.ts b/src/modules/maze/index.ts index db7e978..5b86fa9 100644 --- a/src/modules/maze/index.ts +++ b/src/modules/maze/index.ts @@ -51,9 +51,9 @@ export default class extends Module { } @autobind - private async genMazeFile(seed): Promise { + private async genMazeFile(seed, size?): Promise { this.log('Maze generating...'); - const maze = genMaze(seed); + const maze = genMaze(seed, size); this.log('Maze rendering...'); const [temp] = await this.createTemp(); @@ -68,9 +68,13 @@ export default class extends Module { @autobind private async mentionHook(msg: Message) { if (msg.includes(['迷路'])) { + let size = null; + if (msg.includes(['簡単', 'かんたん', '易しい', 'やさしい', '小さい', 'ちいさい'])) size = 'easy'; + if (msg.includes(['難しい', 'むずかしい', '複雑な', '大きい', 'おおきい'])) size = 'hard'; + if (msg.includes(['死', '鬼', '地獄'])) size = 'veryHard'; this.log('Maze requested'); setTimeout(async () => { - const file = await this.genMazeFile(Date.now()); + const file = await this.genMazeFile(Date.now(), size); this.log('Replying...'); msg.replyWithFile(serifs.maze.foryou, file); }, 3000);