diff options
author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-02 22:07:51 -0500 |
---|---|---|
committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-02 22:07:51 -0500 |
commit | d57515ee54cc2107f2c0ee79a953fa9dd9e21a7d (patch) | |
tree | 2a78d80dc474833618e3aa87d1e9980d911b0c9b /src | |
parent | 0e098085921f3a2f67e05aef76ca7ccbc869e203 (diff) | |
download | tanzanite-d57515ee54cc2107f2c0ee79a953fa9dd9e21a7d.tar.gz tanzanite-d57515ee54cc2107f2c0ee79a953fa9dd9e21a7d.tar.bz2 tanzanite-d57515ee54cc2107f2c0ee79a953fa9dd9e21a7d.zip |
minesweeper changes
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/fun/minesweeper.ts | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/commands/fun/minesweeper.ts b/src/commands/fun/minesweeper.ts index b9737a3..41daa8e 100644 --- a/src/commands/fun/minesweeper.ts +++ b/src/commands/fun/minesweeper.ts @@ -10,7 +10,7 @@ export default class MinesweeperCommand extends BushCommand { aliases: ['minesweeper'], category: 'fun', description: 'minesweeper command.', - usage: ['minesweeper <rows> <columns> <mines> [--spaces] [--revealFirstCell]'], + usage: ['minesweeper <rows> <columns> <mines> [--spaces] [--doNotRevealFirstCell]'], examples: ['minesweeper 10 10 2'], args: [ { @@ -53,11 +53,11 @@ export default class MinesweeperCommand extends BushCommand { optional: true }, { - id: 'reveal_first_cell', - description: 'Whether or not to reveal the first cell automatically.', + id: 'do_not_reveal_first_cell', + description: 'Whether to not reveal the first cell automatically.', match: 'flag', - flag: '--revealFirstCell', - prompt: 'Would you like to automatically reveal the first cell?', + flag: '--doNotRevealFirstCell', + prompt: 'Would you like to not automatically reveal the first cell?', slashType: ApplicationCommandOptionType.Boolean, optional: true } @@ -75,20 +75,31 @@ export default class MinesweeperCommand extends BushCommand { columns: ArgType<'integer'>; mines: ArgType<'integer'>; spaces: boolean; - reveal_first_cell: boolean; + do_not_reveal_first_cell: boolean; } ) { const minesweeper = new Minesweeper({ - rows: args.rows ?? 9, - columns: args.columns ?? 9, - mines: args.mines ?? 10, - emote: 'boom', - revealFirstCell: args.reveal_first_cell ?? false, - zeroFirstCell: true, + rows: args.rows, + columns: args.columns, + mines: args.mines, + revealFirstCell: args.do_not_reveal_first_cell ? false : true, spaces: args.spaces ?? false, - returnType: 'emoji' + zeroFirstCell: false }); + const matrix = minesweeper.start(); - return await message.util.reply(matrix?.toString() ?? `${util.emojis.error} Something went wrong.`); + + if (args.rows * args.columns <= args.mines * 2) + return message.util.reply( + `${util.emojis.error} The number of roles multiplied by the number of columns must be greater than or equal to the number of mines multiplied by two.` + ); + + if (!matrix) return await message.util.reply(`${util.emojis.error} Something went wrong.`); + + const res = matrix.toString().replaceAll(':zero:', ':blue_square:'); + + if (res.length > 2000) return message.util.reply(`${util.emojis.error} The minesweeper generated is over 2,000 characters.`); + + return await message.util.reply(res); } } |